xref: /AOO42X/main/qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java (revision b275ba1e209f5c0cd98ea59c7ca7c8c3c906970f)
1ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ef39d40dSAndrew Rist  * distributed with this work for additional information
6ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18ef39d40dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20ef39d40dSAndrew Rist  *************************************************************/
21ef39d40dSAndrew Rist 
22ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.accessibility;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleAction;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir public class _XAccessibleAction extends lib.MultiMethodTest {
29cdf0e10cSrcweir 
30cdf0e10cSrcweir     public XAccessibleAction oObj = null;
31cdf0e10cSrcweir     public int count = 0;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir     /**
34cdf0e10cSrcweir      * calls the method and stores the result in the <br>
35*b275ba1eSJohn Bampton      * variable count. Is OK if no exception occurs
36cdf0e10cSrcweir      */
37cdf0e10cSrcweir 
_getAccessibleActionCount()38cdf0e10cSrcweir     public void _getAccessibleActionCount() {
39cdf0e10cSrcweir         count = oObj.getAccessibleActionCount();
40cdf0e10cSrcweir         tRes.tested("getAccessibleActionCount()",count > 0);
41cdf0e10cSrcweir     }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     /**
44cdf0e10cSrcweir      * calls the method with invalid argument and check if the <br>
45cdf0e10cSrcweir      * expected Exception is thrown.<br>
46cdf0e10cSrcweir      * Calls the method afterwards the first valid parameter.<br>
47cdf0e10cSrcweir      * This is the last method called and the environment is disposed<br>
48cdf0e10cSrcweir      * afterwards.
49cdf0e10cSrcweir      */
50cdf0e10cSrcweir 
_doAccessibleAction()51cdf0e10cSrcweir     public void _doAccessibleAction() {
52cdf0e10cSrcweir         requiredMethod("getAccessibleActionKeyBinding()");
53cdf0e10cSrcweir         boolean res = true;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir         log.println("Calling method with wrong argument");
56cdf0e10cSrcweir         try {
57cdf0e10cSrcweir             oObj.doAccessibleAction(count);
58cdf0e10cSrcweir             log.println("Exception expected -- FAILED");
59cdf0e10cSrcweir             res &= false;
60cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
61cdf0e10cSrcweir             log.println("Expected exception -- OK");
62cdf0e10cSrcweir             res &= true;
63cdf0e10cSrcweir         }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         try {
66cdf0e10cSrcweir             boolean act = false;
67cdf0e10cSrcweir             for (int i = 0; i< count; i++) {
68cdf0e10cSrcweir                 log.println("do Action "+ oObj.getAccessibleActionDescription(i));
69cdf0e10cSrcweir                 act = oObj.doAccessibleAction(i);
70cdf0e10cSrcweir                 log.println("Worked: "+act);
71cdf0e10cSrcweir             }
72cdf0e10cSrcweir             log.println("Did action: "+act);
73cdf0e10cSrcweir             res &= act ;
74cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
75adc718aaSJohn Bampton             log.println("Unexpected exception -- FAILED");
76cdf0e10cSrcweir             res &= false;
77cdf0e10cSrcweir         }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir         tRes.tested("doAccessibleAction()",res);
80cdf0e10cSrcweir     }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     /**
83cdf0e10cSrcweir      * calls the method with invalid argument and check if the <br>
84cdf0e10cSrcweir      * expected Exception is thrown.<br>
85cdf0e10cSrcweir      * Calls the method afterwards all valid parameters.<br>
86cdf0e10cSrcweir      * Is ok if the exception is thrown and the resulting value
87cdf0e10cSrcweir      * for the calls with valid parameters aren't null.
88cdf0e10cSrcweir      */
89cdf0e10cSrcweir 
_getAccessibleActionDescription()90cdf0e10cSrcweir     public void _getAccessibleActionDescription() {
91cdf0e10cSrcweir         requiredMethod("getAccessibleActionCount()");
92cdf0e10cSrcweir         boolean res = true;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         log.println("Calling method with wrong argument");
95cdf0e10cSrcweir         try {
96cdf0e10cSrcweir             oObj.getAccessibleActionDescription(count);
97cdf0e10cSrcweir             log.println("Exception expected -- FAILED");
98cdf0e10cSrcweir             res &= false;
99cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
100cdf0e10cSrcweir             log.println("Expected exception -- OK");
101cdf0e10cSrcweir             res &= true;
102cdf0e10cSrcweir         }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         for (int i=0;i<count;i++) {
105cdf0e10cSrcweir             try {
106cdf0e10cSrcweir                 String desc = oObj.getAccessibleActionDescription(i);
107cdf0e10cSrcweir                 log.println("Found action: "+desc);
108cdf0e10cSrcweir                 res &= desc!=null ;
109cdf0e10cSrcweir             } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
110adc718aaSJohn Bampton                 log.println("Unexpected exception -- FAILED");
111cdf0e10cSrcweir                 res &= false;
112cdf0e10cSrcweir             }
113cdf0e10cSrcweir         }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         tRes.tested("getAccessibleActionDescription()",res);
116cdf0e10cSrcweir     }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     /**
119cdf0e10cSrcweir      * calls the method with invalid argument and check if the <br>
120cdf0e10cSrcweir      * expected Exception is thrown.<br>
121cdf0e10cSrcweir      * Calls the method afterwards all valid parameters.<br>
122cdf0e10cSrcweir      * Is ok if the exception is thrown and the resulting value
123cdf0e10cSrcweir      * for the calls with valid parameters aren't null.
124cdf0e10cSrcweir      */
125cdf0e10cSrcweir 
_getAccessibleActionKeyBinding()126cdf0e10cSrcweir     public void _getAccessibleActionKeyBinding() {
127cdf0e10cSrcweir         requiredMethod("getAccessibleActionDescription()");
128cdf0e10cSrcweir         boolean res = true;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         log.println("Calling method with wrong argument");
131cdf0e10cSrcweir         try {
132cdf0e10cSrcweir             oObj.getAccessibleActionKeyBinding(count);
133cdf0e10cSrcweir             log.println("Exception expected -- FAILED");
134cdf0e10cSrcweir             res &= false;
135cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
136cdf0e10cSrcweir             log.println("Expected exception -- OK");
137cdf0e10cSrcweir             res &= true;
138cdf0e10cSrcweir         }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         for (int i=0;i<count;i++) {
141cdf0e10cSrcweir             try {
142cdf0e10cSrcweir                 Object key = oObj.getAccessibleActionKeyBinding(i);
143cdf0e10cSrcweir                 if (key != null ) {
144cdf0e10cSrcweir                     log.println("Found key: "+key.toString());
145cdf0e10cSrcweir                 }
146cdf0e10cSrcweir                 res &= true;
147cdf0e10cSrcweir             } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
148adc718aaSJohn Bampton                 log.println("Unexpected exception -- FAILED");
149cdf0e10cSrcweir                 res &= false;
150cdf0e10cSrcweir             }
151cdf0e10cSrcweir         }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         tRes.tested("getAccessibleActionKeyBinding()",res);
154cdf0e10cSrcweir     }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     /**
157cdf0e10cSrcweir     * Forces environment recreation.
158cdf0e10cSrcweir     */
after()159cdf0e10cSrcweir     protected void after() {
160cdf0e10cSrcweir         disposeEnvironment();
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir }
164