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::XAccessibleAction</code></li>
56 * ::com::sun::star::accessibility::XAccessibleText</code></li>
58 * ::com::sun::star::accessibility::XAccessibleValue</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.XAccessibleAction
66 * @see com.sun.star.accessibility.XAccessibleText
67 * @see com.sun.star.accessibility.XAccessibleValue
68 * @see ifc.accessibility._XAccessibleEventBroadcaster
69 * @see ifc.accessibility._XAccessibleContext
70 * @see ifc.accessibility._XAccessibleComponent
71 * @see ifc.accessibility._XAccessibleExtendedComponent
72 * @see ifc.accessibility._XAccessibleAction
73 * @see ifc.accessibility._XAccessibleText
74 * @see ifc.accessibility._XAccessibleValue
76 public class AccessibleWindow
extends TestCase
{
77 private static XTextDocument xTextDoc
;
80 * Disposes the document, if exists, created in
81 * <code>createTestEnvironment</code> method.
84 protected void cleanup(TestParameters Param
, PrintWriter log
) {
85 log
.println("disposing xTextDoc");
87 if (xTextDoc
!= null) {
88 util
.DesktopTools
.closeDoc(xTextDoc
);
93 * Creates a text document.
94 * Then obtains an accessible object with
95 * the role <code>AccessibleRole.PUSHBUTTON</code> and with the name
96 * <code>"Bold"</code>.
97 * Object relations created :
99 * <li> <code>'EventProducer'</code> for
100 * {@link ifc.accessibility._XAccessibleEventBroadcaster}</li>
101 * <li> <code>'XAccessibleText.Text'</code> for
102 * {@link ifc.accessibility._XAccessibleText}: the name of button</li>
105 * @param tParam test parameters
106 * @param log writer to log information while testing
108 * @see com.sun.star.awt.Toolkit
109 * @see com.sun.star.accessibility.AccessibleRole
110 * @see ifc.accessibility._XAccessibleEventBroadcaster
111 * @see ifc.accessibility._XAccessibleText
112 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
113 * @see com.sun.star.accessibility.XAccessibleText
116 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
117 PrintWriter log
) throws Exception
{
118 log
.println("creating a test environment");
120 if (xTextDoc
!= null) {
121 util
.DesktopTools
.closeDoc(xTextDoc
);
124 // get a soffice factory object
125 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
128 XInterface toolkit
= null;
130 log
.println("creating a text document");
131 xTextDoc
= SOF
.createTextDoc(null);
132 toolkit
= (XInterface
) tParam
.getMSF().createInstance(
133 "com.sun.star.awt.Toolkit");
135 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class,
138 XInterface oObj
= null;
140 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(
143 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
145 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
147 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PANEL
);
149 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
151 TestEnvironment tEnv
= new TestEnvironment(oObj
);
153 final XExtendedToolkit tk
= UnoRuntime
.queryInterface(
154 XExtendedToolkit
.class, toolkit
);
156 tEnv
.addObjRelation("EventProducer",
157 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
158 public void fireEvent() {
159 XWindow xWin
= UnoRuntime
.queryInterface(
160 XWindow
.class, tk
.getActiveTopWindow());
161 Rectangle newPosSize
= xWin
.getPosSize();
162 newPosSize
.Width
= newPosSize
.Width
- 20;
163 newPosSize
.Height
= newPosSize
.Height
- 20;
164 newPosSize
.X
= newPosSize
.X
+ 20;
165 newPosSize
.Y
= newPosSize
.Y
+ 20;
166 xWin
.setPosSize(newPosSize
.X
, newPosSize
.Y
, newPosSize
.Width
,
167 newPosSize
.Height
, PosSize
.POSSIZE
);