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
.lang
.XMultiServiceFactory
;
46 import com
.sun
.star
.text
.XTextDocument
;
47 import com
.sun
.star
.uno
.UnoRuntime
;
48 import com
.sun
.star
.uno
.XInterface
;
49 import com
.sun
.star
.util
.URL
;
53 * Test for object that implements the following interfaces :
56 * <code>::com::sun::star::accessibility::XAccessibleContext
59 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
63 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
64 * @see com.sun.star.accessibility.XAccessibleContext
65 * @see ifc.accessibility._XAccessibleEventBroadcaster
66 * @see ifc.accessibility._XAccessibleContext
68 public class AccessibleBrowseBoxHeaderBar
extends TestCase
{
69 static XDesktop the_Desk
;
70 static XTextDocument xTextDoc
;
73 * 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(
78 (XMultiServiceFactory
) Param
.getMSF()));
82 * Disposes the document, if exists, created in
83 * <code>createTestEnvironment</code> method.
85 protected void cleanup(TestParameters Param
, PrintWriter log
) {
86 log
.println("disposing xTextDoc");
88 if (xTextDoc
!= null) {
94 * Creates a text document. Opens the DataSource browser.
95 * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code>
96 * and gets active top window. Then obtains an accessible object with
97 * the role <code>AccessibleRole.TABLE</code>.
98 * Object relations created :
100 * <li> <code>'EventProducer'</code> for
101 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
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 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
115 log
.println("creating a test environment");
117 if (xTextDoc
!= null) {
121 // get a soffice factory object
122 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
) tParam
.getMSF());
125 log
.println("creating a text document");
126 xTextDoc
= SOF
.createTextDoc(null);
127 } catch (com
.sun
.star
.uno
.Exception e
) {
128 // Some exception occurs.FAILED
129 e
.printStackTrace(log
);
130 throw new StatusException("Couldn't create document", e
);
135 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
138 XController secondController
= aModel1
.getCurrentController();
140 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
141 XDispatchProvider
.class,
144 XDispatch getting
= null;
146 log
.println("opening DatasourceBrowser");
148 URL the_url
= new URL();
149 the_url
.Complete
= ".component:DB/DataSourceBrowser";
150 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
152 //am controller ein XSelectionSupplier->mit params rufen
153 PropertyValue
[] noArgs
= new PropertyValue
[0];
154 getting
.dispatch(the_url
, noArgs
);
156 PropertyValue
[] params
= new PropertyValue
[3];
157 PropertyValue param1
= new PropertyValue();
158 param1
.Name
= "DataSourceName";
159 param1
.Value
= "Bibliography";
162 PropertyValue param2
= new PropertyValue();
163 param2
.Name
= "CommandType";
164 param2
.Value
= new Integer(com
.sun
.star
.sdb
.CommandType
.TABLE
);
167 PropertyValue param3
= new PropertyValue();
168 param3
.Name
= "Command";
169 param3
.Value
= "biblio";
174 XFrame the_frame1
= the_Desk
.getCurrentFrame();
176 if (the_frame1
== null) {
177 log
.println("Current frame was not found !!!");
180 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
182 the_frame2
.setName("DatasourceBrowser");
184 XController xCont
= the_frame2
.getController();
186 XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
187 XSelectionSupplier
.class, xCont
);
190 xSelect
.select(params
);
191 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
192 throw new StatusException("Could not select Biblio-Database", ex
);
195 XInterface oObj
= null;
197 AccessibilityTools at
= new AccessibilityTools();
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
);
212 XAccessibleComponent accComp
= UnoRuntime
.queryInterface(
213 XAccessibleComponent
.class,
215 final Point point
= accComp
.getLocationOnScreen();
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");
236 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
239 private void shortWait() {
242 } catch (InterruptedException e
) {
243 System
.out
.println("While waiting :" + e
);