tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleBrowseBoxTableCell.java
blob0adc36e3bf1ba8a3e7b4c9e15698d579f4f6a344
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 java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.DesktopTools;
28 import util.SOfficeFactory;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.awt.XWindow;
33 import com.sun.star.beans.PropertyValue;
34 import com.sun.star.frame.XController;
35 import com.sun.star.frame.XDesktop;
36 import com.sun.star.frame.XDispatch;
37 import com.sun.star.frame.XDispatchProvider;
38 import com.sun.star.frame.XFrame;
39 import com.sun.star.frame.XModel;
40 import com.sun.star.text.XTextDocument;
41 import com.sun.star.uno.UnoRuntime;
42 import com.sun.star.uno.XInterface;
43 import com.sun.star.util.URL;
45 /**
46 * Test for object that implements the following interfaces :
47 * <ul>
48 * <li>
49 * <code>::com::sun::star::accessibility::XAccessibleContext
50 * </code></li>
51 * <li>
52 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
53 * </code></li>
54 * </ul> <p>
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleContext
58 * @see ifc.accessibility._XAccessibleEventBroadcaster
59 * @see ifc.accessibility._XAccessibleContext
61 public class AccessibleBrowseBoxTableCell extends TestCase {
63 static XDesktop xDesktop;
64 static XTextDocument xTextDoc;
66 /**
67 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
69 @Override
70 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
71 xDesktop = DesktopTools.createDesktop(Param.getMSF());
74 /**
75 * Disposes the document, if exists, created in
76 * <code>createTestEnvironment</code> method.
78 @Override
79 protected void cleanup( TestParameters Param, PrintWriter log) {
81 log.println("disposing xTextDoc");
83 if (xTextDoc != null) {
84 xTextDoc.dispose();
88 /**
89 * Creates a text document. Opens the DataSource browser and loads
90 * the table. Creates an instance of the service
91 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
92 * Then obtains an accessible object with the role
93 * <code>AccessibleRole.TABLE_CELL</code>.
94 * Object relations created :
95 * <ul>
96 * <li> <code>'EventProducer'</code> for
97 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
98 * method <code>fireEvent()</code> is empty because object is transient
99 * </li>
100 * </ul>
102 * @param tParam test parameters
103 * @param log writer to log information while testing
105 * @see com.sun.star.awt.Toolkit
106 * @see com.sun.star.accessibility.AccessibleRole
107 * @see ifc.accessibility._XAccessibleEventBroadcaster
108 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
110 @Override
111 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
113 log.println( "creating a test environment" );
115 if (xTextDoc != null) xTextDoc.dispose();
117 // get a soffice factory object
118 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
120 log.println( "creating a text document" );
121 xTextDoc = SOF.createTextDoc(null);
123 util.utils.waitForEventIdle(tParam.getMSF());
125 XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc);
127 XController secondController = aModel1.getCurrentController();
130 XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class,secondController);
132 XDispatch getting = null;
134 log.println( "opening DatasourceBrowser" );
135 URL the_url = new URL();
136 the_url.Complete = ".component:DB/DataSourceBrowser";
137 getting = aProv.queryDispatch(the_url,"_beamer",12);
138 PropertyValue[] noArgs = new PropertyValue[0];
139 getting.dispatch(the_url,noArgs);
141 util.utils.waitForEventIdle(tParam.getMSF());
143 XFrame the_frame1 = xDesktop.getCurrentFrame();
145 if (the_frame1 == null) {
146 log.println("Current frame was not found !!!");
149 XFrame the_frame2 = the_frame1.findFrame("_beamer",4);
151 the_frame2.setName("DatasourceBrowser");
153 util.utils.waitForEventIdle(tParam.getMSF());
155 XWindow xWindow = secondController.getFrame().getContainerWindow();
157 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
159 XInterface oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL);
161 log.println("ImplementationName: "+util.utils.getImplName(oObj));
163 TestEnvironment tEnv = new TestEnvironment( oObj );
165 tEnv.addObjRelation("EventProducer",
166 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
167 public void fireEvent() {
171 return tEnv;