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
;
23 import java
.io
.PrintWriter
;
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
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
38 import com
.sun
.star
.util
.XCloseable
;
42 * Test for object that implements the following interfaces :
44 * <li><code>::com::sun::star::accessibility::XAccessibleComponent
46 * <li><code>::com::sun::star::accessibility::XAccessibleContext
48 * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster
51 * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent
53 * <li><code>::com::sun::star::accessibility::XAccessibleSelection
57 * @see com.sun.star.accessibility.XAccessibleSelection
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._XAccessibleSelection
63 * @see ifc.accessibility._XAccessibleComponent
64 * @see ifc.accessibility._XAccessibleExtendedComponent
65 * @see ifc.accessibility._XAccessibleEventBroadcaster
66 * @see ifc.accessibility._XAccessibleContext
68 public class AccessibleTabBarPageList
extends TestCase
{
69 static XComponent xDoc
;
72 * Disposes the document, if exists, created in
73 * <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
103 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
104 PrintWriter log
) throws Exception
{
105 log
.println("creating a test environment");
111 // get a soffice factory object
112 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
114 log
.println("creating a draw document");
115 xDoc
= SOF
.createDrawDoc(null);
117 util
.utils
.waitForEventIdle(tParam
.getMSF());
119 XInterface oObj
= (XInterface
) tParam
.getMSF()
120 .createInstance("com.sun.star.awt.Toolkit");
122 XExtendedToolkit tk
= UnoRuntime
.queryInterface(
123 XExtendedToolkit
.class, oObj
);
125 util
.utils
.waitForEventIdle(tParam
.getMSF());
127 XWindow xWindow
= UnoRuntime
.queryInterface(XWindow
.class,
128 tk
.getActiveTopWindow());
130 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
132 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
,
133 AccessibleRole
.PAGE_TAB_LIST
);
135 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
137 TestEnvironment tEnv
= new TestEnvironment(oObj
);
139 tEnv
.addObjRelation("XAccessibleSelection.multiSelection",
142 tEnv
.addObjRelation("XAccessibleSelection.OneAlwaysSelected",
145 XLayerSupplier oLS
= UnoRuntime
.queryInterface(XLayerSupplier
.class, xDoc
);
146 XInterface oLM
= oLS
.getLayerManager();
147 final XLayerManager xLM
= UnoRuntime
.queryInterface(XLayerManager
.class, oLM
);
150 tEnv
.addObjRelation("EventProducer",
151 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
152 public void fireEvent() {
153 xLM
.insertNewByIndex(0);
160 protected void closeDoc() {
161 XCloseable closer
= UnoRuntime
.queryInterface(
162 XCloseable
.class, xDoc
);
166 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
167 log
.println("Couldn't close document " + e
.getMessage());
168 } catch (com
.sun
.star
.lang
.DisposedException e
) {
169 log
.println("Couldn't close document " + e
.getMessage());