bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleStatusBarItem.java
blobee55d7b4fb6ca9e8d9ca721a3d1b2df4ce1f0ac8
1 /*
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 .
18 package mod._toolkit;
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.lang.XMultiServiceFactory;
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;
33 import lib.StatusException;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
38 import util.AccessibilityTools;
39 import util.DesktopTools;
40 import util.SOfficeFactory;
43 /**
44 * Test for object that implements the following interfaces :
45 * <ul>
46 * <li><code>
47 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
48 * <li><code>
49 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
50 * </code></li>
51 * <li><code>
52 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
53 * <li><code>
54 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
55 * </code></li>
56 * <li><code>
57 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
58 * <li><code>
59 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
60 * </ul> <p>
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 AccessibleStatusBarItem extends TestCase {
76 private static XTextDocument xTextDoc;
78 /**
79 * 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(
84 (XMultiServiceFactory) Param.getMSF()));
87 /**
88 * Disposes the document, if exists, created in
89 * <code>createTestEnvironment</code> method.
91 protected void cleanup(TestParameters Param, PrintWriter log) {
92 log.println("disposing xTextDoc");
94 if (xTextDoc != null) {
95 util.DesktopTools.closeDoc(xTextDoc);
99 /**
100 * Creates a text document.
101 * Then obtains an accessible object with
102 * the role <code>AccessibleRole.SCROLLBAR</code>.
103 * Object relations created :
104 * <ul>
105 * <li> <code>'EventProducer'</code> for
106 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
107 * grabs focus </li>
108 * </ul>
110 * @param tParam test parameters
111 * @param log writer to log information while testing
113 * @see com.sun.star.awt.Toolkit
114 * @see com.sun.star.accessibility.AccessibleRole
115 * @see ifc.accessibility._XAccessibleEventBroadcaster
116 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
118 protected TestEnvironment createTestEnvironment(TestParameters tParam,
119 PrintWriter log) {
120 log.println("creating a test environment");
122 if (xTextDoc != null) {
123 util.DesktopTools.closeDoc(xTextDoc);
126 // get a soffice factory object
127 SOfficeFactory SOF = SOfficeFactory.getFactory(
128 (XMultiServiceFactory) tParam.getMSF());
130 try {
131 log.println("creating a text document");
132 xTextDoc = SOF.createTextDoc(null);
133 } catch (com.sun.star.uno.Exception e) {
134 // Some exception occurs.FAILED
135 e.printStackTrace(log);
136 throw new StatusException("Couldn't create document", e);
139 XModel aModel = UnoRuntime.queryInterface(XModel.class,
140 xTextDoc);
142 XInterface oObj = null;
143 XInterface secondItem = null;
145 AccessibilityTools at = new AccessibilityTools();
147 XWindow xWindow = AccessibilityTools.getCurrentContainerWindow(
148 (XMultiServiceFactory) tParam.getMSF(),
149 aModel);
151 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
153 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
154 XAccessibleContext statusbar = AccessibilityTools.getAccessibleObjectForRole(xRoot,
155 AccessibleRole.STATUS_BAR);
157 try {
158 oObj = statusbar.getAccessibleChild(6);
159 secondItem = statusbar.getAccessibleChild(1);
160 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
163 log.println("ImplementationName: " + util.utils.getImplName(oObj));
165 TestEnvironment tEnv = new TestEnvironment(oObj);
167 tEnv.addObjRelation("EditOnly",
168 "Can't change or select Text in StatusBarItem");
169 tEnv.addObjRelation("XAccessibleText", secondItem);
171 tEnv.addObjRelation("LimitedBounds", "yes");
173 final XTextDocument doc = xTextDoc;
175 tEnv.addObjRelation("EventProducer",
176 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
177 public void fireEvent() {
178 doc.getText().setString("AccessibleStatusBarItem");
182 return tEnv;