1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.view;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.container.NoSuchElementException;
27cdf0e10cSrcweir import com.sun.star.container.XEnumeration;
28cdf0e10cSrcweir import com.sun.star.lang.WrappedTargetException;
29cdf0e10cSrcweir import com.sun.star.view.XMultiSelectionSupplier;
30cdf0e10cSrcweir import java.util.Comparator;
31cdf0e10cSrcweir import lib.MultiMethodTest;
32cdf0e10cSrcweir import lib.Status;
33cdf0e10cSrcweir import lib.StatusException;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /**
36cdf0e10cSrcweir  * Testing <code>com.sun.star.view.XSelectionSupplier</code>
37cdf0e10cSrcweir  * interface methods :
38cdf0e10cSrcweir  * <ul>
39cdf0e10cSrcweir  *  <li><code> addSelection()</code></li>
40cdf0e10cSrcweir  *  <li><code> removeSelection()</code></li>
41cdf0e10cSrcweir  *  <li><code> clearSelection()</code></li>
42cdf0e10cSrcweir  *  <li><code> getSelectionCount()</code></li>
43cdf0e10cSrcweir  *  <li><code> createSelectionEnumeration()</code></li>
44cdf0e10cSrcweir  *  <li><code> createReverseSelectionEnumeration()</code></li>
45cdf0e10cSrcweir  * </ul>
46cdf0e10cSrcweir  * This test needs the following object relations :
47cdf0e10cSrcweir  * <ul>
48cdf0e10cSrcweir  *  <li> <code>'Selections'</code> of type <code>Object[]</code> :
49cdf0e10cSrcweir  *   the array of the instances which can be selected.</li>
50cdf0e10cSrcweir  *  <li> <code>'Comparer'</code> of type <code>Comparator</code> :
51cdf0e10cSrcweir  *   the interface for comparing of selected instances</li>
52cdf0e10cSrcweir  * <ul> <p>
53cdf0e10cSrcweir  * Test is <b> NOT </b> multithread compilant. <p>
54cdf0e10cSrcweir  * @see com.sun.star.view.XSelectionSupplier
55cdf0e10cSrcweir  */
56cdf0e10cSrcweir public class _XMultiSelectionSupplier extends MultiMethodTest {
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     public XMultiSelectionSupplier oObj = null;
59cdf0e10cSrcweir     public boolean selectionChanged = false;
60cdf0e10cSrcweir     Object[] selections = null;
61cdf0e10cSrcweir     Comparator ObjCompare = null;
62cdf0e10cSrcweir 
before()63cdf0e10cSrcweir     protected void before() {
64cdf0e10cSrcweir         selections = (Object[])tEnv.getObjRelation("Selections");
65cdf0e10cSrcweir         if (selections == null) {
66cdf0e10cSrcweir             throw new StatusException(Status.failed(
67cdf0e10cSrcweir                 "Couldn't get relation 'Selections'"));
68cdf0e10cSrcweir         }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         ObjCompare = (Comparator)tEnv.getObjRelation("Comparer");
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir 
after()73cdf0e10cSrcweir     protected void after() {
74cdf0e10cSrcweir         disposeEnvironment();
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     /**
78cdf0e10cSrcweir      * Selects an instance from relation 'First'. <p>
79cdf0e10cSrcweir      * Has <b> OK </b> status if no exceptions were thrown. <p>
80cdf0e10cSrcweir      */
_addSelection()81cdf0e10cSrcweir     public void _addSelection() {
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         boolean bOK = true;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir         log.println("clear selections");
86cdf0e10cSrcweir         oObj.clearSelection();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         int count = oObj.getSelectionCount();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         bOK &= (count == 0);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
95cdf0e10cSrcweir             try {
96cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
97cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
98cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
99cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
100cdf0e10cSrcweir                 bOK = false;
101cdf0e10cSrcweir             }
102cdf0e10cSrcweir             count = oObj.getSelectionCount();
103cdf0e10cSrcweir             if (count != (i+1)){
104cdf0e10cSrcweir                 log.println("ERROR: add a selection but selection count ("+count+ ") " +
105cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
106cdf0e10cSrcweir                 bOK = false;
107cdf0e10cSrcweir             }
108cdf0e10cSrcweir         }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir         log.println("try to select object relation 'selections[0]' second time...");
111cdf0e10cSrcweir         try {
112cdf0e10cSrcweir             count = oObj.getSelectionCount();
113cdf0e10cSrcweir             oObj.addSelection(selections[0]);
114cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
115cdf0e10cSrcweir             log.println("ERROR: could not add selection from object relation 'selections[0] a second time': " + ex.toString());
116cdf0e10cSrcweir         }
117cdf0e10cSrcweir         if (count != oObj.getSelectionCount()){
118cdf0e10cSrcweir             log.println("ERROR: the selected count ("+oObj.getSelectionCount() +") is not that before (" + count + ")");
119cdf0e10cSrcweir             bOK = false;
120cdf0e10cSrcweir         }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         log.println("try to select invalid object...");
123cdf0e10cSrcweir         try {
124cdf0e10cSrcweir 
125cdf0e10cSrcweir             oObj.addSelection(oObj);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir             log.println("ERORR: expected exception 'com.sun.star.lang.IllegalArgumentException' was not thrown => FAILED");
128cdf0e10cSrcweir             bOK = false;
129cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
130cdf0e10cSrcweir             log.println("expected exception 'com.sun.star.lang.IllegalArgumentException' => OK");
131cdf0e10cSrcweir         }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         tRes.tested("addSelection()", bOK);
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir 
_removeSelection()136cdf0e10cSrcweir     public void _removeSelection() {
137cdf0e10cSrcweir         requiredMethod("addSelection()");
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         boolean bOK = true;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         log.println("clear selections");
142cdf0e10cSrcweir         oObj.clearSelection();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         int count = oObj.getSelectionCount();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         bOK &= (count == 0);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         log.println("add some selections...");
151cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
152cdf0e10cSrcweir             try {
153cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
154cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
155cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
156cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
157cdf0e10cSrcweir                 bOK = false;
158cdf0e10cSrcweir             }
159cdf0e10cSrcweir             count = oObj.getSelectionCount();
160cdf0e10cSrcweir             if (count != (i+1)){
161cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
162cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
163cdf0e10cSrcweir                 bOK = false;
164cdf0e10cSrcweir             }
165cdf0e10cSrcweir         }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir         log.println("try now to remove selections...");
168cdf0e10cSrcweir 
169cdf0e10cSrcweir         count = oObj.getSelectionCount();
170cdf0e10cSrcweir         int oldCount = oObj.getSelectionCount();
171cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
172cdf0e10cSrcweir             try {
173cdf0e10cSrcweir                 log.println("remove selection for object relation 'selections["+i+"]'");
174cdf0e10cSrcweir                 oObj.removeSelection(selections[i]);
175cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
176cdf0e10cSrcweir                 log.println("ERROR: could not remove selection from object relation 'selections[" + i + "]': " + ex.toString());
177cdf0e10cSrcweir                 bOK = false;
178cdf0e10cSrcweir             }
179cdf0e10cSrcweir             count = oObj.getSelectionCount();
180cdf0e10cSrcweir             if (count !=  (oldCount - i - 1)){
181cdf0e10cSrcweir                 log.println("ERROR: removed a selection but selection count ("+count+ ") " +
182cdf0e10cSrcweir                     "is not as expected (" + (oldCount -i -1) + ") => FAILED");
183cdf0e10cSrcweir                 bOK = false;
184cdf0e10cSrcweir             }
185cdf0e10cSrcweir         }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         log.println("try to remove a removed selection a second time...");
188cdf0e10cSrcweir         count = oObj.getSelectionCount();
189cdf0e10cSrcweir         try {
190cdf0e10cSrcweir             oObj.removeSelection(selections[0]);
191cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
192cdf0e10cSrcweir             log.println("ERROR: could not remove selection from object relation 'selections[0] a second time': " + ex.toString());
193cdf0e10cSrcweir         }
194cdf0e10cSrcweir         if (count != oObj.getSelectionCount()){
195cdf0e10cSrcweir             log.println("ERROR: the selected count ("+oObj.getSelectionCount() +") is not that before (" + count + ")");
196cdf0e10cSrcweir             bOK = false;
197cdf0e10cSrcweir         }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir         log.println("try to remove invalid object...");
200cdf0e10cSrcweir         try {
201cdf0e10cSrcweir 
202cdf0e10cSrcweir             oObj.removeSelection(oObj);
203cdf0e10cSrcweir 
204cdf0e10cSrcweir             log.println("ERORR: expected exception 'com.sun.star.lang.IllegalArgumentException' was not thrown => FAILED");
205cdf0e10cSrcweir             bOK = false;
206cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException ex) {
207cdf0e10cSrcweir             log.println("expected exception 'com.sun.star.lang.IllegalArgumentException' => OK");
208cdf0e10cSrcweir         }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir         tRes.tested("removeSelection()", bOK);
211cdf0e10cSrcweir     }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     /**
215cdf0e10cSrcweir      * First test changes selection of the object : if nothing is
216cdf0e10cSrcweir      * currently selected or first instance ('First' relation) is
217cdf0e10cSrcweir      * selected then selects second instance; if second instance
218cdf0e10cSrcweir      * is currently selected then the first instance is selected. <p>
219cdf0e10cSrcweir      * Then <code>getSelection</code> is called and values set and
220cdf0e10cSrcweir      * get are compared. Comparison has some special cases. For
221cdf0e10cSrcweir      * example if selection is a Cell, then the values contained
222cdf0e10cSrcweir      * in cells are compared. <p>
223cdf0e10cSrcweir      * Has <b>OK</b> status if selection changed properly.
224cdf0e10cSrcweir      */
_getSelectionCount()225cdf0e10cSrcweir     public void _getSelectionCount() {
226cdf0e10cSrcweir         requiredMethod("addSelection()");
227cdf0e10cSrcweir         tRes.tested("getSelectionCount()", true);
228cdf0e10cSrcweir     }
229cdf0e10cSrcweir 
_clearSelection()230cdf0e10cSrcweir     public void _clearSelection() {
231cdf0e10cSrcweir         requiredMethod("addSelection()");
232cdf0e10cSrcweir         boolean bOK = true;
233cdf0e10cSrcweir 
234cdf0e10cSrcweir         log.println("clear selections");
235cdf0e10cSrcweir         oObj.clearSelection();
236cdf0e10cSrcweir 
237cdf0e10cSrcweir         int count = oObj.getSelectionCount();
238cdf0e10cSrcweir 
239cdf0e10cSrcweir         bOK &= (count == 0);
240cdf0e10cSrcweir 
241cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         log.println("add some selections...");
244cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
245cdf0e10cSrcweir             try {
246cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
247cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
248cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
249cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
250cdf0e10cSrcweir                 bOK = false;
251cdf0e10cSrcweir             }
252cdf0e10cSrcweir             count = oObj.getSelectionCount();
253cdf0e10cSrcweir             if (count != (i+1)){
254cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
255cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
256cdf0e10cSrcweir                 bOK = false;
257cdf0e10cSrcweir             }
258cdf0e10cSrcweir         }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir         count = oObj.getSelectionCount();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir         log.println("clear selections...");
263cdf0e10cSrcweir         oObj.clearSelection();
264cdf0e10cSrcweir 
265cdf0e10cSrcweir         count = oObj.getSelectionCount();
266cdf0e10cSrcweir 
267cdf0e10cSrcweir         bOK &= (count == 0);
268cdf0e10cSrcweir 
269cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
270cdf0e10cSrcweir 
271cdf0e10cSrcweir         tRes.tested("clearSelection()", bOK);
272cdf0e10cSrcweir     }
273cdf0e10cSrcweir 
_createSelectionEnumeration()274cdf0e10cSrcweir     public void _createSelectionEnumeration() {
275cdf0e10cSrcweir         requiredMethod("addSelection()");
276cdf0e10cSrcweir         boolean bOK = true;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir         log.println("clear selections");
279cdf0e10cSrcweir         oObj.clearSelection();
280cdf0e10cSrcweir 
281cdf0e10cSrcweir         int count = oObj.getSelectionCount();
282cdf0e10cSrcweir 
283cdf0e10cSrcweir         bOK &= (count == 0);
284cdf0e10cSrcweir 
285cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
286cdf0e10cSrcweir 
287cdf0e10cSrcweir         log.println("add some selections...");
288cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
289cdf0e10cSrcweir             try {
290cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
291cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
292cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
293cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
294cdf0e10cSrcweir                 bOK = false;
295cdf0e10cSrcweir             }
296cdf0e10cSrcweir             count = oObj.getSelectionCount();
297cdf0e10cSrcweir             if (count != (i+1)){
298cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
299cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
300cdf0e10cSrcweir                 bOK = false;
301cdf0e10cSrcweir             }
302cdf0e10cSrcweir         }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir         log.println("create enumeration...");
305cdf0e10cSrcweir         XEnumeration xEnum = oObj.createSelectionEnumeration();
306cdf0e10cSrcweir 
307cdf0e10cSrcweir         boolean compRes = true; //compare result
308cdf0e10cSrcweir         int i = 0;
309cdf0e10cSrcweir 
310cdf0e10cSrcweir         while (xEnum.hasMoreElements()){
311cdf0e10cSrcweir             log.println("try to get first element..");
312cdf0e10cSrcweir             Object nextElement = null;
313cdf0e10cSrcweir             try {
314cdf0e10cSrcweir                 nextElement = xEnum.nextElement();
315cdf0e10cSrcweir             } catch (WrappedTargetException ex) {
316cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
317cdf0e10cSrcweir                 bOK = false;
318cdf0e10cSrcweir             } catch (NoSuchElementException ex) {
319cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
320cdf0e10cSrcweir                 bOK = false;
321cdf0e10cSrcweir             }
322cdf0e10cSrcweir             Object shouldElement = selections[i];
323cdf0e10cSrcweir             i++;
324cdf0e10cSrcweir 
325cdf0e10cSrcweir             if (ObjCompare != null) {
326cdf0e10cSrcweir                 ObjCompare.compare(shouldElement, nextElement);
327cdf0e10cSrcweir             } else {
328cdf0e10cSrcweir                 compRes = util.ValueComparer.equalValue(shouldElement, nextElement);
329cdf0e10cSrcweir             }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir             log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes);
332cdf0e10cSrcweir 
333cdf0e10cSrcweir             if (!compRes) {
334cdf0e10cSrcweir                 if ((selections[i]) instanceof Object[]){
335cdf0e10cSrcweir                     if (((Object[])selections[i])[0] instanceof Integer) {
336cdf0e10cSrcweir                         log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue());
337cdf0e10cSrcweir                         log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue());
338cdf0e10cSrcweir                     }
339cdf0e10cSrcweir                 }
340cdf0e10cSrcweir             }
341cdf0e10cSrcweir             bOK &= compRes;
342cdf0e10cSrcweir         }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir         tRes.tested("createSelectionEnumeration()", bOK);
345cdf0e10cSrcweir     }
346cdf0e10cSrcweir 
_createReverseSelectionEnumeration()347cdf0e10cSrcweir     public void _createReverseSelectionEnumeration() {
348cdf0e10cSrcweir         requiredMethod("addSelection()");
349cdf0e10cSrcweir         boolean bOK = true;
350cdf0e10cSrcweir 
351cdf0e10cSrcweir         log.println("clear selections");
352cdf0e10cSrcweir         oObj.clearSelection();
353cdf0e10cSrcweir 
354cdf0e10cSrcweir         int count = oObj.getSelectionCount();
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         bOK &= (count == 0);
357cdf0e10cSrcweir 
358cdf0e10cSrcweir         if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED");
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         log.println("add some selections...");
361cdf0e10cSrcweir         for(int i = 0; i < selections.length; i++) {
362cdf0e10cSrcweir             try {
363cdf0e10cSrcweir                 log.println("select object from object relation 'selections["+i+"]'");
364cdf0e10cSrcweir                 oObj.addSelection(selections[i]);
365cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException ex) {
366cdf0e10cSrcweir                 log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString());
367cdf0e10cSrcweir                 bOK = false;
368cdf0e10cSrcweir             }
369cdf0e10cSrcweir             count = oObj.getSelectionCount();
370cdf0e10cSrcweir             if (count != (i+1)){
371cdf0e10cSrcweir                 log.println("ERROR: added a selection but selection count ("+count+ ") " +
372cdf0e10cSrcweir                     "is not as expected (" + (i+1) + ") => FAILED");
373cdf0e10cSrcweir                 bOK = false;
374cdf0e10cSrcweir             }
375cdf0e10cSrcweir         }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir         log.println("create enumeration...");
378cdf0e10cSrcweir         XEnumeration xEnum = oObj.createSelectionEnumeration();
379cdf0e10cSrcweir 
380cdf0e10cSrcweir         boolean compRes = true; //compare result
381cdf0e10cSrcweir         int i = selections.length - 1;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir         while (xEnum.hasMoreElements()){
384cdf0e10cSrcweir             log.println("try to get first element..");
385cdf0e10cSrcweir             Object nextElement = null;
386cdf0e10cSrcweir             try {
387cdf0e10cSrcweir                 nextElement = xEnum.nextElement();
388cdf0e10cSrcweir             } catch (WrappedTargetException ex) {
389cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
390cdf0e10cSrcweir                 bOK = false;
391cdf0e10cSrcweir             } catch (NoSuchElementException ex) {
392cdf0e10cSrcweir                 log.println("ERROR: could not get nextElement: " + ex.toString());
393cdf0e10cSrcweir                 bOK = false;
394cdf0e10cSrcweir             }
395cdf0e10cSrcweir             Object shouldElement = selections[i];
396cdf0e10cSrcweir             i--;
397cdf0e10cSrcweir 
398cdf0e10cSrcweir             if (ObjCompare != null) {
399cdf0e10cSrcweir                 ObjCompare.compare(shouldElement, nextElement);
400cdf0e10cSrcweir             } else {
401cdf0e10cSrcweir                 compRes = util.ValueComparer.equalValue(shouldElement, nextElement);
402cdf0e10cSrcweir             }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir             log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes);
405cdf0e10cSrcweir 
406cdf0e10cSrcweir             if (!compRes) {
407cdf0e10cSrcweir                 if ((selections[i]) instanceof Object[]){
408cdf0e10cSrcweir                     if (((Object[])selections[i])[0] instanceof Integer) {
409cdf0e10cSrcweir                         log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue());
410cdf0e10cSrcweir                         log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue());
411cdf0e10cSrcweir                     }
412cdf0e10cSrcweir                 }
413cdf0e10cSrcweir             }
414cdf0e10cSrcweir             bOK &= compRes;
415cdf0e10cSrcweir         }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir         tRes.tested("createReverseSelectionEnumeration()", bOK);
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir }  // finish class _XMultiSelectionSupplier
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 
424