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 com
.sun
.star
.view
.XSelectionSupplier
;
22 import java
.io
.PrintWriter
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
28 import util
.AccessibilityTools
;
29 import util
.DesktopTools
;
30 import util
.SOfficeFactory
;
32 import com
.sun
.star
.accessibility
.AccessibleRole
;
33 import com
.sun
.star
.accessibility
.XAccessible
;
34 import com
.sun
.star
.awt
.XWindow
;
35 import com
.sun
.star
.beans
.PropertyValue
;
36 import com
.sun
.star
.frame
.XController
;
37 import com
.sun
.star
.frame
.XDesktop
;
38 import com
.sun
.star
.frame
.XDispatch
;
39 import com
.sun
.star
.frame
.XDispatchProvider
;
40 import com
.sun
.star
.frame
.XFrame
;
41 import com
.sun
.star
.frame
.XModel
;
42 import com
.sun
.star
.lang
.XInitialization
;
43 import com
.sun
.star
.text
.XTextDocument
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
45 import com
.sun
.star
.uno
.XInterface
;
46 import com
.sun
.star
.util
.URL
;
49 * Test for object that implements the following interfaces :
52 * <code>::com::sun::star::accessibility::XAccessibleContext
55 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
59 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see ifc.accessibility._XAccessibleEventBroadcaster
62 * @see ifc.accessibility._XAccessibleContext
64 public class AccessibleBrowseBoxHeaderCell
extends TestCase
{
66 static XDesktop the_Desk
;
67 static XTextDocument xTextDoc
;
70 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
73 protected void initialize(TestParameters Param
, PrintWriter log
) {
74 the_Desk
= UnoRuntime
.queryInterface(
75 XDesktop
.class, DesktopTools
.createDesktop(Param
.getMSF()));
79 * Disposes the document, if exists, created in
80 * <code>createTestEnvironment</code> method.
83 protected void cleanup( TestParameters Param
, PrintWriter log
) {
85 log
.println("disposing xTextDoc");
87 if (xTextDoc
!= null) {
93 * Creates a text document. Opens the DataSource browser and loads
94 * the table. Creates an instance of the service
95 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
96 * Then obtains an accessible object with the role
97 * <code>AccessibleRole.UNKNOWN</code> and with the name
98 * <code>"Identifier"</code>.
99 * Object relations created :
101 * <li> <code>'EventProducer'</code> for
102 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
103 * method <code>fireEvent()</code> is empty because object is transient
107 * @param tParam test parameters
108 * @param log writer to log information while testing
110 * @see com.sun.star.awt.Toolkit
111 * @see com.sun.star.accessibility.AccessibleRole
112 * @see ifc.accessibility._XAccessibleEventBroadcaster
113 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
116 protected TestEnvironment
createTestEnvironment(
117 TestParameters tParam
, PrintWriter log
) {
119 log
.println( "creating a test environment" );
121 if (xTextDoc
!= null) xTextDoc
.dispose();
123 // get a soffice factory object
124 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
127 log
.println( "creating a text document" );
128 xTextDoc
= SOF
.createTextDoc(null);
129 } catch ( com
.sun
.star
.uno
.Exception e
) {
130 // Some exception occurs.FAILED
131 e
.printStackTrace( log
);
132 throw new StatusException( "Couldn't create document", e
);
135 util
.utils
.pause(5000);
137 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
139 XController secondController
= aModel1
.getCurrentController();
141 XDispatchProvider aProv
= UnoRuntime
.
142 queryInterface(XDispatchProvider
.class, secondController
);
144 XDispatch getting
= null;
146 log
.println( "opening DatasourceBrowser" );
147 URL the_url
= new URL();
148 the_url
.Complete
= ".component:DB/DataSourceBrowser";
149 getting
= aProv
.queryDispatch(the_url
, "_beamer", 12);
150 PropertyValue
[] noArgs
= new PropertyValue
[0];
151 getting
.dispatch(the_url
, noArgs
);
153 util
.utils
.pause(5000);
155 XFrame the_frame1
= the_Desk
.getCurrentFrame();
157 if (the_frame1
== null) {
158 log
.println("Current frame was not found !!!");
161 XFrame the_frame2
= the_frame1
.findFrame("_beamer", 4);
163 the_frame2
.setName("DatasourceBrowser");
165 XInterface oObj
= null;
167 UnoRuntime
.queryInterface(
168 XInitialization
.class, the_frame2
.getController());
170 PropertyValue
[] params
= new PropertyValue
[3];
171 PropertyValue param1
= new PropertyValue();
172 param1
.Name
= "DataSourceName";
173 param1
.Value
= "Bibliography";
175 PropertyValue param2
= new PropertyValue();
176 param2
.Name
= "CommandType";
177 param2
.Value
= Integer
.valueOf(com
.sun
.star
.sdb
.CommandType
.TABLE
);
179 PropertyValue param3
= new PropertyValue();
180 param3
.Name
= "Command";
181 param3
.Value
= "biblio";
184 XController xCont
= the_frame2
.getController();
186 XSelectionSupplier xSelect
= UnoRuntime
.queryInterface(
187 XSelectionSupplier
.class, xCont
);
190 xSelect
.select(params
);
191 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
192 throw new StatusException("Could not select Biblio-Database", ex
);
195 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
197 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
199 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
201 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
202 AccessibleRole
.ROW_HEADER
);
204 log
.println("ImplementationName: "+ util
.utils
.getImplName(oObj
));
206 TestEnvironment tEnv
= new TestEnvironment(oObj
);
208 tEnv
.addObjRelation("EventProducer",
209 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
210 public void fireEvent() {