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
.XAccessibleContext
;
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::XAccessibleValue</code></li>
58 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
61 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
62 * @see com.sun.star.accessibility.XAccessibleContext
63 * @see com.sun.star.accessibility.XAccessibleComponent
64 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
65 * @see com.sun.star.accessibility.XAccessibleValue
66 * @see com.sun.star.accessibility.XAccessibleAction
67 * @see ifc.accessibility._XAccessibleEventBroadcaster
68 * @see ifc.accessibility._XAccessibleContext
69 * @see ifc.accessibility._XAccessibleComponent
70 * @see ifc.accessibility._XAccessibleExtendedComponent
71 * @see ifc.accessibility._XAccessibleValue
72 * @see ifc.accessibility._XAccessibleAction
74 public class AccessibleStatusBarItem
extends TestCase
{
75 private static XTextDocument xTextDoc
;
78 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
81 protected void initialize(TestParameters Param
, PrintWriter log
) {
82 UnoRuntime
.queryInterface(XDesktop
.class,
83 DesktopTools
.createDesktop(
88 * Disposes the document, if exists, created in
89 * <code>createTestEnvironment</code> method.
92 protected void cleanup(TestParameters Param
, PrintWriter log
) {
93 log
.println("disposing xTextDoc");
95 if (xTextDoc
!= null) {
96 util
.DesktopTools
.closeDoc(xTextDoc
);
101 * Creates a text document.
102 * Then obtains an accessible object with
103 * the role <code>AccessibleRole.SCROLLBAR</code>.
104 * Object relations created :
106 * <li> <code>'EventProducer'</code> for
107 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
111 * @param tParam test parameters
112 * @param log writer to log information while testing
114 * @see com.sun.star.awt.Toolkit
115 * @see com.sun.star.accessibility.AccessibleRole
116 * @see ifc.accessibility._XAccessibleEventBroadcaster
117 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
120 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
122 log
.println("creating a test environment");
124 if (xTextDoc
!= null) {
125 util
.DesktopTools
.closeDoc(xTextDoc
);
128 // get a soffice factory object
129 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
133 log
.println("creating a text document");
134 xTextDoc
= SOF
.createTextDoc(null);
135 } catch (com
.sun
.star
.uno
.Exception e
) {
136 // Some exception occurs.FAILED
137 e
.printStackTrace(log
);
138 throw new StatusException("Couldn't create document", e
);
141 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class,
144 XInterface oObj
= null;
145 XInterface secondItem
= null;
147 XWindow xWindow
= AccessibilityTools
.getCurrentContainerWindow(
150 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
152 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
153 XAccessibleContext statusbar
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
154 AccessibleRole
.STATUS_BAR
);
157 oObj
= statusbar
.getAccessibleChild(6);
158 secondItem
= statusbar
.getAccessibleChild(1);
159 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
162 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
164 TestEnvironment tEnv
= new TestEnvironment(oObj
);
166 tEnv
.addObjRelation("EditOnly",
167 "Can't change or select Text in StatusBarItem");
168 tEnv
.addObjRelation("XAccessibleText", secondItem
);
170 tEnv
.addObjRelation("LimitedBounds", "yes");
172 final XTextDocument doc
= xTextDoc
;
174 tEnv
.addObjRelation("EventProducer",
175 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
176 public void fireEvent() {
177 doc
.getText().setString("AccessibleStatusBarItem");