bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleParagraphView.java
blobc1928be736739b37c51c15edb3ccd81edb72d9de
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.lang.XMultiServiceFactory;
34 import com.sun.star.text.XText;
35 import com.sun.star.text.XTextDocument;
36 import com.sun.star.uno.UnoRuntime;
37 import com.sun.star.uno.XInterface;
39 /**
40 * Test of accessible object for paragraph of a text document.<p>
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
44 * </ul>
45 * @see com.sun.star.accessibility.XAccessible
47 public class SwAccessibleParagraphView extends TestCase {
49 XTextDocument xTextDoc = null;
51 /**
52 * Called to create an instance of <code>TestEnvironment</code>
53 * with an object to test and related objects. Obtains accessible object
54 * for one of document paragraph.
56 * @param Param test parameters
57 * @param log writer to log information while testing
59 * @see TestEnvironment
60 * @see #getTestEnvironment
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 AccessibilityTools at = new AccessibilityTools();
74 XWindow xWindow = AccessibilityTools.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), aModel);
75 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
77 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PARAGRAPH);
79 log.println("ImplementationName " + utils.getImplName(oObj));
81 TestEnvironment tEnv = new TestEnvironment(oObj);
83 final XText paraText = xTextDoc.getText();
85 tEnv.addObjRelation("EventProducer",
86 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
87 public void fireEvent() {
88 String old = paraText.getString();
89 paraText.setString("Just a line");
90 paraText.setString(old);
92 });
94 final String text = "XAccessibleText";
96 tEnv.addObjRelation("XAccessibleText.Text", text);
98 return tEnv;
103 * Called while disposing a <code>TestEnvironment</code>.
104 * Disposes text document.
105 * @param Param test parameters
106 * @param log writer to log information while testing
108 protected void cleanup( TestParameters Param, PrintWriter log) {
109 log.println("dispose text document");
110 util.DesktopTools.closeDoc(xTextDoc);
114 * Called while the <code>TestCase</code> initialization.
115 * Creates a text document.
117 * @param Param test parameters
118 * @param log writer to log information while testing
120 * @see #initializeTestCase
122 protected void initialize(TestParameters Param, PrintWriter log) {
123 log.println( "creating a text document" );
124 xTextDoc = WriterTools.createTextDoc( (XMultiServiceFactory) Param.getMSF());