From 351a0743e9f9952d4e2596e040cfce6c41d77084 Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Tue, 24 Jul 2007 12:04:33 +0000 Subject: INTEGRATION: CWS complextest1 (1.1.2); FILE ADDED 2007/06/22 15:07:14 sg 1.1.2.1: #i78662# distributed tests for toolkit --- .../toolkit/interface_tests/_XAccessibleText.java | 1051 ++++++++++++++++++++ 1 file changed, 1051 insertions(+) create mode 100755 toolkit/qa/complex/toolkit/interface_tests/_XAccessibleText.java (limited to 'toolkit/qa') diff --git a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleText.java b/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleText.java new file mode 100755 index 000000000000..29f93ffe6aa6 --- /dev/null +++ b/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleText.java @@ -0,0 +1,1051 @@ +/************************************************************************* + * + * $RCSfile: _XAccessibleText.java,v $ + * + * $Revision: 1.2 $ + * + * last change:$Date: 2007-07-24 13:04:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package complex.toolkit.interface_tests; + +import com.sun.star.accessibility.XAccessibleText; +import lib.MultiMethodTest; +//import lib.StatusException; +//import lib.Status; +import com.sun.star.beans.PropertyValue; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.Point; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.accessibility.AccessibleTextType; +import com.sun.star.accessibility.TextSegment; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; +import share.LogWriter; + +/** + * Testing com.sun.star.accessibility.XAccessibleText + * interface methods : + *

+ * This test needs the following object relations : + *

+ * @see com.sun.star.accessibility.XAccessibleText + */ +public class _XAccessibleText { + + private LogWriter log; + + private static final String className = + "com.sun.star.accessibility.XAccessibleText" ; + + public XAccessibleText oObj = null; + private XMultiServiceFactory xMSF; + + Rectangle chBounds = null; + int chCount = 0; + + String text = null; + String editOnly = null; + + + public _XAccessibleText(XInterface object, LogWriter log, XMultiServiceFactory xMSF, String editOnly) { + oObj = (XAccessibleText)UnoRuntime.queryInterface( + XAccessibleText.class, object); + this.xMSF = xMSF; + this.log = log; + this.editOnly = editOnly; + } + + + /** + * Calls the method and checks returned value. + * Has OK status if returned value is equal to chCount - 1. + * The following method tests are to be executed before: + *

+ */ + public boolean _getCaretPosition() { + + if (editOnly != null) { + log.println(editOnly); + return true; + } + + boolean res = true; + if ( chCount > 0 ) { + try { + oObj.setCaretPosition(chCount - 1); + } catch (com.sun.star.lang.IndexOutOfBoundsException ie) { + + } + int carPos = oObj.getCaretPosition(); + log.println("getCaretPosition: " + carPos); + res = carPos == (chCount - 1); + } + return res; + } + + /** + * Calls the method with the wrong index and with the correct index + * chCount - 1. + * Has OK status if exception was thrown for wrong index and + * if exception wasn't thrown for the correct index. + * The following method tests are to be executed before: + * + */ + public boolean _setCaretPosition() { + boolean res = true; + + try { + log.println("setCaretPosition(-1):"); + oObj.setCaretPosition(-1); + res &= false; + log.println("exception was expected"); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("expected exception"); + res &= true; + } + + try { + log.println("setCaretPosition(chCount+1):"); + oObj.setCaretPosition(chCount+1); + res &= false; + log.println("exception was expected"); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("expected exception"); + res &= true; + } + if ( chCount > 0 ) { + try { + log.println("setCaretPosition(chCount - 1)"); + oObj.setCaretPosition(chCount - 1); + res &= true; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("unexpected exception"); + e.printStackTrace(); + res &= false; + } + } + + return res; + } + + /** + * Calls the method with the wrong index and with the correct indexes. + * Checks every character in the text. + * Has OK status if exception was thrown for wrong index, + * if exception wasn't thrown for the correct index and + * if every character is equal to corresponding character in the text. + * The following method tests are to be executed before: + * + */ + public boolean _getCharacter() { + boolean res = true; + + try { + log.println("getCharacter(-1)"); + oObj.getCharacter(-1); + log.println("Exception was expected"); + res = false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res = true; + } + + try { + log.println("getCharacter(chCount)"); + oObj.getCharacter(chCount); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("Checking of every character in the text..."); + boolean isEqCh = true; + for(int i = 0; i < chCount; i++) { + char ch = oObj.getCharacter(i); + isEqCh = ch == text.charAt(i); + res &= isEqCh; + if (!isEqCh) { + log.println("At the position " + i + + "was expected character: " + text.charAt(i)); + log.println("but was returned: " + ch); + break; + } + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Calls the method with the wrong indexes and with the correct index, + * checks a returned value. + * Has OK status if exception was thrown for the wrong indexes, + * if exception wasn't thrown for the correct index and + * if returned value isn't null. + * The following method tests are to be executed before: + * + */ + public boolean _getCharacterAttributes() { + boolean res = true; + + try { + log.println("getCharacterAttributes(-1)"); + oObj.getCharacterAttributes(-1, new String[0]); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("getCharacterAttributes(chCount)"); + oObj.getCharacterAttributes(chCount, new String[0]); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + if ( chCount > 0 ) { + log.println("getCharacterAttributes(chCount-1)"); + PropertyValue[] props = oObj.getCharacterAttributes(chCount - 1, new String[0]); + res &= props != null; + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + + /** + * Calls the method with the wrong indexes and with the correct index. + * checks and stores a returned value. + * Has OK status if exception was thrown for the wrong indexes, + * if exception wasn't thrown for the correct index and + * if returned value isn't null. + * The following method tests are to be executed before: + * + */ + public boolean _getCharacterBounds() { + boolean res = true; + + try { + log.println("getCharacterBounds(-1)"); + oObj.getCharacterBounds(-1); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("getCharacterBounds(chCount)"); + oObj.getCharacterBounds(chCount); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + if (chCount > 0) { + log.println("getCharacterBounds(chCount-1)"); + chBounds = oObj.getCharacterBounds(chCount-1); + res &= chBounds != null; + log.println("rect: " + chBounds.X + ", " + chBounds.Y + ", " + + chBounds.Width + ", " + chBounds.Height); + } + + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + + /** + * Calls the method and stores a returned value to the variable + * chCount. + * Has OK status if a returned value is equal to the text length. + */ + public boolean _getCharacterCount() { + chCount = oObj.getCharacterCount(); + log.println("Character count:" + chCount); + boolean res = chCount == text.length(); + return res; + } + + /** + * Calls the method for an invalid point and for the point of rectangle + * returned by the method getCharacterBounds(). + * Has OK status if returned value is equal to -1 for an + * invalid point and if returned value is equal to chCount-1 + * for a valid point. + * The following method tests are to be executed before: + * + */ + public boolean _getIndexAtPoint() { + + boolean res = true; + log.println("getIndexAtPoint(-1, -1):"); + Point pt = new Point(-1, -1); + int index = oObj.getIndexAtPoint(pt); + log.println(Integer.toString(index)); + res &= index == -1; + + if (chBounds != null) { + pt = new Point(chBounds.X , chBounds.Y ); + log.println("getIndexAtPoint(" + pt.X + ", " + pt.Y + "):"); + index = oObj.getIndexAtPoint(pt); + log.println(Integer.toString(index)); + res &= index == (chCount - 1); + } + + return res; + } + + /** + * Checks a returned values after different calls of the method + * setSelection(). + * The following method tests are to be executed before: + * + */ + public boolean _getSelectedText() { + if (editOnly != null) { + log.println(editOnly); + return true; + } + + boolean res = true; + + try { + log.println("setSelection(0, 0)"); + oObj.setSelection(0, 0); + log.println("getSelectedText():"); + String txt = oObj.getSelectedText(); + log.println("'" + txt + "'"); + res &= txt.length() == 0; + + log.println("setSelection(0, chCount)"); + oObj.setSelection(0, chCount); + log.println("getSelectedText():"); + txt = oObj.getSelectedText(); + log.println("'" + txt + "'"); + res &= txt.equals(text); + + if (chCount > 2) { + log.println("setSelection(1, chCount-1)"); + oObj.setSelection(1, chCount - 1); + log.println("getSelectedText():"); + txt = oObj.getSelectedText(); + log.println("'" + txt + "'"); + res &= txt.equals(text.substring(1, chCount - 1)); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Checks a returned values after different calls of the method + * setSelection(). + * The following method tests are to be executed before: + * + */ + public boolean _getSelectionStart() { + if (editOnly != null) { + log.println(editOnly); + return true; + } + + boolean res = true; + + try { + log.println("setSelection(0, chCount)"); + oObj.setSelection(0, chCount); + int start = oObj.getSelectionStart(); + log.println("getSelectionStart():" + start); + res &= start == 0; + + if (chCount > 2) { + log.println("setSelection(1, chCount-1)"); + oObj.setSelection(1, chCount - 1); + start = oObj.getSelectionStart(); + log.println("getSelectionStart():" + start); + res &= start == 1; + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Checks a returned values after different calls of the method + * setSelection(). + * The following method tests are to be executed before: + * + */ + public boolean _getSelectionEnd() { + if (editOnly != null) { + log.println(editOnly); + return true; + } + + boolean res = true; + + try { + log.println("setSelection(0, chCount)"); + oObj.setSelection(0, chCount); + int end = oObj.getSelectionEnd(); + log.println("getSelectionEnd():" + end); + res &= end == chCount; + + if (chCount > 2) { + log.println("setSelection(1, chCount-1)"); + oObj.setSelection(1, chCount - 1); + end = oObj.getSelectionEnd(); + log.println("getSelectionEnd():" + end); + res &= end == chCount - 1; + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Calls the method with invalid parameters an with valid parameters. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters. + * The following method tests are to be executed before: + * + */ + public boolean _setSelection() { + boolean res = true; + boolean locRes = true; + + if (editOnly != null) { + log.println(editOnly); + return true; + } + + try { + log.println("setSelection(-1, chCount-1):"); + locRes = oObj.setSelection(-1, chCount - 1); + log.println(locRes + " exception was expected"); + res &= !locRes; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("setSelection(0, chCount+1):"); + locRes = oObj.setSelection(0, chCount + 1); + log.println(locRes + " excepion was expected"); + res &= !locRes; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + if (chCount > 2) { + log.println("setSelection(1, chCount-1):"); + locRes = oObj.setSelection(1, chCount - 1); + log.println(Boolean.toString(locRes)); + res &= locRes; + + log.println("setSelection(chCount-1, 1):"); + locRes = oObj.setSelection(chCount - 1, 1); + log.println(Boolean.toString(locRes)); + res &= locRes; + } + + if (chCount > 1) { + log.println("setSelection(0, chCount-1):"); + locRes = oObj.setSelection(0, chCount-1); + log.println(Boolean.toString(locRes)); + res &= locRes; + + log.println("setSelection(chCount-1, 0):"); + locRes = oObj.setSelection(chCount-1, 0); + log.println(Boolean.toString(locRes)); + res &= locRes; + } + + log.println("setSelection(0, 0):"); + locRes = oObj.setSelection(0, 0); + log.println(Boolean.toString(locRes)); + res &= locRes; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } + + /** + * Calls the method and checks returned value. + * Has OK status if returned string is not null + * received from relation. + */ + public boolean _getText() { + text = oObj.getText(); + log.println("getText: '" + text + "'"); + return (text != null); + } + + /** + * Calls the method with invalid parameters an with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + * + */ + public boolean _getTextRange() { + boolean res = true; + boolean locRes = true; + + try { + if (chCount > 3) { + log.println("getTextRange(1, chCount - 2): "); + String txtRange = oObj.getTextRange(1, chCount - 2); + log.println(txtRange); + locRes = txtRange.equals(text.substring(1, chCount - 2)); + res &= locRes; + if (!locRes) { + log.println("Was expected: " + + text.substring(1, chCount - 2)); + } + } + + if (chCount > 0) { + log.println("getTextRange(0, chCount-1): "); + String txtRange = oObj.getTextRange(0, chCount-1); + log.println(txtRange); + locRes = txtRange.equals(text.substring(0, chCount - 1)); + res &= locRes; + if (!locRes) { + log.println("Was expected: " + + text.substring(0, chCount - 1)); + } + + log.println("getTextRange(chCount, 0): "); + txtRange = oObj.getTextRange(chCount, 0); + log.println(txtRange); + res &= txtRange.equals(text); + + log.println("getTextRange(0, 0): "); + txtRange = oObj.getTextRange(0, 0); + log.println(txtRange); + locRes = txtRange.equals(""); + res &= locRes; + if (!locRes) { + log.println("Empty string was expected"); + } + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + try { + log.println("getTextRange(-1, chCount - 1): "); + String txtRange = oObj.getTextRange(-1, chCount - 1); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("getTextRange(0, chCount + 1): "); + String txtRange = oObj.getTextRange(0, chCount + 1); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("getTextRange(chCount+1, -1): "); + String txtRange = oObj.getTextRange(chCount+1, -1); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + return res; + } + + /** + * Calls the method with invalid parameters an with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + * + */ + public boolean _getTextAtIndex() { + boolean res = true; + + try { + log.println("getTextAtIndex(-1, AccessibleTextType.PARAGRAPH):"); + TextSegment txt = + oObj.getTextAtIndex(-1, AccessibleTextType.PARAGRAPH); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("getTextAtIndex(chCount+1," + + " AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextAtIndex(chCount + 1, + AccessibleTextType.PARAGRAPH); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception"); + res &= true; + } + + + try { + if ( chCount > 0 ) { + log.println("getTextAtIndex(chCount," + + " AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextAtIndex(chCount, + AccessibleTextType.PARAGRAPH); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + + log.println("getTextAtIndex(1," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextAtIndex(1, + AccessibleTextType.PARAGRAPH); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected exception"); + res &= false; + } + + + return res; + } + + /** + * Calls the method with invalid parameters an with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + * + */ + public boolean _getTextBeforeIndex() { + boolean res = true; + + try { + log.println("getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextBeforeIndex(-1, + AccessibleTextType.PARAGRAPH); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception"); + res &= true; + } + + + try { + log.println("getTextBeforeIndex(chCount+1, " + + "AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextBeforeIndex(chCount + 1, + AccessibleTextType.PARAGRAPH); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception"); + res &= true; + } + + TextSegment txt = null; + try { + if (chCount > 0) { + log.println("getTextBeforeIndex(chCount," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextBeforeIndex(chCount, + AccessibleTextType.PARAGRAPH); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == chCount ; + + log.println("getTextBeforeIndex(1," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextBeforeIndex(1, + AccessibleTextType.PARAGRAPH); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + } + + if (chCount > 2) { + log.println("getTextBeforeIndex(chCount-1," + + " AccessibleTextType.CHARACTER):"); + txt = oObj.getTextBeforeIndex(chCount - 1, + AccessibleTextType.CHARACTER); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(chCount - 2, chCount - 1)); + log.println("getTextBeforeIndex(2," + + " AccessibleTextType.CHARACTER):"); + txt = oObj.getTextBeforeIndex(2, + AccessibleTextType.CHARACTER); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(1, 2)); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected exception"); + res &= false; + } + + + return res; + } + + /** + * Calls the method with invalid parameters an with valid parameters, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameters and if returned values + * are equal to corresponding substrings of the text received by relation. + * The following method tests are to be executed before: + * + */ + public boolean _getTextBehindIndex() { + boolean res = true; + + try { + log.println("getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextBehindIndex(-1, + AccessibleTextType.PARAGRAPH); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception"); + res &= true; + } + + + try { + log.println("getTextBehindIndex(chCount+1, " + + "AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextBehindIndex(chCount + 1, + AccessibleTextType.PARAGRAPH); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception"); + res &= true; + } + + + try { + if ( chCount > 0 ) { + log.println("getTextBehindIndex(chCount," + + " AccessibleTextType.PARAGRAPH):"); + TextSegment txt = oObj.getTextBehindIndex(chCount, + AccessibleTextType.PARAGRAPH); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + + log.println("getTextBehindIndex(chCount-1," + + " AccessibleTextType.PARAGRAPH):"); + txt = oObj.getTextBehindIndex(chCount - 1, + AccessibleTextType.PARAGRAPH); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.length() == 0; + } + if ( chCount > 1 ) { + log.println("getTextBehindIndex(1," + + " AccessibleTextType.CHARACTER):"); + TextSegment txt = oObj.getTextBehindIndex(1, + AccessibleTextType.CHARACTER); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(2, 3)); + } + if (chCount > 2) { + log.println("getTextBehindIndex(chCount-2," + + " AccessibleTextType.CHARACTER):"); + TextSegment txt = oObj.getTextBehindIndex(chCount - 2, + AccessibleTextType.CHARACTER); + log.println("'" + txt.SegmentText + "'"); + res &= txt.SegmentText.equals(text.substring(chCount - 1, chCount)); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected exception"); + res &= false; + } + + + return res; + } + + /** + * Calls the method with invalid parameters an with valid parameter, + * checks returned values. + * Has OK status if exception was thrown for invalid parameters, + * if exception wasn't thrown for valid parameter and if returned value for + * valid parameter is equal to true. + */ + public boolean _copyText() { + boolean res = true; + boolean locRes = true; + + if (editOnly != null) { + log.println(editOnly); + return true; + } + + try { + log.println("copyText(-1,chCount):"); + oObj.copyText(-1, chCount); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("copyText(0,chCount+1):"); + oObj.copyText(0, chCount + 1); + log.println("Exception was expected"); + res &= false; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Expected exception"); + res &= true; + } + + try { + log.println("copyText(0,chCount):"); + locRes = oObj.copyText(0, chCount); + log.println(""+locRes); + res &= locRes; + + String cbText = null; + try { + cbText = + util.SysUtils.getSysClipboardText(xMSF); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't access system clipboard :"); + e.printStackTrace(); + } + log.println("Clipboard: '" + cbText + "'"); + res &= text.equals(cbText); + + if (chCount > 2) { + log.println("copyText(1,chCount-1):"); + locRes = oObj.copyText(1, chCount - 1); + log.println(""+locRes); + res &= locRes; + + try { + cbText = util.SysUtils.getSysClipboardText(xMSF); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't access system clipboard :"); + e.printStackTrace(); + } + + log.println("Clipboard: '" + cbText + "'"); + res &= text.substring(1, chCount - 1).equals(cbText); + } + + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(); + res &= false; + } + + return res; + } +} -- cgit