tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleTextFrameView.java
blob133cfcb78e21cb1083b2a114ccd226961a7ec8e2
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.TextContentAnchorType;
37 import com.sun.star.text.XText;
38 import com.sun.star.text.XTextContent;
39 import com.sun.star.text.XTextCursor;
40 import com.sun.star.text.XTextDocument;
41 import com.sun.star.text.XTextFrame;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XInterface;
44 import com.sun.star.view.XViewSettingsSupplier;
46 /**
47 * Test of accessible object for the text frame of a text document.<p>
48 * Object implements the following interfaces :
49 * <ul>
50 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
51 * </ul>
52 * @see com.sun.star.accessibility.XAccessible
54 public class SwAccessibleTextFrameView extends TestCase {
56 XTextDocument xTextDoc = null;
58 /**
59 * Called to create an instance of <code>TestEnvironment</code>
60 * with an object to test and related objects.
61 * Creates a frame and inserts it into document.
62 * Obtains accessible object for the inserted text frame.
64 * @param Param test parameters
65 * @param log writer to log information while testing
67 * @see TestEnvironment
68 * @see #getTestEnvironment
70 @Override
71 protected TestEnvironment createTestEnvironment(
72 TestParameters Param, PrintWriter log) throws Exception {
74 XInterface oObj = null;
75 XTextFrame oFrame1 = null;
76 XPropertySet oPropSet = null;
77 XText oText = null;
78 XTextCursor oCursor = null;
80 // get a soffice factory object
81 SOfficeFactory.getFactory( Param.getMSF() );
82 // creating Frames
83 log.println( "creating Frames" );
84 oFrame1 = SOfficeFactory.createTextFrame(xTextDoc, 500, 500);
85 oPropSet = UnoRuntime.queryInterface(
86 XPropertySet.class, oFrame1 );
87 oPropSet.setPropertyValue("AnchorType",
88 TextContentAnchorType.AS_CHARACTER);
89 oText = xTextDoc.getText();
90 oCursor = oText.createTextCursor();
92 log.println( "inserting Frame1" );
93 XTextContent the_content = UnoRuntime.queryInterface(XTextContent.class, oFrame1);
94 oText.insertTextContent(oCursor, the_content, true);
96 XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
98 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
99 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
101 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT_FRAME);
103 log.println("ImplementationName " + utils.getImplName(oObj));
104 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
106 TestEnvironment tEnv = new TestEnvironment(oObj);
108 XController xController = xTextDoc.getCurrentController();
109 XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class,
110 xController);
112 final XPropertySet PropSet = xViewSetSup.getViewSettings();
114 tEnv.addObjRelation("EventProducer",
115 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
116 public void fireEvent() {
117 try {
118 //change zoom value to 15%
119 PropSet.setPropertyValue("ZoomValue", Short.valueOf("15"));
120 //and back to 100%
121 PropSet.setPropertyValue("ZoomValue", Short.valueOf("100"));
122 } catch ( com.sun.star.lang.WrappedTargetException e ) {
124 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
126 } catch ( com.sun.star.beans.PropertyVetoException e ) {
128 } catch ( com.sun.star.beans.UnknownPropertyException e ) {
135 return tEnv;
140 * Called while disposing a <code>TestEnvironment</code>.
141 * Disposes text document.
142 * @param Param test parameters
143 * @param log writer to log information while testing
145 @Override
146 protected void cleanup( TestParameters Param, PrintWriter log) {
147 log.println("dispose text document");
148 util.DesktopTools.closeDoc(xTextDoc);
152 * Called while the <code>TestCase</code> initialization.
153 * Creates a text document.
155 * @param Param test parameters
156 * @param log writer to log information while testing
158 * @see #initializeTestCase
160 @Override
161 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
162 log.println( "creating a text document" );
163 xTextDoc = WriterTools.createTextDoc(Param.getMSF());