bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleTextEmbeddedObject.java
blob6d2ef55e278c6ced381f37d908ece5b9ec36c54c
1 /*
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 .
18 package mod._sw;
20 import java.io.PrintWriter;
22 import lib.TestCase;
23 import lib.TestEnvironment;
24 import lib.TestParameters;
25 import util.AccessibilityTools;
26 import util.WriterTools;
27 import util.utils;
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.lang.XMultiServiceFactory;
36 import com.sun.star.text.XTextDocument;
37 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.uno.XInterface;
39 import com.sun.star.view.XViewSettingsSupplier;
41 /**
42 * Test of accessible object for the text embedded object of a text document.<p>
43 * Object implements the following interfaces :
44 * <ul>
45 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
46 * </ul>
47 * @see com.sun.star.accessibility.XAccessible
49 public class SwAccessibleTextEmbeddedObject extends TestCase {
51 XTextDocument xTextDoc = null;
53 /**
54 * Called to create an instance of <code>TestEnvironment</code>
55 * with an object to test and related objects.
56 * Obtains accessible object for the embedded object.
58 * @param Param test parameters
59 * @param log writer to log information while testing
61 * @see TestEnvironment
62 * @see #getTestEnvironment
64 protected TestEnvironment createTestEnvironment(
65 TestParameters Param, PrintWriter log) {
67 XInterface oObj = null;
69 XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
71 AccessibilityTools at = new AccessibilityTools();
73 XWindow xWindow = AccessibilityTools.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), aModel);
74 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
76 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.EMBEDDED_OBJECT);
78 log.println("ImplementationName " + utils.getImplName(oObj));
79 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
81 TestEnvironment tEnv = new TestEnvironment(oObj);
83 XController xController = xTextDoc.getCurrentController();
84 XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class,
85 xController);
87 final XPropertySet PropSet = xViewSetSup.getViewSettings();
89 tEnv.addObjRelation("EventProducer",
90 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
91 public void fireEvent() {
92 try {
93 //change zoom value to 15%
94 PropSet.setPropertyValue("ZoomValue", new Short("15"));
95 //and back to 100%
96 PropSet.setPropertyValue("ZoomValue", new Short("100"));
97 } catch ( com.sun.star.lang.WrappedTargetException e ) {
99 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
101 } catch ( com.sun.star.beans.PropertyVetoException e ) {
103 } catch ( com.sun.star.beans.UnknownPropertyException e ) {
110 return tEnv;
115 * Called while disposing a <code>TestEnvironment</code>.
116 * Disposes text document.
117 * @param Param test parameters
118 * @param log writer to log information while testing
120 protected void cleanup( TestParameters Param, PrintWriter log) {
121 log.println("dispose text document");
122 util.DesktopTools.closeDoc(xTextDoc);
126 * Called while the <code>TestCase</code> initialization.
127 * Loads the text document <code>SwXTextEmbeddedObject.sxw</code>
128 * with a text embedded object.
130 * @param Param test parameters
131 * @param log writer to log information while testing
133 * @see #initializeTestCase
135 protected void initialize(TestParameters Param, PrintWriter log) {
136 log.println( "open a text document" );
137 String testdoc = utils.getFullTestURL("SwXTextEmbeddedObject.sxw");
138 log.println(testdoc);
139 xTextDoc = WriterTools.loadTextDoc((XMultiServiceFactory)Param.getMSF(),testdoc);