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
.awt
.XWindow
;
24 import com
.sun
.star
.lang
.XMultiServiceFactory
;
25 import com
.sun
.star
.text
.XTextDocument
;
26 import com
.sun
.star
.uno
.UnoRuntime
;
27 import com
.sun
.star
.uno
.XInterface
;
29 import java
.io
.PrintWriter
;
31 import lib
.StatusException
;
33 import lib
.TestEnvironment
;
34 import lib
.TestParameters
;
36 import util
.AccessibilityTools
;
37 import util
.DesktopTools
;
38 import util
.SOfficeFactory
;
43 * Test for object which is represented by style list box
44 * on toolbar of a document. <p>
46 * Object implements the following interfaces :
48 * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
51 * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li>
52 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
55 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleComponent
58 * @see com.sun.star.accessibility.XAccessibleAction
59 * @see com.sun.star.accessibility.XAccessibleContext
60 * @see ifc.accessibility._XAccessibleExtendedComponent
61 * @see ifc.accessibility._XAccessibleEventBroadcaster
62 * @see ifc.accessibility._XAccessibleComponent
63 * @see ifc.accessibility._XAccessibleAction
64 * @see ifc.accessibility._XAccessibleContext
66 public class AccessibleDropDownListBox
extends TestCase
{
67 private static XTextDocument xTextDoc
= null;
69 * Finds AccessibleDropDownListBox walking through the
70 * accessible component tree of a writer document.
72 protected TestEnvironment
createTestEnvironment(TestParameters Param
,
74 XInterface oObj
= null;
78 AccessibilityTools at
= new AccessibilityTools();
80 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(
81 (XMultiServiceFactory
) Param
.getMSF(),
84 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
86 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
88 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.COMBO_BOX
,
89 "", "AccessibleDropDownListBox");
91 log
.println("ImplementationName " + utils
.getImplName(oObj
));
93 TestEnvironment tEnv
= new TestEnvironment(oObj
);
95 final XAccessibleAction acomp
= UnoRuntime
.queryInterface(
96 XAccessibleAction
.class, oObj
);
97 tEnv
.addObjRelation("EventProducer",
98 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
99 public void fireEvent() {
101 acomp
.doAccessibleAction(0);
102 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
103 throw new StatusException("Can't perform action 0", e
);
112 * Creates writer document.
114 protected void initialize(TestParameters Param
, PrintWriter log
) {
116 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
117 (XMultiServiceFactory
) Param
.getMSF());
118 DesktopTools
.dockStylist((XMultiServiceFactory
) Param
.getMSF());
119 xTextDoc
= SOF
.createTextDoc(null);
120 } catch (com
.sun
.star
.uno
.Exception e
) {
121 throw new StatusException("Can't create document", e
);
126 * Disposes writer document.
128 protected void cleanup(TestParameters Param
, PrintWriter log
) {
129 util
.DesktopTools
.closeDoc(xTextDoc
);
133 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
136 private void shortWait() {
139 } catch (InterruptedException e
) {
140 log
.println("While waiting :" + e
);