1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew 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> 35cdf0e10cSrcweir * variable count. Is OK if no excpetion 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) { 75cdf0e10cSrcweir log.println("Unexepected 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) { 110cdf0e10cSrcweir log.println("Unexepected 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) { 148cdf0e10cSrcweir log.println("Unexepected 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