tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _svtools / AccessibleTabBarPage.java
blobe8b4c56e74981cdf4203ce8ef046fd92c718901a
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 .
19 package mod._svtools;
21 import com.sun.star.accessibility.AccessibleRole;
22 import com.sun.star.accessibility.XAccessibleComponent;
23 import com.sun.star.accessibility.XAccessibleContext;
24 import com.sun.star.awt.Point;
26 import java.awt.Robot;
27 import java.awt.event.InputEvent;
28 import java.io.PrintWriter;
30 import lib.TestCase;
31 import lib.TestEnvironment;
32 import lib.TestParameters;
33 import util.AccessibilityTools;
34 import util.SOfficeFactory;
36 import com.sun.star.accessibility.XAccessible;
37 import com.sun.star.awt.XExtendedToolkit;
38 import com.sun.star.awt.XWindow;
39 import com.sun.star.lang.XComponent;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
43 /**
44 * Test for object that implements the following interfaces :
45 * <ul>
46 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
47 * </code></li>
48 * <li><code>::com::sun::star::accessibility::XAccessibleContext
49 * </code></li>
50 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
51 * </code></li>
52 * <li>
53 * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent
54 * </code></li>
55 * </ul> <p>
57 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
58 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
59 * @see com.sun.star.accessibility.XAccessibleContext
60 * @see com.sun.star.accessibility.XAccessibleComponent
61 * @see ifc.accessibility._XAccessibleComponent
62 * @see ifc.accessibility._XAccessibleExtendedComponent
63 * @see ifc.accessibility._XAccessibleEventBroadcaster
64 * @see ifc.accessibility._XAccessibleContext
66 public class AccessibleTabBarPage extends TestCase {
68 static XComponent xDoc;
70 /**
71 * Disposes the document, if exists, created in
72 * <code>createTestEnvironment</code> method.
74 @Override
75 protected void cleanup( TestParameters Param, PrintWriter log) {
77 log.println("disposing xCalcDoc");
78 if (xDoc != null) {
79 util.DesktopTools.closeDoc(xDoc);
83 /**
84 * Creates a spreadsheet document. Then obtains an accessible object with
85 * the role <code>AccessibleRole.PAGETAB</code>.
86 * Object relations created :
87 * <ul>
88 * <li> <code>'EventProducer'</code> for
89 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
90 * </li>
91 * </ul>
93 * @param tParam test parameters
94 * @param log writer to log information while testing
96 * @see com.sun.star.awt.Toolkit
97 * @see com.sun.star.accessibility.AccessibleRole
98 * @see ifc.accessibility._XAccessibleEventBroadcaster
99 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
101 @Override
102 protected TestEnvironment createTestEnvironment(TestParameters tParam,
103 PrintWriter log) throws Exception {
105 log.println( "creating a test environment" );
107 if (xDoc != null) xDoc.dispose();
109 // get a soffice factory object
110 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
112 log.println( "creating a calc document" );
113 xDoc = UnoRuntime.queryInterface(XComponent.class, SOF.createCalcDoc(null));// SOF.createDrawDoc(null);
115 util.utils.waitForEventIdle(tParam.getMSF());
117 XInterface oObj = (XInterface) tParam.getMSF().createInstance
118 ("com.sun.star.awt.Toolkit") ;
121 XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, oObj);
124 util.utils.waitForEventIdle(tParam.getMSF());
126 XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,tk.getActiveTopWindow());
128 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
129 AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
130 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PAGE_TAB, "Sheet1");
131 XAccessibleContext acc = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PAGE_TAB, "Sheet2");
132 XAccessibleComponent accComp = UnoRuntime.queryInterface(
133 XAccessibleComponent.class,
134 acc);
135 final Point point = accComp.getLocationOnScreen();
136 log.println("ImplementationName: " + util.utils.getImplName(oObj));
138 TestEnvironment tEnv = new TestEnvironment( oObj );
139 tEnv.addObjRelation("Destroy","yes");
140 tEnv.addObjRelation("EventProducer",
141 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
142 public void fireEvent() {
143 try {
144 Robot rob = new Robot();
145 rob.mouseMove(point.X + 25, point.Y + 5);
146 rob.mousePress(InputEvent.BUTTON1_MASK);
147 } catch (java.awt.AWTException e) {
148 System.out.println("couldn't fire event");
153 return tEnv;