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 .
20 import com
.sun
.star
.view
.XSelectionSupplier
;
22 import java
.awt
.Robot
;
23 import java
.awt
.event
.InputEvent
;
24 import java
.io
.PrintWriter
;
27 import lib
.TestEnvironment
;
28 import lib
.TestParameters
;
29 import util
.AccessibilityTools
;
30 import util
.DesktopTools
;
31 import util
.SOfficeFactory
;
33 import com
.sun
.star
.accessibility
.AccessibleRole
;
34 import com
.sun
.star
.accessibility
.XAccessible
;
35 import com
.sun
.star
.accessibility
.XAccessibleComponent
;
36 import com
.sun
.star
.awt
.Point
;
37 import com
.sun
.star
.awt
.XWindow
;
38 import com
.sun
.star
.beans
.PropertyValue
;
39 import com
.sun
.star
.frame
.XController
;
40 import com
.sun
.star
.frame
.XDesktop
;
41 import com
.sun
.star
.frame
.XDispatch
;
42 import com
.sun
.star
.frame
.XDispatchProvider
;
43 import com
.sun
.star
.frame
.XFrame
;
44 import com
.sun
.star
.frame
.XModel
;
45 import com
.sun
.star
.text
.XTextDocument
;
46 import com
.sun
.star
.uno
.UnoRuntime
;
47 import com
.sun
.star
.uno
.XInterface
;
48 import com
.sun
.star
.util
.URL
;
52 * Test for object that implements the following interfaces :
55 * <code>::com::sun::star::accessibility::XAccessibleContext
58 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
62 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
63 * @see com.sun.star.accessibility.XAccessibleContext
64 * @see ifc.accessibility._XAccessibleEventBroadcaster
65 * @see ifc.accessibility._XAccessibleContext
67 public class AccessibleBrowseBoxHeaderBar
extends TestCase
{
68 static XDesktop xDesktop
;
69 static XTextDocument xTextDoc
;
72 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
75 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
76 xDesktop
= DesktopTools
.createDesktop(Param
.getMSF());
80 * Disposes the document, if exists, created in
81 * <code>createTestEnvironment</code> method.
84 protected void cleanup(TestParameters Param
, PrintWriter log
) {
85 log
.println("disposing xTextDoc");
87 if (xTextDoc
!= null) {
93 * Creates a text document. Opens the DataSource browser.
94 * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code>
95 * and gets active top window. Then obtains an accessible object with
96 * the role <code>AccessibleRole.TABLE</code>.
97 * Object relations created :
99 * <li> <code>'EventProducer'</code> for
100 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
104 * @param tParam test parameters
105 * @param log writer to log information while testing
107 * @see com.sun.star.awt.Toolkit
108 * @see com.sun.star.accessibility.AccessibleRole
109 * @see ifc.accessibility._XAccessibleEventBroadcaster
110 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
113 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
114 PrintWriter log
) throws Exception
{
115 log
.println("creating a test environment");
117 if (xTextDoc
!= null) {
121 // get a soffice factory object
122 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
124 log
.println("creating a text document");
125 xTextDoc
= SOF
.createTextDoc(null);
127 util
.utils
.waitForEventIdle(tParam
.getMSF());
129 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
132 XController secondController
= aModel1
.getCurrentController();
134 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
135 XDispatchProvider
.class,
138 XDispatch getting
= null;
140 log
.println("opening DatasourceBrowser");
142 URL the_url
= new URL();
143 the_url
.Complete
= ".component:DB/DataSourceBrowser";
144 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
146 // an XSelectionSupplier at the controller -> call with params
147 PropertyValue
[] noArgs
= new PropertyValue
[0];
148 getting
.dispatch(the_url
, noArgs
);
150 PropertyValue
[] params
= new PropertyValue
[3];
151 PropertyValue param1
= new PropertyValue();
152 param1
.Name
= "DataSourceName";
153 param1
.Value
= "Bibliography";
156 PropertyValue param2
= new PropertyValue();
157 param2
.Name
= "CommandType";
158 param2
.Value
= Integer
.valueOf(com
.sun
.star
.sdb
.CommandType
.TABLE
);
161 PropertyValue param3
= new PropertyValue();
162 param3
.Name
= "Command";
163 param3
.Value
= "biblio";
166 util
.utils
.waitForEventIdle(tParam
.getMSF());
168 XFrame the_frame1
= xDesktop
.getCurrentFrame();
170 if (the_frame1
== null) {
171 log
.println("Current frame was not found !!!");
174 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
176 the_frame2
.setName("DatasourceBrowser");
178 XController xCont
= the_frame2
.getController();
180 XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
181 XSelectionSupplier
.class, xCont
);
183 xSelect
.select(params
);
185 XInterface oObj
= null;
187 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
189 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
191 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TABLE
);
193 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
194 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
196 TestEnvironment tEnv
= new TestEnvironment(oObj
);
198 util
.utils
.waitForEventIdle(tParam
.getMSF());
200 XAccessibleComponent accComp
= UnoRuntime
.queryInterface(
201 XAccessibleComponent
.class,
203 final Point point
= accComp
.getLocationOnScreen();
205 util
.utils
.waitForEventIdle(tParam
.getMSF());
207 tEnv
.addObjRelation("EventProducer",
208 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
209 public void fireEvent() {
211 Robot rob
= new Robot();
212 rob
.mouseMove(point
.X
+ 5, point
.Y
+ 5);
213 rob
.mousePress(InputEvent
.BUTTON1_MASK
);
214 } catch (java
.awt
.AWTException e
) {
215 System
.out
.println("couldn't fire event");