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 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.AccessibilityTools
;
28 import util
.SOfficeFactory
;
31 import com
.sun
.star
.accessibility
.AccessibleRole
;
32 import com
.sun
.star
.accessibility
.XAccessible
;
33 import com
.sun
.star
.accessibility
.XAccessibleContext
;
34 import com
.sun
.star
.accessibility
.XAccessibleEditableText
;
35 import com
.sun
.star
.awt
.XWindow
;
36 import com
.sun
.star
.frame
.XModel
;
37 import com
.sun
.star
.lang
.XComponent
;
38 import com
.sun
.star
.lang
.XMultiServiceFactory
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
43 public class AccessibleEditableTextPara
extends TestCase
{
45 static XComponent xSpreadsheetDoc
= null;
48 * Called to create an instance of <code>TestEnvironment</code>
49 * with an object to test and related objects.
50 * Obtains accissible object for the spreadsheet document.
52 * @param Param test parameters
53 * @param log writer to log information while testing
55 * @see TestEnvironment
56 * @see #getTestEnvironment
58 protected TestEnvironment
createTestEnvironment(
59 TestParameters Param
, PrintWriter log
) {
61 XInterface oObj
= null;
64 XModel aModel
= UnoRuntime
.queryInterface(XModel
.class, xSpreadsheetDoc
);
66 AccessibilityTools at
= new AccessibilityTools();
68 XWindow xWindow
= AccessibilityTools
.getCurrentWindow( (XMultiServiceFactory
) Param
.getMSF(), aModel
);
69 XAccessible xRoot
= AccessibilityTools
.getAccessibleObject(xWindow
);
71 AccessibilityTools
.printAccessibleTree(log
, xRoot
, Param
.getBool(util
.PropertyName
.DEBUG_IS_ACTIVE
));
73 XAccessibleContext InputLine
= AccessibilityTools
.getAccessibleObjectForRole(xRoot
, AccessibleRole
.TEXT_FRAME
,"Input line");
75 oObj
= InputLine
.getAccessibleChild(0);
76 XAccessibleEditableText et
= UnoRuntime
.queryInterface(XAccessibleEditableText
.class, oObj
);
77 et
.setText("AccessibleEditablePara");
78 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
81 log
.println("ImplementationName " + utils
.getImplName(oObj
));
83 TestEnvironment tEnv
= new TestEnvironment(oObj
);
85 final XAccessibleEditableText edText
= UnoRuntime
.queryInterface(XAccessibleEditableText
.class,oObj
) ;
87 tEnv
.addObjRelation("EventProducer",
88 new ifc
.accessibility
._XAccessibleEventBroadcaster
.EventProducer() {
89 public void fireEvent() {
91 int l
= new String("AccessibleEditablePara").length();
92 edText
.deleteText(0, l
);
93 edText
.setText("Event");
94 edText
.setText("AccessibleEditablePara");
95 }catch(com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {}
104 * Called while disposing a <code>TestEnvironment</code>.
105 * Disposes text document.
106 * @param Param test parameters
107 * @param log writer to log information while testing
109 protected void cleanup( TestParameters Param
, PrintWriter log
) {
110 log
.println( " disposing xSheetDoc " );
111 util
.DesktopTools
.closeDoc(xSpreadsheetDoc
);
115 * Called while the <code>TestCase</code> initialization. In the
116 * implementation does nothing. Subclasses can override to initialize
117 * objects shared among all <code>TestEnvironment</code>s.
119 * @param Param test parameters
120 * @param log writer to log information while testing
122 * @see #initializeTestCase
124 protected void initialize(TestParameters Param
, PrintWriter log
) {
125 // get a soffice factory object
126 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
) Param
.getMSF());
129 log
.println("creating a spreadsheetdocument");
130 xSpreadsheetDoc
= UnoRuntime
.queryInterface(XComponent
.class,SOF
.createCalcDoc(null));
132 } catch (com
.sun
.star
.uno
.Exception e
) {
133 e
.printStackTrace( log
);
134 throw new StatusException( "Couldn't create document ", e
);
139 * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
142 private void shortWait() {
145 } catch (InterruptedException e
) {
146 log
.println("While waiting :" + e
) ;