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
.XInitialization
;
42 import com
.sun
.star
.lang
.XMultiServiceFactory
;
43 import com
.sun
.star
.text
.XTextDocument
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
45 import com
.sun
.star
.uno
.XInterface
;
46 import com
.sun
.star
.util
.URL
;
47 import com
.sun
.star
.util
.XCloseable
;
51 * Test for object that implements the following interfaces :
53 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
55 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
57 * <li><code>::com::sun::star::accessibility::XAccessibleContext
59 * <li><code>::com::sun::star::accessibility::XAccessibleSelection
61 * <li><code>::com::sun::star::accessibility::XAccessibleAction
63 * <li><code>::com::sun::star::accessibility::XAccessibleText
67 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
68 * @see com.sun.star.accessibility.XAccessibleContext
69 * @see com.sun.star.accessibility.XAccessibleComponent
70 * @see com.sun.star.accessibility.XAccessibleSelection
71 * @see com.sun.star.accessibility.XAccessibleAction
72 * @see com.sun.star.accessibility.XAccessibleText
73 * @see ifc.accessibility._XAccessibleEventBroadcaster
74 * @see ifc.accessibility._XAccessibleContext
75 * @see ifc.accessibility._XAccessibleComponent
76 * @see ifc.accessibility._XAccessibleSelection
77 * @see ifc.accessibility._XAccessibleAction
78 * @see ifc.accessibility._XAccessibleText
80 public class AccessibleTreeListBoxEntry
extends TestCase
{
81 static XDesktop the_Desk
;
82 static XTextDocument xTextDoc
;
85 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
87 protected void initialize(TestParameters Param
, PrintWriter log
) {
88 the_Desk
= UnoRuntime
.queryInterface(XDesktop
.class,
89 DesktopTools
.createDesktop(
90 (XMultiServiceFactory
) Param
.getMSF()));
94 * Disposes the document, if exists, created in
95 * <code>createTestEnvironment</code> method.
97 protected void cleanup(TestParameters Param
, PrintWriter log
) {
98 log
.println("disposing xTextDoc");
100 if (xTextDoc
!= null) {
106 * Creates a text document. Opens the DataSource browser.
107 * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code>
108 * and gets active top window. Then obtains an accessible object with
109 * the role <code>AccessibleRole.LABEL</code> and with the name
110 * <code>"Bibliography"</code>.
111 * Object relations created :
113 * <li> <code>'EventProducer'</code> for
114 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
116 * <li> <code>'XAccessibleSelection.multiSelection'</code>
117 * of type <code>Boolean</code> for
118 * {@link ifc.accessibility._XAccessibleSelection}:
119 * indicates that component supports single selection mode.</li>
120 * <li> <code>'XAccessibleText.Text'</code> for
121 * {@link ifc.accessibility._XAccessibleText}:
122 * the text of the component</li>
125 * @param tParam test parameters
126 * @param log writer to log information while testing
128 * @see com.sun.star.awt.Toolkit
129 * @see com.sun.star.accessibility.AccessibleRole
130 * @see ifc.accessibility._XAccessibleEventBroadcaster
131 * @see ifc.accessibility._XAccessibleSelection
132 * @see ifc.accessibility._XAccessibleText
133 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
134 * @see com.sun.star.accessibility.XAccessibleSelection
135 * @see com.sun.star.accessibility.XAccessibleText
137 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
139 log
.println("creating a test environment");
141 if (xTextDoc
!= null) {
145 // get a soffice factory object
146 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
) tParam
.getMSF());
149 log
.println("creating a text document");
150 xTextDoc
= SOF
.createTextDoc(null);
151 } catch (com
.sun
.star
.uno
.Exception e
) {
152 // Some exception occurs.FAILED
153 e
.printStackTrace(log
);
154 throw new StatusException("Couldn't create document", e
);
159 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
162 XController secondController
= aModel1
.getCurrentController();
164 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
165 XDispatchProvider
.class,
168 XDispatch getting
= null;
170 log
.println("opening DatasourceBrowser");
172 URL the_url
= new URL();
173 the_url
.Complete
= ".component:DB/DataSourceBrowser";
174 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
176 PropertyValue
[] noArgs
= new PropertyValue
[0];
177 getting
.dispatch(the_url
, noArgs
);
181 XFrame the_frame1
= the_Desk
.getCurrentFrame();
183 if (the_frame1
== null) {
184 log
.println("Current frame was not found !!!");
187 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
189 the_frame2
.setName("DatasourceBrowser");
191 XInterface oObj
= null;
193 UnoRuntime
.queryInterface(
194 XInitialization
.class,
195 the_frame2
.getController());
197 PropertyValue
[] params
= new PropertyValue
[3];
198 PropertyValue param1
= new PropertyValue();
199 param1
.Name
= "DataSourceName";
200 param1
.Value
= "Bibliography";
203 PropertyValue param2
= new PropertyValue();
204 param2
.Name
= "CommandType";
205 param2
.Value
= new Integer(com
.sun
.star
.sdb
.CommandType
.QUERY
);
208 PropertyValue param3
= new PropertyValue();
209 param3
.Name
= "Command";
210 param3
.Value
= "select * from biblio";
213 XController xCont
= the_frame2
.getController();
215 XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
216 XSelectionSupplier
.class, xCont
);
219 xSelect
.select(params
);
220 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
221 throw new StatusException("Could not select Biblio-Database", ex
);
226 AccessibilityTools at
= new AccessibilityTools();
228 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
230 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
232 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
234 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.LABEL
,
237 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
239 TestEnvironment tEnv
= new TestEnvironment(oObj
);
241 tEnv
.addObjRelation("EditOnly",
242 "This method isn't supported in this component");
244 //adding ObjectRelation for XAccessibleText
245 tEnv
.addObjRelation("LimitedBounds", "true");
248 tEnv
.addObjRelation("EventProducer",
249 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
250 public void fireEvent() {
254 tEnv
.addObjRelation("XAccessibleSelection.multiSelection",
257 tEnv
.addObjRelation("XAccessibleText.Text", "Bibliography");
263 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
266 private void shortWait() {
269 } catch (InterruptedException e
) {
270 System
.out
.println("While waiting :" + e
);
274 protected void closeDoc() {
275 XCloseable closer
= UnoRuntime
.queryInterface(
276 XCloseable
.class, xTextDoc
);
280 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
281 log
.println("Couldn't close document " + e
.getMessage());
282 } catch (com
.sun
.star
.lang
.DisposedException e
) {
283 log
.println("Couldn't close document " + e
.getMessage());