bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _toolkit / AccessibleStatusBar.java
blob085254e728852ec9ec1ea0891e0e73b677d8a9a4
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.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.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 AccessibleStatusBar extends TestCase {
75 private static XTextDocument xTextDoc;
77 /**
78 * Disposes the document, if exists, created in
79 * <code>createTestEnvironment</code> method.
81 @Override
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 @Override
110 protected TestEnvironment createTestEnvironment(TestParameters tParam,
111 PrintWriter log) {
112 log.println("creating a test environment");
114 if (xTextDoc != null) {
115 util.DesktopTools.closeDoc(xTextDoc);
118 // get a soffice factory object
119 SOfficeFactory SOF = SOfficeFactory.getFactory(
120 tParam.getMSF());
122 XInterface toolkit = null;
124 try {
125 log.println("creating a text document");
126 xTextDoc = SOF.createTextDoc(null);
127 toolkit = (XInterface) tParam.getMSF().createInstance(
128 "com.sun.star.awt.Toolkit");
129 } catch (com.sun.star.uno.Exception e) {
130 // Some exception occurs.FAILED
131 e.printStackTrace(log);
132 throw new StatusException("Couldn't create document", e);
135 XInterface oObj = null;
137 final XWindow xWindow =
138 UnoRuntime.queryInterface(XModel.class, xTextDoc).
139 getCurrentController().getFrame().getContainerWindow();
141 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
143 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.STATUS_BAR);
145 log.println("ImplementationName: " + util.utils.getImplName(oObj));
147 TestEnvironment tEnv = new TestEnvironment(oObj);
149 UnoRuntime.queryInterface(
150 XExtendedToolkit.class, toolkit);
152 tEnv.addObjRelation("EventProducer",
153 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
154 public void fireEvent() {
155 Rectangle newPosSize = xWindow.getPosSize();
156 newPosSize.Width = newPosSize.Width - 20;
157 newPosSize.Height = newPosSize.Height - 20;
158 newPosSize.X = newPosSize.X + 20;
159 newPosSize.Y = newPosSize.Y + 20;
160 xWindow.setPosSize(
161 newPosSize.X, newPosSize.Y, newPosSize.Width,
162 newPosSize.Height, PosSize.POSSIZE);
166 return tEnv;