tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleFootnoteView.java
blob0899108a83d3025bf3d7fca893acbc59f6bf3b03
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.XFootnote;
37 import com.sun.star.text.XText;
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 public class SwAccessibleFootnoteView extends TestCase {
46 XTextDocument xTextDoc = null;
48 /**
49 * Called to create an instance of <code>TestEnvironment</code>
50 * with an object to test and related objects.
51 * Inserts the created footnote to the document.
52 * Changes zoom value to 10%(endnote must be in visible area of the document).
53 * Obtains accessible object for the inserted footnote.
55 * @param Param test parameters
56 * @param log writer to log information while testing
58 * @see TestEnvironment
59 * @see #getTestEnvironment
61 @Override
62 protected TestEnvironment createTestEnvironment(
63 TestParameters Param, PrintWriter log) throws Exception {
65 XInterface oObj = null;
66 XFootnote oFootnote = null;
68 log.println( "Creating a test environment" );
69 // get a soffice factory object
70 XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc);
71 log.println("creating a footnote");
73 oFootnote = UnoRuntime.queryInterface(XFootnote.class,
74 msf.createInstance("com.sun.star.text.Footnote"));
76 XText oText = xTextDoc.getText();
77 XTextCursor oCursor = oText.createTextCursor();
79 log.println("inserting the footnote into text document");
80 oText.insertTextContent(oCursor, oFootnote, false);
82 XController xController = xTextDoc.getCurrentController();
83 XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class,
84 xController);
85 XPropertySet xPropSet = xViewSetSup.getViewSettings();
87 //change zoom value to 10%
88 //footer should be in the visible area of the document
89 xPropSet.setPropertyValue("ZoomValue", Short.valueOf("10"));
91 XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
93 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
94 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
96 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.FOOTNOTE);
98 log.println("ImplementationName " + utils.getImplName(oObj));
99 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
101 TestEnvironment tEnv = new TestEnvironment(oObj);
103 final XPropertySet PropSet = xViewSetSup.getViewSettings();
105 tEnv.addObjRelation("EventProducer",
106 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
107 public void fireEvent() {
108 try {
109 //change zoom value to 130%
110 PropSet.setPropertyValue("ZoomValue", Short.valueOf("15"));
111 //and back to 10%
112 PropSet.setPropertyValue("ZoomValue", Short.valueOf("10"));
113 } catch ( com.sun.star.lang.WrappedTargetException e ) {
115 } catch ( com.sun.star.lang.IllegalArgumentException e ) {
117 } catch ( com.sun.star.beans.PropertyVetoException e ) {
119 } catch ( com.sun.star.beans.UnknownPropertyException e ) {
125 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. In the
143 * implementation does nothing. Subclasses can override to initialize
144 * objects shared among all <code>TestEnvironment</code>s.
146 * @param Param test parameters
147 * @param log writer to log information while testing
149 * @see #initializeTestCase
151 @Override
152 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
153 log.println( "creating a text document" );
154 xTextDoc = WriterTools.createTextDoc(Param.getMSF());