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