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
.text
.XTextDocument
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
28 import com
.sun
.star
.uno
.XInterface
;
30 import java
.io
.PrintWriter
;
32 import lib
.StatusException
;
34 import lib
.TestEnvironment
;
35 import lib
.TestParameters
;
37 import util
.AccessibilityTools
;
38 import util
.DesktopTools
;
39 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
56 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
58 * ::com::sun::star::accessibility::XAccessibleText</code></li>
60 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
63 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
64 * @see com.sun.star.accessibility.XAccessibleContext
65 * @see com.sun.star.accessibility.XAccessibleComponent
66 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
67 * @see com.sun.star.accessibility.XAccessibleAction
68 * @see com.sun.star.accessibility.XAccessibleText
69 * @see com.sun.star.accessibility.XAccessibleValue
70 * @see ifc.accessibility._XAccessibleEventBroadcaster
71 * @see ifc.accessibility._XAccessibleContext
72 * @see ifc.accessibility._XAccessibleComponent
73 * @see ifc.accessibility._XAccessibleExtendedComponent
74 * @see ifc.accessibility._XAccessibleAction
75 * @see ifc.accessibility._XAccessibleText
76 * @see ifc.accessibility._XAccessibleValue
78 public class AccessibleToolBoxItem
extends TestCase
{
79 private static XTextDocument xTextDoc
;
82 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
85 protected void initialize(TestParameters Param
, PrintWriter log
) {
86 UnoRuntime
.queryInterface(XDesktop
.class,
87 DesktopTools
.createDesktop(
92 * Disposes the document, if exists, created in
93 * <code>createTestEnvironment</code> method.
96 protected void cleanup(TestParameters Param
, PrintWriter log
) {
97 log
.println("disposing xTextDoc");
99 if (xTextDoc
!= null) {
105 * Creates a text document.
106 * Then obtains an accessible object with
107 * the role <code>AccessibleRole.PUSHBUTTON</code> and with the name
108 * <code>"Bold"</code>.
109 * Object relations created :
111 * <li> <code>'EventProducer'</code> for
112 * {@link ifc.accessibility._XAccessibleEventBroadcaster}</li>
113 * <li> <code>'XAccessibleText.Text'</code> for
114 * {@link ifc.accessibility._XAccessibleText}: the name of button</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._XAccessibleText
124 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
125 * @see com.sun.star.accessibility.XAccessibleText
128 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
130 log
.println("creating a test environment");
132 if (xTextDoc
!= null) {
136 // get a soffice factory object
137 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
141 log
.println("creating a text document");
142 xTextDoc
= SOF
.createTextDoc(null);
143 } catch (com
.sun
.star
.uno
.Exception e
) {
144 // Some exception occurs.FAILED
145 e
.printStackTrace(log
);
146 throw new StatusException("Couldn't create document", e
);
149 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class,
152 XInterface oObj
= null;
154 XWindow xWindow
= AccessibilityTools
.getCurrentContainerWindow(
157 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
160 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
161 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
162 AccessibleRole
.TOGGLE_BUTTON
,
165 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
167 TestEnvironment tEnv
= new TestEnvironment(oObj
);
169 tEnv
.addObjRelation("EditOnly",
170 "This method isn't supported in this dialog");
172 tEnv
.addObjRelation("LimitedBounds", "yes");
174 final XAccessibleAction oAction
= UnoRuntime
.queryInterface(
175 XAccessibleAction
.class,
178 tEnv
.addObjRelation("EventProducer",
179 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
180 public void fireEvent() {
182 oAction
.doAccessibleAction(0);
183 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
188 tEnv
.addObjRelation("XAccessibleText.Text", "Bold");
193 protected void closeDoc() {
194 util
.DesktopTools
.closeDoc(xTextDoc
);