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
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.AccessibilityTools
;
28 import util
.DesktopTools
;
29 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.awt
.XWindow
;
34 import com
.sun
.star
.beans
.PropertyValue
;
35 import com
.sun
.star
.frame
.XController
;
36 import com
.sun
.star
.frame
.XDesktop
;
37 import com
.sun
.star
.frame
.XDispatch
;
38 import com
.sun
.star
.frame
.XDispatchProvider
;
39 import com
.sun
.star
.frame
.XFrame
;
40 import com
.sun
.star
.frame
.XModel
;
41 import com
.sun
.star
.lang
.XMultiServiceFactory
;
42 import com
.sun
.star
.text
.XTextDocument
;
43 import com
.sun
.star
.uno
.UnoRuntime
;
44 import com
.sun
.star
.uno
.XInterface
;
45 import com
.sun
.star
.util
.URL
;
49 * Test for object that implements the following interfaces :
52 * <code>::com::sun::star::accessibility::XAccessibleContext
55 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
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 AccessibleBrowseBoxTable
extends TestCase
{
65 static XDesktop the_Desk
;
66 static XTextDocument xTextDoc
;
69 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
71 protected void initialize(TestParameters Param
, PrintWriter log
) {
72 the_Desk
= UnoRuntime
.queryInterface(XDesktop
.class,
73 DesktopTools
.createDesktop(
74 (XMultiServiceFactory
)Param
.getMSF()));
78 * Disposes the document, if exists, created in
79 * <code>createTestEnvironment</code> method.
81 protected void cleanup(TestParameters Param
, PrintWriter log
) {
82 log
.println("disposing xTextDoc");
84 if (xTextDoc
!= null) {
90 * Creates a text document. Opens the DataSource browser.
91 * Creates an instance of the service
92 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
93 * Then obtains an accessible object with the role
94 * <code>AccessibleRole.TABLE</code> and with the name
95 * <code>"Table"</code>.
96 * Object relations created :
98 * <li> <code>'EventProducer'</code> for
99 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
100 * method <code>fireEvent()</code> is empty because object is transient
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
112 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
114 log
.println("creating a test environment");
116 if (xTextDoc
!= null) {
120 // get a soffice factory object
121 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
122 (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 PropertyValue
[] noArgs
= new PropertyValue
[0];
153 getting
.dispatch(the_url
, noArgs
);
157 XFrame the_frame1
= the_Desk
.getCurrentFrame();
159 if (the_frame1
== null) {
160 log
.println("Current frame was not found !!!");
163 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
164 XController xCont
= the_frame2
.getController();
166 the_frame2
.setName("DatasourceBrowser");
168 final PropertyValue
[] params
= new PropertyValue
[3];
169 PropertyValue param1
= new PropertyValue();
170 param1
.Name
= "DataSourceName";
171 param1
.Value
= "Bibliography";
174 PropertyValue param2
= new PropertyValue();
175 param2
.Name
= "CommandType";
176 param2
.Value
= new Integer(com
.sun
.star
.sdb
.CommandType
.TABLE
);
179 PropertyValue param3
= new PropertyValue();
180 param3
.Name
= "Command";
181 param3
.Value
= "biblio";
184 final XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
185 XSelectionSupplier
.class, xCont
);
188 XInterface oObj
= null;
190 AccessibilityTools at
= new AccessibilityTools();
192 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
194 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
196 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TABLE
,
199 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
201 TestEnvironment tEnv
= new TestEnvironment(oObj
);
203 tEnv
.addObjRelation("EventProducer",
204 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
205 public void fireEvent() {
207 xSelect
.select(params
);
208 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
217 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
220 private void shortWait() {
223 } catch (InterruptedException e
) {
224 System
.out
.println("While waiting :" + e
);