bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleDropDownComboBox.java
blob4eac734ec462bdbe961eba6fc2ed25b48fea648b
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 .
18 package mod._toolkit;
20 import com.sun.star.accessibility.AccessibleRole;
21 import com.sun.star.accessibility.XAccessible;
22 import com.sun.star.accessibility.XAccessibleAction;
23 import com.sun.star.awt.XWindow;
24 import com.sun.star.lang.XMultiServiceFactory;
25 import com.sun.star.text.XTextDocument;
26 import com.sun.star.uno.UnoRuntime;
27 import com.sun.star.uno.XInterface;
29 import java.io.PrintWriter;
31 import lib.StatusException;
32 import lib.TestCase;
33 import lib.TestEnvironment;
34 import lib.TestParameters;
36 import util.AccessibilityTools;
37 import util.SOfficeFactory;
38 import util.utils;
41 /**
42 * Test for object which is represented by accessible component
43 * of the URL locator combo box located in the left upper corner
44 * of a document. <p>
46 * Object implements the following interfaces :
47 * <ul>
48 * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
51 * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li>
52 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
53 * </ul> <p>
55 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleComponent
58 * @see com.sun.star.accessibility.XAccessibleAction
59 * @see com.sun.star.accessibility.XAccessibleContext
60 * @see ifc.accessibility._XAccessibleExtendedComponent
61 * @see ifc.accessibility._XAccessibleEventBroadcaster
62 * @see ifc.accessibility._XAccessibleComponent
63 * @see ifc.accessibility._XAccessibleAction
64 * @see ifc.accessibility._XAccessibleContext
66 public class AccessibleDropDownComboBox extends TestCase {
67 private static XTextDocument xTextDoc = null;
69 /**
70 * Finds AccessibleDropDownComboBox walking through the
71 * accessible component tree of a writer document.
73 protected TestEnvironment createTestEnvironment(TestParameters Param,
74 PrintWriter log) {
75 XInterface oObj = null;
77 AccessibilityTools at = new AccessibilityTools();
79 XWindow xWindow = AccessibilityTools.getCurrentContainerWindow(
80 (XMultiServiceFactory) Param.getMSF(),
81 xTextDoc);
83 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
85 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.COMBO_BOX,
86 "", "AccessibleDropDownComboBox");
88 log.println("ImplementationName " + utils.getImplName(oObj));
90 TestEnvironment tEnv = new TestEnvironment(oObj);
92 final XAccessibleAction editAction = UnoRuntime.queryInterface(
93 XAccessibleAction.class,
94 oObj);
96 tEnv.addObjRelation("EventProducer",
97 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
98 public void fireEvent() {
99 try {
100 editAction.doAccessibleAction(0);
101 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
102 e.printStackTrace();
107 return tEnv;
111 * Creates writer document.
113 protected void initialize(TestParameters Param, PrintWriter log) {
114 try {
115 SOfficeFactory SOF = SOfficeFactory.getFactory(
116 (XMultiServiceFactory) Param.getMSF());
117 xTextDoc = SOF.createTextDoc(null);
118 } catch (com.sun.star.uno.Exception e) {
119 throw new StatusException("Can't create document", e);
124 * Disposes writer document.
126 protected void cleanup(TestParameters Param, PrintWriter log) {
127 util.DesktopTools.closeDoc(xTextDoc);