bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleStatusBarItem.java
bloba6f29e18e0d7d556cb7e59ceb6b9b0f6669cb74c
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.text.XTextDocument;
27 import com.sun.star.uno.UnoRuntime;
28 import com.sun.star.uno.XInterface;
30 import java.io.PrintWriter;
32 import lib.StatusException;
33 import lib.TestCase;
34 import lib.TestEnvironment;
35 import lib.TestParameters;
37 import util.AccessibilityTools;
38 import util.DesktopTools;
39 import util.SOfficeFactory;
42 /**
43 * Test for object that implements the following interfaces :
44 * <ul>
45 * <li><code>
46 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
47 * <li><code>
48 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
49 * </code></li>
50 * <li><code>
51 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
52 * <li><code>
53 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
54 * </code></li>
55 * <li><code>
56 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
57 * <li><code>
58 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
59 * </ul> <p>
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 AccessibleStatusBarItem extends TestCase {
75 private static XTextDocument xTextDoc;
77 /**
78 * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>).
80 @Override
81 protected void initialize(TestParameters Param, PrintWriter log) {
82 UnoRuntime.queryInterface(XDesktop.class,
83 DesktopTools.createDesktop(
84 Param.getMSF()));
87 /**
88 * Disposes the document, if exists, created in
89 * <code>createTestEnvironment</code> method.
91 @Override
92 protected void cleanup(TestParameters Param, PrintWriter log) {
93 log.println("disposing xTextDoc");
95 if (xTextDoc != null) {
96 util.DesktopTools.closeDoc(xTextDoc);
101 * Creates a text document.
102 * Then obtains an accessible object with
103 * the role <code>AccessibleRole.SCROLLBAR</code>.
104 * Object relations created :
105 * <ul>
106 * <li> <code>'EventProducer'</code> for
107 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
108 * grabs focus </li>
109 * </ul>
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
119 @Override
120 protected TestEnvironment createTestEnvironment(TestParameters tParam,
121 PrintWriter log) {
122 log.println("creating a test environment");
124 if (xTextDoc != null) {
125 util.DesktopTools.closeDoc(xTextDoc);
128 // get a soffice factory object
129 SOfficeFactory SOF = SOfficeFactory.getFactory(
130 tParam.getMSF());
132 try {
133 log.println("creating a text document");
134 xTextDoc = SOF.createTextDoc(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,
142 xTextDoc);
144 XInterface oObj = null;
145 XInterface secondItem = null;
147 XWindow xWindow = AccessibilityTools.getCurrentContainerWindow(
148 aModel);
150 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
152 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
153 XAccessibleContext statusbar = AccessibilityTools.getAccessibleObjectForRole(xRoot,
154 AccessibleRole.STATUS_BAR);
156 try {
157 oObj = statusbar.getAccessibleChild(6);
158 secondItem = statusbar.getAccessibleChild(1);
159 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
162 log.println("ImplementationName: " + util.utils.getImplName(oObj));
164 TestEnvironment tEnv = new TestEnvironment(oObj);
166 tEnv.addObjRelation("EditOnly",
167 "Can't change or select Text in StatusBarItem");
168 tEnv.addObjRelation("XAccessibleText", secondItem);
170 tEnv.addObjRelation("LimitedBounds", "yes");
172 final XTextDocument doc = xTextDoc;
174 tEnv.addObjRelation("EventProducer",
175 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
176 public void fireEvent() {
177 doc.getText().setString("AccessibleStatusBarItem");
181 return tEnv;