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
.lang
.XMultiServiceFactory
;
28 import com
.sun
.star
.text
.XTextDocument
;
29 import com
.sun
.star
.uno
.UnoRuntime
;
30 import com
.sun
.star
.uno
.XInterface
;
32 import java
.io
.PrintWriter
;
34 import lib
.StatusException
;
36 import lib
.TestEnvironment
;
37 import lib
.TestParameters
;
39 import util
.AccessibilityTools
;
40 import util
.SOfficeFactory
;
44 * Test for object that implements the following interfaces :
47 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
49 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
52 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
54 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
57 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
59 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
62 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
63 * @see com.sun.star.accessibility.XAccessibleContext
64 * @see com.sun.star.accessibility.XAccessibleComponent
65 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
66 * @see com.sun.star.accessibility.XAccessibleValue
67 * @see com.sun.star.accessibility.XAccessibleAction
68 * @see ifc.accessibility._XAccessibleEventBroadcaster
69 * @see ifc.accessibility._XAccessibleContext
70 * @see ifc.accessibility._XAccessibleComponent
71 * @see ifc.accessibility._XAccessibleExtendedComponent
72 * @see ifc.accessibility._XAccessibleValue
73 * @see ifc.accessibility._XAccessibleAction
75 public class AccessibleStatusBar
extends TestCase
{
76 private static XTextDocument xTextDoc
;
79 * Disposes the document, if exists, created in
80 * <code>createTestEnvironment</code> method.
82 protected void cleanup(TestParameters Param
, PrintWriter log
) {
83 log
.println("disposing xTextDoc");
85 if (xTextDoc
!= null) {
86 util
.DesktopTools
.closeDoc(xTextDoc
);
91 * Creates a text document.
92 * Then obtains an accessible object with
93 * the role <code>AccessibleRole.SCROLLBAR</code>.
94 * Object relations created :
96 * <li> <code>'EventProducer'</code> for
97 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
101 * @param tParam test parameters
102 * @param log writer to log information while testing
104 * @see com.sun.star.awt.Toolkit
105 * @see com.sun.star.accessibility.AccessibleRole
106 * @see ifc.accessibility._XAccessibleEventBroadcaster
107 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
109 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
111 log
.println("creating a test environment");
113 if (xTextDoc
!= null) {
114 util
.DesktopTools
.closeDoc(xTextDoc
);
117 // get a soffice factory object
118 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
119 (XMultiServiceFactory
) tParam
.getMSF());
121 XInterface toolkit
= null;
124 log
.println("creating a text document");
125 xTextDoc
= SOF
.createTextDoc(null);
126 toolkit
= (XInterface
) ((XMultiServiceFactory
) tParam
.getMSF()).createInstance(
127 "com.sun.star.awt.Toolkit");
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 AccessibilityTools at
= new AccessibilityTools();
138 final XWindow xWindow
=
139 UnoRuntime
.queryInterface(XModel
.class, xTextDoc
).
140 getCurrentController().getFrame().getContainerWindow();
142 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
144 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.STATUS_BAR
);
146 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
148 TestEnvironment tEnv
= new TestEnvironment(oObj
);
150 UnoRuntime
.queryInterface(
151 XExtendedToolkit
.class, toolkit
);
153 tEnv
.addObjRelation("EventProducer",
154 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
155 public void fireEvent() {
156 Rectangle newPosSize
= xWindow
.getPosSize();
157 newPosSize
.Width
= newPosSize
.Width
- 20;
158 newPosSize
.Height
= newPosSize
.Height
- 20;
159 newPosSize
.X
= newPosSize
.X
+ 20;
160 newPosSize
.Y
= newPosSize
.Y
+ 20;
162 newPosSize
.X
, newPosSize
.Y
, newPosSize
.Width
,
163 newPosSize
.Height
, PosSize
.POSSIZE
);