merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleParagraphView.java
blobbaef64383862fd761a4f15e17401e18577b87c1f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SwAccessibleParagraphView.java,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package mod._sw;
32 import java.io.PrintWriter;
34 import lib.TestCase;
35 import lib.TestEnvironment;
36 import lib.TestParameters;
37 import util.AccessibilityTools;
38 import util.WriterTools;
39 import util.utils;
41 import com.sun.star.accessibility.AccessibleRole;
42 import com.sun.star.accessibility.XAccessible;
43 import com.sun.star.awt.XWindow;
44 import com.sun.star.frame.XModel;
45 import com.sun.star.lang.XMultiServiceFactory;
46 import com.sun.star.text.XText;
47 import com.sun.star.text.XTextDocument;
48 import com.sun.star.uno.UnoRuntime;
49 import com.sun.star.uno.XInterface;
51 /**
52 * Test of accessible object for paragraph of a text document.<p>
53 * Object implements the following interfaces :
54 * <ul>
55 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
56 * </ul>
57 * @see com.sun.star.accessibility.XAccessible
59 public class SwAccessibleParagraphView extends TestCase {
61 XTextDocument xTextDoc = null;
63 /**
64 * Called to create an instance of <code>TestEnvironment</code>
65 * with an object to test and related objects. Obtains accessible object
66 * for one of document paragraph.
68 * @param tParam test parameters
69 * @param log writer to log information while testing
71 * @see TestEnvironment
72 * @see #getTestEnvironment()
74 protected TestEnvironment createTestEnvironment(
75 TestParameters Param, PrintWriter log) {
77 XInterface oObj = null;
79 XText oText = xTextDoc.getText();
80 oText.setString("XAccessibleText");
82 XModel aModel = (XModel)
83 UnoRuntime.queryInterface(XModel.class, xTextDoc);
85 AccessibilityTools at = new AccessibilityTools();
87 XWindow xWindow = at.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), aModel);
88 XAccessible xRoot = at.getAccessibleObject(xWindow);
90 at.getAccessibleObjectForRole(xRoot, AccessibleRole.PARAGRAPH);
92 oObj = at.SearchedContext;
94 log.println("ImplementationName " + utils.getImplName(oObj));
96 TestEnvironment tEnv = new TestEnvironment(oObj);
98 final XText paraText = xTextDoc.getText();
100 tEnv.addObjRelation("EventProducer",
101 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
102 public void fireEvent() {
103 String old = paraText.getString();
104 paraText.setString("Just a line");
105 paraText.setString(old);
109 final String text = "XAccessibleText";
111 tEnv.addObjRelation("XAccessibleText.Text", text);
113 return tEnv;
118 * Called while disposing a <code>TestEnvironment</code>.
119 * Disposes text document.
120 * @param tParam test parameters
121 * @param tEnv the environment to cleanup
122 * @param log writer to log information while testing
124 protected void cleanup( TestParameters Param, PrintWriter log) {
125 log.println("dispose text document");
126 util.DesktopTools.closeDoc(xTextDoc);
130 * Called while the <code>TestCase</code> initialization.
131 * Creates a text document.
133 * @param tParam test parameters
134 * @param log writer to log information while testing
136 * @see #initializeTestCase()
138 protected void initialize(TestParameters Param, PrintWriter log) {
139 log.println( "creating a text document" );
140 xTextDoc = WriterTools.createTextDoc( (XMultiServiceFactory) Param.getMSF());