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
.XAccessibleContext
;
24 import com
.sun
.star
.accessibility
.XAccessibleSelection
;
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
61 * ::com::sun::star::accessibility::XAccessibleSelection
65 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
66 * @see com.sun.star.accessibility.XAccessibleContext
67 * @see com.sun.star.accessibility.XAccessibleComponent
68 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
69 * @see com.sun.star.accessibility.XAccessibleSelection
70 * @see ifc.accessibility._XAccessibleEventBroadcaster
71 * @see ifc.accessibility._XAccessibleContext
72 * @see ifc.accessibility._XAccessibleComponent
73 * @see ifc.accessibility._XAccessibleExtendedComponent
74 * @see ifc.accessibility._XAccessibleSelection
76 public class AccessibleTabControl
extends TestCase
{
77 private static XTextDocument xTextDoc
;
78 private static XAccessibleAction accCloseButton
= null;
81 * Closes an InsertFields dialog, disposes the document, if exists, created in
82 * <code>createTestEnvironment</code> method.
85 protected void cleanup(TestParameters Param
, PrintWriter log
) {
87 if (accCloseButton
!= null) {
88 log
.println("closing InsertFields Dialog");
89 accCloseButton
.doAccessibleAction(0);
91 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
92 e
.printStackTrace(log
);
95 log
.println("disposing xTextDoc");
97 if (xTextDoc
!= null) {
98 util
.DesktopTools
.closeDoc(xTextDoc
);
103 * Creates a text document, opens an InsertField dialog.
104 * Then obtains an accessible object with
105 * the role <code>AccessibleRole.PAGETABLIST</code>.
106 * Object relations created :
108 * <li> <code>'EventProducer'</code> for
109 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
110 * selects items </li>
111 * <li> <code>'XAccessibleSelection.multiSelection'</code>
112 * of type <code>Boolean</code> for
113 * {@link ifc.accessibility._XAccessibleSelection}:
114 * indicates that component supports single selection mode.</li>
117 * @param tParam test parameters
118 * @param log writer to log information while testing
120 * @see com.sun.star.awt.Toolkit
121 * @see com.sun.star.accessibility.AccessibleRole
122 * @see ifc.accessibility._XAccessibleEventBroadcaster
123 * @see ifc.accessibility._XAccessibleSelection
124 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
125 * @see com.sun.star.accessibility.XAccessibleSelection
128 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
129 PrintWriter log
) throws Exception
{
130 log
.println("creating a test environment");
132 if (xTextDoc
!= null) {
133 util
.DesktopTools
.closeDoc(xTextDoc
);
136 // get a soffice factory object
137 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
140 log
.println("creating a text document");
141 xTextDoc
= SOF
.createTextDoc(null);
143 util
.utils
.waitForEventIdle(tParam
.getMSF());
145 XModel aModel1
= UnoRuntime
.queryInterface(XModel
.class,
148 XController secondController
= aModel1
.getCurrentController();
150 XDispatchProvider aProv
= UnoRuntime
.queryInterface(
151 XDispatchProvider
.class,
154 XURLTransformer urlTransf
= null;
156 XInterface transf
= (XInterface
) tParam
.getMSF().createInstance(
157 "com.sun.star.util.URLTransformer");
158 urlTransf
= UnoRuntime
.queryInterface(
159 XURLTransformer
.class, transf
);
161 XDispatch getting
= null;
162 log
.println("opening InsertField dialog");
164 URL
[] url
= new URL
[1];
166 url
[0].Complete
= ".uno:InsertField";
167 urlTransf
.parseStrict(url
);
168 getting
= aProv
.queryDispatch(url
[0], "", 0);
170 PropertyValue
[] noArgs
= new PropertyValue
[0];
171 getting
.dispatch(url
[0], noArgs
);
173 util
.utils
.waitForEventIdle(tParam
.getMSF());
175 XInterface oObj
= (XInterface
) tParam
.getMSF().createInstance(
176 "com.sun.star.awt.Toolkit");
178 XExtendedToolkit tk
= UnoRuntime
.queryInterface(
179 XExtendedToolkit
.class, oObj
);
181 util
.utils
.waitForEventIdle(tParam
.getMSF());
183 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,
184 tk
.getActiveTopWindow());
186 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
188 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
189 AccessibleRole
.PAGE_TAB_LIST
);
191 XAccessibleContext closeButton
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
192 AccessibleRole
.PUSH_BUTTON
,
195 accCloseButton
= UnoRuntime
.queryInterface(
196 XAccessibleAction
.class, closeButton
);
198 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
200 TestEnvironment tEnv
= new TestEnvironment(oObj
);
202 final XAccessibleSelection selection
= UnoRuntime
.queryInterface(
203 XAccessibleSelection
.class,
206 tEnv
.addObjRelation("EventProducer",
207 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
208 public void fireEvent() {
210 selection
.selectAccessibleChild(1);
211 selection
.selectAccessibleChild(0);
212 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
217 tEnv
.addObjRelation("XAccessibleSelection.OneAlwaysSelected",
220 tEnv
.addObjRelation("XAccessibleSelection.multiSelection",