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
.text
.XTextDocument
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
42 import com
.sun
.star
.uno
.XInterface
;
43 import com
.sun
.star
.util
.URL
;
46 * Test for object that implements the following interfaces :
49 * <code>::com::sun::star::accessibility::XAccessibleContext
52 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleContext
58 * @see ifc.accessibility._XAccessibleEventBroadcaster
59 * @see ifc.accessibility._XAccessibleContext
61 public class AccessibleBrowseBoxTableCell
extends TestCase
{
63 static XDesktop xDesktop
;
64 static XTextDocument xTextDoc
;
67 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
70 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
71 xDesktop
= DesktopTools
.createDesktop(Param
.getMSF());
75 * Disposes the document, if exists, created in
76 * <code>createTestEnvironment</code> method.
79 protected void cleanup( TestParameters Param
, PrintWriter log
) {
81 log
.println("disposing xTextDoc");
83 if (xTextDoc
!= null) {
89 * Creates a text document. Opens the DataSource browser and loads
90 * the table. Creates an instance of the service
91 * <code>com.sun.star.awt.Toolkit</code> and gets active top window.
92 * Then obtains an accessible object with the role
93 * <code>AccessibleRole.TABLE_CELL</code>.
94 * Object relations created :
96 * <li> <code>'EventProducer'</code> for
97 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
98 * method <code>fireEvent()</code> is empty because object is transient
102 * @param tParam test parameters
103 * @param log writer to log information while testing
105 * @see com.sun.star.awt.Toolkit
106 * @see com.sun.star.accessibility.AccessibleRole
107 * @see ifc.accessibility._XAccessibleEventBroadcaster
108 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
111 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) throws Exception
{
113 log
.println( "creating a test environment" );
115 if (xTextDoc
!= null) xTextDoc
.dispose();
117 // get a soffice factory object
118 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
120 log
.println( "creating a text document" );
121 xTextDoc
= SOF
.createTextDoc(null);
123 util
.utils
.waitForEventIdle(tParam
.getMSF());
125 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
127 XController secondController
= aModel1
.getCurrentController();
130 XDispatchProvider aProv
= UnoRuntime
.queryInterface(XDispatchProvider
.class,secondController
);
132 XDispatch getting
= null;
134 log
.println( "opening DatasourceBrowser" );
135 URL the_url
= new URL();
136 the_url
.Complete
= ".component:DB/DataSourceBrowser";
137 getting
= aProv
.queryDispatch(the_url
,"_beamer",12);
138 PropertyValue
[] noArgs
= new PropertyValue
[0];
139 getting
.dispatch(the_url
,noArgs
);
141 util
.utils
.waitForEventIdle(tParam
.getMSF());
143 XFrame the_frame1
= xDesktop
.getCurrentFrame();
145 if (the_frame1
== null) {
146 log
.println("Current frame was not found !!!");
149 XFrame the_frame2
= the_frame1
.findFrame("_beamer",4);
151 the_frame2
.setName("DatasourceBrowser");
153 util
.utils
.waitForEventIdle(tParam
.getMSF());
155 XWindow xWindow
= secondController
.getFrame().getContainerWindow();
157 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
159 XInterface oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TABLE_CELL
);
161 log
.println("ImplementationName: "+util
.utils
.getImplName(oObj
));
163 TestEnvironment tEnv
= new TestEnvironment( oObj
);
165 tEnv
.addObjRelation("EventProducer",
166 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
167 public void fireEvent() {