tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleBrowseBoxTable.java
blob49f42f4c624bcf87fd4a839fca0f6e5147bf5c28
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._svtools;
20 import com.sun.star.view.XSelectionSupplier;
22 import java.io.PrintWriter;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.AccessibilityTools;
28 import util.DesktopTools;
29 import util.SOfficeFactory;
31 import com.sun.star.accessibility.AccessibleRole;
32 import com.sun.star.accessibility.XAccessible;
33 import com.sun.star.awt.XWindow;
34 import com.sun.star.beans.PropertyValue;
35 import com.sun.star.frame.XController;
36 import com.sun.star.frame.XDesktop;
37 import com.sun.star.frame.XDispatch;
38 import com.sun.star.frame.XDispatchProvider;
39 import com.sun.star.frame.XFrame;
40 import com.sun.star.frame.XModel;
41 import com.sun.star.text.XTextDocument;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XInterface;
44 import com.sun.star.util.URL;
47 /**
48 * Test for object that implements the following interfaces :
49 * <ul>
50 * <li>
51 * <code>::com::sun::star::accessibility::XAccessibleContext
52 * </code></li>
53 * <li>
54 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
55 * </code></li>
56 * </ul> <p>
58 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
59 * @see com.sun.star.accessibility.XAccessibleContext
60 * @see ifc.accessibility._XAccessibleEventBroadcaster
61 * @see ifc.accessibility._XAccessibleContext
63 public class AccessibleBrowseBoxTable extends TestCase {
64 static XDesktop the_Desk;
65 static XTextDocument xTextDoc;
67 /**
68 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
70 @Override
71 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
72 the_Desk = UnoRuntime.queryInterface(XDesktop.class,
73 DesktopTools.createDesktop(
74 Param.getMSF()));
77 /**
78 * Disposes the document, if exists, created in
79 * <code>createTestEnvironment</code> method.
81 @Override
82 protected void cleanup(TestParameters Param, PrintWriter log) {
83 log.println("disposing xTextDoc");
85 if (xTextDoc != null) {
86 xTextDoc.dispose();
90 /**
91 * Creates a text document. Opens the DataSource browser.
92 * Creates an instance of the service
93 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
94 * Then obtains an accessible object with the role
95 * <code>AccessibleRole.TABLE</code> and with the name
96 * <code>"Table"</code>.
97 * Object relations created :
98 * <ul>
99 * <li> <code>'EventProducer'</code> for
100 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
101 * method <code>fireEvent()</code> is empty because object is transient
102 * </li>
103 * </ul>
105 * @param tParam test parameters
106 * @param log writer to log information while testing
108 * @see com.sun.star.awt.Toolkit
109 * @see com.sun.star.accessibility.AccessibleRole
110 * @see ifc.accessibility._XAccessibleEventBroadcaster
111 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
113 @Override
114 protected TestEnvironment createTestEnvironment(TestParameters tParam,
115 PrintWriter log) throws Exception {
116 log.println("creating a test environment");
118 if (xTextDoc != null) {
119 xTextDoc.dispose();
122 // get a soffice factory object
123 SOfficeFactory SOF = SOfficeFactory.getFactory(
124 tParam.getMSF());
126 log.println("creating a text document");
127 xTextDoc = SOF.createTextDoc(null);
129 util.utils.waitForEventIdle(tParam.getMSF());
131 XModel aModel1 = UnoRuntime.queryInterface(XModel.class,
132 xTextDoc);
134 XController secondController = aModel1.getCurrentController();
136 XDispatchProvider aProv = UnoRuntime.queryInterface(
137 XDispatchProvider.class,
138 secondController);
140 XDispatch getting = null;
142 log.println("opening DatasourceBrowser");
144 URL the_url = new URL();
145 the_url.Complete = ".component:DB/DataSourceBrowser";
146 getting = aProv.queryDispatch(the_url, "_beamer", 12);
148 PropertyValue[] noArgs = new PropertyValue[0];
149 getting.dispatch(the_url, noArgs);
151 util.utils.waitForEventIdle(tParam.getMSF());
153 XFrame the_frame1 = the_Desk.getCurrentFrame();
155 if (the_frame1 == null) {
156 log.println("Current frame was not found !!!");
159 XFrame the_frame2 = the_frame1.findFrame("_beamer", 4);
160 XController xCont = the_frame2.getController();
162 the_frame2.setName("DatasourceBrowser");
164 final PropertyValue[] params = new PropertyValue[3];
165 PropertyValue param1 = new PropertyValue();
166 param1.Name = "DataSourceName";
167 param1.Value = "Bibliography";
168 params[0] = param1;
170 PropertyValue param2 = new PropertyValue();
171 param2.Name = "CommandType";
172 param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE);
173 params[1] = param2;
175 PropertyValue param3 = new PropertyValue();
176 param3.Name = "Command";
177 param3.Value = "biblio";
178 params[2] = param3;
180 final XSelectionSupplier xSelect = UnoRuntime.queryInterface(
181 XSelectionSupplier.class, xCont);
184 XInterface oObj = null;
186 XWindow xWindow = secondController.getFrame().getContainerWindow();
188 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
190 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE,
191 "Table");
193 log.println("ImplementationName: " + util.utils.getImplName(oObj));
195 TestEnvironment tEnv = new TestEnvironment(oObj);
197 tEnv.addObjRelation("EventProducer",
198 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
199 public void fireEvent() {
200 try {
201 xSelect.select(params);
202 } catch (com.sun.star.lang.IllegalArgumentException ex) {
207 return tEnv;