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
.lang
.XMultiServiceFactory
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
42 import com
.sun
.star
.uno
.XInterface
;
45 * Test for object that implements the following interfaces :
47 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
49 * <li><code>::com::sun::star::accessibility::XAccessibleContext
51 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
54 * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent
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._XAccessibleComponent
63 * @see ifc.accessibility._XAccessibleExtendedComponent
64 * @see ifc.accessibility._XAccessibleEventBroadcaster
65 * @see ifc.accessibility._XAccessibleContext
67 public class AccessibleTabBarPage
extends TestCase
{
69 static XComponent xDoc
;
72 * Disposes the document, if exists, created in
73 * <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
101 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
104 log
.println( "creating a test environment" );
106 if (xDoc
!= null) xDoc
.dispose();
108 // get a soffice factory object
109 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
112 log
.println( "creating a calc document" );
113 xDoc
= UnoRuntime
.queryInterface(XComponent
.class, SOF
.createCalcDoc(null));// SOF.createDrawDoc(null);
114 } catch ( com
.sun
.star
.uno
.Exception e
) {
115 // Some exception occurs.FAILED
116 e
.printStackTrace( log
);
117 throw new StatusException( "Couldn't create document", e
);
122 XInterface oObj
= null;
125 oObj
= (XInterface
) ((XMultiServiceFactory
)tParam
.getMSF()).createInstance
126 ("com.sun.star.awt.Toolkit") ;
127 } catch (com
.sun
.star
.uno
.Exception e
) {
128 log
.println("Couldn't get toolkit");
129 e
.printStackTrace(log
);
130 throw new StatusException("Couldn't get toolkit", e
);
134 XExtendedToolkit tk
= UnoRuntime
.queryInterface(XExtendedToolkit
.class, oObj
);
137 AccessibilityTools at
= new AccessibilityTools();
141 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,tk
.getActiveTopWindow());
143 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
144 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
145 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
, "Sheet1");
146 XAccessibleContext acc
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PAGE_TAB
, "Sheet2");
147 XAccessibleComponent accComp
= UnoRuntime
.queryInterface(
148 XAccessibleComponent
.class,
150 final Point point
= accComp
.getLocationOnScreen();
151 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
153 TestEnvironment tEnv
= new TestEnvironment( oObj
);
154 tEnv
.addObjRelation("Destroy","yes");
155 tEnv
.addObjRelation("EventProducer",
156 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer(){
157 public void fireEvent() {
159 Robot rob
= new Robot();
160 rob
.mouseMove(point
.X
+ 25, point
.Y
+ 5);
161 rob
.mousePress(InputEvent
.BUTTON1_MASK
);
162 } catch (java
.awt
.AWTException e
) {
163 System
.out
.println("couldn't fire event");
172 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
175 private void shortWait() {
178 } catch (InterruptedException e
) {
179 System
.out
.println("While waiting :" + e
) ;