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
;
22 import java
.io
.PrintWriter
;
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 xDesktop
;
81 static XTextDocument xTextDoc
;
84 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
87 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
88 xDesktop
= DesktopTools
.createDesktop(Param
.getMSF());
92 * Disposes the document, if exists, created in
93 * <code>createTestEnvironment</code> method.
96 protected void cleanup(TestParameters Param
, PrintWriter log
) {
97 log
.println("disposing xTextDoc");
99 if (xTextDoc
!= null) {
105 * Creates a text document. Opens the DataSource browser.
106 * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code>
107 * and gets active top window. Then obtains an accessible object with
108 * the role <code>AccessibleRole.LABEL</code> and with the name
109 * <code>"Bibliography"</code>.
110 * Object relations created :
112 * <li> <code>'EventProducer'</code> for
113 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
115 * <li> <code>'XAccessibleSelection.multiSelection'</code>
116 * of type <code>Boolean</code> for
117 * {@link ifc.accessibility._XAccessibleSelection}:
118 * indicates that component supports single selection mode.</li>
119 * <li> <code>'XAccessibleText.Text'</code> for
120 * {@link ifc.accessibility._XAccessibleText}:
121 * the text of the component</li>
124 * @param tParam test parameters
125 * @param log writer to log information while testing
127 * @see com.sun.star.awt.Toolkit
128 * @see com.sun.star.accessibility.AccessibleRole
129 * @see ifc.accessibility._XAccessibleEventBroadcaster
130 * @see ifc.accessibility._XAccessibleSelection
131 * @see ifc.accessibility._XAccessibleText
132 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
133 * @see com.sun.star.accessibility.XAccessibleSelection
134 * @see com.sun.star.accessibility.XAccessibleText
137 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
138 PrintWriter log
) throws Exception
{
139 log
.println("creating a test environment");
141 if (xTextDoc
!= null) {
145 // get a soffice factory object
146 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
148 log
.println("creating a text document");
149 xTextDoc
= SOF
.createTextDoc(null);
151 util
.utils
.waitForEventIdle(tParam
.getMSF());
153 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
156 XController secondController
= aModel1
.getCurrentController();
158 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
159 XDispatchProvider
.class,
162 XDispatch getting
= null;
164 log
.println("opening DatasourceBrowser");
166 URL the_url
= new URL();
167 the_url
.Complete
= ".component:DB/DataSourceBrowser";
168 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
170 PropertyValue
[] noArgs
= new PropertyValue
[0];
171 getting
.dispatch(the_url
, noArgs
);
173 util
.utils
.waitForEventIdle(tParam
.getMSF());
175 XFrame the_frame1
= xDesktop
.getCurrentFrame();
177 if (the_frame1
== null) {
178 log
.println("Current frame was not found !!!");
181 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
183 the_frame2
.setName("DatasourceBrowser");
185 XInterface oObj
= null;
187 UnoRuntime
.queryInterface(
188 XInitialization
.class,
189 the_frame2
.getController());
191 PropertyValue
[] params
= new PropertyValue
[3];
192 PropertyValue param1
= new PropertyValue();
193 param1
.Name
= "DataSourceName";
194 param1
.Value
= "Bibliography";
197 PropertyValue param2
= new PropertyValue();
198 param2
.Name
= "CommandType";
199 param2
.Value
= Integer
.valueOf(com
.sun
.star
.sdb
.CommandType
.QUERY
);
202 PropertyValue param3
= new PropertyValue();
203 param3
.Name
= "Command";
204 param3
.Value
= "select * from biblio";
207 XController xCont
= the_frame2
.getController();
209 XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
210 XSelectionSupplier
.class, xCont
);
212 xSelect
.select(params
);
214 util
.utils
.waitForEventIdle(tParam
.getMSF());
216 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
218 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
220 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
222 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.LABEL
,
225 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
227 TestEnvironment tEnv
= new TestEnvironment(oObj
);
229 tEnv
.addObjRelation("EditOnly",
230 "This method isn't supported in this component");
232 //adding ObjectRelation for XAccessibleText
233 tEnv
.addObjRelation("LimitedBounds", "true");
236 tEnv
.addObjRelation("EventProducer",
237 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
238 public void fireEvent() {
242 tEnv
.addObjRelation("XAccessibleSelection.multiSelection",
245 tEnv
.addObjRelation("XAccessibleText.Text", "Bibliography");
250 protected void closeDoc() {
251 XCloseable closer
= UnoRuntime
.queryInterface(
252 XCloseable
.class, xTextDoc
);
256 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
257 log
.println("Couldn't close document " + e
.getMessage());
258 } catch (com
.sun
.star
.lang
.DisposedException e
) {
259 log
.println("Couldn't close document " + e
.getMessage());