tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleParagraphView.java
blob01af4ed5da5673f5ac54824ba2d514f7efedb0f7
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.frame.XModel;
33 import com.sun.star.text.XText;
34 import com.sun.star.text.XTextDocument;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
38 /**
39 * Test of accessible object for paragraph of a text document.<p>
40 * Object implements the following interfaces :
41 * <ul>
42 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
43 * </ul>
44 * @see com.sun.star.accessibility.XAccessible
46 public class SwAccessibleParagraphView extends TestCase {
48 XTextDocument xTextDoc = null;
50 /**
51 * Called to create an instance of <code>TestEnvironment</code>
52 * with an object to test and related objects. Obtains accessible object
53 * for one of document paragraph.
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) {
65 XInterface oObj = null;
67 XText oText = xTextDoc.getText();
68 oText.setString("XAccessibleText");
70 XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
72 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
73 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
75 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PARAGRAPH);
77 log.println("ImplementationName " + utils.getImplName(oObj));
79 TestEnvironment tEnv = new TestEnvironment(oObj);
81 final XText paraText = xTextDoc.getText();
83 tEnv.addObjRelation("EventProducer",
84 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
85 public void fireEvent() {
86 String old = paraText.getString();
87 paraText.setString("Just a line");
88 paraText.setString(old);
90 });
92 final String text = "XAccessibleText";
94 tEnv.addObjRelation("XAccessibleText.Text", text);
96 return tEnv;
101 * Called while disposing a <code>TestEnvironment</code>.
102 * Disposes text document.
103 * @param Param test parameters
104 * @param log writer to log information while testing
106 @Override
107 protected void cleanup( TestParameters Param, PrintWriter log) {
108 log.println("dispose text document");
109 util.DesktopTools.closeDoc(xTextDoc);
113 * Called while the <code>TestCase</code> initialization.
114 * Creates a text document.
116 * @param Param test parameters
117 * @param log writer to log information while testing
119 * @see #initializeTestCase
121 @Override
122 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
123 log.println( "creating a text document" );
124 xTextDoc = WriterTools.createTextDoc( Param.getMSF());