tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / AccessibleEditableTextPara_HeaderFooter.java
blobed9e5da9a65c487b6ffbbde7d6bcc182e20fb353
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._sc;
20 import java.io.PrintWriter;
22 import lib.TestCase;
23 import lib.TestEnvironment;
24 import lib.TestParameters;
25 import util.AccessibilityTools;
26 import util.SOfficeFactory;
27 import util.utils;
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.accessibility.XAccessibleContext;
33 import com.sun.star.accessibility.XAccessibleEditableText;
34 import com.sun.star.accessibility.XAccessibleText;
35 import com.sun.star.awt.XExtendedToolkit;
36 import com.sun.star.awt.XWindow;
37 import com.sun.star.frame.XController;
38 import com.sun.star.frame.XDispatch;
39 import com.sun.star.frame.XDispatchProvider;
40 import com.sun.star.frame.XModel;
41 import com.sun.star.lang.XComponent;
42 import com.sun.star.lang.XMultiServiceFactory;
43 import com.sun.star.uno.UnoRuntime;
44 import com.sun.star.util.URL;
45 import com.sun.star.util.XURLTransformer;
48 public class AccessibleEditableTextPara_HeaderFooter extends TestCase {
49 protected static XComponent xCalcDoc = null;
50 protected static XMultiServiceFactory msf = null;
51 protected static XAccessibleAction action = null;
53 @Override
54 protected TestEnvironment createTestEnvironment(TestParameters Param,
55 PrintWriter log) throws Exception {
56 XAccessibleContext oObj = null;
57 Object toolkit = msf.createInstance("com.sun.star.awt.Toolkit");
59 XExtendedToolkit tk = UnoRuntime.queryInterface(
60 XExtendedToolkit.class, toolkit);
62 util.utils.waitForEventIdle(Param.getMSF());
64 DiagThread psDiag = new DiagThread(xCalcDoc, msf);
65 psDiag.start();
67 util.utils.waitForEventIdle(Param.getMSF());
69 Object atw = tk.getActiveTopWindow();
71 XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,
72 atw);
74 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
76 util.utils.waitForEventIdle(Param.getMSF());
78 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
79 XAccessibleContext ok_button = AccessibilityTools.getAccessibleObjectForRole(xRoot,
80 AccessibleRole.PUSH_BUTTON,
81 "Cancel");
83 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PARAGRAPH);
85 log.println("ImplementationName " + utils.getImplName(oObj));
86 log.println("AccessibleName " + oObj.getAccessibleName());
87 log.println("ParentDescription " +
88 oObj.getAccessibleParent().getAccessibleContext()
89 .getAccessibleDescription());
91 TestEnvironment tEnv = new TestEnvironment(oObj);
93 action = UnoRuntime.queryInterface(
94 XAccessibleAction.class, ok_button);
96 XAccessibleText text = UnoRuntime.queryInterface(
97 XAccessibleText.class, oObj);
99 XAccessibleEditableText eText = UnoRuntime.queryInterface(
100 XAccessibleEditableText.class,
101 oObj);
103 eText.setText("LEFT");
105 tEnv.addObjRelation("XAccessibleText.Text", text.getText());
107 tEnv.addObjRelation("Destroy", "AccessibleEditableTextPara_PreviewCell");
109 final XAccessibleEditableText editText = eText;
111 tEnv.addObjRelation("EventProducer",
112 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
113 public void fireEvent() {
114 editText.setText("LEFT_EVENT");
118 return tEnv;
122 * Closes the dialog using accessible button 'OK' found in
123 * <code>createTestEnvironment()</code>.
125 @Override
126 protected void cleanup(TestParameters Param, PrintWriter log) {
127 log.println(" disposing xCalcDoc ");
129 try {
130 action.doAccessibleAction(0);
131 } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
132 log.println("Couldn't close dialog");
133 } catch (com.sun.star.lang.DisposedException de) {
134 log.println("Dialog already disposed");
137 util.DesktopTools.closeDoc(xCalcDoc);
141 * Opens new writer document.
143 @Override
144 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
145 msf = Param.getMSF();
147 SOfficeFactory SOF = SOfficeFactory.getFactory(msf);
148 xCalcDoc = UnoRuntime.queryInterface(XComponent.class,
149 SOF.createCalcDoc(
150 null));
155 * Thread for opening modal dialog 'Print Settings'.
157 private class DiagThread extends Thread {
158 private XComponent xCalcDoc = null;
159 private XMultiServiceFactory msf = null;
161 private DiagThread(XComponent xCalcDoc, XMultiServiceFactory msf) {
162 this.xCalcDoc = xCalcDoc;
163 this.msf = msf;
166 @Override
167 public void run() {
168 XModel aModel = UnoRuntime.queryInterface(XModel.class,
169 xCalcDoc);
171 XController xController = aModel.getCurrentController();
173 //Opening HeaderFooterDialog
174 try {
175 String aSlotID = ".uno:EditHeaderAndFooter";
176 XDispatchProvider xDispProv = UnoRuntime.queryInterface(
177 XDispatchProvider.class,
178 xController);
179 XURLTransformer xParser = UnoRuntime.queryInterface(
180 XURLTransformer.class,
181 msf.createInstance(
182 "com.sun.star.util.URLTransformer"));
184 // Because it's an in/out parameter
185 // we must use an array of URL objects.
186 URL[] aParseURL = new URL[1];
187 aParseURL[0] = new URL();
188 aParseURL[0].Complete = aSlotID;
189 xParser.parseStrict(aParseURL);
191 URL aURL = aParseURL[0];
192 XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0);
194 if (xDispatcher != null) {
195 xDispatcher.dispatch(aURL, null);
197 } catch (com.sun.star.uno.Exception e) {
198 log.println("Couldn't open dialog");