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
.XModel
;
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
;
32 import lib
.TestEnvironment
;
33 import lib
.TestParameters
;
34 import util
.AccessibilityTools
;
35 import util
.SOfficeFactory
;
39 * Test for object that implements the following interfaces :
42 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
44 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
47 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
49 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
52 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
54 * ::com::sun::star::accessibility::XAccessibleText</code></li>
56 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
59 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see com.sun.star.accessibility.XAccessibleComponent
62 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
63 * @see com.sun.star.accessibility.XAccessibleAction
64 * @see com.sun.star.accessibility.XAccessibleText
65 * @see com.sun.star.accessibility.XAccessibleValue
66 * @see ifc.accessibility._XAccessibleEventBroadcaster
67 * @see ifc.accessibility._XAccessibleContext
68 * @see ifc.accessibility._XAccessibleComponent
69 * @see ifc.accessibility._XAccessibleExtendedComponent
70 * @see ifc.accessibility._XAccessibleAction
71 * @see ifc.accessibility._XAccessibleText
72 * @see ifc.accessibility._XAccessibleValue
74 public class AccessibleToolBoxItem
extends TestCase
{
75 private static XTextDocument xTextDoc
;
78 * Disposes the document, if exists, created in
79 * <code>createTestEnvironment</code> method.
82 protected void cleanup(TestParameters Param
, PrintWriter log
) {
83 log
.println("disposing xTextDoc");
85 if (xTextDoc
!= null) {
91 * Creates a text document.
92 * Then obtains an accessible object with
93 * the role <code>AccessibleRole.PUSHBUTTON</code> and with the name
94 * <code>"Bold"</code>.
95 * Object relations created :
97 * <li> <code>'EventProducer'</code> for
98 * {@link ifc.accessibility._XAccessibleEventBroadcaster}</li>
99 * <li> <code>'XAccessibleText.Text'</code> for
100 * {@link ifc.accessibility._XAccessibleText}: the name of button</li>
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 ifc.accessibility._XAccessibleText
110 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
111 * @see com.sun.star.accessibility.XAccessibleText
114 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
115 PrintWriter log
) throws Exception
{
116 log
.println("creating a test environment");
118 if (xTextDoc
!= null) {
122 // get a soffice factory object
123 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
126 log
.println("creating a text document");
127 xTextDoc
= SOF
.createTextDoc(null);
129 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class,
132 XInterface oObj
= null;
134 XWindow xWindow
= AccessibilityTools
.getCurrentContainerWindow(
137 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
140 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
141 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
142 AccessibleRole
.TOGGLE_BUTTON
,
145 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
147 TestEnvironment tEnv
= new TestEnvironment(oObj
);
149 tEnv
.addObjRelation("EditOnly",
150 "This method isn't supported in this dialog");
152 tEnv
.addObjRelation("LimitedBounds", "yes");
154 final XAccessibleAction oAction
= UnoRuntime
.queryInterface(
155 XAccessibleAction
.class,
158 tEnv
.addObjRelation("EventProducer",
159 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
160 public void fireEvent() {
162 oAction
.doAccessibleAction(0);
163 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
168 tEnv
.addObjRelation("XAccessibleText.Text", "Bold");
173 protected void closeDoc() {
174 util
.DesktopTools
.closeDoc(xTextDoc
);