Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / accessibility / _XAccessibleAction.java
blobf95ae9e9907774e8cba9d1eb6ffa2f7dbfda4a6b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XAccessibleAction.java,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.accessibility;
33 import com.sun.star.accessibility.XAccessibleAction;
35 public class _XAccessibleAction extends lib.MultiMethodTest {
37 public XAccessibleAction oObj = null;
38 public int count = 0;
40 /**
41 * calls the method and stores the result in the <br>
42 * variable count. Is OK if no excpetion occurs
45 public void _getAccessibleActionCount() {
46 count = oObj.getAccessibleActionCount();
47 tRes.tested("getAccessibleActionCount()",count > 0);
50 /**
51 * calls the method with invalid argument and check if the <br>
52 * expected Exception is thrown.<br>
53 * Calls the method afterwards the first valid parameter.<br>
54 * This is the last method called and the environment is disposed<br>
55 * afterwards.
58 public void _doAccessibleAction() {
59 requiredMethod("getAccessibleActionKeyBinding()");
60 boolean res = true;
62 log.println("Calling method with wrong argument");
63 try {
64 oObj.doAccessibleAction(count);
65 log.println("Exception expected -- FAILED");
66 res &= false;
67 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
68 log.println("Expected exception -- OK");
69 res &= true;
72 try {
73 boolean act = false;
74 for (int i = 0; i< count; i++) {
75 log.println("do Action "+ oObj.getAccessibleActionDescription(i));
76 act = oObj.doAccessibleAction(i);
77 log.println("Worked: "+act);
79 log.println("Did action: "+act);
80 res &= act ;
81 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
82 log.println("Unexepected exception -- FAILED");
83 res &= false;
86 tRes.tested("doAccessibleAction()",res);
89 /**
90 * calls the method with invalid argument and check if the <br>
91 * expected Exception is thrown.<br>
92 * Calls the method afterwards all valid parameters.<br>
93 * Is ok if the exception is thrown and the resulting value
94 * for the calls with valid parameters aren't null.
97 public void _getAccessibleActionDescription() {
98 requiredMethod("getAccessibleActionCount()");
99 boolean res = true;
101 log.println("Calling method with wrong argument");
102 try {
103 oObj.getAccessibleActionDescription(count);
104 log.println("Exception expected -- FAILED");
105 res &= false;
106 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
107 log.println("Expected exception -- OK");
108 res &= true;
111 for (int i=0;i<count;i++) {
112 try {
113 String desc = oObj.getAccessibleActionDescription(i);
114 log.println("Found action: "+desc);
115 res &= desc!=null ;
116 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
117 log.println("Unexepected exception -- FAILED");
118 res &= false;
122 tRes.tested("getAccessibleActionDescription()",res);
126 * calls the method with invalid argument and check if the <br>
127 * expected Exception is thrown.<br>
128 * Calls the method afterwards all valid parameters.<br>
129 * Is ok if the exception is thrown and the resulting value
130 * for the calls with valid parameters aren't null.
133 public void _getAccessibleActionKeyBinding() {
134 requiredMethod("getAccessibleActionDescription()");
135 boolean res = true;
137 log.println("Calling method with wrong argument");
138 try {
139 oObj.getAccessibleActionKeyBinding(count);
140 log.println("Exception expected -- FAILED");
141 res &= false;
142 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
143 log.println("Expected exception -- OK");
144 res &= true;
147 for (int i=0;i<count;i++) {
148 try {
149 Object key = oObj.getAccessibleActionKeyBinding(i);
150 if (key != null ) {
151 log.println("Found key: "+key.toString());
153 res &= true;
154 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
155 log.println("Unexepected exception -- FAILED");
156 res &= false;
160 tRes.tested("getAccessibleActionKeyBinding()",res);
164 * Forces environment recreation.
166 protected void after() {
167 disposeEnvironment();