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
.frame
.XDesktop
;
25 import com
.sun
.star
.frame
.XModel
;
26 import com
.sun
.star
.lang
.XMultiServiceFactory
;
27 import com
.sun
.star
.text
.XTextDocument
;
28 import com
.sun
.star
.uno
.UnoRuntime
;
29 import com
.sun
.star
.uno
.XInterface
;
31 import java
.io
.PrintWriter
;
33 import lib
.StatusException
;
35 import lib
.TestEnvironment
;
36 import lib
.TestParameters
;
38 import util
.AccessibilityTools
;
39 import util
.DesktopTools
;
40 import util
.SOfficeFactory
;
43 * Test for object that implements the following interfaces :
46 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
48 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
51 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
53 * ::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li>
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleContext
58 * @see com.sun.star.accessibility.XAccessibleComponent
59 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
60 * @see ifc.accessibility._XAccessibleEventBroadcaster
61 * @see ifc.accessibility._XAccessibleContext
62 * @see ifc.accessibility._XAccessibleComponent
63 * @see ifc.accessibility._XAccessibleExtendedComponent
65 public class AccessibleToolBox
extends TestCase
{
66 private static XTextDocument xTextDoc
;
69 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
72 protected void initialize(TestParameters Param
, PrintWriter log
) {
73 UnoRuntime
.queryInterface(XDesktop
.class,
74 DesktopTools
.createDesktop(
79 * Disposes the document, if exists, created in
80 * <code>createTestEnvironment</code> method.
83 protected void cleanup(TestParameters Param
, PrintWriter log
) {
84 log
.println("disposing xTextDoc");
86 if (xTextDoc
!= null) {
87 util
.DesktopTools
.closeDoc(xTextDoc
);
92 * Creates a text document.
93 * Then obtains an accessible object with
94 * the role <code>AccessibleRole.TOOLBAR</code>.
95 * Object relations created :
97 * <li> <code>'EventProducer'</code> for
98 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
103 * @param tParam test parameters
104 * @param log writer to log information while testing
106 * @see com.sun.star.awt.Toolkit
107 * @see com.sun.star.accessibility.AccessibleRole
108 * @see ifc.accessibility._XAccessibleEventBroadcaster
109 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
112 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
114 log
.println("creating a test environment");
116 if (xTextDoc
!= null) {
117 util
.DesktopTools
.closeDoc(xTextDoc
);
120 XMultiServiceFactory msf
= tParam
.getMSF();
122 // get a soffice factory object
123 SOfficeFactory SOF
= SOfficeFactory
.getFactory(msf
);
126 log
.println("creating a text document");
127 xTextDoc
= SOF
.createTextDoc(null);
128 } catch (com
.sun
.star
.uno
.Exception e
) {
129 // Some exception occurs.FAILED
130 e
.printStackTrace(log
);
131 throw new StatusException("Couldn't create document", e
);
134 XInterface oObj
= null;
136 XWindow xWindow
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
).
137 getCurrentController().getFrame().getContainerWindow();
139 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
141 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
143 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TOOL_BAR
);
145 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
147 TestEnvironment tEnv
= new TestEnvironment(oObj
);
149 tEnv
.addObjRelation("LimitedBounds", "yes");
151 XAccessible acc
= AccessibilityTools
.getAccessibleObject(oObj
);
152 XAccessible child
= null;
155 child
= acc
.getAccessibleContext().getAccessibleChild(0);
156 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
159 util
.dbg
.printInterfaces(child
);
161 final XAccessibleAction action
= UnoRuntime
.queryInterface(
162 XAccessibleAction
.class,
165 tEnv
.addObjRelation("EventProducer",
166 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
167 public void fireEvent() {
169 action
.doAccessibleAction(0);
170 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
171 System
.out
.println("Couldn't fire event");