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 com
.sun
.star
.accessibility
.AccessibleRole
;
21 import com
.sun
.star
.accessibility
.XAccessible
;
22 import com
.sun
.star
.accessibility
.XAccessibleAction
;
23 import com
.sun
.star
.accessibility
.XAccessibleComponent
;
24 import com
.sun
.star
.accessibility
.XAccessibleContext
;
25 import com
.sun
.star
.awt
.XExtendedToolkit
;
26 import com
.sun
.star
.awt
.XWindow
;
27 import com
.sun
.star
.beans
.PropertyValue
;
28 import com
.sun
.star
.frame
.XController
;
29 import com
.sun
.star
.frame
.XDesktop
;
30 import com
.sun
.star
.frame
.XDispatch
;
31 import com
.sun
.star
.frame
.XDispatchProvider
;
32 import com
.sun
.star
.frame
.XModel
;
33 import com
.sun
.star
.text
.XTextDocument
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
35 import com
.sun
.star
.uno
.XInterface
;
36 import com
.sun
.star
.util
.URL
;
37 import com
.sun
.star
.util
.XURLTransformer
;
40 import java
.io
.PrintWriter
;
42 import lib
.StatusException
;
44 import lib
.TestEnvironment
;
45 import lib
.TestParameters
;
47 import util
.AccessibilityTools
;
48 import util
.DesktopTools
;
49 import util
.SOfficeFactory
;
53 * Test for object that implements the following interfaces :
56 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
58 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
61 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
63 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
67 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
68 * @see com.sun.star.accessibility.XAccessibleContext
69 * @see com.sun.star.accessibility.XAccessibleComponent
70 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
71 * @see ifc.accessibility._XAccessibleEventBroadcaster
72 * @see ifc.accessibility._XAccessibleContext
73 * @see ifc.accessibility._XAccessibleComponent
74 * @see ifc.accessibility._XAccessibleExtendedComponent
76 public class AccessibleTabPage
extends TestCase
{
77 private static XTextDocument xTextDoc
;
78 private static XAccessibleAction accCloseButton
= null;
81 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
84 protected void initialize(TestParameters Param
, PrintWriter log
) {
85 UnoRuntime
.queryInterface(XDesktop
.class,
86 DesktopTools
.createDesktop(
91 * Closes an InsertFields dialog, disposes the document, if exists, created in
92 * <code>createTestEnvironment</code> method.
95 protected void cleanup(TestParameters Param
, PrintWriter log
) {
97 if (accCloseButton
!= null) {
98 log
.println("closing InsertFields Dialog");
99 accCloseButton
.doAccessibleAction(0);
100 util
.utils
.pause(1000);
102 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
103 e
.printStackTrace(log
);
104 } catch (com
.sun
.star
.lang
.DisposedException e
) {
105 log
.println("Couldn't close dialog " + e
.getMessage());
108 log
.println("disposing xTextDoc");
110 if (xTextDoc
!= null) {
116 * Creates a text document, opens an InsertField dialog.
117 * Then obtains an accessible object with
118 * the role <code>AccessibleRole.PAGETAB</code>.
119 * Object relations created :
121 * <li> <code>'EventProducer'</code> for
122 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
126 * @param tParam test parameters
127 * @param log writer to log information while testing
129 * @see com.sun.star.awt.Toolkit
130 * @see com.sun.star.accessibility.AccessibleRole
131 * @see ifc.accessibility._XAccessibleEventBroadcaster
132 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
135 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
137 log
.println("creating a test environment");
140 if (accCloseButton
!= null) {
141 log
.println("closing InsertFields Dialog");
142 accCloseButton
.doAccessibleAction(0);
143 util
.utils
.pause(1000);
145 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
146 e
.printStackTrace(log
);
147 } catch (com
.sun
.star
.lang
.DisposedException e
) {
148 log
.println("Couldn't close dialog " + e
.getMessage());
151 log
.println("disposing xTextDoc");
153 if (xTextDoc
!= null) {
157 // get a soffice factory object
158 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
162 log
.println("creating a text document");
163 xTextDoc
= SOF
.createTextDoc(null);
164 } catch (com
.sun
.star
.uno
.Exception e
) {
165 // Some exception occurs.FAILED
166 e
.printStackTrace(log
);
167 throw new StatusException("Couldn't create document", e
);
170 util
.utils
.pause(1000);
172 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
175 XController secondController
= aModel1
.getCurrentController();
177 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
178 XDispatchProvider
.class,
181 XURLTransformer urlTransf
= null;
184 XInterface transf
= (XInterface
) tParam
.getMSF().createInstance(
185 "com.sun.star.util.URLTransformer");
186 urlTransf
= UnoRuntime
.queryInterface(
187 XURLTransformer
.class, transf
);
188 } catch (com
.sun
.star
.uno
.Exception e
) {
189 e
.printStackTrace(log
);
190 throw new StatusException("Couldn't create URLTransformer", e
);
193 XDispatch getting
= null;
194 log
.println("opening InsertField dialog");
196 URL
[] url
= new URL
[1];
198 url
[0].Complete
= ".uno:InsertField";
199 urlTransf
.parseStrict(url
);
200 getting
= aProv
.queryDispatch(url
[0], "", 0);
202 PropertyValue
[] noArgs
= new PropertyValue
[0];
203 getting
.dispatch(url
[0], noArgs
);
205 util
.utils
.pause(1000);
207 XInterface oObj
= null;
210 oObj
= (XInterface
) tParam
.getMSF().createInstance(
211 "com.sun.star.awt.Toolkit");
212 } catch (com
.sun
.star
.uno
.Exception e
) {
213 log
.println("Couldn't get toolkit");
214 e
.printStackTrace(log
);
215 throw new StatusException("Couldn't get toolkit", e
);
218 XExtendedToolkit tk
= UnoRuntime
.queryInterface(
219 XExtendedToolkit
.class, oObj
);
221 util
.utils
.pause(1000);
223 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,
224 tk
.getActiveTopWindow());
226 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
228 XAccessibleContext closeButton
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
229 AccessibleRole
.PUSH_BUTTON
,
232 accCloseButton
= UnoRuntime
.queryInterface(
233 XAccessibleAction
.class, closeButton
);
235 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
);
237 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
239 TestEnvironment tEnv
= new TestEnvironment(oObj
);
241 tEnv
.addObjRelation("EditOnly", "toolkit.AccessibleTabPage");
242 tEnv
.addObjRelation("LimitedBounds", "toolkit.AccessibleTabPage");
244 XAccessibleComponent accComp
= UnoRuntime
.queryInterface(
245 XAccessibleComponent
.class,
247 accComp
.getLocationOnScreen();
249 util
.utils
.pause(1000);
251 XInterface xEventInt
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
, "Variables");
252 final XAccessibleComponent eventAccComp
= UnoRuntime
.queryInterface(
253 XAccessibleComponent
.class,
256 tEnv
.addObjRelation("EventProducer",
257 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
258 public void fireEvent() {
259 eventAccComp
.grabFocus();
266 protected void closeDoc() {
267 util
.DesktopTools
.closeDoc(xTextDoc
);