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 java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.AccessibilityTools
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.awt
.Rectangle
;
34 import com
.sun
.star
.awt
.XWindow
;
35 import com
.sun
.star
.frame
.XModel
;
36 import com
.sun
.star
.lang
.XComponent
;
37 import com
.sun
.star
.lang
.XMultiServiceFactory
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
43 * Test for object which is represented by accessible component of
44 * a spreadsheet document.
46 * Object implements the following interfaces :
48 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
50 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
51 * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li>
54 * @see com.sun.star.accessibility.XAccessibleComponent
55 * @see com.sun.star.accessibility.XAccessibleContext
56 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
57 * @see com.sun.star.accessibility.XAccessibleSelection
58 * @see ifc.accessibility._XAccessibleComponent
59 * @see ifc.accessibility._XAccessibleEventBroadcaster
60 * @see ifc.accessibility._XAccessibleSelection
61 * @see ifc.accessibility._XAccessibleContext
63 public class ScAccessibleDocument
extends TestCase
{
65 static XComponent xSpreadsheetDoc
= null;
68 * Called to create an instance of <code>TestEnvironment</code>
69 * with an object to test and related objects.
70 * Obtains accessible object for the spreadsheet document.
72 * @param Param test parameters
73 * @param log writer to log information while testing
75 * @see TestEnvironment
76 * @see #getTestEnvironment
78 protected TestEnvironment
createTestEnvironment(
79 TestParameters Param
, PrintWriter log
) {
81 XInterface oObj
= null;
83 // get the drawpage of drawing here
84 log
.println( "getting Drawpages" );
86 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xSpreadsheetDoc
);
88 AccessibilityTools at
= new AccessibilityTools();
90 XWindow xWindow
= AccessibilityTools
.getCurrentWindow((XMultiServiceFactory
)Param
.getMSF(), aModel
);
91 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
93 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.DOCUMENT
, "");
94 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
95 log
.println("ImplementationName " + utils
.getImplName(oObj
));
97 TestEnvironment tEnv
= new TestEnvironment(oObj
);
99 final XWindow xDocWin
= xWindow
;
100 tEnv
.addObjRelation("EventProducer",
101 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
102 public void fireEvent() {
103 Rectangle rect
= xDocWin
.getPosSize();
104 xDocWin
.setPosSize(rect
.X
,rect
.Y
,rect
.Height
,rect
.Width
-10,com
.sun
.star
.awt
.PosSize
.POSSIZE
);
113 * Called while disposing a <code>TestEnvironment</code>.
114 * Disposes calc document.
115 * @param Param test parameters
116 * @param log writer to log information while testing
118 protected void cleanup( TestParameters Param
, PrintWriter log
) {
119 log
.println( " disposing xSheetDoc " );
120 util
.DesktopTools
.closeDoc(xSpreadsheetDoc
);
124 * Called while the <code>TestCase</code> initialization. In the
125 * implementation does nothing. Subclasses can override to initialize
126 * objects shared among all <code>TestEnvironment</code>s.
128 * @param Param test parameters
129 * @param log writer to log information while testing
131 * @see #initializeTestCase
133 protected void initialize(TestParameters Param
, PrintWriter log
) {
134 // get a soffice factory object
135 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
138 log
.println("creating a spreadsheetdocument");
139 String url
= utils
.getFullTestURL("calcshapes.sxc");
140 log
.println("loading document "+url
);
141 xSpreadsheetDoc
= SOF
.loadDocument(url
);
143 } catch (com
.sun
.star
.uno
.Exception e
) {
144 e
.printStackTrace( log
);
145 throw new StatusException( "Couldn't create document ", e
);
150 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
153 private void shortWait() {
156 } catch (InterruptedException e
) {
157 log
.println("While waiting :" + e
) ;