bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleTabBar.java
blob9803a450272a0be2a88b6d5a760e8531d73b6644
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 java.io.PrintWriter;
22 import lib.StatusException;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.SOfficeFactory;
29 import com.sun.star.accessibility.AccessibleRole;
30 import com.sun.star.accessibility.XAccessible;
31 import com.sun.star.awt.PosSize;
32 import com.sun.star.awt.XWindow;
33 import com.sun.star.frame.XModel;
34 import com.sun.star.lang.XComponent;
35 import com.sun.star.lang.XMultiServiceFactory;
36 import com.sun.star.uno.UnoRuntime;
37 import com.sun.star.uno.XInterface;
38 import com.sun.star.util.XCloseable;
41 public class AccessibleTabBar extends TestCase {
42 static XComponent xDoc;
44 /**
45 * Disposes the document, if exists, created in
46 * <code>createTestEnvironment</code> method.
48 @Override
49 protected void cleanup(TestParameters Param, PrintWriter log) {
50 log.println("disposing xCalcDoc");
52 if (xDoc != null) {
53 closeDoc(xDoc);
57 /**
58 * Creates a spreadsheet document. Then obtains an accessible object with
59 * the role <code>AccessibleRole.PAGETAB</code>.
60 * Object relations created :
61 * <ul>
62 * <li> <code>'EventProducer'</code> for
63 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
64 * </li>
65 * </ul>
67 * @param tParam test parameters
68 * @param log writer to log information while testing
70 * @see com.sun.star.awt.Toolkit
71 * @see com.sun.star.accessibility.AccessibleRole
72 * @see ifc.accessibility._XAccessibleEventBroadcaster
73 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
75 @Override
76 protected TestEnvironment createTestEnvironment(TestParameters tParam,
77 PrintWriter log) {
78 log.println("creating a test environment");
80 if (xDoc != null) {
81 closeDoc(xDoc);
84 XMultiServiceFactory msf = tParam.getMSF();
86 // get a soffice factory object
87 SOfficeFactory SOF = SOfficeFactory.getFactory(msf);
89 try {
90 log.println("creating a calc document");
91 xDoc = UnoRuntime.queryInterface(XComponent.class,
92 SOF.createCalcDoc(
93 null));
94 } catch (com.sun.star.uno.Exception e) {
95 // Some exception occurs.FAILED
96 e.printStackTrace(log);
97 throw new StatusException("Couldn't create document", e);
100 util.utils.pause(5000);
102 XInterface oObj = null;
104 util.utils.pause(5000);
106 XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xDoc).
107 getCurrentController().getFrame().getContainerWindow();
109 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
110 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
111 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL);
113 log.println("ImplementationName: " + util.utils.getImplName(oObj));
115 TestEnvironment tEnv = new TestEnvironment(oObj);
117 final XWindow aWin = xWindow;
119 tEnv.addObjRelation("EventProducer",
120 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
121 public void fireEvent() {
122 aWin.setPosSize(100,100, 500, 500, PosSize.POSSIZE);
126 return tEnv;
129 protected void closeDoc(XComponent xDoc) {
130 XCloseable closer = UnoRuntime.queryInterface(
131 XCloseable.class, xDoc);
133 try {
134 closer.close(true);
135 } catch (com.sun.star.util.CloseVetoException e) {
136 log.println("Couldn't close document " + e.getMessage());
137 } catch (NullPointerException e) {
138 log.println("Couldn't close document " + e.getMessage());