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