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
;
21 import java
.awt
.Robot
;
22 import java
.awt
.event
.InputEvent
;
23 import java
.io
.PrintWriter
;
25 import lib
.StatusException
;
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 the_Desk
;
69 static XTextDocument xTextDoc
;
72 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
75 protected void initialize(TestParameters Param
, PrintWriter log
) {
76 the_Desk
= UnoRuntime
.queryInterface(XDesktop
.class,
77 DesktopTools
.createDesktop(
82 * Disposes the document, if exists, created in
83 * <code>createTestEnvironment</code> method.
86 protected void cleanup(TestParameters Param
, PrintWriter log
) {
87 log
.println("disposing xTextDoc");
89 if (xTextDoc
!= null) {
95 * Creates a text document. Opens the DataSource browser.
96 * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code>
97 * and gets active top window. Then obtains an accessible object with
98 * the role <code>AccessibleRole.TABLE</code>.
99 * Object relations created :
101 * <li> <code>'EventProducer'</code> for
102 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
106 * @param tParam test parameters
107 * @param log writer to log information while testing
109 * @see com.sun.star.awt.Toolkit
110 * @see com.sun.star.accessibility.AccessibleRole
111 * @see ifc.accessibility._XAccessibleEventBroadcaster
112 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
115 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
117 log
.println("creating a test environment");
119 if (xTextDoc
!= null) {
123 // get a soffice factory object
124 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
127 log
.println("creating a text document");
128 xTextDoc
= SOF
.createTextDoc(null);
129 } catch (com
.sun
.star
.uno
.Exception e
) {
130 // Some exception occurs.FAILED
131 e
.printStackTrace(log
);
132 throw new StatusException("Couldn't create document", e
);
135 util
.utils
.pause(5000);
137 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
140 XController secondController
= aModel1
.getCurrentController();
142 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
143 XDispatchProvider
.class,
146 XDispatch getting
= null;
148 log
.println("opening DatasourceBrowser");
150 URL the_url
= new URL();
151 the_url
.Complete
= ".component:DB/DataSourceBrowser";
152 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
154 //am controller ein XSelectionSupplier->mit params rufen
155 PropertyValue
[] noArgs
= new PropertyValue
[0];
156 getting
.dispatch(the_url
, noArgs
);
158 PropertyValue
[] params
= new PropertyValue
[3];
159 PropertyValue param1
= new PropertyValue();
160 param1
.Name
= "DataSourceName";
161 param1
.Value
= "Bibliography";
164 PropertyValue param2
= new PropertyValue();
165 param2
.Name
= "CommandType";
166 param2
.Value
= Integer
.valueOf(com
.sun
.star
.sdb
.CommandType
.TABLE
);
169 PropertyValue param3
= new PropertyValue();
170 param3
.Name
= "Command";
171 param3
.Value
= "biblio";
174 util
.utils
.pause(5000);
176 XFrame the_frame1
= the_Desk
.getCurrentFrame();
178 if (the_frame1
== null) {
179 log
.println("Current frame was not found !!!");
182 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
184 the_frame2
.setName("DatasourceBrowser");
186 XController xCont
= the_frame2
.getController();
188 XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
189 XSelectionSupplier
.class, xCont
);
192 xSelect
.select(params
);
193 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
194 throw new StatusException("Could not select Biblio-Database", ex
);
197 XInterface oObj
= null;
199 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
201 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
203 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TABLE
);
205 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
206 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
208 TestEnvironment tEnv
= new TestEnvironment(oObj
);
210 util
.utils
.pause(5000);
212 XAccessibleComponent accComp
= UnoRuntime
.queryInterface(
213 XAccessibleComponent
.class,
215 final Point point
= accComp
.getLocationOnScreen();
217 util
.utils
.pause(5000);
219 tEnv
.addObjRelation("EventProducer",
220 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
221 public void fireEvent() {
223 Robot rob
= new Robot();
224 rob
.mouseMove(point
.X
+ 5, point
.Y
+ 5);
225 rob
.mousePress(InputEvent
.BUTTON1_MASK
);
226 } catch (java
.awt
.AWTException e
) {
227 System
.out
.println("couldn't fire event");