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 .
20 import com
.sun
.star
.drawing
.XLayerManager
;
21 import com
.sun
.star
.drawing
.XLayerSupplier
;
22 import java
.io
.PrintWriter
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
28 import util
.AccessibilityTools
;
29 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.awt
.XExtendedToolkit
;
34 import com
.sun
.star
.awt
.XWindow
;
35 import com
.sun
.star
.lang
.XComponent
;
36 import com
.sun
.star
.lang
.XMultiServiceFactory
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
38 import com
.sun
.star
.uno
.XInterface
;
39 import com
.sun
.star
.util
.XCloseable
;
43 * Test for object that implements the following interfaces :
45 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
47 * <li><code>::com::sun::star::accessibility::XAccessibleContext
49 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
52 * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent
54 * <li><code>::com::sun::star::accessibility::XAccessibleSelection
58 * @see com.sun.star.accessibility.XAccessibleSelection
59 * @see com.sun.star.accessibility.XAccessibleExtendedComponent
60 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
61 * @see com.sun.star.accessibility.XAccessibleContext
62 * @see com.sun.star.accessibility.XAccessibleComponent
63 * @see ifc.accessibility._XAccessibleSelection
64 * @see ifc.accessibility._XAccessibleComponent
65 * @see ifc.accessibility._XAccessibleExtendedComponent
66 * @see ifc.accessibility._XAccessibleEventBroadcaster
67 * @see ifc.accessibility._XAccessibleContext
69 public class AccessibleTabBarPageList
extends TestCase
{
70 static XComponent xDoc
;
73 * Disposes the document, if exists, created in
74 * <code>createTestEnvironment</code> method.
76 protected void cleanup(TestParameters Param
, PrintWriter log
) {
77 log
.println("disposing xDoc");
85 * Creates a spreadsheet document. Then obtains an accessible object with
86 * the role <code>AccessibleRole.PAGETABLIST</code>.
87 * Object relations created :
89 * <li> <code>'EventProducer'</code> for
90 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
94 * @param tParam test parameters
95 * @param log writer to log information while testing
97 * @see com.sun.star.awt.Toolkit
98 * @see com.sun.star.accessibility.AccessibleRole
99 * @see ifc.accessibility._XAccessibleEventBroadcaster
100 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
102 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
104 log
.println("creating a test environment");
110 // get a soffice factory object
111 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
) tParam
.getMSF());
114 log
.println("creating a draw document");
115 xDoc
= SOF
.createDrawDoc(null);
116 } catch (com
.sun
.star
.uno
.Exception e
) {
117 // Some exception occurs.FAILED
118 e
.printStackTrace(log
);
119 throw new StatusException("Couldn't create document", e
);
124 XInterface oObj
= null;
127 oObj
= (XInterface
) ( (XMultiServiceFactory
) tParam
.getMSF())
128 .createInstance("com.sun.star.awt.Toolkit");
129 } catch (com
.sun
.star
.uno
.Exception e
) {
130 log
.println("Couldn't get toolkit");
131 e
.printStackTrace(log
);
132 throw new StatusException("Couldn't get toolkit", e
);
135 XExtendedToolkit tk
= UnoRuntime
.queryInterface(
136 XExtendedToolkit
.class, oObj
);
138 AccessibilityTools at
= new AccessibilityTools();
142 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,
143 tk
.getActiveTopWindow());
145 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
147 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
148 AccessibleRole
.PAGE_TAB_LIST
);
150 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
152 TestEnvironment tEnv
= new TestEnvironment(oObj
);
154 tEnv
.addObjRelation("XAccessibleSelection.multiSelection",
157 tEnv
.addObjRelation("XAccessibleSelection.OneAlwaysSelected",
160 XLayerSupplier oLS
= UnoRuntime
.queryInterface(XLayerSupplier
.class, xDoc
);
161 XInterface oLM
= oLS
.getLayerManager();
162 final XLayerManager xLM
= UnoRuntime
.queryInterface(XLayerManager
.class, oLM
);
165 tEnv
.addObjRelation("EventProducer",
166 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
167 public void fireEvent() {
168 xLM
.insertNewByIndex(0);
176 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
179 private void shortWait() {
182 } catch (InterruptedException e
) {
183 System
.out
.println("While waiting :" + e
);
187 protected void closeDoc() {
188 XCloseable closer
= UnoRuntime
.queryInterface(
189 XCloseable
.class, xDoc
);
193 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
194 log
.println("Couldn't close document " + e
.getMessage());
195 } catch (com
.sun
.star
.lang
.DisposedException e
) {
196 log
.println("Couldn't close document " + e
.getMessage());