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
;
22 import lib
.StatusException
;
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
.XMultiServiceFactory
;
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
;
45 import com
.sun
.star
.view
.XSelectionSupplier
;
47 public class AccessibleBrowseBox
extends TestCase
{
49 static XDesktop the_Desk
;
50 static XTextDocument xTextDoc
;
53 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
55 protected void initialize(TestParameters Param
, PrintWriter log
) {
56 the_Desk
= UnoRuntime
.queryInterface(
57 XDesktop
.class, DesktopTools
.createDesktop((XMultiServiceFactory
) Param
.getMSF()));
61 * Disposes the document, if exists, created in
62 * <code>createTestEnvironment</code> method.
64 protected void cleanup(TestParameters Param
, PrintWriter log
) {
66 log
.println("disposing xTextDoc");
68 if (xTextDoc
!= null) {
74 * Called to create an instance of <code>TestEnvironment</code> with an
75 * object to test and related objects. Subclasses should implement this
76 * method to provide the implementation and related objects. The method is
77 * called from <code>getTestEnvironment()</code>.
79 * @param tParam test parameters
80 * @param log writer to log information while testing
82 * @see TestEnvironment
83 * @see #getTestEnvironment
85 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) {
87 log
.println("creating a test environment");
89 if (xTextDoc
!= null) {
90 xTextDoc
.dispose(); // get a soffice factory object
92 SOfficeFactory SOF
= SOfficeFactory
.getFactory((XMultiServiceFactory
) tParam
.getMSF());
95 log
.println("creating a text document");
96 xTextDoc
= SOF
.createTextDoc(null);
97 } catch (com
.sun
.star
.uno
.Exception e
) {
98 // Some exception occurs.FAILED
99 e
.printStackTrace(log
);
100 throw new StatusException("Couldn't create document", e
);
105 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
107 XController secondController
= aModel1
.getCurrentController();
110 XDispatchProvider aProv
= UnoRuntime
.queryInterface(XDispatchProvider
.class,
113 XDispatch getting
= null;
115 log
.println("opening DatasourceBrowser");
116 URL the_url
= new URL();
117 the_url
.Complete
= ".component:DB/DataSourceBrowser";
118 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
119 PropertyValue
[] noArgs
= new PropertyValue
[0];
120 getting
.dispatch(the_url
, noArgs
);
124 XFrame the_frame1
= the_Desk
.getCurrentFrame();
126 if (the_frame1
== null) {
127 log
.println("Current frame was not found !!!");
130 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
132 the_frame2
.setName("DatasourceBrowser");
134 XInterface oObj
= null;
136 final XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
137 XSelectionSupplier
.class, the_frame2
.getController());
139 PropertyValue
[] params
= new PropertyValue
[]{new PropertyValue(), new PropertyValue(), new PropertyValue()};
140 params
[0].Name
= "DataSourceName";
141 params
[0].Value
= "Bibliography";
142 params
[1].Name
= "CommandType";
143 params
[1].Value
= new Integer(com
.sun
.star
.sdb
.CommandType
.TABLE
);
144 params
[2].Name
= "Command";
145 params
[2].Value
= "biblio";
147 final PropertyValue
[] fParams
= params
;
151 AccessibilityTools at
= new AccessibilityTools();
153 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
155 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
157 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
159 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PANEL
, "", "AccessibleBrowseBox");
161 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
163 TestEnvironment tEnv
= new TestEnvironment(oObj
);
166 tEnv
.addObjRelation("EventProducer",
167 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
169 public void fireEvent() {
171 xSelect
.select(fParams
);
172 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
182 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
185 private void shortWait() {
188 } catch (InterruptedException e
) {
189 System
.out
.println("While waiting :" + e
);