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
.XDesktop
;
25 import com
.sun
.star
.frame
.XModel
;
26 import com
.sun
.star
.lang
.XComponent
;
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 AccessibleScrollBar
extends TestCase
{
75 private static XComponent xDoc
;
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");
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");
128 // get a soffice factory object
129 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
133 log
.println("creating a text document");
134 xDoc
= SOF
.createDrawDoc(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, xDoc
);
143 XInterface oObj
= null;
145 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(
148 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
150 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.SCROLL_BAR
);
152 final XAccessibleAction act
= UnoRuntime
.queryInterface(
153 XAccessibleAction
.class, oObj
);
155 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
157 TestEnvironment tEnv
= new TestEnvironment(oObj
);
159 tEnv
.addObjRelation("EventProducer",
160 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
161 public void fireEvent() {
163 act
.doAccessibleAction(1);
164 } catch (Exception e
) {
172 protected void closeDoc() {
173 util
.DesktopTools
.closeDoc(xDoc
);