tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleEdit.java
blobd28592b6c5d964a5740abae16fb0bdfe07f8ac8e
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.accessibility.XAccessibleEditableText;
24 import com.sun.star.accessibility.XAccessibleText;
25 import com.sun.star.awt.XExtendedToolkit;
26 import com.sun.star.awt.XWindow;
27 import com.sun.star.beans.PropertyValue;
28 import com.sun.star.frame.XController;
29 import com.sun.star.frame.XDispatch;
30 import com.sun.star.frame.XDispatchProvider;
31 import com.sun.star.frame.XModel;
32 import com.sun.star.text.XTextDocument;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
35 import com.sun.star.util.URL;
36 import com.sun.star.util.XURLTransformer;
38 import java.io.PrintWriter;
40 import lib.TestCase;
41 import lib.TestEnvironment;
42 import lib.TestParameters;
43 import util.AccessibilityTools;
44 import util.SOfficeFactory;
45 import util.utils;
48 /**
49 * Test for object which is represented by edit field
50 * of 'Insert Hyperlink' dialog. <p>
52 * Object implements the following interfaces :
53 * <ul>
54 * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
55 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
56 * <li> <code>::com::sun::star::accessibility::XAccessibleEditableText</code></li>
57 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
58 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
59 * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li>
60 * </ul> <p>
62 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
63 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
64 * @see com.sun.star.accessibility.XAccessibleEditableText
65 * @see com.sun.star.accessibility.XAccessibleComponent
66 * @see com.sun.star.accessibility.XAccessibleContext
67 * @see com.sun.star.accessibility.XAccessibleText
68 * @see ifc.accessibility._XAccessibleExtendedComponent
69 * @see ifc.accessibility._XAccessibleEventBroadcaster
70 * @see ifc.accessibility._XAccessibleEditableText
71 * @see ifc.accessibility._XAccessibleComponent
72 * @see ifc.accessibility._XAccessibleContext
73 * @see ifc.accessibility._XAccessibleText
75 public class AccessibleEdit extends TestCase {
76 private static XTextDocument xTextDoc = null;
77 private static XAccessibleAction action = null;
79 /**
80 * Opens 'Insert Hyperlink' dialog using document dispatch provider.
81 * Finds active top window (the dialog
82 * window) and finds first accessible edit field and
83 * button 'Close' (for closing this dialog when disposing)
84 * walking through the accessible component tree.
86 @Override
87 protected TestEnvironment createTestEnvironment(TestParameters Param,
88 PrintWriter log) throws Exception {
89 XInterface oObj = null;
91 oObj = (XInterface) Param.getMSF().createInstance(
92 "com.sun.star.awt.Toolkit");
94 XExtendedToolkit tk = UnoRuntime.queryInterface(
95 XExtendedToolkit.class, oObj);
97 XModel aModel1 = UnoRuntime.queryInterface(XModel.class,
98 xTextDoc);
100 XController secondController = aModel1.getCurrentController();
102 XDispatchProvider aProv = UnoRuntime.queryInterface(
103 XDispatchProvider.class,
104 secondController);
106 XURLTransformer urlTransf = null;
108 XInterface transf = (XInterface) Param.getMSF().createInstance(
109 "com.sun.star.util.URLTransformer");
110 urlTransf = UnoRuntime.queryInterface(
111 XURLTransformer.class, transf);
113 XDispatch getting = null;
114 log.println("opening HyperlinkDialog");
116 URL[] url = new URL[1];
117 url[0] = new URL();
118 url[0].Complete = ".uno:HyperlinkDialog";
119 urlTransf.parseStrict(url);
120 getting = aProv.queryDispatch(url[0], "", 0);
122 PropertyValue[] noArgs = new PropertyValue[0];
123 getting.dispatch(url[0], noArgs);
125 util.utils.waitForEventIdle(Param.getMSF());
127 XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,
128 tk.getActiveTopWindow());
130 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
132 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON,
133 "Close");
134 action = UnoRuntime.queryInterface(
135 XAccessibleAction.class, oObj);
137 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT);
139 log.println("ImplementationName " + utils.getImplName(oObj));
141 TestEnvironment tEnv = new TestEnvironment(oObj);
143 final XAccessibleEditableText edText = UnoRuntime.queryInterface(
144 XAccessibleEditableText.class,
145 oObj);
146 edText.setText("AccessibleEdit");
148 tEnv.addObjRelation("EventProducer",
149 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
150 public void fireEvent() {
151 edText.setText("firing event ...");
152 edText.setText("firing event ... 2");
153 edText.setText("AccessibleEdit");
157 XAccessibleText text = UnoRuntime.queryInterface(
158 XAccessibleText.class, oObj);
160 tEnv.addObjRelation("XAccessibleText.Text", text.getText());
162 tEnv.addObjRelation("XAccessibleEditableText.hasAttr", Boolean.FALSE);
164 return tEnv;
168 * Closes dialog using action of button 'Close'
170 @Override
171 protected void cleanup(TestParameters Param, PrintWriter log) {
172 log.println(" Closing dialog ... ");
174 try {
175 action.doAccessibleAction(0);
176 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
177 log.println("Couldn't close dialog");
178 } catch (com.sun.star.lang.DisposedException de) {
179 log.println("Dialog already disposed");
182 util.DesktopTools.closeDoc(xTextDoc);
186 * Creates writer document
188 @Override
189 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
190 SOfficeFactory SOF = SOfficeFactory.getFactory(
191 Param.getMSF());
192 xTextDoc = SOF.createTextDoc(null);