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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.AccessibilityTools
;
27 import util
.SOfficeFactory
;
30 import com
.sun
.star
.accessibility
.AccessibleRole
;
31 import com
.sun
.star
.accessibility
.XAccessible
;
32 import com
.sun
.star
.awt
.Rectangle
;
33 import com
.sun
.star
.awt
.XWindow
;
34 import com
.sun
.star
.frame
.XModel
;
35 import com
.sun
.star
.lang
.XComponent
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
41 * Test for object which is represented by accessible component of
42 * a spreadsheet document.
44 * Object implements the following interfaces :
46 * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li>
47 * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li>
48 * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li>
49 * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li>
52 * @see com.sun.star.accessibility.XAccessibleComponent
53 * @see com.sun.star.accessibility.XAccessibleContext
54 * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
55 * @see com.sun.star.accessibility.XAccessibleSelection
56 * @see ifc.accessibility._XAccessibleComponent
57 * @see ifc.accessibility._XAccessibleEventBroadcaster
58 * @see ifc.accessibility._XAccessibleSelection
59 * @see ifc.accessibility._XAccessibleContext
61 public class ScAccessibleDocument
extends TestCase
{
63 static XComponent xSpreadsheetDoc
= null;
66 * Called to create an instance of <code>TestEnvironment</code>
67 * with an object to test and related objects.
68 * Obtains accessible object for the spreadsheet document.
70 * @param Param test parameters
71 * @param log writer to log information while testing
73 * @see TestEnvironment
74 * @see #getTestEnvironment
77 protected TestEnvironment
createTestEnvironment(
78 TestParameters Param
, PrintWriter log
) {
80 XInterface oObj
= null;
82 // get the drawpage of drawing here
83 log
.println( "getting Drawpages" );
85 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xSpreadsheetDoc
);
87 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(aModel
);
88 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
90 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.DOCUMENT
, "");
91 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
92 log
.println("ImplementationName " + utils
.getImplName(oObj
));
94 TestEnvironment tEnv
= new TestEnvironment(oObj
);
96 final XWindow xDocWin
= xWindow
;
97 tEnv
.addObjRelation("EventProducer",
98 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
99 public void fireEvent() {
100 Rectangle rect
= xDocWin
.getPosSize();
101 xDocWin
.setPosSize(rect
.X
,rect
.Y
,rect
.Height
,rect
.Width
-10,com
.sun
.star
.awt
.PosSize
.POSSIZE
);
110 * Called while disposing a <code>TestEnvironment</code>.
111 * Disposes calc document.
112 * @param Param test parameters
113 * @param log writer to log information while testing
116 protected void cleanup( TestParameters Param
, PrintWriter log
) {
117 log
.println( " disposing xSheetDoc " );
118 util
.DesktopTools
.closeDoc(xSpreadsheetDoc
);
122 * Called while the <code>TestCase</code> initialization. In the
123 * implementation does nothing. Subclasses can override to initialize
124 * objects shared among all <code>TestEnvironment</code>s.
126 * @param Param test parameters
127 * @param log writer to log information while testing
129 * @see #initializeTestCase
132 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
133 // get a soffice factory object
134 SOfficeFactory SOF
= SOfficeFactory
.getFactory( Param
.getMSF());
136 log
.println("creating a spreadsheetdocument");
137 String url
= utils
.getFullTestURL("calcshapes.sxc");
138 log
.println("loading document "+url
);
139 xSpreadsheetDoc
= SOF
.loadDocument(url
);
140 util
.utils
.waitForEventIdle(Param
.getMSF());