tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleStatusBarItem.java
blobaa10a8b0045314ecce2b36f5175ae21bf160ea95
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.XModel;
25 import com.sun.star.text.XTextDocument;
26 import com.sun.star.uno.UnoRuntime;
27 import com.sun.star.uno.XInterface;
29 import java.io.PrintWriter;
31 import lib.TestCase;
32 import lib.TestEnvironment;
33 import lib.TestParameters;
34 import util.AccessibilityTools;
35 import util.SOfficeFactory;
38 /**
39 * Test for object that implements the following interfaces :
40 * <ul>
41 * <li><code>
42 * ::com::sun::star::accessibility::XAccessibleContext</code></li>
43 * <li><code>
44 * ::com::sun::star::accessibility::XAccessibleEventBroadcaster
45 * </code></li>
46 * <li><code>
47 * ::com::sun::star::accessibility::XAccessibleComponent</code></li>
48 * <li><code>
49 * ::com::sun::star::accessibility::XAccessibleExtendedComponent
50 * </code></li>
51 * <li><code>
52 * ::com::sun::star::accessibility::XAccessibleValue</code></li>
53 * <li><code>
54 * ::com::sun::star::accessibility::XAccessibleAction</code></li>
55 * </ul> <p>
57 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
58 * @see com.sun.star.accessibility.XAccessibleContext
59 * @see com.sun.star.accessibility.XAccessibleComponent
60 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
61 * @see com.sun.star.accessibility.XAccessibleValue
62 * @see com.sun.star.accessibility.XAccessibleAction
63 * @see ifc.accessibility._XAccessibleEventBroadcaster
64 * @see ifc.accessibility._XAccessibleContext
65 * @see ifc.accessibility._XAccessibleComponent
66 * @see ifc.accessibility._XAccessibleExtendedComponent
67 * @see ifc.accessibility._XAccessibleValue
68 * @see ifc.accessibility._XAccessibleAction
70 public class AccessibleStatusBarItem extends TestCase {
71 private static XTextDocument xTextDoc;
73 /**
74 * Disposes the document, if exists, created in
75 * <code>createTestEnvironment</code> method.
77 @Override
78 protected void cleanup(TestParameters Param, PrintWriter log) {
79 log.println("disposing xTextDoc");
81 if (xTextDoc != null) {
82 util.DesktopTools.closeDoc(xTextDoc);
86 /**
87 * Creates a text document.
88 * Then obtains an accessible object with
89 * the role <code>AccessibleRole.SCROLLBAR</code>.
90 * Object relations created :
91 * <ul>
92 * <li> <code>'EventProducer'</code> for
93 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
94 * grabs focus </li>
95 * </ul>
97 * @param tParam test parameters
98 * @param log writer to log information while testing
100 * @see com.sun.star.awt.Toolkit
101 * @see com.sun.star.accessibility.AccessibleRole
102 * @see ifc.accessibility._XAccessibleEventBroadcaster
103 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
105 @Override
106 protected TestEnvironment createTestEnvironment(TestParameters tParam,
107 PrintWriter log) throws Exception {
108 log.println("creating a test environment");
110 if (xTextDoc != null) {
111 util.DesktopTools.closeDoc(xTextDoc);
114 // get a soffice factory object
115 SOfficeFactory SOF = SOfficeFactory.getFactory(
116 tParam.getMSF());
118 log.println("creating a text document");
119 xTextDoc = SOF.createTextDoc(null);
121 XModel aModel = UnoRuntime.queryInterface(XModel.class,
122 xTextDoc);
124 XInterface oObj = null;
125 XInterface secondItem = null;
127 XWindow xWindow = AccessibilityTools.getCurrentContainerWindow(
128 aModel);
130 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
132 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
133 XAccessibleContext statusbar = AccessibilityTools.getAccessibleObjectForRole(xRoot,
134 AccessibleRole.STATUS_BAR);
136 try {
137 oObj = statusbar.getAccessibleChild(6);
138 secondItem = statusbar.getAccessibleChild(1);
139 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
142 log.println("ImplementationName: " + util.utils.getImplName(oObj));
144 TestEnvironment tEnv = new TestEnvironment(oObj);
146 tEnv.addObjRelation("EditOnly",
147 "Can't change or select Text in StatusBarItem");
148 tEnv.addObjRelation("XAccessibleText", secondItem);
150 tEnv.addObjRelation("LimitedBounds", "yes");
152 final XTextDocument doc = xTextDoc;
154 tEnv.addObjRelation("EventProducer",
155 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
156 public void fireEvent() {
157 doc.getText().setString("AccessibleStatusBarItem");
161 return tEnv;