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