bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleTabBarPageList.java
blob5290e65bcd5d0d8dd479fdbbc8aaebde00222ce3
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._svtools;
20 import com.sun.star.drawing.XLayerManager;
21 import com.sun.star.drawing.XLayerSupplier;
22 import java.io.PrintWriter;
24 import lib.StatusException;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
28 import util.AccessibilityTools;
29 import util.SOfficeFactory;
31 import com.sun.star.accessibility.AccessibleRole;
32 import com.sun.star.accessibility.XAccessible;
33 import com.sun.star.awt.XExtendedToolkit;
34 import com.sun.star.awt.XWindow;
35 import com.sun.star.lang.XComponent;
36 import com.sun.star.uno.UnoRuntime;
37 import com.sun.star.uno.XInterface;
38 import com.sun.star.util.XCloseable;
41 /**
42 * Test for object that implements the following interfaces :
43 * <ul>
44 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
45 * </code></li>
46 * <li><code>::com::sun::star::accessibility::XAccessibleContext
47 * </code></li>
48 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
49 * </code></li>
50 * <li>
51 * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent
52 * </code></li>
53 * <li><code>::com::sun::star::accessibility::XAccessibleSelection
54 * </code></li>
55 * </ul> <p>
57 * @see com.sun.star.accessibility.XAccessibleSelection
58 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
59 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
60 * @see com.sun.star.accessibility.XAccessibleContext
61 * @see com.sun.star.accessibility.XAccessibleComponent
62 * @see ifc.accessibility._XAccessibleSelection
63 * @see ifc.accessibility._XAccessibleComponent
64 * @see ifc.accessibility._XAccessibleExtendedComponent
65 * @see ifc.accessibility._XAccessibleEventBroadcaster
66 * @see ifc.accessibility._XAccessibleContext
68 public class AccessibleTabBarPageList extends TestCase {
69 static XComponent xDoc;
71 /**
72 * Disposes the document, if exists, created in
73 * <code>createTestEnvironment</code> method.
75 @Override
76 protected void cleanup(TestParameters Param, PrintWriter log) {
77 log.println("disposing xDoc");
79 if (xDoc != null) {
80 closeDoc();
84 /**
85 * Creates a spreadsheet document. Then obtains an accessible object with
86 * the role <code>AccessibleRole.PAGETABLIST</code>.
87 * Object relations created :
88 * <ul>
89 * <li> <code>'EventProducer'</code> for
90 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
91 * </li>
92 * </ul>
94 * @param tParam test parameters
95 * @param log writer to log information while testing
97 * @see com.sun.star.awt.Toolkit
98 * @see com.sun.star.accessibility.AccessibleRole
99 * @see ifc.accessibility._XAccessibleEventBroadcaster
100 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
102 @Override
103 protected TestEnvironment createTestEnvironment(TestParameters tParam,
104 PrintWriter log) {
105 log.println("creating a test environment");
107 if (xDoc != null) {
108 closeDoc();
111 // get a soffice factory object
112 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
114 try {
115 log.println("creating a draw document");
116 xDoc = SOF.createDrawDoc(null);
117 } catch (com.sun.star.uno.Exception e) {
118 // Some exception occurs.FAILED
119 e.printStackTrace(log);
120 throw new StatusException("Couldn't create document", e);
123 util.utils.pause(5000);
125 XInterface oObj = null;
127 try {
128 oObj = (XInterface) tParam.getMSF()
129 .createInstance("com.sun.star.awt.Toolkit");
130 } catch (com.sun.star.uno.Exception e) {
131 log.println("Couldn't get toolkit");
132 e.printStackTrace(log);
133 throw new StatusException("Couldn't get toolkit", e);
136 XExtendedToolkit tk = UnoRuntime.queryInterface(
137 XExtendedToolkit.class, oObj);
139 util.utils.pause(5000);
141 XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,
142 tk.getActiveTopWindow());
144 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
146 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot,
147 AccessibleRole.PAGE_TAB_LIST);
149 log.println("ImplementationName: " + util.utils.getImplName(oObj));
151 TestEnvironment tEnv = new TestEnvironment(oObj);
153 tEnv.addObjRelation("XAccessibleSelection.multiSelection",
154 Boolean.FALSE);
156 tEnv.addObjRelation("XAccessibleSelection.OneAlwaysSelected",
157 Boolean.TRUE);
159 XLayerSupplier oLS = UnoRuntime.queryInterface(XLayerSupplier.class, xDoc);
160 XInterface oLM = oLS.getLayerManager();
161 final XLayerManager xLM = UnoRuntime.queryInterface(XLayerManager.class, oLM);
164 tEnv.addObjRelation("EventProducer",
165 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
166 public void fireEvent() {
167 xLM.insertNewByIndex(0);
171 return tEnv;
174 protected void closeDoc() {
175 XCloseable closer = UnoRuntime.queryInterface(
176 XCloseable.class, xDoc);
178 try {
179 closer.close(true);
180 } catch (com.sun.star.util.CloseVetoException e) {
181 log.println("Couldn't close document " + e.getMessage());
182 } catch (com.sun.star.lang.DisposedException e) {
183 log.println("Couldn't close document " + e.getMessage());