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 java
.io
.PrintWriter
;
23 import lib
.TestEnvironment
;
24 import lib
.TestParameters
;
25 import util
.AccessibilityTools
;
26 import util
.SOfficeFactory
;
28 import com
.sun
.star
.accessibility
.AccessibleRole
;
29 import com
.sun
.star
.accessibility
.XAccessible
;
30 import com
.sun
.star
.awt
.PosSize
;
31 import com
.sun
.star
.awt
.XWindow
;
32 import com
.sun
.star
.frame
.XModel
;
33 import com
.sun
.star
.lang
.XComponent
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
37 import com
.sun
.star
.util
.XCloseable
;
40 public class AccessibleTabBar
extends TestCase
{
41 static XComponent xDoc
;
44 * Disposes the document, if exists, created in
45 * <code>createTestEnvironment</code> method.
48 protected void cleanup(TestParameters Param
, PrintWriter log
) {
49 log
.println("disposing xCalcDoc");
57 * Creates a spreadsheet document. Then obtains an accessible object with
58 * the role <code>AccessibleRole.PAGETAB</code>.
59 * Object relations created :
61 * <li> <code>'EventProducer'</code> for
62 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
66 * @param tParam test parameters
67 * @param log writer to log information while testing
69 * @see com.sun.star.awt.Toolkit
70 * @see com.sun.star.accessibility.AccessibleRole
71 * @see ifc.accessibility._XAccessibleEventBroadcaster
72 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
75 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
76 PrintWriter log
) throws Exception
{
77 log
.println("creating a test environment");
83 XMultiServiceFactory msf
= tParam
.getMSF();
85 // get a soffice factory object
86 SOfficeFactory SOF
= SOfficeFactory
.getFactory(msf
);
88 log
.println("creating a calc document");
89 xDoc
= UnoRuntime
.queryInterface(XComponent
.class,
93 util
.utils
.waitForEventIdle(tParam
.getMSF());
95 XInterface oObj
= null;
97 XWindow xWindow
= UnoRuntime
.queryInterface(XModel
.class, xDoc
).
98 getCurrentController().getFrame().getContainerWindow();
100 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
101 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
102 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PANEL
);
104 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
106 TestEnvironment tEnv
= new TestEnvironment(oObj
);
108 final XWindow aWin
= xWindow
;
110 tEnv
.addObjRelation("EventProducer",
111 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
112 public void fireEvent() {
113 aWin
.setPosSize(100,100, 500, 500, PosSize
.POSSIZE
);
120 protected void closeDoc(XComponent xDoc
) {
121 XCloseable closer
= UnoRuntime
.queryInterface(
122 XCloseable
.class, xDoc
);
126 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
127 log
.println("Couldn't close document " + e
.getMessage());