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
.WriterTools
;
29 import com
.sun
.star
.accessibility
.AccessibleRole
;
30 import com
.sun
.star
.accessibility
.XAccessible
;
31 import com
.sun
.star
.awt
.XWindow
;
32 import com
.sun
.star
.beans
.XPropertySet
;
33 import com
.sun
.star
.frame
.XController
;
34 import com
.sun
.star
.frame
.XModel
;
35 import com
.sun
.star
.text
.XTextDocument
;
36 import com
.sun
.star
.uno
.UnoRuntime
;
37 import com
.sun
.star
.uno
.XInterface
;
38 import com
.sun
.star
.view
.XViewSettingsSupplier
;
41 * Test of accessible object for the text embedded object of a text document.<p>
42 * Object implements the following interfaces :
44 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
46 * @see com.sun.star.accessibility.XAccessible
48 public class SwAccessibleTextEmbeddedObject
extends TestCase
{
50 XTextDocument xTextDoc
= null;
53 * Called to create an instance of <code>TestEnvironment</code>
54 * with an object to test and related objects.
55 * Obtains accessible object for the embedded object.
57 * @param Param test parameters
58 * @param log writer to log information while testing
60 * @see TestEnvironment
61 * @see #getTestEnvironment
64 protected TestEnvironment
createTestEnvironment(
65 TestParameters Param
, PrintWriter log
) {
67 XInterface oObj
= null;
69 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
71 XWindow xWindow
= AccessibilityTools
.getCurrentWindow(aModel
);
72 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
74 oObj
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.EMBEDDED_OBJECT
);
76 log
.println("ImplementationName " + utils
.getImplName(oObj
));
77 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
79 TestEnvironment tEnv
= new TestEnvironment(oObj
);
81 XController xController
= xTextDoc
.getCurrentController();
82 XViewSettingsSupplier xViewSetSup
= UnoRuntime
.queryInterface(XViewSettingsSupplier
.class,
85 final XPropertySet PropSet
= xViewSetSup
.getViewSettings();
87 tEnv
.addObjRelation("EventProducer",
88 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
89 public void fireEvent() {
91 //change zoom value to 15%
92 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("15"));
94 PropSet
.setPropertyValue("ZoomValue", Short
.valueOf("100"));
95 } catch ( com
.sun
.star
.lang
.WrappedTargetException e
) {
97 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
99 } catch ( com
.sun
.star
.beans
.PropertyVetoException e
) {
101 } catch ( com
.sun
.star
.beans
.UnknownPropertyException e
) {
113 * Called while disposing a <code>TestEnvironment</code>.
114 * Disposes text document.
115 * @param Param test parameters
116 * @param log writer to log information while testing
119 protected void cleanup( TestParameters Param
, PrintWriter log
) {
120 log
.println("dispose text document");
121 util
.DesktopTools
.closeDoc(xTextDoc
);
125 * Called while the <code>TestCase</code> initialization.
126 * Loads the text document <code>SwXTextEmbeddedObject.sxw</code>
127 * with a text embedded object.
129 * @param Param test parameters
130 * @param log writer to log information while testing
132 * @see #initializeTestCase
135 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
136 log
.println( "open a text document" );
137 String testdoc
= utils
.getFullTestURL("SwXTextEmbeddedObject.sxw");
138 log
.println(testdoc
);
139 xTextDoc
= WriterTools
.loadTextDoc(Param
.getMSF(),testdoc
);