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
.text
.XTextDocument
;
43 import com
.sun
.star
.uno
.UnoRuntime
;
44 import com
.sun
.star
.uno
.XInterface
;
45 import com
.sun
.star
.util
.URL
;
46 import com
.sun
.star
.util
.XCloseable
;
50 * Test for object that implements the following interfaces :
52 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
54 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
56 * <li><code>::com::sun::star::accessibility::XAccessibleContext
58 * <li><code>::com::sun::star::accessibility::XAccessibleSelection
60 * <li><code>::com::sun::star::accessibility::XAccessibleAction
62 * <li><code>::com::sun::star::accessibility::XAccessibleText
66 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
67 * @see com.sun.star.accessibility.XAccessibleContext
68 * @see com.sun.star.accessibility.XAccessibleComponent
69 * @see com.sun.star.accessibility.XAccessibleSelection
70 * @see com.sun.star.accessibility.XAccessibleAction
71 * @see com.sun.star.accessibility.XAccessibleText
72 * @see ifc.accessibility._XAccessibleEventBroadcaster
73 * @see ifc.accessibility._XAccessibleContext
74 * @see ifc.accessibility._XAccessibleComponent
75 * @see ifc.accessibility._XAccessibleSelection
76 * @see ifc.accessibility._XAccessibleAction
77 * @see ifc.accessibility._XAccessibleText
79 public class AccessibleTreeListBoxEntry
extends TestCase
{
80 static XDesktop the_Desk
;
81 static XTextDocument xTextDoc
;
84 * 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(
94 * Disposes the document, if exists, created in
95 * <code>createTestEnvironment</code> method.
98 protected void cleanup(TestParameters Param
, PrintWriter log
) {
99 log
.println("disposing xTextDoc");
101 if (xTextDoc
!= null) {
107 * Creates a text document. Opens the DataSource browser.
108 * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code>
109 * and gets active top window. Then obtains an accessible object with
110 * the role <code>AccessibleRole.LABEL</code> and with the name
111 * <code>"Bibliography"</code>.
112 * Object relations created :
114 * <li> <code>'EventProducer'</code> for
115 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
117 * <li> <code>'XAccessibleSelection.multiSelection'</code>
118 * of type <code>Boolean</code> for
119 * {@link ifc.accessibility._XAccessibleSelection}:
120 * indicates that component supports single selection mode.</li>
121 * <li> <code>'XAccessibleText.Text'</code> for
122 * {@link ifc.accessibility._XAccessibleText}:
123 * the text of the component</li>
126 * @param tParam test parameters
127 * @param log writer to log information while testing
129 * @see com.sun.star.awt.Toolkit
130 * @see com.sun.star.accessibility.AccessibleRole
131 * @see ifc.accessibility._XAccessibleEventBroadcaster
132 * @see ifc.accessibility._XAccessibleSelection
133 * @see ifc.accessibility._XAccessibleText
134 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
135 * @see com.sun.star.accessibility.XAccessibleSelection
136 * @see com.sun.star.accessibility.XAccessibleText
139 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
141 log
.println("creating a test environment");
143 if (xTextDoc
!= null) {
147 // get a soffice factory object
148 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
151 log
.println("creating a text document");
152 xTextDoc
= SOF
.createTextDoc(null);
153 } catch (com
.sun
.star
.uno
.Exception e
) {
154 // Some exception occurs.FAILED
155 e
.printStackTrace(log
);
156 throw new StatusException("Couldn't create document", e
);
159 util
.utils
.pause(5000);
161 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
164 XController secondController
= aModel1
.getCurrentController();
166 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
167 XDispatchProvider
.class,
170 XDispatch getting
= null;
172 log
.println("opening DatasourceBrowser");
174 URL the_url
= new URL();
175 the_url
.Complete
= ".component:DB/DataSourceBrowser";
176 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
178 PropertyValue
[] noArgs
= new PropertyValue
[0];
179 getting
.dispatch(the_url
, noArgs
);
181 util
.utils
.pause(5000);
183 XFrame the_frame1
= the_Desk
.getCurrentFrame();
185 if (the_frame1
== null) {
186 log
.println("Current frame was not found !!!");
189 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
191 the_frame2
.setName("DatasourceBrowser");
193 XInterface oObj
= null;
195 UnoRuntime
.queryInterface(
196 XInitialization
.class,
197 the_frame2
.getController());
199 PropertyValue
[] params
= new PropertyValue
[3];
200 PropertyValue param1
= new PropertyValue();
201 param1
.Name
= "DataSourceName";
202 param1
.Value
= "Bibliography";
205 PropertyValue param2
= new PropertyValue();
206 param2
.Name
= "CommandType";
207 param2
.Value
= Integer
.valueOf(com
.sun
.star
.sdb
.CommandType
.QUERY
);
210 PropertyValue param3
= new PropertyValue();
211 param3
.Name
= "Command";
212 param3
.Value
= "select * from biblio";
215 XController xCont
= the_frame2
.getController();
217 XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
218 XSelectionSupplier
.class, xCont
);
221 xSelect
.select(params
);
222 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
223 throw new StatusException("Could not select Biblio-Database", ex
);
226 util
.utils
.pause(5000);
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");
262 protected void closeDoc() {
263 XCloseable closer
= UnoRuntime
.queryInterface(
264 XCloseable
.class, xTextDoc
);
268 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
269 log
.println("Couldn't close document " + e
.getMessage());
270 } catch (com
.sun
.star
.lang
.DisposedException e
) {
271 log
.println("Couldn't close document " + e
.getMessage());