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
.XDispatch
;
30 import com
.sun
.star
.frame
.XDispatchProvider
;
31 import com
.sun
.star
.frame
.XModel
;
32 import com
.sun
.star
.text
.XTextDocument
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XInterface
;
35 import com
.sun
.star
.util
.URL
;
36 import com
.sun
.star
.util
.XURLTransformer
;
38 import java
.io
.PrintWriter
;
41 import lib
.TestEnvironment
;
42 import lib
.TestParameters
;
43 import util
.AccessibilityTools
;
44 import util
.SOfficeFactory
;
48 * Test for object that implements the following interfaces :
51 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
53 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
56 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
58 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
62 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
63 * @see com.sun.star.accessibility.XAccessibleContext
64 * @see com.sun.star.accessibility.XAccessibleComponent
65 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
66 * @see ifc.accessibility._XAccessibleEventBroadcaster
67 * @see ifc.accessibility._XAccessibleContext
68 * @see ifc.accessibility._XAccessibleComponent
69 * @see ifc.accessibility._XAccessibleExtendedComponent
71 public class AccessibleTabPage
extends TestCase
{
72 private static XTextDocument xTextDoc
;
73 private static XAccessibleAction accCloseButton
= null;
76 * Closes an InsertFields dialog, disposes the document, if exists, created in
77 * <code>createTestEnvironment</code> method.
80 protected void cleanup(TestParameters Param
, PrintWriter log
) {
82 if (accCloseButton
!= null) {
83 log
.println("closing InsertFields Dialog");
84 accCloseButton
.doAccessibleAction(0);
85 util
.utils
.waitForEventIdle(Param
.getMSF());
87 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
88 e
.printStackTrace(log
);
89 } catch (com
.sun
.star
.lang
.DisposedException e
) {
90 log
.println("Couldn't close dialog " + e
.getMessage());
93 log
.println("disposing xTextDoc");
95 if (xTextDoc
!= null) {
101 * Creates a text document, opens an InsertField dialog.
102 * Then obtains an accessible object with
103 * the role <code>AccessibleRole.PAGETAB</code>.
104 * Object relations created :
106 * <li> <code>'EventProducer'</code> for
107 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
111 * @param tParam test parameters
112 * @param log writer to log information while testing
114 * @see com.sun.star.awt.Toolkit
115 * @see com.sun.star.accessibility.AccessibleRole
116 * @see ifc.accessibility._XAccessibleEventBroadcaster
117 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
120 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
121 PrintWriter log
) throws Exception
{
122 log
.println("creating a test environment");
125 if (accCloseButton
!= null) {
126 log
.println("closing InsertFields Dialog");
127 accCloseButton
.doAccessibleAction(0);
128 util
.utils
.waitForEventIdle(tParam
.getMSF());
130 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
131 e
.printStackTrace(log
);
132 } catch (com
.sun
.star
.lang
.DisposedException e
) {
133 log
.println("Couldn't close dialog " + e
.getMessage());
136 log
.println("disposing xTextDoc");
138 if (xTextDoc
!= null) {
142 // get a soffice factory object
143 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
146 log
.println("creating a text document");
147 xTextDoc
= SOF
.createTextDoc(null);
149 util
.utils
.waitForEventIdle(tParam
.getMSF());
151 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
154 XController secondController
= aModel1
.getCurrentController();
156 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
157 XDispatchProvider
.class,
160 XURLTransformer urlTransf
= null;
162 XInterface transf
= (XInterface
) tParam
.getMSF().createInstance(
163 "com.sun.star.util.URLTransformer");
164 urlTransf
= UnoRuntime
.queryInterface(
165 XURLTransformer
.class, transf
);
167 XDispatch getting
= null;
168 log
.println("opening InsertField dialog");
170 URL
[] url
= new URL
[1];
172 url
[0].Complete
= ".uno:InsertField";
173 urlTransf
.parseStrict(url
);
174 getting
= aProv
.queryDispatch(url
[0], "", 0);
176 PropertyValue
[] noArgs
= new PropertyValue
[0];
177 getting
.dispatch(url
[0], noArgs
);
179 util
.utils
.waitForEventIdle(tParam
.getMSF());
181 XInterface oObj
= null;
183 oObj
= (XInterface
) tParam
.getMSF().createInstance(
184 "com.sun.star.awt.Toolkit");
186 XExtendedToolkit tk
= UnoRuntime
.queryInterface(
187 XExtendedToolkit
.class, oObj
);
189 util
.utils
.waitForEventIdle(tParam
.getMSF());
191 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,
192 tk
.getActiveTopWindow());
194 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
196 XAccessibleContext closeButton
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
197 AccessibleRole
.PUSH_BUTTON
,
200 accCloseButton
= UnoRuntime
.queryInterface(
201 XAccessibleAction
.class, closeButton
);
203 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
);
205 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
207 TestEnvironment tEnv
= new TestEnvironment(oObj
);
209 tEnv
.addObjRelation("EditOnly", "toolkit.AccessibleTabPage");
210 tEnv
.addObjRelation("LimitedBounds", "toolkit.AccessibleTabPage");
212 XAccessibleComponent accComp
= UnoRuntime
.queryInterface(
213 XAccessibleComponent
.class,
215 accComp
.getLocationOnScreen();
217 util
.utils
.waitForEventIdle(tParam
.getMSF());
219 XInterface xEventInt
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
, "Variables");
220 final XAccessibleComponent eventAccComp
= UnoRuntime
.queryInterface(
221 XAccessibleComponent
.class,
224 tEnv
.addObjRelation("EventProducer",
225 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
226 public void fireEvent() {
227 eventAccComp
.grabFocus();
234 protected void closeDoc() {
235 util
.DesktopTools
.closeDoc(xTextDoc
);