xref: /AOO41X/main/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir package ifc.accessibility;
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir import lib.MultiMethodTest;
30*cdf0e10cSrcweir import lib.Status;
31*cdf0e10cSrcweir import lib.StatusException;
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleTextType;
34*cdf0e10cSrcweir import com.sun.star.accessibility.TextSegment;
35*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleComponent;
36*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleText;
37*cdf0e10cSrcweir import com.sun.star.awt.Point;
38*cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
39*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
40*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
41*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir /**
45*cdf0e10cSrcweir  * Testing <code>com.sun.star.accessibility.XAccessibleText</code>
46*cdf0e10cSrcweir  * interface methods :
47*cdf0e10cSrcweir  * <ul>
48*cdf0e10cSrcweir  *  <li><code> getCaretPosition()</code></li>
49*cdf0e10cSrcweir  *  <li><code> setCaretPosition()</code></li>
50*cdf0e10cSrcweir  *  <li><code> getCharacter()</code></li>
51*cdf0e10cSrcweir  *  <li><code> getCharacterAttributes()</code></li>
52*cdf0e10cSrcweir  *  <li><code> getCharacterBounds()</code></li>
53*cdf0e10cSrcweir  *  <li><code> getCharacterCount()</code></li>
54*cdf0e10cSrcweir  *  <li><code> getIndexAtPoint()</code></li>
55*cdf0e10cSrcweir  *  <li><code> getSelectedText()</code></li>
56*cdf0e10cSrcweir  *  <li><code> getSelectionStart()</code></li>
57*cdf0e10cSrcweir  *  <li><code> getSelectionEnd()</code></li>
58*cdf0e10cSrcweir  *  <li><code> setSelection()</code></li>
59*cdf0e10cSrcweir  *  <li><code> getText()</code></li>
60*cdf0e10cSrcweir  *  <li><code> getTextRange()</code></li>
61*cdf0e10cSrcweir  *  <li><code> getTextAtIndex()</code></li>
62*cdf0e10cSrcweir  *  <li><code> getTextBeforeIndex()</code></li>
63*cdf0e10cSrcweir  *  <li><code> getTextBehindIndex()</code></li>
64*cdf0e10cSrcweir  *  <li><code> copyText()</code></li>
65*cdf0e10cSrcweir  * </ul> <p>
66*cdf0e10cSrcweir  * This test needs the following object relations :
67*cdf0e10cSrcweir  * <ul>
68*cdf0e10cSrcweir  *  <li> <code>'XAccessibleText.Text'</code> (of type <code>String</code>)
69*cdf0e10cSrcweir  *   <b> optional </b> :
70*cdf0e10cSrcweir  *   the string presentation of component's text. If the relation
71*cdf0e10cSrcweir  *   is not specified, then text from method <code>getText()</code>
72*cdf0e10cSrcweir  *   is used.
73*cdf0e10cSrcweir  *  </li>
74*cdf0e10cSrcweir  *  </ul> <p>
75*cdf0e10cSrcweir  * @see com.sun.star.accessibility.XAccessibleText
76*cdf0e10cSrcweir  */
77*cdf0e10cSrcweir public class _XAccessibleText extends MultiMethodTest {
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     public XAccessibleText oObj = null;
80*cdf0e10cSrcweir     protected com.sun.star.awt.Rectangle bounds = null;
81*cdf0e10cSrcweir     String text = null;
82*cdf0e10cSrcweir     String editOnly = null;
83*cdf0e10cSrcweir     Object LimitedBounds = null;
84*cdf0e10cSrcweir     Rectangle chBounds = null;
85*cdf0e10cSrcweir     int chCount = 0;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     /**
89*cdf0e10cSrcweir      * Retrieves a string representation of the component's text.
90*cdf0e10cSrcweir      * The length of retrieved string must be greater than zero.
91*cdf0e10cSrcweir      */
92*cdf0e10cSrcweir     protected void before() {
93*cdf0e10cSrcweir         Object xat = tEnv.getObjRelation("XAccessibleText");
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir         XAccessibleComponent component = null;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir         if (xat != null) {
98*cdf0e10cSrcweir             oObj = (XAccessibleText) UnoRuntime.queryInterface(
99*cdf0e10cSrcweir                            XAccessibleText.class, xat);
100*cdf0e10cSrcweir             component = (XAccessibleComponent) UnoRuntime.queryInterface(
101*cdf0e10cSrcweir                                 XAccessibleComponent.class, xat);
102*cdf0e10cSrcweir         }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir         text = (String) tEnv.getObjRelation("XAccessibleText.Text");
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir         if (text == null) {
107*cdf0e10cSrcweir             text = oObj.getText();
108*cdf0e10cSrcweir         }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         if (text.length() == 0) {
111*cdf0e10cSrcweir             throw new StatusException(Status.failed(
112*cdf0e10cSrcweir                                               "The length of text must be greater than zero"));
113*cdf0e10cSrcweir         }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir         editOnly = (String) tEnv.getObjRelation("EditOnly");
116*cdf0e10cSrcweir         LimitedBounds = tEnv.getObjRelation("LimitedBounds");
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir         if (component == null) {
119*cdf0e10cSrcweir             component = (XAccessibleComponent) UnoRuntime.queryInterface(
120*cdf0e10cSrcweir                                 XAccessibleComponent.class,
121*cdf0e10cSrcweir                                 tEnv.getTestObject());
122*cdf0e10cSrcweir         }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir         bounds = component.getBounds();
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir         log.println("Text is '" + text + "'");
127*cdf0e10cSrcweir         System.out.println("############################");
128*cdf0e10cSrcweir     }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     /**
131*cdf0e10cSrcweir      * Calls the method and checks returned value.
132*cdf0e10cSrcweir      * Has OK status if returned value is equal to <code>chCount - 1</code>.
133*cdf0e10cSrcweir      * The following method tests are to be executed before:
134*cdf0e10cSrcweir      * <ul>
135*cdf0e10cSrcweir      *  <li> <code>setCaretPosition()</code> </li>
136*cdf0e10cSrcweir      * </ul>
137*cdf0e10cSrcweir      */
138*cdf0e10cSrcweir     public void _getCaretPosition() {
139*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir         if (editOnly != null) {
142*cdf0e10cSrcweir             log.println(editOnly);
143*cdf0e10cSrcweir             throw new StatusException(Status.skipped(true));
144*cdf0e10cSrcweir         }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir         boolean res = true;
147*cdf0e10cSrcweir         boolean sc = true;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         try {
150*cdf0e10cSrcweir             oObj.setCaretPosition(chCount - 1);
151*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException ie) {
152*cdf0e10cSrcweir         }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir         int carPos = oObj.getCaretPosition();
155*cdf0e10cSrcweir         log.println("getCaretPosition: " + carPos);
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir         if (sc) {
158*cdf0e10cSrcweir             res = carPos == (chCount - 1);
159*cdf0e10cSrcweir         } else {
160*cdf0e10cSrcweir             log.println(
161*cdf0e10cSrcweir                     "Object is read only and Caret position couldn't be set");
162*cdf0e10cSrcweir             res = carPos == -1;
163*cdf0e10cSrcweir         }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         tRes.tested("getCaretPosition()", res);
166*cdf0e10cSrcweir     }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     /**
169*cdf0e10cSrcweir      * Calls the method with the wrong index and with the correct index
170*cdf0e10cSrcweir      * <code>chCount - 1</code>.
171*cdf0e10cSrcweir      * Has OK status if exception was thrown for wrong index and
172*cdf0e10cSrcweir      * if exception wasn't thrown for the correct index.
173*cdf0e10cSrcweir      * The following method tests are to be executed before:
174*cdf0e10cSrcweir      * <ul>
175*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
176*cdf0e10cSrcweir      * </ul>
177*cdf0e10cSrcweir      */
178*cdf0e10cSrcweir     public void _setCaretPosition() {
179*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         boolean res = true;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir         try {
184*cdf0e10cSrcweir             log.print("setCaretPosition(-1):");
185*cdf0e10cSrcweir             oObj.setCaretPosition(-1);
186*cdf0e10cSrcweir             res &= false;
187*cdf0e10cSrcweir             log.println("exception was expected ... FAILED");
188*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
189*cdf0e10cSrcweir             log.println("expected exception");
190*cdf0e10cSrcweir             res &= true;
191*cdf0e10cSrcweir         }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir         try {
194*cdf0e10cSrcweir             log.print("setCaretPosition(chCount+1):");
195*cdf0e10cSrcweir             oObj.setCaretPosition(chCount + 1);
196*cdf0e10cSrcweir             res &= false;
197*cdf0e10cSrcweir             log.println("exception was expected  ... FAILED");
198*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
199*cdf0e10cSrcweir             log.println("expected exception");
200*cdf0e10cSrcweir             res &= true;
201*cdf0e10cSrcweir         }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir         try {
204*cdf0e10cSrcweir             log.println("setCaretPosition(chCount - 1)");
205*cdf0e10cSrcweir             oObj.setCaretPosition(chCount - 1);
206*cdf0e10cSrcweir             res &= true;
207*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
208*cdf0e10cSrcweir             log.println("unexpected exception  ... FAILED");
209*cdf0e10cSrcweir             e.printStackTrace(log);
210*cdf0e10cSrcweir             res &= false;
211*cdf0e10cSrcweir         }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir         tRes.tested("setCaretPosition()", res);
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     /**
217*cdf0e10cSrcweir      * Calls the method with the wrong index and with the correct indexes.
218*cdf0e10cSrcweir      * Checks every character in the text.
219*cdf0e10cSrcweir      * Has OK status if exception was thrown for wrong index,
220*cdf0e10cSrcweir      * if exception wasn't thrown for the correct index and
221*cdf0e10cSrcweir      * if every character is equal to corresponding character in the text.
222*cdf0e10cSrcweir      * The following method tests are to be executed before:
223*cdf0e10cSrcweir      * <ul>
224*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
225*cdf0e10cSrcweir      * </ul>
226*cdf0e10cSrcweir      */
227*cdf0e10cSrcweir     public void _getCharacter() {
228*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir         boolean res = true;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir         try {
233*cdf0e10cSrcweir             log.println("getCharacter(-1)");
234*cdf0e10cSrcweir             oObj.getCharacter(-1);
235*cdf0e10cSrcweir             log.println("Exception was expected");
236*cdf0e10cSrcweir             res = false;
237*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
238*cdf0e10cSrcweir             log.println("Expected exception");
239*cdf0e10cSrcweir             res = true;
240*cdf0e10cSrcweir         }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir         try {
243*cdf0e10cSrcweir             log.println("getCharacter(chCount)");
244*cdf0e10cSrcweir             oObj.getCharacter(chCount);
245*cdf0e10cSrcweir             log.println("Exception was expected");
246*cdf0e10cSrcweir             res &= false;
247*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
248*cdf0e10cSrcweir             log.println("Expected exception");
249*cdf0e10cSrcweir             res &= true;
250*cdf0e10cSrcweir         }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir         try {
253*cdf0e10cSrcweir             log.println("Checking of every character in the text...");
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir             boolean isEqCh = true;
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir             for (int i = 0; i < chCount; i++) {
258*cdf0e10cSrcweir                 char ch = oObj.getCharacter(i);
259*cdf0e10cSrcweir                 isEqCh = ch == text.charAt(i);
260*cdf0e10cSrcweir                 res &= isEqCh;
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir                 if (!isEqCh) {
263*cdf0e10cSrcweir                     log.println("At the position " + i +
264*cdf0e10cSrcweir                                 "was expected character: " + text.charAt(i));
265*cdf0e10cSrcweir                     log.println("but was returned: " + ch);
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir                     break;
268*cdf0e10cSrcweir                 }
269*cdf0e10cSrcweir             }
270*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
271*cdf0e10cSrcweir             log.println("Unexpected exception");
272*cdf0e10cSrcweir             e.printStackTrace(log);
273*cdf0e10cSrcweir             res &= false;
274*cdf0e10cSrcweir         }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir         tRes.tested("getCharacter()", res);
277*cdf0e10cSrcweir     }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir     /**
280*cdf0e10cSrcweir      * Calls the method with the wrong indexes and with the correct index,
281*cdf0e10cSrcweir      * checks a returned value.
282*cdf0e10cSrcweir      * Has OK status if exception was thrown for the wrong indexes,
283*cdf0e10cSrcweir      * if exception wasn't thrown for the correct index and
284*cdf0e10cSrcweir      * if returned value isn't <code>null</code>.
285*cdf0e10cSrcweir      * The following method tests are to be executed before:
286*cdf0e10cSrcweir      * <ul>
287*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
288*cdf0e10cSrcweir      * </ul>
289*cdf0e10cSrcweir      */
290*cdf0e10cSrcweir     public void _getCharacterAttributes() {
291*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir         boolean res = true;
294*cdf0e10cSrcweir         String[] attr = new String[] { "" };
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir         try {
297*cdf0e10cSrcweir             log.println("getCharacterAttributes(-1)");
298*cdf0e10cSrcweir             oObj.getCharacterAttributes(-1, attr);
299*cdf0e10cSrcweir             log.println("Exception was expected");
300*cdf0e10cSrcweir             res &= false;
301*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
302*cdf0e10cSrcweir             log.println("Expected exception");
303*cdf0e10cSrcweir             res &= true;
304*cdf0e10cSrcweir         }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir         try {
307*cdf0e10cSrcweir             log.println("getCharacterAttributes(chCount)");
308*cdf0e10cSrcweir             oObj.getCharacterAttributes(chCount, attr);
309*cdf0e10cSrcweir             log.println("Exception was expected");
310*cdf0e10cSrcweir             res &= false;
311*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
312*cdf0e10cSrcweir             log.println("Expected exception");
313*cdf0e10cSrcweir             res &= true;
314*cdf0e10cSrcweir         }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir         try {
317*cdf0e10cSrcweir             log.println("getCharacterAttributes(chCount-1)");
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir             PropertyValue[] props = oObj.getCharacterAttributes(chCount - 1,
320*cdf0e10cSrcweir                                                                 attr);
321*cdf0e10cSrcweir             res &= (props != null);
322*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
323*cdf0e10cSrcweir             log.println("Unexpected exception");
324*cdf0e10cSrcweir             e.printStackTrace(log);
325*cdf0e10cSrcweir             res &= false;
326*cdf0e10cSrcweir         }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir         tRes.tested("getCharacterAttributes()", res);
329*cdf0e10cSrcweir     }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     /**
332*cdf0e10cSrcweir      * Calls the method with the wrong indexes and with the correct index.
333*cdf0e10cSrcweir      * checks and stores a returned value.
334*cdf0e10cSrcweir      * Has OK status if exception was thrown for the wrong indexes,
335*cdf0e10cSrcweir      * if exception wasn't thrown for the correct index and
336*cdf0e10cSrcweir      * if returned value isn't <code>null</code>.
337*cdf0e10cSrcweir      * The following method tests are to be executed before:
338*cdf0e10cSrcweir      * <ul>
339*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
340*cdf0e10cSrcweir      * </ul>
341*cdf0e10cSrcweir      */
342*cdf0e10cSrcweir     public void _getCharacterBounds() {
343*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir         boolean res = true;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         int lastIndex = chCount;
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir         if (LimitedBounds != null) {
350*cdf0e10cSrcweir             if (LimitedBounds instanceof Integer) {
351*cdf0e10cSrcweir                 lastIndex = ((Integer) LimitedBounds).intValue();
352*cdf0e10cSrcweir             } else {
353*cdf0e10cSrcweir                 lastIndex = chCount - 1;
354*cdf0e10cSrcweir             }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir             log.println(LimitedBounds);
357*cdf0e10cSrcweir         }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir         try {
360*cdf0e10cSrcweir             log.println("getCharacterBounds(-1)");
361*cdf0e10cSrcweir             oObj.getCharacterBounds(-1);
362*cdf0e10cSrcweir             log.println("Exception was expected");
363*cdf0e10cSrcweir             res &= false;
364*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
365*cdf0e10cSrcweir             log.println("Expected exception");
366*cdf0e10cSrcweir             res &= true;
367*cdf0e10cSrcweir         }
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir         try {
370*cdf0e10cSrcweir             log.println("getCharacterBounds(" + (lastIndex + 1) + ")");
371*cdf0e10cSrcweir             oObj.getCharacterBounds(lastIndex + 1);
372*cdf0e10cSrcweir             log.println("Exception was expected");
373*cdf0e10cSrcweir             res &= false;
374*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
375*cdf0e10cSrcweir             log.println("Expected exception");
376*cdf0e10cSrcweir             res &= true;
377*cdf0e10cSrcweir         }
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir         try {
380*cdf0e10cSrcweir             for (int i = 0; i < lastIndex; i++) {
381*cdf0e10cSrcweir                 log.println("getCharacterBounds(" + i + ")");
382*cdf0e10cSrcweir                 chBounds = oObj.getCharacterBounds(i);
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir                 boolean localres = true;
385*cdf0e10cSrcweir                 localres = chBounds.X >= 0;
386*cdf0e10cSrcweir                 localres &= (chBounds.Y >= 0);
387*cdf0e10cSrcweir                 localres &= ((chBounds.X + chBounds.Width) <= bounds.Width);
388*cdf0e10cSrcweir                 localres &= ((chBounds.X + chBounds.Width) > 0);
389*cdf0e10cSrcweir                 localres &= ((chBounds.Y + chBounds.Height) <= bounds.Height);
390*cdf0e10cSrcweir                 localres &= ((chBounds.Y + chBounds.Height) > 0);
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir                 if (!localres) {
393*cdf0e10cSrcweir                     log.println("Text at this place: "+oObj.getCharacter(i));
394*cdf0e10cSrcweir                     log.println("Character bounds outside component");
395*cdf0e10cSrcweir                     log.println("Character rect: " + chBounds.X + ", " +
396*cdf0e10cSrcweir                                 chBounds.Y + ", " + chBounds.Width + ", " +
397*cdf0e10cSrcweir                                 chBounds.Height);
398*cdf0e10cSrcweir                     log.println("Component rect: " + bounds.X + ", " +
399*cdf0e10cSrcweir                                 bounds.Y + ", " + bounds.Width + ", " +
400*cdf0e10cSrcweir                                 bounds.Height);
401*cdf0e10cSrcweir                     res &= localres;
402*cdf0e10cSrcweir                 }
403*cdf0e10cSrcweir             }
404*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
405*cdf0e10cSrcweir             log.println("Unexpected exception");
406*cdf0e10cSrcweir             e.printStackTrace(log);
407*cdf0e10cSrcweir             res &= false;
408*cdf0e10cSrcweir         }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir         tRes.tested("getCharacterBounds()", res);
411*cdf0e10cSrcweir     }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir     /**
414*cdf0e10cSrcweir      * Calls the method and stores a returned value to the variable
415*cdf0e10cSrcweir      * <code>chCount</code>.
416*cdf0e10cSrcweir      * Has OK status if a returned value is equal to the text length.
417*cdf0e10cSrcweir      */
418*cdf0e10cSrcweir     public void _getCharacterCount() {
419*cdf0e10cSrcweir         chCount = oObj.getCharacterCount();
420*cdf0e10cSrcweir         log.println("Character count:" + chCount);
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir         boolean res = chCount == text.length();
423*cdf0e10cSrcweir         tRes.tested("getCharacterCount()", res);
424*cdf0e10cSrcweir     }
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir     /**
427*cdf0e10cSrcweir      * Calls the method for an invalid point and for the point of rectangle
428*cdf0e10cSrcweir      * returned by the method <code>getCharacterBounds()</code>.
429*cdf0e10cSrcweir      * Has OK status if returned value is equal to <code>-1</code> for an
430*cdf0e10cSrcweir      * invalid point and if returned value is equal to <code>chCount-1</code>
431*cdf0e10cSrcweir      * for a valid point.
432*cdf0e10cSrcweir      * The following method tests are to be executed before:
433*cdf0e10cSrcweir      * <ul>
434*cdf0e10cSrcweir      *  <li> <code>getCharacterBounds()</code> </li>
435*cdf0e10cSrcweir      * </ul>
436*cdf0e10cSrcweir      */
437*cdf0e10cSrcweir     public void _getIndexAtPoint() {
438*cdf0e10cSrcweir         //requiredMethod("getCharacterBounds()");
439*cdf0e10cSrcweir         boolean res = true;
440*cdf0e10cSrcweir         log.print("getIndexAtPoint(-1, -1):");
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir         Point pt = new Point(-1, -1);
443*cdf0e10cSrcweir         int index = oObj.getIndexAtPoint(pt);
444*cdf0e10cSrcweir         log.println(index);
445*cdf0e10cSrcweir         res &= (index == -1);
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir         int lastIndex = chCount;
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir         if (LimitedBounds != null) {
450*cdf0e10cSrcweir             if (LimitedBounds instanceof Integer) {
451*cdf0e10cSrcweir                 lastIndex = ((Integer) LimitedBounds).intValue();
452*cdf0e10cSrcweir             } else {
453*cdf0e10cSrcweir                 lastIndex = chCount - 1;
454*cdf0e10cSrcweir             }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir             log.println(LimitedBounds);
457*cdf0e10cSrcweir         }
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir         for (int i = 0; i < lastIndex; i++) {
460*cdf0e10cSrcweir             Rectangle aRect = null;
461*cdf0e10cSrcweir             String text = "empty";
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir             try {
464*cdf0e10cSrcweir                 aRect = oObj.getCharacterBounds(i);
465*cdf0e10cSrcweir                 text = oObj.getTextAtIndex(i, (short) 1).SegmentText;
466*cdf0e10cSrcweir             } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
467*cdf0e10cSrcweir             } catch (com.sun.star.lang.IllegalArgumentException e) {
468*cdf0e10cSrcweir             }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir             int x = aRect.X + (aRect.Width / 2);
471*cdf0e10cSrcweir             int y = aRect.Y + (aRect.Height / 2);
472*cdf0e10cSrcweir             Point aPoint = new Point(x, y);
473*cdf0e10cSrcweir             int nIndex = oObj.getIndexAtPoint(aPoint);
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir             x = aRect.X;
476*cdf0e10cSrcweir             y = aRect.Y + (aRect.Height / 2);
477*cdf0e10cSrcweir             aPoint = new Point(x, y);
478*cdf0e10cSrcweir             int left = oObj.getIndexAtPoint(aPoint);
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir             int[] previous = (int[]) tEnv.getObjRelation("PreviousUsed");
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir             if (previous != null) {
485*cdf0e10cSrcweir                 for (int k = 0; k < previous.length; k++) {
486*cdf0e10cSrcweir                     if (i == previous[k]) {
487*cdf0e10cSrcweir                         nIndex++;
488*cdf0e10cSrcweir                     }
489*cdf0e10cSrcweir                 }
490*cdf0e10cSrcweir             }
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir             if (nIndex != i) {
493*cdf0e10cSrcweir                 // for some letters the center of the rectangle isn't recognised
494*cdf0e10cSrcweir                 // in this case we are happy if the left border of the rectangle
495*cdf0e10cSrcweir                 // returns the correct value.
496*cdf0e10cSrcweir                 if (left !=i) {
497*cdf0e10cSrcweir                     log.println("## Method didn't work for Point (" + x + "," + y +
498*cdf0e10cSrcweir                             ")");
499*cdf0e10cSrcweir                     log.println("Expected Index " + i);
500*cdf0e10cSrcweir                     log.println("Gained Index: " + nIndex);
501*cdf0e10cSrcweir                     log.println("Left Border: "+left);
502*cdf0e10cSrcweir                     log.println("CharacterAtIndex: " + text);
503*cdf0e10cSrcweir                     res &= false;
504*cdf0e10cSrcweir                 }
505*cdf0e10cSrcweir             }
506*cdf0e10cSrcweir         }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir         tRes.tested("getIndexAtPoint()", res);
509*cdf0e10cSrcweir     }
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir     /**
512*cdf0e10cSrcweir      * Checks a returned values after different calls of the method
513*cdf0e10cSrcweir      * <code>setSelection()</code>.
514*cdf0e10cSrcweir      * The following method tests are to be executed before:
515*cdf0e10cSrcweir      * <ul>
516*cdf0e10cSrcweir      *  <li> <code>setSelection()</code> </li>
517*cdf0e10cSrcweir      * </ul>
518*cdf0e10cSrcweir      */
519*cdf0e10cSrcweir     public void _getSelectedText() {
520*cdf0e10cSrcweir         if (editOnly != null) {
521*cdf0e10cSrcweir             log.println(editOnly);
522*cdf0e10cSrcweir             throw new StatusException(Status.skipped(true));
523*cdf0e10cSrcweir         }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir         requiredMethod("setSelection()");
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir         boolean res = true;
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir         try {
530*cdf0e10cSrcweir             log.println("setSelection(0, 0)");
531*cdf0e10cSrcweir             oObj.setSelection(0, 0);
532*cdf0e10cSrcweir             log.print("getSelectedText():");
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir             String txt = oObj.getSelectedText();
535*cdf0e10cSrcweir             log.println("'" + txt + "'");
536*cdf0e10cSrcweir             res &= (txt.length() == 0);
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir             log.println("setSelection(0, chCount)");
539*cdf0e10cSrcweir             oObj.setSelection(0, chCount);
540*cdf0e10cSrcweir             log.print("getSelectedText():");
541*cdf0e10cSrcweir             txt = oObj.getSelectedText();
542*cdf0e10cSrcweir             log.println("'" + txt + "'");
543*cdf0e10cSrcweir             res &= txt.equals(text);
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir             if (chCount > 2) {
546*cdf0e10cSrcweir                 log.println("setSelection(1, chCount-1)");
547*cdf0e10cSrcweir                 oObj.setSelection(1, chCount - 1);
548*cdf0e10cSrcweir                 log.print("getSelectedText():");
549*cdf0e10cSrcweir                 txt = oObj.getSelectedText();
550*cdf0e10cSrcweir                 log.println("'" + txt + "'");
551*cdf0e10cSrcweir                 res &= txt.equals(text.substring(1, chCount - 1));
552*cdf0e10cSrcweir             }
553*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
554*cdf0e10cSrcweir             log.println("Unexpected exception");
555*cdf0e10cSrcweir             e.printStackTrace(log);
556*cdf0e10cSrcweir             res &= false;
557*cdf0e10cSrcweir         }
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir         tRes.tested("getSelectedText()", res);
560*cdf0e10cSrcweir     }
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir     /**
563*cdf0e10cSrcweir      * Checks a returned values after different calls of the method
564*cdf0e10cSrcweir      * <code>setSelection()</code>.
565*cdf0e10cSrcweir      * The following method tests are to be executed before:
566*cdf0e10cSrcweir      * <ul>
567*cdf0e10cSrcweir      *  <li> <code>setSelection()</code> </li>
568*cdf0e10cSrcweir      * </ul>
569*cdf0e10cSrcweir      */
570*cdf0e10cSrcweir     public void _getSelectionStart() {
571*cdf0e10cSrcweir         if (editOnly != null) {
572*cdf0e10cSrcweir             log.println(editOnly);
573*cdf0e10cSrcweir             throw new StatusException(Status.skipped(true));
574*cdf0e10cSrcweir         }
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir         requiredMethod("setSelection()");
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir         boolean res = true;
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir         try {
581*cdf0e10cSrcweir             log.println("setSelection(0, chCount)");
582*cdf0e10cSrcweir             oObj.setSelection(0, chCount);
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir             int start = oObj.getSelectionStart();
585*cdf0e10cSrcweir             log.println("getSelectionStart():" + start);
586*cdf0e10cSrcweir             res &= (start == 0);
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir             if (chCount > 2) {
589*cdf0e10cSrcweir                 log.println("setSelection(1, chCount-1)");
590*cdf0e10cSrcweir                 oObj.setSelection(1, chCount - 1);
591*cdf0e10cSrcweir                 start = oObj.getSelectionStart();
592*cdf0e10cSrcweir                 log.println("getSelectionStart():" + start);
593*cdf0e10cSrcweir                 res &= (start == 1);
594*cdf0e10cSrcweir             }
595*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
596*cdf0e10cSrcweir             log.println("Unexpected exception");
597*cdf0e10cSrcweir             e.printStackTrace(log);
598*cdf0e10cSrcweir             res &= false;
599*cdf0e10cSrcweir         }
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir         tRes.tested("getSelectionStart()", res);
602*cdf0e10cSrcweir     }
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir     /**
605*cdf0e10cSrcweir      * Checks a returned values after different calls of the method
606*cdf0e10cSrcweir      * <code>setSelection()</code>.
607*cdf0e10cSrcweir      * The following method tests are to be executed before:
608*cdf0e10cSrcweir      * <ul>
609*cdf0e10cSrcweir      *  <li> <code>setSelection()</code> </li>
610*cdf0e10cSrcweir      * </ul>
611*cdf0e10cSrcweir      */
612*cdf0e10cSrcweir     public void _getSelectionEnd() {
613*cdf0e10cSrcweir         if (editOnly != null) {
614*cdf0e10cSrcweir             log.println(editOnly);
615*cdf0e10cSrcweir             throw new StatusException(Status.skipped(true));
616*cdf0e10cSrcweir         }
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir         requiredMethod("setSelection()");
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir         boolean res = true;
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir         try {
623*cdf0e10cSrcweir             log.println("setSelection(0, chCount)");
624*cdf0e10cSrcweir             oObj.setSelection(0, chCount);
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir             int end = oObj.getSelectionEnd();
627*cdf0e10cSrcweir             log.println("getSelectionEnd():" + end);
628*cdf0e10cSrcweir             res &= (end == chCount);
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir             if (chCount > 2) {
631*cdf0e10cSrcweir                 log.println("setSelection(1, chCount-1)");
632*cdf0e10cSrcweir                 oObj.setSelection(1, chCount - 1);
633*cdf0e10cSrcweir                 end = oObj.getSelectionEnd();
634*cdf0e10cSrcweir                 log.println("getSelectionEnd():" + end);
635*cdf0e10cSrcweir                 res &= (end == (chCount - 1));
636*cdf0e10cSrcweir             }
637*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
638*cdf0e10cSrcweir             log.println("Unexpected exception");
639*cdf0e10cSrcweir             e.printStackTrace(log);
640*cdf0e10cSrcweir             res &= false;
641*cdf0e10cSrcweir         }
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir         tRes.tested("getSelectionEnd()", res);
644*cdf0e10cSrcweir     }
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir     /**
647*cdf0e10cSrcweir      * Calls the method with invalid parameters an with valid parameters.
648*cdf0e10cSrcweir      * Has OK status if exception was thrown for invalid parameters,
649*cdf0e10cSrcweir      * if exception wasn't thrown for valid parameters.
650*cdf0e10cSrcweir      * The following method tests are to be executed before:
651*cdf0e10cSrcweir      * <ul>
652*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
653*cdf0e10cSrcweir      * </ul>
654*cdf0e10cSrcweir      */
655*cdf0e10cSrcweir     public void _setSelection() {
656*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir         boolean res = true;
659*cdf0e10cSrcweir         boolean locRes = true;
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir         if (editOnly != null) {
662*cdf0e10cSrcweir             log.println(editOnly);
663*cdf0e10cSrcweir             throw new StatusException(Status.skipped(true));
664*cdf0e10cSrcweir         }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir         try {
667*cdf0e10cSrcweir             log.print("setSelection(-1, chCount-1):");
668*cdf0e10cSrcweir             locRes = oObj.setSelection(-1, chCount - 1);
669*cdf0e10cSrcweir             log.println(locRes + " excepion was expected");
670*cdf0e10cSrcweir             res &= !locRes;
671*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
672*cdf0e10cSrcweir             log.println("Expected exception");
673*cdf0e10cSrcweir             res &= true;
674*cdf0e10cSrcweir         }
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir         try {
677*cdf0e10cSrcweir             log.print("setSelection(0, chCount+1):");
678*cdf0e10cSrcweir             locRes = oObj.setSelection(0, chCount + 1);
679*cdf0e10cSrcweir             log.println(locRes + " excepion was expected");
680*cdf0e10cSrcweir             res &= !locRes;
681*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
682*cdf0e10cSrcweir             log.println("Expected exception");
683*cdf0e10cSrcweir             res &= true;
684*cdf0e10cSrcweir         }
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir         try {
687*cdf0e10cSrcweir             if (chCount > 2) {
688*cdf0e10cSrcweir                 log.print("setSelection(1, chCount-1):");
689*cdf0e10cSrcweir                 locRes = oObj.setSelection(1, chCount - 1);
690*cdf0e10cSrcweir                 log.println(locRes);
691*cdf0e10cSrcweir                 res &= locRes;
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir                 log.print("setSelection(chCount-1, 1):");
694*cdf0e10cSrcweir                 locRes = oObj.setSelection(chCount - 1, 1);
695*cdf0e10cSrcweir                 log.println(locRes);
696*cdf0e10cSrcweir                 res &= locRes;
697*cdf0e10cSrcweir             }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir             log.print("setSelection(0, chCount-1):");
700*cdf0e10cSrcweir             locRes = oObj.setSelection(0, chCount - 1);
701*cdf0e10cSrcweir             log.println(locRes);
702*cdf0e10cSrcweir             res &= locRes;
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir             log.print("setSelection(chCount-1, 0):");
705*cdf0e10cSrcweir             locRes = oObj.setSelection(chCount - 1, 0);
706*cdf0e10cSrcweir             log.println(locRes);
707*cdf0e10cSrcweir             res &= locRes;
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir             log.print("setSelection(0, 0):");
710*cdf0e10cSrcweir             locRes = oObj.setSelection(0, 0);
711*cdf0e10cSrcweir             log.println(locRes);
712*cdf0e10cSrcweir             res &= locRes;
713*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
714*cdf0e10cSrcweir             log.println("Unexpected exception");
715*cdf0e10cSrcweir             e.printStackTrace(log);
716*cdf0e10cSrcweir             res &= false;
717*cdf0e10cSrcweir         }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir         tRes.tested("setSelection()", res);
720*cdf0e10cSrcweir     }
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir     /**
723*cdf0e10cSrcweir      * Calls the method and checks returned value.
724*cdf0e10cSrcweir      * Has OK status if returned string is equal to string
725*cdf0e10cSrcweir      * received from relation.
726*cdf0e10cSrcweir      */
727*cdf0e10cSrcweir     public void _getText() {
728*cdf0e10cSrcweir         String txt = oObj.getText();
729*cdf0e10cSrcweir         log.println("getText: " + txt);
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir         boolean res = txt.equals(text);
732*cdf0e10cSrcweir         tRes.tested("getText()", res);
733*cdf0e10cSrcweir     }
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir     /**
736*cdf0e10cSrcweir      * Calls the method with invalid parameters an with valid parameters,
737*cdf0e10cSrcweir      * checks returned values.
738*cdf0e10cSrcweir      * Has OK status if exception was thrown for invalid parameters,
739*cdf0e10cSrcweir      * if exception wasn't thrown for valid parameters and if returned values
740*cdf0e10cSrcweir      * are equal to corresponding substrings of the text received by relation.
741*cdf0e10cSrcweir      * The following method tests are to be executed before:
742*cdf0e10cSrcweir      * <ul>
743*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
744*cdf0e10cSrcweir      * </ul>
745*cdf0e10cSrcweir      */
746*cdf0e10cSrcweir     public void _getTextRange() {
747*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir         boolean res = true;
750*cdf0e10cSrcweir         boolean locRes = true;
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir 		String txtRange = "";
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir         try {
755*cdf0e10cSrcweir             if (chCount > 3) {
756*cdf0e10cSrcweir                 log.print("getTextRange(1, chCount - 2): ");
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir                 txtRange = oObj.getTextRange(1, chCount - 2);
759*cdf0e10cSrcweir                 log.println(txtRange);
760*cdf0e10cSrcweir                 locRes = txtRange.equals(text.substring(1, chCount - 2));
761*cdf0e10cSrcweir                 res &= locRes;
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir                 if (!locRes) {
764*cdf0e10cSrcweir                     log.println("Was expected: " +
765*cdf0e10cSrcweir                                 text.substring(1, chCount - 2));
766*cdf0e10cSrcweir                 }
767*cdf0e10cSrcweir             }
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir             log.print("getTextRange(0, chCount-1): ");
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir             txtRange = oObj.getTextRange(0, chCount - 1);
772*cdf0e10cSrcweir             log.println(txtRange);
773*cdf0e10cSrcweir             locRes = txtRange.equals(text.substring(0, chCount - 1));
774*cdf0e10cSrcweir             res &= locRes;
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir             if (!locRes) {
777*cdf0e10cSrcweir                 log.println("Was expected: " +
778*cdf0e10cSrcweir                             text.substring(0, chCount - 1));
779*cdf0e10cSrcweir             }
780*cdf0e10cSrcweir 
781*cdf0e10cSrcweir             log.print("getTextRange(chCount, 0): ");
782*cdf0e10cSrcweir             txtRange = oObj.getTextRange(chCount, 0);
783*cdf0e10cSrcweir             log.println(txtRange);
784*cdf0e10cSrcweir             res &= txtRange.equals(text);
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir             log.print("getTextRange(0, 0): ");
787*cdf0e10cSrcweir             txtRange = oObj.getTextRange(0, 0);
788*cdf0e10cSrcweir             log.println(txtRange);
789*cdf0e10cSrcweir             locRes = txtRange.equals("");
790*cdf0e10cSrcweir             res &= locRes;
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir             if (!locRes) {
793*cdf0e10cSrcweir                 log.println("Empty string was expected");
794*cdf0e10cSrcweir             }
795*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
796*cdf0e10cSrcweir             log.println("Unexpected exception");
797*cdf0e10cSrcweir             e.printStackTrace(log);
798*cdf0e10cSrcweir             res &= false;
799*cdf0e10cSrcweir         }
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir         try {
802*cdf0e10cSrcweir             log.print("getTextRange(-1, chCount - 1): ");
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir             txtRange = oObj.getTextRange(-1, chCount - 1);
805*cdf0e10cSrcweir             log.println("Exception was expected");
806*cdf0e10cSrcweir             res &= false;
807*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
808*cdf0e10cSrcweir             log.println("Expected exception");
809*cdf0e10cSrcweir             res &= true;
810*cdf0e10cSrcweir         }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir         try {
813*cdf0e10cSrcweir             log.print("getTextRange(0, chCount + 1): ");
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir             txtRange = oObj.getTextRange(0, chCount + 1);
816*cdf0e10cSrcweir             log.println("Exception was expected");
817*cdf0e10cSrcweir             res &= false;
818*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
819*cdf0e10cSrcweir             log.println("Expected exception");
820*cdf0e10cSrcweir             res &= true;
821*cdf0e10cSrcweir         }
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir         try {
824*cdf0e10cSrcweir             log.print("getTextRange(chCount+1, -1): ");
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir             txtRange = oObj.getTextRange(chCount + 1, -1);
827*cdf0e10cSrcweir             log.println("Exception was expected");
828*cdf0e10cSrcweir             res &= false;
829*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
830*cdf0e10cSrcweir             log.println("Expected exception");
831*cdf0e10cSrcweir             res &= true;
832*cdf0e10cSrcweir         }
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir         tRes.tested("getTextRange()", res);
835*cdf0e10cSrcweir     }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir     /**
838*cdf0e10cSrcweir      * Calls the method with invalid parameters an with valid parameters,
839*cdf0e10cSrcweir      * checks returned values.
840*cdf0e10cSrcweir      * Has OK status if exception was thrown for invalid parameters,
841*cdf0e10cSrcweir      * if exception wasn't thrown for valid parameters and if returned values
842*cdf0e10cSrcweir      * are equal to corresponding substrings of the text received by relation.
843*cdf0e10cSrcweir      * The following method tests are to be executed before:
844*cdf0e10cSrcweir      * <ul>
845*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
846*cdf0e10cSrcweir      * </ul>
847*cdf0e10cSrcweir      */
848*cdf0e10cSrcweir     public void _getTextAtIndex() {
849*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
850*cdf0e10cSrcweir 		TextSegment txt = null;
851*cdf0e10cSrcweir         boolean res = true;
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir         try {
854*cdf0e10cSrcweir             log.print("getTextAtIndex(-1, AccessibleTextType.PARAGRAPH):");
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir             txt = oObj.getTextAtIndex(-1,
857*cdf0e10cSrcweir                                                   AccessibleTextType.PARAGRAPH);
858*cdf0e10cSrcweir             log.println("Exception was expected");
859*cdf0e10cSrcweir             res &= false;
860*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
861*cdf0e10cSrcweir             log.println("Expected exception");
862*cdf0e10cSrcweir             res &= true;
863*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
864*cdf0e10cSrcweir             log.println("UnExpected exception");
865*cdf0e10cSrcweir             res &= false;
866*cdf0e10cSrcweir         }
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir         try {
869*cdf0e10cSrcweir             log.print("getTextAtIndex(chCount+1," +
870*cdf0e10cSrcweir                       " AccessibleTextType.PARAGRAPH):");
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir             txt = oObj.getTextAtIndex(chCount + 1,
873*cdf0e10cSrcweir                                                   AccessibleTextType.PARAGRAPH);
874*cdf0e10cSrcweir             log.println("Exception was expected");
875*cdf0e10cSrcweir             res &= false;
876*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
877*cdf0e10cSrcweir             log.println("Expected exception");
878*cdf0e10cSrcweir             res &= true;
879*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
880*cdf0e10cSrcweir             log.println("UnExpected exception");
881*cdf0e10cSrcweir             res &= false;
882*cdf0e10cSrcweir         }
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir         try {
885*cdf0e10cSrcweir             log.print("getTextAtIndex(chCount," +
886*cdf0e10cSrcweir                       " AccessibleTextType.WORD):");
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir             txt = oObj.getTextAtIndex(chCount, AccessibleTextType.WORD);
889*cdf0e10cSrcweir             log.println("'" + txt.SegmentText + "'");
890*cdf0e10cSrcweir             res &= compareLength(0,txt.SegmentText);
891*cdf0e10cSrcweir             if (!tEnv.getTestCase().getObjectName().equals("SmGraphicAccessible")) {
892*cdf0e10cSrcweir                 log.print("getTextAtIndex(1," +
893*cdf0e10cSrcweir                           " AccessibleTextType.PARAGRAPH):");
894*cdf0e10cSrcweir                 txt = oObj.getTextAtIndex(1, AccessibleTextType.PARAGRAPH);
895*cdf0e10cSrcweir                 log.println("'" + txt.SegmentText + "'");
896*cdf0e10cSrcweir                 res &= compareStrings(text,txt.SegmentText);
897*cdf0e10cSrcweir             }
898*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
899*cdf0e10cSrcweir             log.println("Unexpected exception");
900*cdf0e10cSrcweir             e.printStackTrace(log);
901*cdf0e10cSrcweir             res &= false;
902*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
903*cdf0e10cSrcweir             log.println("Unexpected exception");
904*cdf0e10cSrcweir             e.printStackTrace(log);
905*cdf0e10cSrcweir             res &= false;
906*cdf0e10cSrcweir         }
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir         tRes.tested("getTextAtIndex()", res);
909*cdf0e10cSrcweir     }
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir     /**
912*cdf0e10cSrcweir      * Calls the method with invalid parameters an with valid parameters,
913*cdf0e10cSrcweir      * checks returned values.
914*cdf0e10cSrcweir      * Has OK status if exception was thrown for invalid parameters,
915*cdf0e10cSrcweir      * if exception wasn't thrown for valid parameters and if returned values
916*cdf0e10cSrcweir      * are equal to corresponding substrings of the text received by relation.
917*cdf0e10cSrcweir      * The following method tests are to be executed before:
918*cdf0e10cSrcweir      * <ul>
919*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
920*cdf0e10cSrcweir      * </ul>
921*cdf0e10cSrcweir      */
922*cdf0e10cSrcweir     public void _getTextBeforeIndex() {
923*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
924*cdf0e10cSrcweir 		TextSegment txt = null;
925*cdf0e10cSrcweir         boolean res = true;
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir         try {
928*cdf0e10cSrcweir             log.print("getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH):");
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir             txt = oObj.getTextBeforeIndex(-1,
931*cdf0e10cSrcweir                                                       AccessibleTextType.PARAGRAPH);
932*cdf0e10cSrcweir             log.println("Exception was expected");
933*cdf0e10cSrcweir             res &= false;
934*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
935*cdf0e10cSrcweir             log.println("Expected exception");
936*cdf0e10cSrcweir             res &= true;
937*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
938*cdf0e10cSrcweir             log.println("UnExpected exception");
939*cdf0e10cSrcweir             res &= false;
940*cdf0e10cSrcweir         }
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir         try {
943*cdf0e10cSrcweir             log.print("getTextBeforeIndex(chCount+1, " +
944*cdf0e10cSrcweir                       "AccessibleTextType.PARAGRAPH):");
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir             txt = oObj.getTextBeforeIndex(chCount + 1,
947*cdf0e10cSrcweir                                                       AccessibleTextType.PARAGRAPH);
948*cdf0e10cSrcweir             log.println("Exception was expected");
949*cdf0e10cSrcweir             res &= false;
950*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
951*cdf0e10cSrcweir             log.println("Expected exception");
952*cdf0e10cSrcweir             res &= true;
953*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
954*cdf0e10cSrcweir             log.println("UnExpected exception");
955*cdf0e10cSrcweir             res &= true;
956*cdf0e10cSrcweir         }
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir         try {
959*cdf0e10cSrcweir             if (!tEnv.getTestCase().getObjectName().equals("SmGraphicAccessible")) {
960*cdf0e10cSrcweir                 log.print("getTextBeforeIndex(chCount," +
961*cdf0e10cSrcweir                           " AccessibleTextType.WORD):");
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir                 txt = oObj.getTextBeforeIndex(chCount,
964*cdf0e10cSrcweir                                                      AccessibleTextType.WORD);
965*cdf0e10cSrcweir                 log.println("'" + txt.SegmentText + "'");
966*cdf0e10cSrcweir                 res &= compareLength(chCount, txt.SegmentText);
967*cdf0e10cSrcweir             }
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir             log.print("getTextBeforeIndex(1," +
970*cdf0e10cSrcweir                       " AccessibleTextType.PARAGRAPH):");
971*cdf0e10cSrcweir             txt = oObj.getTextBeforeIndex(1, AccessibleTextType.PARAGRAPH);
972*cdf0e10cSrcweir             log.println("'" + txt.SegmentText + "'");
973*cdf0e10cSrcweir             res &= compareLength(0, txt.SegmentText);
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir             log.print("getTextBeforeIndex(chCount-1," +
976*cdf0e10cSrcweir                       " AccessibleTextType.CHARACTER):");
977*cdf0e10cSrcweir             txt = oObj.getTextBeforeIndex(chCount - 1,
978*cdf0e10cSrcweir                                           AccessibleTextType.CHARACTER);
979*cdf0e10cSrcweir             log.println("'" + txt.SegmentText + "'");
980*cdf0e10cSrcweir             res &= compareStrings(text.substring(chCount - 2, chCount - 1),
981*cdf0e10cSrcweir                                   txt.SegmentText);
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir             if (chCount > 2) {
984*cdf0e10cSrcweir                 log.print("getTextBeforeIndex(2," +
985*cdf0e10cSrcweir                           " AccessibleTextType.CHARACTER):");
986*cdf0e10cSrcweir                 txt = oObj.getTextBeforeIndex(2, AccessibleTextType.CHARACTER);
987*cdf0e10cSrcweir                 log.println("'" + txt.SegmentText + "'");
988*cdf0e10cSrcweir                 res &= compareStrings(text.substring(1, 2), txt.SegmentText);
989*cdf0e10cSrcweir             }
990*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
991*cdf0e10cSrcweir             log.println("Unexpected exception");
992*cdf0e10cSrcweir             e.printStackTrace(log);
993*cdf0e10cSrcweir             res &= false;
994*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
995*cdf0e10cSrcweir             log.println("Unexpected exception");
996*cdf0e10cSrcweir             e.printStackTrace(log);
997*cdf0e10cSrcweir             res &= false;
998*cdf0e10cSrcweir         }
999*cdf0e10cSrcweir 
1000*cdf0e10cSrcweir         tRes.tested("getTextBeforeIndex()", res);
1001*cdf0e10cSrcweir     }
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir     /**
1004*cdf0e10cSrcweir      * Calls the method with invalid parameters an with valid parameters,
1005*cdf0e10cSrcweir      * checks returned values.
1006*cdf0e10cSrcweir      * Has OK status if exception was thrown for invalid parameters,
1007*cdf0e10cSrcweir      * if exception wasn't thrown for valid parameters and if returned values
1008*cdf0e10cSrcweir      * are equal to corresponding substrings of the text received by relation.
1009*cdf0e10cSrcweir      * The following method tests are to be executed before:
1010*cdf0e10cSrcweir      * <ul>
1011*cdf0e10cSrcweir      *  <li> <code>getCharacterCount()</code> </li>
1012*cdf0e10cSrcweir      * </ul>
1013*cdf0e10cSrcweir      */
1014*cdf0e10cSrcweir     public void _getTextBehindIndex() {
1015*cdf0e10cSrcweir         requiredMethod("getCharacterCount()");
1016*cdf0e10cSrcweir 		TextSegment txt = null;
1017*cdf0e10cSrcweir         boolean res = true;
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir         try {
1020*cdf0e10cSrcweir             log.print("getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH):");
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir             txt = oObj.getTextBehindIndex(-1,
1023*cdf0e10cSrcweir                                                       AccessibleTextType.PARAGRAPH);
1024*cdf0e10cSrcweir             log.println("Exception was expected");
1025*cdf0e10cSrcweir             res &= false;
1026*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
1027*cdf0e10cSrcweir             log.println("Expected exception");
1028*cdf0e10cSrcweir             res &= true;
1029*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
1030*cdf0e10cSrcweir             log.println("UnExpected exception");
1031*cdf0e10cSrcweir             res &= true;
1032*cdf0e10cSrcweir         }
1033*cdf0e10cSrcweir 
1034*cdf0e10cSrcweir         try {
1035*cdf0e10cSrcweir             log.print("getTextBehindIndex(chCount+1, " +
1036*cdf0e10cSrcweir                       "AccessibleTextType.PARAGRAPH):");
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir             txt = oObj.getTextBehindIndex(chCount + 1,
1039*cdf0e10cSrcweir                                                       AccessibleTextType.PARAGRAPH);
1040*cdf0e10cSrcweir             log.println("Exception was expected");
1041*cdf0e10cSrcweir             res &= false;
1042*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
1043*cdf0e10cSrcweir             log.println("Expected exception");
1044*cdf0e10cSrcweir             res &= true;
1045*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
1046*cdf0e10cSrcweir             log.println("UnExpected exception");
1047*cdf0e10cSrcweir             res &= true;
1048*cdf0e10cSrcweir         }
1049*cdf0e10cSrcweir 
1050*cdf0e10cSrcweir         try {
1051*cdf0e10cSrcweir             log.print("getTextBehindIndex(chCount," +
1052*cdf0e10cSrcweir                       " AccessibleTextType.PARAGRAPH):");
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir             txt = oObj.getTextBehindIndex(chCount,
1055*cdf0e10cSrcweir                                                  AccessibleTextType.PARAGRAPH);
1056*cdf0e10cSrcweir             log.println("'" + txt.SegmentText + "'");
1057*cdf0e10cSrcweir             res &= (txt.SegmentText.length() == 0);
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir             log.print("getTextBehindIndex(chCount-1," +
1060*cdf0e10cSrcweir                       " AccessibleTextType.PARAGRAPH):");
1061*cdf0e10cSrcweir             txt = oObj.getTextBehindIndex(chCount - 1,
1062*cdf0e10cSrcweir                                           AccessibleTextType.PARAGRAPH);
1063*cdf0e10cSrcweir             log.println("'" + txt.SegmentText + "'");
1064*cdf0e10cSrcweir             res &= (txt.SegmentText.length() == 0);
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir             log.print("getTextBehindIndex(1," +
1067*cdf0e10cSrcweir                       " AccessibleTextType.CHARACTER):");
1068*cdf0e10cSrcweir             txt = oObj.getTextBehindIndex(1, AccessibleTextType.CHARACTER);
1069*cdf0e10cSrcweir             log.println("'" + txt.SegmentText + "'");
1070*cdf0e10cSrcweir             res &= txt.SegmentText.equals(text.substring(2, 3));
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir             if (chCount > 2) {
1073*cdf0e10cSrcweir                 log.print("getTextBehindIndex(chCount-2," +
1074*cdf0e10cSrcweir                           " AccessibleTextType.CHARACTER):");
1075*cdf0e10cSrcweir                 txt = oObj.getTextBehindIndex(chCount - 2,
1076*cdf0e10cSrcweir                                               AccessibleTextType.CHARACTER);
1077*cdf0e10cSrcweir                 log.println("'" + txt.SegmentText + "'");
1078*cdf0e10cSrcweir                 res &= txt.SegmentText.equals(text.substring(chCount - 1, chCount));
1079*cdf0e10cSrcweir             }
1080*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
1081*cdf0e10cSrcweir             log.println("Unexpected exception");
1082*cdf0e10cSrcweir             e.printStackTrace(log);
1083*cdf0e10cSrcweir             res &= false;
1084*cdf0e10cSrcweir         } catch (com.sun.star.lang.IllegalArgumentException e) {
1085*cdf0e10cSrcweir             log.println("Unexpected exception");
1086*cdf0e10cSrcweir             e.printStackTrace(log);
1087*cdf0e10cSrcweir             res &= false;
1088*cdf0e10cSrcweir         }
1089*cdf0e10cSrcweir 
1090*cdf0e10cSrcweir         tRes.tested("getTextBehindIndex()", res);
1091*cdf0e10cSrcweir     }
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir     /**
1094*cdf0e10cSrcweir      * Calls the method with invalid parameters an with valid parameter,
1095*cdf0e10cSrcweir      * checks returned values.
1096*cdf0e10cSrcweir      * Has OK status if exception was thrown for invalid parameters,
1097*cdf0e10cSrcweir      * if exception wasn't thrown for valid parameter and if returned value for
1098*cdf0e10cSrcweir      * valid parameter is equal to <code>true</code>.
1099*cdf0e10cSrcweir      */
1100*cdf0e10cSrcweir     public void _copyText() {
1101*cdf0e10cSrcweir         boolean res = true;
1102*cdf0e10cSrcweir         boolean locRes = true;
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir         if (editOnly != null) {
1105*cdf0e10cSrcweir             log.println(editOnly);
1106*cdf0e10cSrcweir             throw new StatusException(Status.skipped(true));
1107*cdf0e10cSrcweir         }
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir         try {
1110*cdf0e10cSrcweir             log.print("copyText(-1,chCount):");
1111*cdf0e10cSrcweir             oObj.copyText(-1, chCount);
1112*cdf0e10cSrcweir             log.println("Exception was expected");
1113*cdf0e10cSrcweir             res &= false;
1114*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
1115*cdf0e10cSrcweir             log.println("Expected exception");
1116*cdf0e10cSrcweir             res &= true;
1117*cdf0e10cSrcweir         }
1118*cdf0e10cSrcweir 
1119*cdf0e10cSrcweir         try {
1120*cdf0e10cSrcweir             log.print("copyText(0,chCount+1):");
1121*cdf0e10cSrcweir             oObj.copyText(0, chCount + 1);
1122*cdf0e10cSrcweir             log.println("Exception was expected");
1123*cdf0e10cSrcweir             res &= false;
1124*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
1125*cdf0e10cSrcweir             log.println("Expected exception");
1126*cdf0e10cSrcweir             res &= true;
1127*cdf0e10cSrcweir         }
1128*cdf0e10cSrcweir 
1129*cdf0e10cSrcweir         try {
1130*cdf0e10cSrcweir             log.print("copyText(0,chCount):");
1131*cdf0e10cSrcweir             locRes = oObj.copyText(0, chCount);
1132*cdf0e10cSrcweir             log.println(locRes);
1133*cdf0e10cSrcweir             res &= locRes;
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir             String cbText = null;
1136*cdf0e10cSrcweir 
1137*cdf0e10cSrcweir             try {
1138*cdf0e10cSrcweir                 cbText = util.SysUtils.getSysClipboardText((XMultiServiceFactory)tParam.getMSF());
1139*cdf0e10cSrcweir             } catch (com.sun.star.uno.Exception e) {
1140*cdf0e10cSrcweir                 log.println("Couldn't access system clipboard :");
1141*cdf0e10cSrcweir                 e.printStackTrace(log);
1142*cdf0e10cSrcweir             }
1143*cdf0e10cSrcweir 
1144*cdf0e10cSrcweir             log.println("Clipboard: '" + cbText + "'");
1145*cdf0e10cSrcweir             res &= text.equals(cbText);
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir             if (chCount > 2) {
1148*cdf0e10cSrcweir                 log.print("copyText(1,chCount-1):");
1149*cdf0e10cSrcweir                 locRes = oObj.copyText(1, chCount - 1);
1150*cdf0e10cSrcweir                 log.println(locRes);
1151*cdf0e10cSrcweir                 res &= locRes;
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir                 try {
1154*cdf0e10cSrcweir                     cbText = util.SysUtils.getSysClipboardText((XMultiServiceFactory)tParam.getMSF());
1155*cdf0e10cSrcweir                 } catch (com.sun.star.uno.Exception e) {
1156*cdf0e10cSrcweir                     log.println("Couldn't access system clipboard :");
1157*cdf0e10cSrcweir                     e.printStackTrace(log);
1158*cdf0e10cSrcweir                 }
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir                 log.println("Clipboard: '" + cbText + "'");
1161*cdf0e10cSrcweir                 res &= text.substring(1, chCount - 1).equals(cbText);
1162*cdf0e10cSrcweir             }
1163*cdf0e10cSrcweir         } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
1164*cdf0e10cSrcweir             log.println("Unexpected exception");
1165*cdf0e10cSrcweir             e.printStackTrace(log);
1166*cdf0e10cSrcweir             res &= false;
1167*cdf0e10cSrcweir         }
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir         tRes.tested("copyText()", res);
1170*cdf0e10cSrcweir     }
1171*cdf0e10cSrcweir 
1172*cdf0e10cSrcweir     public boolean compareStrings(String expected, String getting) {
1173*cdf0e10cSrcweir         boolean res = expected.equals(getting);
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir         if (!res) {
1176*cdf0e10cSrcweir             log.println("## The result isn't the expected:");
1177*cdf0e10cSrcweir             log.println("\tGetting: " + getting);
1178*cdf0e10cSrcweir             log.println("\tExpected: " + expected);
1179*cdf0e10cSrcweir         }
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir         return res;
1182*cdf0e10cSrcweir     }
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir     public boolean compareLength(int expected, String getting) {
1185*cdf0e10cSrcweir         boolean res = (expected == getting.length());
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir         if (!res) {
1188*cdf0e10cSrcweir             log.println("## The result isn't the expected:");
1189*cdf0e10cSrcweir             log.println("\tGetting: " + getting.length());
1190*cdf0e10cSrcweir             log.println("\tExpected: " + expected);
1191*cdf0e10cSrcweir         }
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir         return res;
1194*cdf0e10cSrcweir     }
1195*cdf0e10cSrcweir }