tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleTextGraphicObject.java
blobf3b23fbdf7ccc2245ff9ca30801c65a2810642a4
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.SOfficeFactory;
27 import util.WriterTools;
28 import util.utils;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.awt.XWindow;
33 import com.sun.star.beans.XPropertySet;
34 import com.sun.star.frame.XController;
35 import com.sun.star.frame.XModel;
36 import com.sun.star.text.XText;
37 import com.sun.star.text.XTextContent;
38 import com.sun.star.text.XTextCursor;
39 import com.sun.star.text.XTextDocument;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
42 import com.sun.star.view.XViewSettingsSupplier;
44 /**
45 * Test of accessible object for the graphic object of a text document.<p>
46 * Object implements the following interfaces :
47 * <ul>
48 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
49 * </ul>
50 * @see com.sun.star.accessibility.XAccessible
52 public class SwAccessibleTextGraphicObject extends TestCase {
54 XTextDocument xTextDoc = null;
56 /**
57 * Called to create an instance of <code>TestEnvironment</code>
58 * with an object to test and related objects.
59 * Creates a graphic object and inserts it into the document.
60 * Obtains accessible object for graphic object.
62 * @param Param test parameters
63 * @param log writer to log information while testing
65 * @see TestEnvironment
66 * @see #getTestEnvironment
68 @Override
69 protected TestEnvironment createTestEnvironment(
70 TestParameters Param, PrintWriter log) {
72 XInterface oObj = null;
74 SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF());
75 Object oGraphObj = SOF.createInstance(
76 xTextDoc, "com.sun.star.text.GraphicObject");
78 XText the_text = xTextDoc.getText();
79 XTextCursor the_cursor = the_text.createTextCursor();
80 XTextContent the_content = UnoRuntime.queryInterface(XTextContent.class, oGraphObj);
82 log.println( "inserting graphic" );
83 the_text.insertTextContent(the_cursor, the_content, true);
85 XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
87 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
88 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
90 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.GRAPHIC);
92 log.println("ImplementationName " + utils.getImplName(oObj));
93 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
95 TestEnvironment tEnv = new TestEnvironment(oObj);
97 XController xController = xTextDoc.getCurrentController();
98 XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class,
99 xController);
101 final XPropertySet PropSet = xViewSetSup.getViewSettings();
103 tEnv.addObjRelation("EventProducer",
104 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
105 public void fireEvent() {
106 try {
107 //change zoom value to 20%
108 PropSet.setPropertyValue("ZoomValue", Short.valueOf("20"));
109 //and back to 100%
110 PropSet.setPropertyValue("ZoomValue", Short.valueOf("100"));
111 } catch ( com.sun.star.lang.WrappedTargetException e ) {
113 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
115 } catch ( com.sun.star.beans.PropertyVetoException e ) {
117 } catch ( com.sun.star.beans.UnknownPropertyException e ) {
124 return tEnv;
130 * Called while disposing a <code>TestEnvironment</code>.
131 * Disposes text document.
132 * @param Param test parameters
133 * @param log writer to log information while testing
135 @Override
136 protected void cleanup( TestParameters Param, PrintWriter log) {
137 log.println("dispose text document");
138 util.DesktopTools.closeDoc(xTextDoc);
142 * Called while the <code>TestCase</code> initialization.
143 * Creates a text document.
145 * @param Param test parameters
146 * @param log writer to log information while testing
148 * @see #initializeTestCase
150 @Override
151 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
152 log.println( "creating a text document" );
153 xTextDoc = WriterTools.createTextDoc(Param.getMSF());