tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleTabBar.java
blob64de47ec088a2db7a771a34f705e46ebc3daeba9
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.TestCase;
23 import lib.TestEnvironment;
24 import lib.TestParameters;
25 import util.AccessibilityTools;
26 import util.SOfficeFactory;
28 import com.sun.star.accessibility.AccessibleRole;
29 import com.sun.star.accessibility.XAccessible;
30 import com.sun.star.awt.PosSize;
31 import com.sun.star.awt.XWindow;
32 import com.sun.star.frame.XModel;
33 import com.sun.star.lang.XComponent;
34 import com.sun.star.lang.XMultiServiceFactory;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
37 import com.sun.star.util.XCloseable;
40 public class AccessibleTabBar extends TestCase {
41 static XComponent xDoc;
43 /**
44 * Disposes the document, if exists, created in
45 * <code>createTestEnvironment</code> method.
47 @Override
48 protected void cleanup(TestParameters Param, PrintWriter log) {
49 log.println("disposing xCalcDoc");
51 if (xDoc != null) {
52 closeDoc(xDoc);
56 /**
57 * Creates a spreadsheet document. Then obtains an accessible object with
58 * the role <code>AccessibleRole.PAGETAB</code>.
59 * Object relations created :
60 * <ul>
61 * <li> <code>'EventProducer'</code> for
62 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
63 * </li>
64 * </ul>
66 * @param tParam test parameters
67 * @param log writer to log information while testing
69 * @see com.sun.star.awt.Toolkit
70 * @see com.sun.star.accessibility.AccessibleRole
71 * @see ifc.accessibility._XAccessibleEventBroadcaster
72 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
74 @Override
75 protected TestEnvironment createTestEnvironment(TestParameters tParam,
76 PrintWriter log) throws Exception {
77 log.println("creating a test environment");
79 if (xDoc != null) {
80 closeDoc(xDoc);
83 XMultiServiceFactory msf = tParam.getMSF();
85 // get a soffice factory object
86 SOfficeFactory SOF = SOfficeFactory.getFactory(msf);
88 log.println("creating a calc document");
89 xDoc = UnoRuntime.queryInterface(XComponent.class,
90 SOF.createCalcDoc(
91 null));
93 util.utils.waitForEventIdle(tParam.getMSF());
95 XInterface oObj = null;
97 XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xDoc).
98 getCurrentController().getFrame().getContainerWindow();
100 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
101 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
102 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL);
104 log.println("ImplementationName: " + util.utils.getImplName(oObj));
106 TestEnvironment tEnv = new TestEnvironment(oObj);
108 final XWindow aWin = xWindow;
110 tEnv.addObjRelation("EventProducer",
111 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
112 public void fireEvent() {
113 aWin.setPosSize(100,100, 500, 500, PosSize.POSSIZE);
117 return tEnv;
120 protected void closeDoc(XComponent xDoc) {
121 XCloseable closer = UnoRuntime.queryInterface(
122 XCloseable.class, xDoc);
124 try {
125 closer.close(true);
126 } catch (com.sun.star.util.CloseVetoException e) {
127 log.println("Couldn't close document " + e.getMessage());