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 .
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
;
25 import java
.awt
.Robot
;
26 import java
.awt
.event
.InputEvent
;
27 import java
.io
.PrintWriter
;
29 import lib
.StatusException
;
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
;
44 * Test for object that implements the following interfaces :
46 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
48 * <li><code>::com::sun::star::accessibility::XAccessibleContext
50 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
53 * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent
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
;
71 * Disposes the document, if exists, created in
72 * <code>createTestEnvironment</code> method.
75 protected void cleanup( TestParameters Param
, PrintWriter log
) {
77 log
.println("disposing xCalcDoc");
79 util
.DesktopTools
.closeDoc(xDoc
);
84 * Creates a spreadsheet document. Then obtains an accessible object with
85 * the role <code>AccessibleRole.PAGETAB</code>.
86 * Object relations created :
88 * <li> <code>'EventProducer'</code> for
89 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
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
102 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
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());
113 log
.println( "creating a calc document" );
114 xDoc
= UnoRuntime
.queryInterface(XComponent
.class, SOF
.createCalcDoc(null));// SOF.createDrawDoc(null);
115 } catch ( com
.sun
.star
.uno
.Exception e
) {
116 // Some exception occurs.FAILED
117 e
.printStackTrace( log
);
118 throw new StatusException( "Couldn't create document", e
);
121 util
.utils
.pause(5000);
123 XInterface oObj
= null;
126 oObj
= (XInterface
) tParam
.getMSF().createInstance
127 ("com.sun.star.awt.Toolkit") ;
128 } catch (com
.sun
.star
.uno
.Exception e
) {
129 log
.println("Couldn't get toolkit");
130 e
.printStackTrace(log
);
131 throw new StatusException("Couldn't get toolkit", e
);
135 XExtendedToolkit tk
= UnoRuntime
.queryInterface(XExtendedToolkit
.class, oObj
);
138 util
.utils
.pause(5000);
140 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,tk
.getActiveTopWindow());
142 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
143 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
144 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
, "Sheet1");
145 XAccessibleContext acc
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
, "Sheet2");
146 XAccessibleComponent accComp
= UnoRuntime
.queryInterface(
147 XAccessibleComponent
.class,
149 final Point point
= accComp
.getLocationOnScreen();
150 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
152 TestEnvironment tEnv
= new TestEnvironment( oObj
);
153 tEnv
.addObjRelation("Destroy","yes");
154 tEnv
.addObjRelation("EventProducer",
155 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
156 public void fireEvent() {
158 Robot rob
= new Robot();
159 rob
.mouseMove(point
.X
+ 25, point
.Y
+ 5);
160 rob
.mousePress(InputEvent
.BUTTON1_MASK
);
161 } catch (java
.awt
.AWTException e
) {
162 System
.out
.println("couldn't fire event");