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
;
22 import lib
.StatusException
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.AccessibilityTools
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.accessibility
.AccessibleRole
;
30 import com
.sun
.star
.accessibility
.XAccessible
;
31 import com
.sun
.star
.awt
.PosSize
;
32 import com
.sun
.star
.awt
.XWindow
;
33 import com
.sun
.star
.frame
.XModel
;
34 import com
.sun
.star
.lang
.XComponent
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
38 import com
.sun
.star
.util
.XCloseable
;
41 public class AccessibleTabBar
extends TestCase
{
42 static XComponent xDoc
;
45 * Disposes the document, if exists, created in
46 * <code>createTestEnvironment</code> method.
49 protected void cleanup(TestParameters Param
, PrintWriter log
) {
50 log
.println("disposing xCalcDoc");
58 * Creates a spreadsheet document. Then obtains an accessible object with
59 * the role <code>AccessibleRole.PAGETAB</code>.
60 * Object relations created :
62 * <li> <code>'EventProducer'</code> for
63 * {@link ifc.accessibility._XAccessibleEventBroadcaster}:
67 * @param tParam test parameters
68 * @param log writer to log information while testing
70 * @see com.sun.star.awt.Toolkit
71 * @see com.sun.star.accessibility.AccessibleRole
72 * @see ifc.accessibility._XAccessibleEventBroadcaster
73 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
76 protected TestEnvironment
createTestEnvironment(TestParameters tParam
,
78 log
.println("creating a test environment");
84 XMultiServiceFactory msf
= tParam
.getMSF();
86 // get a soffice factory object
87 SOfficeFactory SOF
= SOfficeFactory
.getFactory(msf
);
90 log
.println("creating a calc document");
91 xDoc
= UnoRuntime
.queryInterface(XComponent
.class,
94 } catch (com
.sun
.star
.uno
.Exception e
) {
95 // Some exception occurs.FAILED
96 e
.printStackTrace(log
);
97 throw new StatusException("Couldn't create document", e
);
100 util
.utils
.pause(5000);
102 XInterface oObj
= null;
104 util
.utils
.pause(5000);
106 XWindow xWindow
= UnoRuntime
.queryInterface(XModel
.class, xDoc
).
107 getCurrentController().getFrame().getContainerWindow();
109 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
110 AccessibilityTools
.printAccessibleTree(log
, xRoot
, tParam
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
111 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.PANEL
);
113 log
.println("ImplementationName: " + util
.utils
.getImplName(oObj
));
115 TestEnvironment tEnv
= new TestEnvironment(oObj
);
117 final XWindow aWin
= xWindow
;
119 tEnv
.addObjRelation("EventProducer",
120 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
121 public void fireEvent() {
122 aWin
.setPosSize(100,100, 500, 500, PosSize
.POSSIZE
);
129 protected void closeDoc(XComponent xDoc
) {
130 XCloseable closer
= UnoRuntime
.queryInterface(
131 XCloseable
.class, xDoc
);
135 } catch (com
.sun
.star
.util
.CloseVetoException e
) {
136 log
.println("Couldn't close document " + e
.getMessage());
137 } catch (NullPointerException e
) {
138 log
.println("Couldn't close document " + e
.getMessage());