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 .
21 import java
.io
.PrintWriter
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.AccessibilityTools
;
27 import util
.DesktopTools
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.accessibility
.AccessibleRole
;
31 import com
.sun
.star
.accessibility
.XAccessible
;
32 import com
.sun
.star
.awt
.XWindow
;
33 import com
.sun
.star
.beans
.PropertyValue
;
34 import com
.sun
.star
.frame
.XController
;
35 import com
.sun
.star
.frame
.XDesktop
;
36 import com
.sun
.star
.frame
.XDispatch
;
37 import com
.sun
.star
.frame
.XDispatchProvider
;
38 import com
.sun
.star
.frame
.XFrame
;
39 import com
.sun
.star
.frame
.XModel
;
40 import com
.sun
.star
.lang
.XInitialization
;
41 import com
.sun
.star
.text
.XTextDocument
;
42 import com
.sun
.star
.uno
.UnoRuntime
;
43 import com
.sun
.star
.uno
.XInterface
;
44 import com
.sun
.star
.util
.URL
;
47 * Test for object that implements the following interfaces :
49 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
51 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
53 * <li><code>::com::sun::star::accessibility::XAccessibleContext
55 * <li><code>::com::sun::star::accessibility::XAccessibleSelection
59 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see com.sun.star.accessibility.XAccessibleComponent
62 * @see com.sun.star.accessibility.XAccessibleSelection
63 * @see ifc.accessibility._XAccessibleEventBroadcaster
64 * @see ifc.accessibility._XAccessibleContext
65 * @see ifc.accessibility._XAccessibleComponent
66 * @see ifc.accessibility._XAccessibleSelection
68 public class AccessibleTreeListBox
extends TestCase
{
70 static XDesktop xDesktop
;
71 static XTextDocument xTextDoc
;
74 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
77 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
78 xDesktop
= DesktopTools
.createDesktop(Param
.getMSF());
82 * Disposes the document, if exists, created in
83 * <code>createTestEnvironment</code> method.
86 protected void cleanup( TestParameters Param
, PrintWriter log
) {
88 log
.println("disposing xTextDoc");
90 if (xTextDoc
!= null) {
96 * Creates a text document. Opens the DataSource browser.
97 * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code>
98 * and gets active top window. Then obtains an accessible object with
99 * the role <code>AccessibleRole.TREE</code>.
100 * Object relations created :
102 * <li> <code>'EventProducer'</code> for
103 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
105 * <li> <code>'XAccessibleSelection.multiSelection'</code>
106 * of type <code>Boolean</code> for
107 * {@link ifc.accessibility._XAccessibleSelection}:
108 * indicates that component supports single selection mode.</li>
111 * @param tParam test parameters
112 * @param log writer to log information while testing
114 * @see com.sun.star.awt.Toolkit
115 * @see com.sun.star.accessibility.AccessibleRole
116 * @see ifc.accessibility._XAccessibleEventBroadcaster
117 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
120 protected TestEnvironment
createTestEnvironment(
121 TestParameters tParam
, PrintWriter log
) throws Exception
{
123 log
.println( "creating a test environment" );
125 if (xTextDoc
!= null) xTextDoc
.dispose();
127 // get a soffice factory object
128 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
130 log
.println( "creating a text document" );
131 xTextDoc
= SOF
.createTextDoc(null);
133 util
.utils
.waitForEventIdle(tParam
.getMSF());
135 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
137 XController secondController
= aModel1
.getCurrentController();
139 XDispatchProvider aProv
= UnoRuntime
.
140 queryInterface(XDispatchProvider
.class, secondController
);
142 XDispatch getting
= null;
144 log
.println( "opening DatasourceBrowser" );
145 URL the_url
= new URL();
146 the_url
.Complete
= ".component:DB/DataSourceBrowser";
147 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
148 PropertyValue
[] noArgs
= new PropertyValue
[0];
149 getting
.dispatch(the_url
, noArgs
);
151 util
.utils
.waitForEventIdle(tParam
.getMSF());
153 XFrame the_frame1
= xDesktop
.getCurrentFrame();
155 if (the_frame1
== null) {
156 log
.println("Current frame was not found !!!");
159 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
161 the_frame2
.setName("DatasourceBrowser");
163 XInterface oObj
= null;
165 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
167 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
169 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TREE
);
171 log
.println("ImplementationName: "+ util
.utils
.getImplName(oObj
));
173 TestEnvironment tEnv
= new TestEnvironment(oObj
);
175 final XInitialization xInit
= UnoRuntime
.queryInterface(
176 XInitialization
.class, the_frame2
.getController());
178 Object
[] params
= new Object
[3];
179 PropertyValue param1
= new PropertyValue();
180 param1
.Name
= "DataSourceName";
181 param1
.Value
= "Bibliography";
183 PropertyValue param2
= new PropertyValue();
184 param2
.Name
= "CommandType";
185 param2
.Value
= Integer
.valueOf(com
.sun
.star
.sdb
.CommandType
.TABLE
);
187 PropertyValue param3
= new PropertyValue();
188 param3
.Name
= "Command";
189 param3
.Value
= "biblio";
192 final Object
[] fParams
= params
;
194 tEnv
.addObjRelation("EventProducer",
195 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
196 public void fireEvent() {
198 xInit
.initialize(fParams
);
199 } catch(com
.sun
.star
.uno
.Exception e
) {
205 tEnv
.addObjRelation("XAccessibleSelection.multiSelection",