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
.XAccessibleSelection
;
25 import com
.sun
.star
.awt
.XExtendedToolkit
;
26 import com
.sun
.star
.awt
.XWindow
;
27 import com
.sun
.star
.frame
.XController
;
28 import com
.sun
.star
.frame
.XDispatch
;
29 import com
.sun
.star
.frame
.XDispatchProvider
;
30 import com
.sun
.star
.frame
.XModel
;
31 import com
.sun
.star
.text
.XTextDocument
;
32 import com
.sun
.star
.uno
.UnoRuntime
;
33 import com
.sun
.star
.uno
.XInterface
;
34 import com
.sun
.star
.util
.URL
;
35 import com
.sun
.star
.util
.XURLTransformer
;
37 import java
.io
.PrintWriter
;
40 import lib
.TestEnvironment
;
41 import lib
.TestParameters
;
42 import util
.AccessibilityTools
;
43 import util
.SOfficeFactory
;
47 * Test for object which is represented by accessible component of the 'Font'
48 * combo box in Format->Character... dialog box.
51 * Object implements the following interfaces :
54 * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
56 * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
57 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
58 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
62 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
63 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
64 * @see com.sun.star.accessibility.XAccessibleComponent
65 * @see com.sun.star.accessibility.XAccessibleContext
66 * @see ifc.accessibility._XAccessibleExtendedComponent
67 * @see ifc.accessibility._XAccessibleEventBroadcaster
68 * @see ifc.accessibility._XAccessibleComponent
69 * @see ifc.accessibility._XAccessibleContext
71 public class AccessibleComboBox
extends TestCase
{
72 private static XTextDocument xTextDoc
= null;
73 private static XAccessibleAction action
= null;
76 * Opens CharacterStyle dialog and finds AccessibleComboBox walking through
77 * the accessible component tree.
80 protected TestEnvironment
createTestEnvironment(TestParameters Param
,
81 PrintWriter log
) throws Exception
{
82 XInterface oObj
= null;
84 oObj
= (XInterface
) Param
.getMSF().createInstance(
85 "com.sun.star.awt.Toolkit");
87 XExtendedToolkit tk
= UnoRuntime
.queryInterface(XExtendedToolkit
.class,
90 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
92 XController xController
= aModel
.getCurrentController();
94 // Opening PrinterSetupDialog
95 String aSlotID
= ".uno:FontDialog";
96 XDispatchProvider xDispProv
= UnoRuntime
.queryInterface(
97 XDispatchProvider
.class, xController
);
98 XURLTransformer xParser
= UnoRuntime
.queryInterface(
99 XURLTransformer
.class,
100 Param
.getMSF().createInstance(
101 "com.sun.star.util.URLTransformer"));
103 // Because it's an in/out parameter we must use an array of URL
105 URL
[] aParseURL
= new URL
[] { new URL() };
106 aParseURL
[0].Complete
= aSlotID
;
107 xParser
.parseStrict(aParseURL
);
109 XDispatch xDispatcher
= xDispProv
.queryDispatch(aParseURL
[0], "", 0);
110 if (xDispatcher
!= null) {
111 xDispatcher
.dispatch(aParseURL
[0], null);
114 util
.utils
.waitForEventIdle(Param
.getMSF());
116 Object atw
= tk
.getActiveTopWindow();
118 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class, atw
);
120 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
122 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
123 AccessibleRole
.PUSH_BUTTON
, "Cancel");
124 action
= UnoRuntime
.queryInterface(XAccessibleAction
.class, oObj
);
126 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
127 AccessibleRole
.PAGE_TAB_LIST
);
129 XAccessibleSelection xAccSel
= UnoRuntime
.queryInterface(
130 XAccessibleSelection
.class, oObj
);
133 xAccSel
.selectAccessibleChild(0);
134 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
135 e
.printStackTrace(log
);
137 util
.utils
.waitForEventIdle(Param
.getMSF());
139 AccessibilityTools
.printAccessibleTree(log
, xRoot
,
140 Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
141 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
142 AccessibleRole
.PANEL
, "", "AccessibleComboBox");
144 log
.println("ImplementationName " + utils
.getImplName(oObj
));
146 TestEnvironment tEnv
= new TestEnvironment(oObj
);
148 final XAccessibleComponent acomp
= UnoRuntime
.queryInterface(
149 XAccessibleComponent
.class, oObj
);
150 final XAccessibleComponent acomp1
= UnoRuntime
.queryInterface(
151 XAccessibleComponent
.class, action
);
155 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
156 public void fireEvent() {
166 * Closes the dialog using accessible button 'Cancel' found in
167 * <code>createTestEnvironment()</code>.
170 protected void cleanup(TestParameters Param
, PrintWriter log
) {
171 log
.println(" closing dialog ");
174 action
.doAccessibleAction(0);
175 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException ioe
) {
176 log
.println("Couldn't close dialog");
177 } catch (com
.sun
.star
.lang
.DisposedException de
) {
178 log
.println("Dialog already disposed");
181 util
.DesktopTools
.closeDoc(xTextDoc
);
188 protected void initialize(TestParameters Param
, PrintWriter log
)
190 SOfficeFactory SOF
= SOfficeFactory
.getFactory(Param
.getMSF());
191 xTextDoc
= SOF
.createTextDoc(null);