tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleBrowseBoxHeaderCell.java
blobe050458ecc0988fcc86ce655124e90967e09cc9b
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 .
19 package mod._svtools;
21 import com.sun.star.view.XSelectionSupplier;
23 import java.io.PrintWriter;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
28 import util.AccessibilityTools;
29 import util.DesktopTools;
30 import util.SOfficeFactory;
32 import com.sun.star.accessibility.AccessibleRole;
33 import com.sun.star.accessibility.XAccessible;
34 import com.sun.star.awt.XWindow;
35 import com.sun.star.beans.PropertyValue;
36 import com.sun.star.frame.XController;
37 import com.sun.star.frame.XDesktop;
38 import com.sun.star.frame.XDispatch;
39 import com.sun.star.frame.XDispatchProvider;
40 import com.sun.star.frame.XFrame;
41 import com.sun.star.frame.XModel;
42 import com.sun.star.lang.XInitialization;
43 import com.sun.star.text.XTextDocument;
44 import com.sun.star.uno.UnoRuntime;
45 import com.sun.star.uno.XInterface;
46 import com.sun.star.util.URL;
48 /**
49 * Test for object that implements the following interfaces :
50 * <ul>
51 * <li>
52 * <code>::com::sun::star::accessibility::XAccessibleContext
53 * </code></li>
54 * <li>
55 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
56 * </code></li>
57 * </ul> <p>
59 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see ifc.accessibility._XAccessibleEventBroadcaster
62 * @see ifc.accessibility._XAccessibleContext
64 public class AccessibleBrowseBoxHeaderCell extends TestCase {
66 static XDesktop the_Desk;
67 static XTextDocument xTextDoc;
69 /**
70 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
72 @Override
73 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
74 the_Desk = UnoRuntime.queryInterface(
75 XDesktop.class, DesktopTools.createDesktop(Param.getMSF()));
78 /**
79 * Disposes the document, if exists, created in
80 * <code>createTestEnvironment</code> method.
82 @Override
83 protected void cleanup( TestParameters Param, PrintWriter log) {
85 log.println("disposing xTextDoc");
87 if (xTextDoc != null) {
88 xTextDoc.dispose();
92 /**
93 * Creates a text document. Opens the DataSource browser and loads
94 * the table. Creates an instance of the service
95 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
96 * Then obtains an accessible object with the role
97 * <code>AccessibleRole.UNKNOWN</code> and with the name
98 * <code>"Identifier"</code>.
99 * Object relations created :
100 * <ul>
101 * <li> <code>'EventProducer'</code> for
102 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
103 * method <code>fireEvent()</code> is empty because object is transient
104 * </li>
105 * </ul>
107 * @param tParam test parameters
108 * @param log writer to log information while testing
110 * @see com.sun.star.awt.Toolkit
111 * @see com.sun.star.accessibility.AccessibleRole
112 * @see ifc.accessibility._XAccessibleEventBroadcaster
113 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
115 @Override
116 protected TestEnvironment createTestEnvironment(
117 TestParameters tParam, PrintWriter log) throws Exception {
119 log.println( "creating a test environment" );
121 if (xTextDoc != null) xTextDoc.dispose();
123 // get a soffice factory object
124 SOfficeFactory SOF = SOfficeFactory.getFactory( 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, xTextDoc);
133 XController secondController = aModel1.getCurrentController();
135 XDispatchProvider aProv = UnoRuntime.
136 queryInterface(XDispatchProvider.class, secondController);
138 XDispatch getting = null;
140 log.println( "opening DatasourceBrowser" );
141 URL the_url = new URL();
142 the_url.Complete = ".component:DB/DataSourceBrowser";
143 getting = aProv.queryDispatch(the_url, "_beamer", 12);
144 PropertyValue[] noArgs = new PropertyValue[0];
145 getting.dispatch(the_url, noArgs);
147 util.utils.waitForEventIdle(tParam.getMSF());
149 XFrame the_frame1 = the_Desk.getCurrentFrame();
151 if (the_frame1 == null) {
152 log.println("Current frame was not found !!!");
155 XFrame the_frame2 = the_frame1.findFrame("_beamer", 4);
157 the_frame2.setName("DatasourceBrowser");
159 XInterface oObj = null;
161 UnoRuntime.queryInterface(
162 XInitialization.class, the_frame2.getController());
164 PropertyValue[] params = new PropertyValue[3];
165 PropertyValue param1 = new PropertyValue();
166 param1.Name = "DataSourceName";
167 param1.Value = "Bibliography";
168 params[0] = param1;
169 PropertyValue param2 = new PropertyValue();
170 param2.Name = "CommandType";
171 param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE);
172 params[1] = param2;
173 PropertyValue param3 = new PropertyValue();
174 param3.Name = "Command";
175 param3.Value = "biblio";
176 params[2] = param3;
178 XController xCont = the_frame2.getController();
180 XSelectionSupplier xSelect = UnoRuntime.queryInterface(
181 XSelectionSupplier.class, xCont);
183 xSelect.select(params);
185 XWindow xWindow = secondController.getFrame().getContainerWindow();
187 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
189 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
191 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot,
192 AccessibleRole.ROW_HEADER);
194 log.println("ImplementationName: "+ util.utils.getImplName(oObj));
196 TestEnvironment tEnv = new TestEnvironment(oObj);
198 tEnv.addObjRelation("EventProducer",
199 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
200 public void fireEvent() {
204 return tEnv;