merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _svx / AccessibleEditableTextPara.java
blobf17bf50d869d9b60c26f6c51760fa169002566c7
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: AccessibleEditableTextPara.java,v $
10 * $Revision: 1.6.8.2 $
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 ************************************************************************/
31 package mod._svx;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
39 import util.AccessibilityTools;
40 import util.SOfficeFactory;
41 import util.utils;
43 import com.sun.star.accessibility.AccessibleRole;
44 import com.sun.star.accessibility.XAccessible;
45 import com.sun.star.accessibility.XAccessibleContext;
46 import com.sun.star.accessibility.XAccessibleEditableText;
47 import com.sun.star.awt.XWindow;
48 import com.sun.star.frame.XModel;
49 import com.sun.star.lang.XComponent;
50 import com.sun.star.lang.XMultiServiceFactory;
51 import com.sun.star.uno.UnoRuntime;
52 import com.sun.star.uno.XInterface;
55 public class AccessibleEditableTextPara extends TestCase {
57 static XComponent xSpreadsheetDoc = null;
59 /**
60 * Called to create an instance of <code>TestEnvironment</code>
61 * with an object to test and related objects.
62 * Obtains accissible object for the spreadsheet document.
64 * @param tParam test parameters
65 * @param log writer to log information while testing
67 * @see TestEnvironment
68 * @see #getTestEnvironment()
70 protected TestEnvironment createTestEnvironment(
71 TestParameters Param, PrintWriter log) {
73 XInterface oObj = null;
76 XModel aModel = (XModel)
77 UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc);
79 AccessibilityTools at = new AccessibilityTools();
81 XWindow xWindow = at.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), aModel);
82 XAccessible xRoot = at.getAccessibleObject(xWindow);
84 at.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
86 XAccessibleContext InputLine = at.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT_FRAME,"Input line");
87 try {
88 oObj = InputLine.getAccessibleChild(0);
89 XAccessibleEditableText et = (XAccessibleEditableText) UnoRuntime.queryInterface(XAccessibleEditableText.class, oObj);
90 et.setText("AccessibleEditablePara");
91 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
94 log.println("ImplementationName " + utils.getImplName(oObj));
96 TestEnvironment tEnv = new TestEnvironment(oObj);
98 final XAccessibleEditableText edText = (XAccessibleEditableText)
99 UnoRuntime.queryInterface(XAccessibleEditableText.class,oObj) ;
101 tEnv.addObjRelation("EventProducer",
102 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
103 public void fireEvent() {
104 try {
105 int l = new String("AccessibleEditablePara").length();
106 edText.deleteText(0, l);
107 edText.setText("Event");
108 edText.setText("AccessibleEditablePara");
109 }catch(com.sun.star.lang.IndexOutOfBoundsException e) {}
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( " disposing xSheetDoc " );
126 util.DesktopTools.closeDoc(xSpreadsheetDoc);
130 * Called while the <code>TestCase</code> initialization. In the
131 * implementation does nothing. Subclasses can override to initialize
132 * objects shared among all <code>TestEnvironment</code>s.
134 * @param tParam test parameters
135 * @param log writer to log information while testing
137 * @see #initializeTestCase()
139 protected void initialize(TestParameters Param, PrintWriter log) {
140 // get a soffice factory object
141 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory) Param.getMSF());
143 try {
144 log.println("creating a spreadsheetdocument");
145 xSpreadsheetDoc = (XComponent) UnoRuntime.queryInterface(XComponent.class,SOF.createCalcDoc(null));
146 shortWait();
147 } catch (com.sun.star.uno.Exception e) {
148 e.printStackTrace( log );
149 throw new StatusException( "Couldn't create document ", e );
154 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
155 * reset</code> call.
157 private void shortWait() {
158 try {
159 Thread.sleep(500) ;
160 } catch (InterruptedException e) {
161 log.println("While waiting :" + e) ;