bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleStatusBar.java
blobba8f8114499be6ddaa1d9b7e2c68877e0543e2db
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.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.lang.XMultiServiceFactory;
28 import com.sun.star.text.XTextDocument;
29 import com.sun.star.uno.UnoRuntime;
30 import com.sun.star.uno.XInterface;
32 import java.io.PrintWriter;
34 import lib.StatusException;
35 import lib.TestCase;
36 import lib.TestEnvironment;
37 import lib.TestParameters;
39 import util.AccessibilityTools;
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 AccessibleStatusBar extends TestCase {
76 private static XTextDocument xTextDoc;
78 /**
79 * Disposes the document, if exists, created in
80 * <code>createTestEnvironment</code> method.
82 protected void cleanup(TestParameters Param, PrintWriter log) {
83 log.println("disposing xTextDoc");
85 if (xTextDoc != null) {
86 util.DesktopTools.closeDoc(xTextDoc);
90 /**
91 * Creates a text document.
92 * Then obtains an accessible object with
93 * the role <code>AccessibleRole.SCROLLBAR</code>.
94 * Object relations created :
95 * <ul>
96 * <li> <code>'EventProducer'</code> for
97 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
98 * grabs focus </li>
99 * </ul>
101 * @param tParam test parameters
102 * @param log writer to log information while testing
104 * @see com.sun.star.awt.Toolkit
105 * @see com.sun.star.accessibility.AccessibleRole
106 * @see ifc.accessibility._XAccessibleEventBroadcaster
107 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
109 protected TestEnvironment createTestEnvironment(TestParameters tParam,
110 PrintWriter log) {
111 log.println("creating a test environment");
113 if (xTextDoc != null) {
114 util.DesktopTools.closeDoc(xTextDoc);
117 // get a soffice factory object
118 SOfficeFactory SOF = SOfficeFactory.getFactory(
119 (XMultiServiceFactory) tParam.getMSF());
121 XInterface toolkit = null;
123 try {
124 log.println("creating a text document");
125 xTextDoc = SOF.createTextDoc(null);
126 toolkit = (XInterface) ((XMultiServiceFactory) tParam.getMSF()).createInstance(
127 "com.sun.star.awt.Toolkit");
128 } catch (com.sun.star.uno.Exception e) {
129 // Some exception occurs.FAILED
130 e.printStackTrace(log);
131 throw new StatusException("Couldn't create document", e);
134 XInterface oObj = null;
136 AccessibilityTools at = new AccessibilityTools();
138 final XWindow xWindow =
139 UnoRuntime.queryInterface(XModel.class, xTextDoc).
140 getCurrentController().getFrame().getContainerWindow();
142 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
144 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.STATUS_BAR);
146 log.println("ImplementationName: " + util.utils.getImplName(oObj));
148 TestEnvironment tEnv = new TestEnvironment(oObj);
150 UnoRuntime.queryInterface(
151 XExtendedToolkit.class, toolkit);
153 tEnv.addObjRelation("EventProducer",
154 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
155 public void fireEvent() {
156 Rectangle newPosSize = xWindow.getPosSize();
157 newPosSize.Width = newPosSize.Width - 20;
158 newPosSize.Height = newPosSize.Height - 20;
159 newPosSize.X = newPosSize.X + 20;
160 newPosSize.Y = newPosSize.Y + 20;
161 xWindow.setPosSize(
162 newPosSize.X, newPosSize.Y, newPosSize.Width,
163 newPosSize.Height, PosSize.POSSIZE);
167 return tEnv;