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 package mod._toolkit; 28 29 import com.sun.star.accessibility.AccessibleRole; 30 import com.sun.star.accessibility.XAccessible; 31 import com.sun.star.accessibility.XAccessibleAction; 32 import com.sun.star.awt.XWindow; 33 import com.sun.star.lang.XMultiServiceFactory; 34 import com.sun.star.text.XTextDocument; 35 import com.sun.star.uno.UnoRuntime; 36 import com.sun.star.uno.XInterface; 37 38 import java.io.PrintWriter; 39 40 import lib.StatusException; 41 import lib.TestCase; 42 import lib.TestEnvironment; 43 import lib.TestParameters; 44 45 import util.AccessibilityTools; 46 import util.SOfficeFactory; 47 import util.utils; 48 49 50 /** 51 * Test for object which is represented by accessible component 52 * of the URL locator combo box located in the left upper corner 53 * of a document. <p> 54 * 55 * Object implements the following interfaces : 56 * <ul> 57 * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> 58 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> 59 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> 60 * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li> 61 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> 62 * </ul> <p> 63 * 64 * @see com.sun.star.accessibility.XAccessibleExtendedComponent 65 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster 66 * @see com.sun.star.accessibility.XAccessibleComponent 67 * @see com.sun.star.accessibility.XAccessibleAction 68 * @see com.sun.star.accessibility.XAccessibleContext 69 * @see ifc.accessibility._XAccessibleExtendedComponent 70 * @see ifc.accessibility._XAccessibleEventBroadcaster 71 * @see ifc.accessibility._XAccessibleComponent 72 * @see ifc.accessibility._XAccessibleAction 73 * @see ifc.accessibility._XAccessibleContext 74 */ 75 public class AccessibleDropDownComboBox extends TestCase { 76 private static XTextDocument xTextDoc = null; 77 78 /** 79 * Finds AccessibleDropDownComboBox walking through the 80 * accessible component tree of a writer document. 81 */ 82 protected TestEnvironment createTestEnvironment(TestParameters Param, 83 PrintWriter log) { 84 XInterface oObj = null; 85 86 AccessibilityTools at = new AccessibilityTools(); 87 88 XWindow xWindow = at.getCurrentContainerWindow( 89 (XMultiServiceFactory) Param.getMSF(), 90 xTextDoc); 91 92 XAccessible xRoot = at.getAccessibleObject(xWindow); 93 94 oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.COMBO_BOX, 95 "", "AccessibleDropDownComboBox"); 96 97 log.println("ImplementationName " + utils.getImplName(oObj)); 98 99 TestEnvironment tEnv = new TestEnvironment(oObj); 100 101 final XAccessibleAction editAction = (XAccessibleAction) UnoRuntime.queryInterface( 102 XAccessibleAction.class, 103 oObj); 104 105 tEnv.addObjRelation("EventProducer", 106 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { 107 public void fireEvent() { 108 try { 109 editAction.doAccessibleAction(0); 110 } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 111 e.printStackTrace(); 112 } 113 } 114 }); 115 116 return tEnv; 117 } 118 119 /** 120 * Creates writer document. 121 */ 122 protected void initialize(TestParameters Param, PrintWriter log) { 123 try { 124 SOfficeFactory SOF = SOfficeFactory.getFactory( 125 (XMultiServiceFactory) Param.getMSF()); 126 xTextDoc = SOF.createTextDoc(null); 127 } catch (com.sun.star.uno.Exception e) { 128 throw new StatusException("Can't create document", e); 129 } 130 } 131 132 /** 133 * Disposes writer document. 134 */ 135 protected void cleanup(TestParameters Param, PrintWriter log) { 136 util.DesktopTools.closeDoc(xTextDoc); 137 ; 138 } 139 }