1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.accessibility;
25 
26 import lib.MultiMethodTest;
27 
28 import com.sun.star.accessibility.XAccessible;
29 import com.sun.star.accessibility.XAccessibleContext;
30 import com.sun.star.accessibility.XAccessibleSelection;
31 import com.sun.star.accessibility.XAccessibleTable;
32 import com.sun.star.uno.UnoRuntime;
33 
34 /**
35  * Testing <code>com.sun.star.accessibility.XAccessibleTable</code>
36  * interface methods :
37  * <ul>
38  *  <li><code>getAccessibleRowCount()</code></li>
39  *  <li><code>getAccessibleColumnCount()</code></li>
40  *  <li><code>getAccessibleRowDescription()</code></li>
41  *  <li><code>getAccessibleColumnDescription()</code></li>
42  *  <li><code>getAccessibleRowExtentAt()</code></li>
43  *  <li><code>getAccessibleColumnExtentAt()</code></li>
44  *  <li><code>getAccessibleRowHeaders()</code></li>
45  *  <li><code>getAccessibleColumnHeaders()</code></li>
46  *  <li><code>getSelectedAccessibleRows()</code></li>
47  *  <li><code>getSelectedAccessibleColumns()</code></li>
48  *  <li><code>isAccessibleRowSelected()</code></li>
49  *  <li><code>isAccessibleColumnSelected()</code></li>
50  *  <li><code>getAccessibleCellAt()</code></li>
51  *  <li><code>getAccessibleCaption()</code></li>
52  *  <li><code>getAccessibleSummary()</code></li>
53  *  <li><code>isAccessibleSelected()</code></li>
54  *  <li><code>getAccessibleIndex()</code></li>
55  *  <li><code>getAccessibleRow()</code></li>
56  *  <li><code>getAccessibleColumn()</code></li>
57  * </ul> <p>
58  * @see com.sun.star.accessibility.XAccessibleTable
59  */
60 public class _XAccessibleTable extends MultiMethodTest {
61 
62     public XAccessibleTable oObj = null;
63     XAccessibleSelection xASel = null;
64     XAccessibleContext xACont = null;
65 
before()66     protected void before() {
67         xASel = (XAccessibleSelection)
68             UnoRuntime.queryInterface(XAccessibleSelection.class, oObj);
69         if (xASel == null) {
70             log.println("The component doesn't implement the interface " +
71                 "XAccessibleSelection.");
72             log.println("This interface is required for more detailed tests.");
73         }
74 
75         xACont = (XAccessibleContext)
76             UnoRuntime.queryInterface(XAccessibleContext.class, oObj);
77     }
78 
79     int rowCount = 0;
80 
81     /**
82      * Calls the method and stores the returned value to the variable
83      * <code>rowCount</code>.
84      */
_getAccessibleRowCount()85     public void _getAccessibleRowCount() {
86         rowCount = oObj.getAccessibleRowCount();
87         log.println("Accessible row count: " + rowCount);
88         tRes.tested("getAccessibleRowCount()", true);
89     }
90 
91     int colCount = 0;
92 
93     /**
94      * Calls the method and stores the returned value to the variable
95      * <code>colCount</code>.
96      */
_getAccessibleColumnCount()97     public void _getAccessibleColumnCount() {
98         colCount = oObj.getAccessibleColumnCount();
99         log.println("Accessible column count: " + colCount);
100         tRes.tested("getAccessibleColumnCount()", true);
101     }
102 
103     /**
104      * Calls the method with the wrong indexes and with the correct index,
105      * checks a returned value.
106      * Has OK status if exceptions were thrown for the wrong indexes,
107      * if exception wasn't thrown for the correct index and
108      * if returned value isn't <code>null</code>.
109      * The following method tests are to be executed before:
110      * <ul>
111      *  <li> <code>getAccessibleRowCount()</code> </li>
112      * </ul>
113      */
_getAccessibleRowDescription()114     public void _getAccessibleRowDescription() {
115         requiredMethod("getAccessibleRowCount()");
116         boolean res = true;
117 
118         try {
119             log.print("getAccessibleRowDescription(-1): ");
120             String descr = oObj.getAccessibleRowDescription(-1);
121             log.println("'" + descr + "'");
122             log.println("Exception was expected");
123             res &= false;
124         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
125             log.println("expected exception");
126             res &= true;
127         }
128 
129         try {
130             log.print("getAccessibleRowDescription(" + rowCount + "): ");
131             String descr = oObj.getAccessibleRowDescription(rowCount);
132             log.println("'" + descr + "'");
133             log.println("Exception was expected");
134             res &= false;
135         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
136             log.println("expected exception");
137             res &= true;
138         }
139 
140         try {
141             log.print("getAccessibleRowDescription(" + (rowCount - 1) + "): ");
142             String descr =
143                 oObj.getAccessibleRowDescription(rowCount - 1);
144             res &= descr != null;
145             log.println("'" + descr + "'");
146         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
147             log.println("Unexpected exception");
148             e.printStackTrace(log);
149             res &= false;
150         }
151 
152         tRes.tested("getAccessibleRowDescription()", res);
153     }
154 
155     /**
156      * Calls the method with the wrong indexes and with the correct index,
157      * checks a returned value.
158      * Has OK status if exceptions were thrown for the wrong indexes,
159      * if exception wasn't thrown for the correct index and
160      * if returned value isn't <code>null</code>.
161      * The following method tests are to be executed before:
162      * <ul>
163      *  <li> <code>getAccessibleColumnCount()</code> </li>
164      * </ul>
165      */
_getAccessibleColumnDescription()166     public void _getAccessibleColumnDescription() {
167         requiredMethod("getAccessibleColumnCount()");
168         boolean res = true;
169 
170         try {
171             log.print("getAccessibleColumnDescription(-1): ");
172             String descr = oObj.getAccessibleColumnDescription(-1);
173             log.println("'" + descr + "'");
174             log.println("Exception was expected");
175             res &= false;
176         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
177             log.println("expected exception");
178             res &= true;
179         }
180 
181         try {
182             log.print("getAccessibleColumnDescription(" + colCount + "): ");
183             String descr = oObj.getAccessibleColumnDescription(colCount);
184             log.println("'" + descr + "'");
185             log.println("Exception was expected");
186             res &= false;
187         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
188             log.println("expected exception");
189             res &= true;
190         }
191 
192         try {
193             log.print("getAccessibleColumnDescription(" + (colCount - 1) + "): ");
194             String descr =
195                 oObj.getAccessibleColumnDescription(colCount - 1);
196             res &= descr != null;
197             log.println("'" + descr + "'");
198         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
199             log.println("Unexpected exception");
200             e.printStackTrace(log);
201             res &= false;
202         }
203 
204         tRes.tested("getAccessibleColumnDescription()", res);
205     }
206 
207 
208      /**
209      * Calls the method with the wrong parameters and with the correct
210      * parameters, checks a returned value.
211      * Has OK status if exceptions were thrown for the wrong indexes,
212      * if exception wasn't thrown for the correct index and
213      * if returned value is greater than or is equal to 1.
214      * The following method tests are to be executed before:
215      * <ul>
216      *  <li> <code>getAccessibleColumnCount()</code> </li>
217      *  <li> <code>getAccessibleRowCount()</code> </li>
218      * </ul>
219      */
_getAccessibleRowExtentAt()220     public void _getAccessibleRowExtentAt() {
221         requiredMethod("getAccessibleRowCount()");
222         requiredMethod("getAccessibleColumnCount()");
223         boolean res = true;
224 
225         try {
226             log.print("getAccessibleRowExtentAt(-1," + (colCount-1) + "):");
227             int ext = oObj.getAccessibleRowExtentAt(-1, colCount - 1);
228             log.println(ext);
229             log.println("Exception was expected");
230             res &= false;
231         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
232             log.println("expected exception");
233             res &= true;
234         }
235 
236         try {
237             log.print("getAccessibleRowExtentAt(" + (rowCount-1) + ",-1):");
238             int ext = oObj.getAccessibleRowExtentAt(rowCount - 1, -1);
239             log.println(ext);
240             log.println("Exception was expected");
241             res &= false;
242         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
243             log.println("expected exception");
244             res &= true;
245         }
246 
247         try {
248             log.print("getAccessibleRowExtentAt(0," + colCount + "):");
249             int ext = oObj.getAccessibleRowExtentAt(0, colCount);
250             log.println(ext);
251             log.println("Exception was expected");
252             res &= false;
253         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
254             log.println("expected exception");
255             res &= true;
256         }
257 
258         try {
259             log.print("getAccessibleRowExtentAt(" + rowCount + ",0):");
260             int ext = oObj.getAccessibleRowExtentAt(rowCount, 0);
261             log.println(ext);
262             log.println("Exception was expected");
263             res &= false;
264         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
265             log.println("expected exception");
266             res &= true;
267         }
268 
269         try {
270             log.print("getAccessibleRowExtentAt(" +
271                 (rowCount-1) + "," + (colCount-1) + "):");
272             int ext = oObj.getAccessibleRowExtentAt(rowCount-1, colCount - 1);
273             log.println(ext);
274             res &= ext >= 1;
275         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
276             log.println("Unexpected exception");
277             e.printStackTrace(log);
278             res &= false;
279         }
280 
281         tRes.tested("getAccessibleRowExtentAt()", res);
282     }
283 
284     /**
285      * Calls the method with the wrong parameters and with the correct
286      * parameters, checks a returned value.
287      * Has OK status if exceptions were thrown for the wrong indexes,
288      * if exception wasn't thrown for the correct index and
289      * if returned value is greater than or is equal to 1.
290      * The following method tests are to be executed before:
291      * <ul>
292      *  <li> <code>getAccessibleColumnCount()</code> </li>
293      *  <li> <code>getAccessibleRowCount()</code> </li>
294      * </ul>
295      */
_getAccessibleColumnExtentAt()296     public void _getAccessibleColumnExtentAt() {
297         requiredMethod("getAccessibleRowCount()");
298         requiredMethod("getAccessibleColumnCount()");
299         boolean res = true;
300 
301         try {
302             log.print("getAccessibleColumnExtentAt(-1," + (colCount-1) + "):");
303             int ext = oObj.getAccessibleColumnExtentAt(-1, colCount - 1);
304             log.println(ext);
305             log.println("Exception was expected");
306             res &= false;
307         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
308             log.println("expected exception");
309             res &= true;
310         }
311 
312         try {
313             log.print("getAccessibleColumnExtentAt(" + (rowCount-1) + ",-1):");
314             int ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, -1);
315             log.println(ext);
316             log.println("Exception was expected");
317             res &= false;
318         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
319             log.println("expected exception");
320             res &= true;
321         }
322 
323         try {
324             log.print("getAccessibleColumnExtentAt(0," + colCount + "):");
325             int ext = oObj.getAccessibleColumnExtentAt(0, colCount);
326             log.println(ext);
327             log.println("Exception was expected");
328             res &= false;
329         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
330             log.println("expected exception");
331             res &= true;
332         }
333 
334         try {
335             log.print("getAccessibleColumnExtentAt(" + rowCount + ",0):");
336             int ext = oObj.getAccessibleColumnExtentAt(rowCount, 0);
337             log.println(ext);
338             log.println("Exception was expected");
339             res &= false;
340         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
341             log.println("expected exception");
342             res &= true;
343         }
344 
345         try {
346             log.print("getAccessibleColumnExtentAt(" +
347                 (rowCount-1) + "," + (colCount-1) + "):");
348             int ext = oObj.getAccessibleColumnExtentAt(rowCount-1,colCount - 1);
349             log.println(ext);
350             res &= ext >= 1;
351         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
352             log.println("Unexpected exception");
353             e.printStackTrace(log);
354             res &= false;
355         }
356 
357         tRes.tested("getAccessibleColumnExtentAt()", res);
358     }
359 
360     /**
361      * Calls the method and checks a returned value.
362      * Has OK status if returned value isn't <code>null</code>.
363      */
_getAccessibleRowHeaders()364     public void _getAccessibleRowHeaders() {
365         XAccessibleTable rowHeaders = oObj.getAccessibleRowHeaders();
366         log.println("getAccessibleRowHeaders(): " + rowHeaders);
367         tRes.tested("getAccessibleRowHeaders()", true);
368     }
369 
370     /**
371      * Calls the method and checks a returned value.
372      * Has OK status if returned value isn't <code>null</code>.
373      */
_getAccessibleColumnHeaders()374     public void _getAccessibleColumnHeaders() {
375         XAccessibleTable colHeaders = oObj.getAccessibleColumnHeaders();
376         log.println("getAccessibleColumnHeaders(): " + colHeaders);
377         tRes.tested("getAccessibleColumnHeaders()", true);
378     }
379 
380     /**
381      * If the interface <code>XAccessibleSelection</code> is supported by
382      * the component than selects all accessible childs.
383      * Calls the method and checks a returned sequence.
384      * Has OK status if a returned sequince is in ascending order.
385      * The following method tests are to be executed before:
386      * <ul>
387      *  <li> <code>getAccessibleRowCount()</code> </li>
388      * </ul>
389      */
_getSelectedAccessibleRows()390     public void _getSelectedAccessibleRows() {
391         requiredMethod("getAccessibleRowCount()");
392         boolean res = true;
393         boolean locRes = true;
394         int selRows[] = null;
395 
396         if (xASel != null) {
397             log.println("XAccessibleSelection.selectAllAccessibleChildren()");
398             xASel.selectAllAccessibleChildren();
399         }
400 
401         log.println("getSelectedAccessibleRows()");
402         selRows = oObj.getSelectedAccessibleRows();
403         log.println("Length of the returned sequince: " + selRows.length);
404         if (xASel != null) {
405             res &= selRows.length == rowCount;
406         } else {
407             res &= selRows.length == 0;
408         }
409 
410         if (selRows.length > 0) {
411             log.println("Checking that returned sequence is" +
412                 " in ascending order");
413         }
414 
415         for(int i = 1; i < selRows.length; i++) {
416             locRes &= selRows[i] >= selRows[i - 1];
417             res &= locRes;
418             if (!locRes) {
419                 log.println("Element #" + i + ":" + selRows[i] +
420                     " is less than element #" + (i-1) + ": " +
421                     selRows[i-1]);
422                 break;
423             }
424         }
425 
426         tRes.tested("getSelectedAccessibleRows()", res);
427     }
428 
429     /**
430      * If the interface <code>XAccessibleSelection</code> is supported by
431      * the component than selects all accessible childs.
432      * Calls the method and checks a returned sequence.
433      * Has OK status if a returned sequince is in ascending order.
434      * The following method tests are to be executed before:
435      * <ul>
436      *  <li> <code>getAccessibleColumnCount()</code> </li>
437      * </ul>
438      */
_getSelectedAccessibleColumns()439     public void _getSelectedAccessibleColumns() {
440         requiredMethod("getAccessibleColumnCount()");
441         boolean res = true;
442         boolean locRes = true;
443         int selCols[] = null;
444 
445         if (xASel != null) {
446             log.println("XAccessibleSelection.selectAllAccessibleChildren()");
447             xASel.selectAllAccessibleChildren();
448         }
449 
450         log.println("getSelectedAccessibleColumns()");
451         selCols = oObj.getSelectedAccessibleColumns();
452         log.println("Length of the returned sequince: " + selCols.length);
453 
454         if (xASel != null) {
455             res &= selCols.length == colCount;
456         } else {
457             res &= selCols.length == 0;
458         }
459 
460         if (selCols.length > 0) {
461             log.println("Checking that returned sequence is" +
462                 " in ascending order");
463         }
464 
465         for(int i = 1; i < selCols.length; i++) {
466             locRes &= selCols[i] >= selCols[i - 1];
467             res &= locRes;
468             if (!locRes) {
469                 log.println("Element #" + i + ":" + selCols[i] +
470                     " is less than element #" + (i-1) + ": " +
471                     selCols[i-1]);
472                 break;
473             }
474         }
475 
476         tRes.tested("getSelectedAccessibleColumns()", res);
477     }
478 
479     /**
480      * Calls the method with invalid indexes.
481      * If the interface <code>XAccessibleSelection</code> is supported by
482      * the component than selects all accessible childs.
483      * Calls the method for every row and checks returned values.
484      * The following method tests are to be executed before:
485      * <ul>
486      *  <li> <code>getAccessibleRowCount()</code> </li>
487      * </ul>
488      */
_isAccessibleRowSelected()489     public void _isAccessibleRowSelected() {
490         requiredMethod("getAccessibleRowCount()");
491         boolean res = true;
492         boolean locRes = true;
493 
494         try {
495             log.print("isAccessibleRowSelected(-1): ");
496             locRes = oObj.isAccessibleRowSelected(-1);
497             log.println(locRes);
498             log.println("Exception was expected");
499             res &= false;
500         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
501             log.println("expected exception");
502             res &= true;
503         }
504 
505         try {
506             log.print("isAccessibleRowSelected(" + rowCount + "): ");
507             locRes = oObj.isAccessibleRowSelected(rowCount);
508             log.println(locRes);
509             log.println("Exception was expected");
510             res &= false;
511         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
512             log.println("expected exception");
513             res &= true;
514         }
515 
516         if (xASel != null) {
517             log.println("XAccessibleSelection.selectAllAccessibleChildren()");
518             xASel.selectAllAccessibleChildren();
519         }
520 
521         try {
522             log.println("Checking of every row selection...");
523             for(int i = 0; i < rowCount; i++) {
524                 boolean isSel = oObj.isAccessibleRowSelected(i);
525                 locRes = (xASel == null) ? !isSel : isSel;
526                 res &= locRes;
527                 if (!locRes) {
528                     log.println("isAccessibleRowSelected(" + i + "): " + isSel);
529                     break;
530                 }
531             }
532         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
533             log.println("Unexpected exception");
534             e.printStackTrace(log);
535             res &= false;
536         }
537 
538         tRes.tested("isAccessibleRowSelected()", res);
539     }
540 
541     /**
542      * Calls the method with invalid indexes.
543      * If the interface <code>XAccessibleSelection</code> is supported by
544      * the component than selects all accessible childs.
545      * Calls the method for every column and checks returned values.
546      * The following method tests are to be executed before:
547      * <ul>
548      *  <li> <code>getAccessibleRowCount()</code> </li>
549      * </ul>
550      */
_isAccessibleColumnSelected()551     public void _isAccessibleColumnSelected() {
552         requiredMethod("getAccessibleColumnCount()");
553         boolean res = true;
554         boolean locRes = true;
555 
556         try {
557             log.print("isAccessibleColumnSelected(-1): ");
558             locRes = oObj.isAccessibleColumnSelected(-1);
559             log.println(locRes);
560             log.println("Exception was expected");
561             res &= false;
562         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
563             log.println("expected exception");
564             res &= true;
565         }
566 
567         try {
568             log.print("isAccessibleColumnSelected(" + colCount + "): ");
569             locRes = oObj.isAccessibleColumnSelected(colCount);
570             log.println(locRes);
571             log.println("Exception was expected");
572             res &= false;
573         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
574             log.println("expected exception");
575             res &= true;
576         }
577 
578         if (xASel != null) {
579             log.println("XAccessibleSelection.selectAllAccessibleChildren()");
580             xASel.selectAllAccessibleChildren();
581         }
582 
583         try {
584             log.println("Checking of every column selection...");
585             for(int i = 0; i < colCount; i++) {
586                 boolean isSel = oObj.isAccessibleColumnSelected(i);
587                 locRes = (xASel == null) ? !isSel : isSel;
588                 res &= locRes;
589                 if (!locRes) {
590                     log.println("isAccessibleColumnSelected(" + i + "): " + isSel);
591                     break;
592                 }
593             }
594         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
595             log.println("Unexpected exception");
596             e.printStackTrace(log);
597             res &= false;
598         }
599 
600         tRes.tested("isAccessibleColumnSelected()", res);
601     }
602 
603     XAccessible xCellAc = null;
604 
605     /**
606      * Calls the method with the wrong parameters and with the correct
607      * parameter, checks a returned value and stores it to the variable
608      * <code>xCellAc</code>.
609      * Has OK status if exceptions were thrown for the wrong indexes,
610      * if exception wasn't thrown for the correct index and
611      * if returned value isn't null.
612      * The following method tests are to be executed before:
613      * <ul>
614      *  <li> <code>getAccessibleColumnCount()</code> </li>
615      *  <li> <code>getAccessibleRowCount()</code> </li>
616      * </ul>
617      */
_getAccessibleCellAt()618     public void _getAccessibleCellAt() {
619         requiredMethod("getAccessibleRowCount()");
620         requiredMethod("getAccessibleColumnCount()");
621         boolean res = true;
622 
623         try {
624             log.print("getAccessibleCellAt(-1," + (colCount-1) + "):");
625             xCellAc = oObj.getAccessibleCellAt(-1, colCount - 1);
626             log.println(xCellAc);
627             log.println("Exception was expected");
628             res &= false;
629         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
630             log.println("expected exception");
631             res &= true;
632         }
633 
634         try {
635             log.print("getAccessibleCellAt(" + (rowCount-1) + ",-1):");
636             xCellAc = oObj.getAccessibleCellAt(rowCount - 1, -1);
637             log.println(xCellAc);
638             log.println("Exception was expected");
639             res &= false;
640         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
641             log.println("expected exception");
642             res &= true;
643         }
644 
645         try {
646             log.print("getAccessibleCellAt(0, " + colCount + "):");
647             xCellAc = oObj.getAccessibleCellAt(0, colCount);
648             log.println(xCellAc);
649             log.println("Exception was expected");
650             res &= false;
651         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
652             log.println("expected exception");
653             res &= true;
654         }
655 
656         try {
657             log.print("getAccessibleCellAt(" + rowCount + ",0):");
658             XAccessible xCellAc = oObj.getAccessibleCellAt(rowCount, 0);
659             log.println(xCellAc);
660             log.println("Exception was expected");
661             res &= false;
662         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
663             log.println("expected exception");
664             res &= true;
665         }
666 
667         try {
668             log.print("getAccessibleCellAt(" + (rowCount-1) + "," +
669                 (colCount-1) + "): ");
670             xCellAc = oObj.getAccessibleCellAt(
671                 rowCount - 1, colCount - 1);
672             log.println(xCellAc);
673             res &= xCellAc != null;
674         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
675             log.println("Unexpected exception");
676             e.printStackTrace(log);
677             res &= false;
678         }
679 
680         tRes.tested("getAccessibleCellAt()", res);
681     }
682 
683     /**
684      * Just calls the method.
685      */
_getAccessibleCaption()686     public void _getAccessibleCaption() {
687         XAccessible caption = oObj.getAccessibleCaption();
688         log.println("getAccessibleCaption(): " + caption);
689         tRes.tested("getAccessibleCaption()", true);
690     }
691 
692     /**
693      * Just calls the method.
694      */
_getAccessibleSummary()695     public void _getAccessibleSummary() {
696         XAccessible summary = oObj.getAccessibleSummary();
697         log.println("getAccessibleSummary(): " + summary);
698         tRes.tested("getAccessibleSummary()", true);
699     }
700 
701     /**
702      * Calls the method with the wrong parameters and with the correct
703      * parameter, checks a returned value.
704      * Has OK status if exceptions were thrown for the wrong indexes,
705      * if exception wasn't thrown for the correct index.
706      * The following method tests are to be executed before:
707      * <ul>
708      *  <li> <code>getAccessibleColumnCount()</code> </li>
709      *  <li> <code>getAccessibleRowCount()</code> </li>
710      * </ul>
711      */
_isAccessibleSelected()712     public void _isAccessibleSelected() {
713         requiredMethod("getAccessibleRowCount()");
714         requiredMethod("getAccessibleColumnCount()");
715         boolean res = true;
716         boolean locRes = true;
717 
718         try {
719             log.print("isAccessibleSelected(-1," + (colCount-1) + "):");
720             locRes = oObj.isAccessibleSelected(-1, colCount - 1);
721             log.println(locRes);
722             log.println("Exception was expected");
723             res &= false;
724         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
725             log.println("expected exception");
726             res &= true;
727         }
728 
729         try {
730             log.print("isAccessibleSelected(" + (rowCount-1) + ",-1):");
731             locRes = oObj.isAccessibleSelected(rowCount - 1, -1);
732             log.println(locRes);
733             log.println("Exception was expected");
734             res &= false;
735         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
736             log.println("expected exception");
737             res &= true;
738         }
739 
740         try {
741             log.print("isAccessibleSelected(0, " + colCount + "):");
742             locRes = oObj.isAccessibleSelected(0, colCount);
743             log.println(locRes);
744             log.println("Exception was expected");
745             res &= false;
746         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
747             log.println("expected exception");
748             res &= true;
749         }
750 
751         try {
752             log.print("isAccessibleSelected(" + rowCount + ",0):");
753             locRes = oObj.isAccessibleSelected(rowCount, 0);
754             log.println(locRes);
755             log.println("Exception was expected");
756             res &= false;
757         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
758             log.println("expected exception");
759             res &= true;
760         }
761 
762         if (xASel != null) {
763             log.println("XAccessibleSelection.selectAllAccessibleChildren()");
764             xASel.selectAllAccessibleChildren();
765         }
766 
767         try {
768             log.print("isAccessibleSelected(" + (rowCount-1) + "," +
769                 (colCount-1) + "): ");
770             boolean isSel = oObj.isAccessibleSelected(
771                 rowCount - 1, colCount - 1);
772             log.println(isSel);
773             locRes = (xASel == null) ? !isSel : isSel ;
774             res &= locRes;
775         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
776             log.println("Unexpected exception");
777             e.printStackTrace(log);
778             res &= false;
779         }
780 
781         tRes.tested("isAccessibleSelected()", res);
782     }
783 
784     /**
785      * Calls the method with the wrong parameters and with the correct
786      * parameter, checks a returned value.
787      * Has OK status if exceptions were thrown for the wrong indexes,
788      * if exception wasn't thrown for the correct index and
789      * if returned value is equal to value returned by calling
790      * <code>XAccessibleContext::getAccessibleIndexInParent</code> for the cell.
791      * The following method tests are to be executed before:
792      * <ul>
793      *  <li> <code>getAccessibleCellAt()</code> </li>
794      * </ul>
795      */
_getAccessibleIndex()796     public void _getAccessibleIndex() {
797         executeMethod("getAccessibleCellAt()");
798         boolean res = true;
799 
800         try {
801             log.print("getAccessibleIndex(-1," + (colCount-1) + "):");
802             int indx = oObj.getAccessibleIndex(-1, colCount - 1);
803             log.println(indx);
804             log.println("Exception was expected");
805             res &= false;
806         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
807             log.println("expected exception");
808             res &= true;
809         }
810 
811         try {
812             log.print("getAccessibleIndex(" + (rowCount-1) + ",-1):");
813             int indx = oObj.getAccessibleIndex(rowCount - 1, -1);
814             log.println(indx);
815             log.println("Exception was expected");
816             res &= false;
817         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
818             log.println("expected exception");
819             res &= true;
820         }
821 
822         try {
823             log.print("getAccessibleIndex(0," + colCount + "):");
824             int indx = oObj.getAccessibleIndex(0, colCount);
825             log.println(indx);
826             log.println("Exception was expected");
827             res &= false;
828         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
829             log.println("expected exception");
830             res &= true;
831         }
832 
833         try {
834             log.print("getAccessibleIndex(" + rowCount + ",0):");
835             int indx = oObj.getAccessibleIndex(rowCount, 0);
836             log.println(indx);
837             log.println("Exception was expected");
838             res &= false;
839         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
840             log.println("expected exception");
841             res &= true;
842         }
843 
844         try {
845             log.print("getAccessibleIndex(" + (rowCount-1) + "," +
846                 (colCount-1) + "): ");
847             int indx = oObj.getAccessibleIndex(
848                 rowCount - 1, colCount - 1);
849             log.println(indx);
850             if (xCellAc != null) {
851                 XAccessibleContext xAC = xCellAc.getAccessibleContext();
852                 int expIndx = xAC.getAccessibleIndexInParent();
853                 log.println("Expected index: " + expIndx);
854                 res &= expIndx == indx;
855             } else {
856                 res &= true;
857             }
858         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
859             log.println("Unexpected exception");
860             e.printStackTrace(log);
861             res &= false;
862         }
863 
864         tRes.tested("getAccessibleIndex()", res);
865     }
866 
867     /**
868      * Receives an accessible child count using the interface
869      * <code>XAccessibleContext</code>.
870      * Calls the method with the wrong parameters and with the correct
871      * parameter, checks a returned value.
872      * Has OK status if exceptions were thrown for the wrong indexes,
873      * if exception wasn't thrown for the correct index and
874      * if returned value is greater than zero and is less than
875      * accessible row count.
876      * The following method tests are to be executed before:
877      * <ul>
878      *  <li> <code>getAccessibleRowCount()</code> </li>
879      * </ul>
880      */
_getAccessibleRow()881     public void _getAccessibleRow() {
882         requiredMethod("getAccessibleRowCount()");
883         boolean res = true;
884 
885         if (xACont != null) {
886             int childCount = xACont.getAccessibleChildCount();
887             log.println("accessible child count: " + childCount);
888 
889             try {
890                 log.print("getAccessibleRow(" + childCount + "): ");
891                 int rowIndx = oObj.getAccessibleRow(childCount);
892                 log.println(rowIndx);
893                 log.println("Exception was expected");
894                 res &= false;
895             } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
896                 log.println("expected exception");
897                 res &= true;
898             }
899 
900             try {
901                 log.print("getAccessibleRow(" + (childCount-1) + "): ");
902                 int rowIndx = oObj.getAccessibleRow(childCount - 1);
903                 log.println(rowIndx);
904                 res &= (rowIndx >= 0 && rowIndx <= rowCount);
905             } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
906                 log.println("Unexpected exception");
907                 e.printStackTrace(log);
908                 res &= false;
909             }
910         }
911 
912         try {
913             log.print("getAccessibleRow(-1): ");
914             int rowIndx = oObj.getAccessibleRow(-1);
915             log.println(rowIndx);
916             log.println("Exception was expected");
917             res &= false;
918         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
919             log.println("expected exception");
920             res &= true;
921         }
922 
923         try {
924             log.print("getAccessibleRow(0): ");
925             int rowIndx = oObj.getAccessibleRow(0);
926             log.println(rowIndx);
927             res &= (rowIndx >= 0 && rowIndx <= rowCount);
928         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
929             log.println("Unexpected exception");
930             e.printStackTrace(log);
931             res &= false;
932         }
933 
934         tRes.tested("getAccessibleRow()", res);
935     }
936 
937     /**
938      * Receives an accessible child count using the interface
939      * <code>XAccessibleContext</code>.
940      * Calls the method with the wrong parameters and with the correct
941      * parameter, checks a returned value.
942      * Has OK status if exceptions were thrown for the wrong indexes,
943      * if exception wasn't thrown for the correct index and
944      * if returned value is greater than zero and is less than
945      * accessible column count.
946      * The following method tests are to be executed before:
947      * <ul>
948      *  <li> <code>getAccessibleColumnCount()</code> </li>
949      * </ul>
950      */
_getAccessibleColumn()951     public void _getAccessibleColumn() {
952         requiredMethod("getAccessibleColumnCount()");
953         boolean res = true;
954 
955         if (xACont != null) {
956             int childCount = xACont.getAccessibleChildCount();
957             log.println("accessible child count: " + childCount);
958 
959             try {
960                 log.print("getAccessibleColumn(" + childCount + "): ");
961                 int colIndx = oObj.getAccessibleColumn(childCount);
962                 log.println(colIndx);
963                 log.println("Exception was expected");
964                 res &= false;
965             } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
966                 log.println("expected exception");
967                 res &= true;
968             }
969 
970             try {
971                 log.print("getAccessibleColumn(" + (childCount-1) + "): ");
972                 int colIndx = oObj.getAccessibleColumn(childCount - 1);
973                 log.println(colIndx);
974                 res &= (colIndx >= 0 && colIndx <= colCount);
975             } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
976                 log.println("Unexpected exception");
977                 e.printStackTrace(log);
978                 res &= false;
979             }
980         }
981 
982         try {
983             log.print("getAccessibleColumn(-1): ");
984             int colIndx = oObj.getAccessibleColumn(-1);
985             log.println(colIndx);
986             log.println("Exception was expected");
987             res &= false;
988         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
989             log.println("expected exception");
990             res &= true;
991         }
992 
993         try {
994             log.print("getAccessibleColumn(0): ");
995             int colIndx = oObj.getAccessibleColumn(0);
996             log.println(colIndx);
997             res &= (colIndx >= 0 && colIndx <= rowCount);
998         } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
999             log.println("Unexpected exception");
1000             e.printStackTrace(log);
1001             res &= false;
1002         }
1003 
1004         tRes.tested("getAccessibleColumn()", res);
1005     }
1006 }