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
.awt
.PosSize
;
23 import com
.sun
.star
.awt
.Rectangle
;
24 import com
.sun
.star
.awt
.XExtendedToolkit
;
25 import com
.sun
.star
.awt
.XWindow
;
26 import com
.sun
.star
.frame
.XModel
;
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
;
34 import lib
.TestEnvironment
;
35 import lib
.TestParameters
;
36 import util
.AccessibilityTools
;
37 import util
.SOfficeFactory
;
41 * Test for object that implements the following interfaces :
44 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
46 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
49 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
51 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
54 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
56 * ::com::sun::star::accessibility::XAccessibleAction</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.XAccessibleValue
64 * @see com.sun.star.accessibility.XAccessibleAction
65 * @see ifc.accessibility._XAccessibleEventBroadcaster
66 * @see ifc.accessibility._XAccessibleContext
67 * @see ifc.accessibility._XAccessibleComponent
68 * @see ifc.accessibility._XAccessibleExtendedComponent
69 * @see ifc.accessibility._XAccessibleValue
70 * @see ifc.accessibility._XAccessibleAction
72 public class AccessibleStatusBar
extends TestCase
{
73 private static XTextDocument xTextDoc
;
76 * Disposes the document, if exists, created in
77 * <code>createTestEnvironment</code> method.
80 protected void cleanup(TestParameters Param
, PrintWriter log
) {
81 log
.println("disposing xTextDoc");
83 if (xTextDoc
!= null) {
84 util
.DesktopTools
.closeDoc(xTextDoc
);
89 * Creates a text document.
90 * Then obtains an accessible object with
91 * the role <code>AccessibleRole.SCROLLBAR</code>.
92 * Object relations created :
94 * <li> <code>'EventProducer'</code> for
95 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
99 * @param tParam test parameters
100 * @param log writer to log information while testing
102 * @see com.sun.star.awt.Toolkit
103 * @see com.sun.star.accessibility.AccessibleRole
104 * @see ifc.accessibility._XAccessibleEventBroadcaster
105 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
108 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
109 PrintWriter log
) throws Exception
{
110 log
.println("creating a test environment");
112 if (xTextDoc
!= null) {
113 util
.DesktopTools
.closeDoc(xTextDoc
);
116 // get a soffice factory object
117 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
120 XInterface toolkit
= null;
122 log
.println("creating a text document");
123 xTextDoc
= SOF
.createTextDoc(null);
124 toolkit
= (XInterface
) tParam
.getMSF().createInstance(
125 "com.sun.star.awt.Toolkit");
127 XInterface oObj
= null;
129 final XWindow xWindow
=
130 UnoRuntime
.queryInterface(XModel
.class, xTextDoc
).
131 getCurrentController().getFrame().getContainerWindow();
133 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
135 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.STATUS_BAR
);
137 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
139 TestEnvironment tEnv
= new TestEnvironment(oObj
);
141 UnoRuntime
.queryInterface(
142 XExtendedToolkit
.class, toolkit
);
144 tEnv
.addObjRelation("EventProducer",
145 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
146 public void fireEvent() {
147 Rectangle newPosSize
= xWindow
.getPosSize();
148 newPosSize
.Width
= newPosSize
.Width
- 20;
149 newPosSize
.Height
= newPosSize
.Height
- 20;
150 newPosSize
.X
= newPosSize
.X
+ 20;
151 newPosSize
.Y
= newPosSize
.Y
+ 20;
153 newPosSize
.X
, newPosSize
.Y
, newPosSize
.Width
,
154 newPosSize
.Height
, PosSize
.POSSIZE
);