Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / accessibility / _XAccessibleAction.java
blobbc0de990ced77f108878b77211682c7d7ed92758
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.accessibility;
21 import com.sun.star.accessibility.XAccessibleAction;
23 public class _XAccessibleAction extends lib.MultiMethodTest {
25 public XAccessibleAction oObj = null;
26 public int count = 0;
28 /**
29 * calls the method and stores the result in the <br>
30 * variable count. Is OK if no excpetion occurs
33 public void _getAccessibleActionCount() {
34 count = oObj.getAccessibleActionCount();
35 tRes.tested("getAccessibleActionCount()",count > 0);
38 /**
39 * calls the method with invalid argument and check if the <br>
40 * expected Exception is thrown.<br>
41 * Calls the method afterwards the first valid parameter.<br>
42 * This is the last method called and the environment is disposed<br>
43 * afterwards.
46 public void _doAccessibleAction() {
47 requiredMethod("getAccessibleActionKeyBinding()");
48 boolean res = true;
50 log.println("Calling method with wrong argument");
51 try {
52 oObj.doAccessibleAction(count);
53 log.println("Exception expected -- FAILED");
54 res &= false;
55 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
56 log.println("Expected exception -- OK");
57 res &= true;
60 try {
61 boolean act = false;
62 for (int i = 0; i< count; i++) {
63 log.println("do Action "+ oObj.getAccessibleActionDescription(i));
64 act = oObj.doAccessibleAction(i);
65 log.println("Worked: "+act);
67 log.println("Did action: "+act);
68 res &= act ;
69 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
70 log.println("Unexepected exception -- FAILED");
71 res &= false;
74 tRes.tested("doAccessibleAction()",res);
77 /**
78 * calls the method with invalid argument and check if the <br>
79 * expected Exception is thrown.<br>
80 * Calls the method afterwards all valid parameters.<br>
81 * Is ok if the exception is thrown and the resulting value
82 * for the calls with valid parameters aren't null.
85 public void _getAccessibleActionDescription() {
86 requiredMethod("getAccessibleActionCount()");
87 boolean res = true;
89 log.println("Calling method with wrong argument");
90 try {
91 oObj.getAccessibleActionDescription(count);
92 log.println("Exception expected -- FAILED");
93 res &= false;
94 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
95 log.println("Expected exception -- OK");
96 res &= true;
99 for (int i=0;i<count;i++) {
100 try {
101 String desc = oObj.getAccessibleActionDescription(i);
102 log.println("Found action: "+desc);
103 res &= desc!=null ;
104 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
105 log.println("Unexepected exception -- FAILED");
106 res &= false;
110 tRes.tested("getAccessibleActionDescription()",res);
114 * calls the method with invalid argument and check if the <br>
115 * expected Exception is thrown.<br>
116 * Calls the method afterwards all valid parameters.<br>
117 * Is ok if the exception is thrown and the resulting value
118 * for the calls with valid parameters aren't null.
121 public void _getAccessibleActionKeyBinding() {
122 requiredMethod("getAccessibleActionDescription()");
123 boolean res = true;
125 log.println("Calling method with wrong argument");
126 try {
127 oObj.getAccessibleActionKeyBinding(count);
128 log.println("Exception expected -- FAILED");
129 res &= false;
130 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
131 log.println("Expected exception -- OK");
132 res &= true;
135 for (int i=0;i<count;i++) {
136 try {
137 Object key = oObj.getAccessibleActionKeyBinding(i);
138 if (key != null ) {
139 log.println("Found key: "+key.toString());
141 res &= true;
142 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
143 log.println("Unexepected exception -- FAILED");
144 res &= false;
148 tRes.tested("getAccessibleActionKeyBinding()",res);
152 * Forces environment recreation.
154 @Override
155 protected void after() {
156 disposeEnvironment();