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 java
.io
.PrintWriter
;
23 import lib
.TestEnvironment
;
24 import lib
.TestParameters
;
25 import util
.AccessibilityTools
;
26 import util
.DesktopTools
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.accessibility
.AccessibleRole
;
30 import com
.sun
.star
.accessibility
.XAccessible
;
31 import com
.sun
.star
.awt
.XWindow
;
32 import com
.sun
.star
.beans
.PropertyValue
;
33 import com
.sun
.star
.frame
.XController
;
34 import com
.sun
.star
.frame
.XDesktop
;
35 import com
.sun
.star
.frame
.XDispatch
;
36 import com
.sun
.star
.frame
.XDispatchProvider
;
37 import com
.sun
.star
.frame
.XFrame
;
38 import com
.sun
.star
.frame
.XModel
;
39 import com
.sun
.star
.text
.XTextDocument
;
40 import com
.sun
.star
.uno
.UnoRuntime
;
41 import com
.sun
.star
.uno
.XInterface
;
42 import com
.sun
.star
.util
.URL
;
43 import com
.sun
.star
.view
.XSelectionSupplier
;
45 public class AccessibleBrowseBox
extends TestCase
{
47 static XDesktop xDesktop
;
48 static XTextDocument xTextDoc
;
51 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
54 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
55 xDesktop
= DesktopTools
.createDesktop(Param
.getMSF());
59 * Disposes the document, if exists, created in
60 * <code>createTestEnvironment</code> method.
63 protected void cleanup(TestParameters Param
, PrintWriter log
) {
65 log
.println("disposing xTextDoc");
67 if (xTextDoc
!= null) {
73 * Called to create an instance of <code>TestEnvironment</code> with an
74 * object to test and related objects. Subclasses should implement this
75 * method to provide the implementation and related objects. The method is
76 * called from <code>getTestEnvironment()</code>.
78 * @param tParam test parameters
79 * @param log writer to log information while testing
81 * @see TestEnvironment
82 * @see #getTestEnvironment
85 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) throws Exception
{
87 log
.println("creating a test environment");
89 if (xTextDoc
!= null) {
90 xTextDoc
.dispose(); // get a soffice factory object
92 SOfficeFactory SOF
= SOfficeFactory
.getFactory(tParam
.getMSF());
94 log
.println("creating a text document");
95 xTextDoc
= SOF
.createTextDoc(null);
97 util
.utils
.waitForEventIdle(tParam
.getMSF());
99 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
101 XController secondController
= aModel1
.getCurrentController();
104 XDispatchProvider aProv
= UnoRuntime
.queryInterface(XDispatchProvider
.class,
107 XDispatch getting
= null;
109 log
.println("opening DatasourceBrowser");
110 URL the_url
= new URL();
111 the_url
.Complete
= ".component:DB/DataSourceBrowser";
112 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
113 PropertyValue
[] noArgs
= new PropertyValue
[0];
114 getting
.dispatch(the_url
, noArgs
);
116 util
.utils
.waitForEventIdle(tParam
.getMSF());
118 XFrame the_frame1
= xDesktop
.getCurrentFrame();
120 if (the_frame1
== null) {
121 log
.println("Current frame was not found !!!");
124 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
126 the_frame2
.setName("DatasourceBrowser");
128 XInterface oObj
= null;
130 final XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
131 XSelectionSupplier
.class, the_frame2
.getController());
133 PropertyValue
[] params
= new PropertyValue
[]{new PropertyValue(), new PropertyValue(), new PropertyValue()};
134 params
[0].Name
= "DataSourceName";
135 params
[0].Value
= "Bibliography";
136 params
[1].Name
= "CommandType";
137 params
[1].Value
= Integer
.valueOf(com
.sun
.star
.sdb
.CommandType
.TABLE
);
138 params
[2].Name
= "Command";
139 params
[2].Value
= "biblio";
141 final PropertyValue
[] fParams
= params
;
143 util
.utils
.waitForEventIdle(tParam
.getMSF());
145 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
147 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
149 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
151 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PANEL
, "", "AccessibleBrowseBox");
153 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
155 TestEnvironment tEnv
= new TestEnvironment(oObj
);
158 tEnv
.addObjRelation("EventProducer",
159 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
161 public void fireEvent() {
163 xSelect
.select(fParams
);
164 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {