summaryrefslogtreecommitdiff
path: root/qadevOOo/tests/java/ifc/accessibility
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2003-09-08 09:06:15 +0000
committerRüdiger Timm <rt@openoffice.org>2003-09-08 09:06:15 +0000
commit424d032d6ef76fecd2647160f7a04c9cbd92d877 (patch)
tree938eaad1f4eabe6c9026bcf346c5755c60a96b22 /qadevOOo/tests/java/ifc/accessibility
parent9ba1924f5babfece097c292ed12a1520ddaac75e (diff)
INTEGRATION: CWS qadev11 (1.13.14); FILE MERGED
2003/09/03 14:58:01 sw 1.13.14.1: #112049#
Diffstat (limited to 'qadevOOo/tests/java/ifc/accessibility')
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java476
1 files changed, 270 insertions, 206 deletions
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java
index 41318569aae5..e4c714a57587 100644
--- a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java
@@ -2,9 +2,9 @@
*
* $RCSfile: _XAccessibleText.java,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change:$Date: 2003-05-28 10:03:34 $
+ * last change:$Date: 2003-09-08 10:06:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,21 +58,22 @@
*
*
************************************************************************/
-
package ifc.accessibility;
-import com.sun.star.accessibility.XAccessibleText;
-import com.sun.star.accessibility.XAccessibleComponent;
import lib.MultiMethodTest;
-import lib.StatusException;
import lib.Status;
-import com.sun.star.beans.PropertyValue;
-import com.sun.star.awt.Rectangle;
+import lib.StatusException;
+
+import com.sun.star.accessibility.AccessibleTextType;
+import com.sun.star.accessibility.TextSegment;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleText;
import com.sun.star.awt.Point;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.beans.PropertyValue;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.accessibility.AccessibleTextType;
-import com.sun.star.accessibility.TextSegment;
+
/**
* Testing <code>com.sun.star.accessibility.XAccessibleText</code>
@@ -109,20 +110,14 @@ import com.sun.star.accessibility.TextSegment;
*/
public class _XAccessibleText extends MultiMethodTest {
- private static final String className =
- "com.sun.star.accessibility.XAccessibleText" ;
-
public XAccessibleText oObj = null;
protected com.sun.star.awt.Rectangle bounds = null;
-
- // temporary while accessibility package is in com.sun.star
- protected String getTestedClassName() {
- return className;
- }
-
String text = null;
String editOnly = null;
Object LimitedBounds = null;
+ Rectangle chBounds = null;
+ int chCount = 0;
+
/**
* Retrieves a string representation of the component's text.
@@ -134,28 +129,30 @@ public class _XAccessibleText extends MultiMethodTest {
XAccessibleComponent component = null;
if (xat != null) {
- oObj = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, xat);
- component = (XAccessibleComponent)
- UnoRuntime.queryInterface(
- XAccessibleComponent.class, xat);
+ oObj = (XAccessibleText) UnoRuntime.queryInterface(
+ XAccessibleText.class, xat);
+ component = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xat);
}
- text = (String)tEnv.getObjRelation("XAccessibleText.Text");
+ text = (String) tEnv.getObjRelation("XAccessibleText.Text");
+
if (text == null) {
text = oObj.getText();
}
+
if (text.length() == 0) {
throw new StatusException(Status.failed(
- "The length of text must be greater than zero"));
+ "The length of text must be greater than zero"));
}
- editOnly = (String)tEnv.getObjRelation("EditOnly");
+ editOnly = (String) tEnv.getObjRelation("EditOnly");
LimitedBounds = tEnv.getObjRelation("LimitedBounds");
if (component == null) {
- component = (XAccessibleComponent)
- UnoRuntime.queryInterface(
- XAccessibleComponent.class, tEnv.getTestObject());
+ component = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class,
+ tEnv.getTestObject());
}
bounds = component.getBounds();
@@ -182,19 +179,23 @@ public class _XAccessibleText extends MultiMethodTest {
boolean res = true;
boolean sc = true;
+
try {
oObj.setCaretPosition(chCount - 1);
} catch (com.sun.star.lang.IndexOutOfBoundsException ie) {
-
}
+
int carPos = oObj.getCaretPosition();
log.println("getCaretPosition: " + carPos);
+
if (sc) {
res = carPos == (chCount - 1);
} else {
- log.println("Object is read only and Caret position couldn't be set");
+ log.println(
+ "Object is read only and Caret position couldn't be set");
res = carPos == -1;
}
+
tRes.tested("getCaretPosition()", res);
}
@@ -210,6 +211,7 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _setCaretPosition() {
requiredMethod("getCharacterCount()");
+
boolean res = true;
try {
@@ -217,17 +219,17 @@ public class _XAccessibleText extends MultiMethodTest {
oObj.setCaretPosition(-1);
res &= false;
log.println("exception was expected");
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("expected exception");
res &= true;
}
try {
log.print("setCaretPosition(chCount+1):");
- oObj.setCaretPosition(chCount+1);
+ oObj.setCaretPosition(chCount + 1);
res &= false;
log.println("exception was expected");
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("expected exception");
res &= true;
}
@@ -236,7 +238,7 @@ public class _XAccessibleText extends MultiMethodTest {
log.println("setCaretPosition(chCount - 1)");
oObj.setCaretPosition(chCount - 1);
res &= true;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -258,6 +260,7 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getCharacter() {
requiredMethod("getCharacterCount()");
+
boolean res = true;
try {
@@ -265,7 +268,7 @@ public class _XAccessibleText extends MultiMethodTest {
oObj.getCharacter(-1);
log.println("Exception was expected");
res = false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res = true;
}
@@ -275,26 +278,30 @@ public class _XAccessibleText extends MultiMethodTest {
oObj.getCharacter(chCount);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } 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++) {
+
+ 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));
+ "was expected character: " + text.charAt(i));
log.println("but was returned: " + ch);
+
break;
}
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -316,34 +323,37 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getCharacterAttributes() {
requiredMethod("getCharacterCount()");
+
boolean res = true;
- String[] attr = new String[] {""};
+ String[] attr = new String[] { "" };
try {
log.println("getCharacterAttributes(-1)");
- oObj.getCharacterAttributes(-1,attr);
+ oObj.getCharacterAttributes(-1, attr);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
try {
log.println("getCharacterAttributes(chCount)");
- oObj.getCharacterAttributes(chCount,attr);
+ oObj.getCharacterAttributes(chCount, attr);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
try {
log.println("getCharacterAttributes(chCount-1)");
- PropertyValue[] props = oObj.getCharacterAttributes(chCount - 1,attr);
- res &= props != null;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+
+ PropertyValue[] props = oObj.getCharacterAttributes(chCount - 1,
+ attr);
+ res &= (props != null);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -352,8 +362,6 @@ public class _XAccessibleText extends MultiMethodTest {
tRes.tested("getCharacterAttributes()", res);
}
- Rectangle chBounds = null;
-
/**
* Calls the method with the wrong indexes and with the correct index.
* checks and stores a returned value.
@@ -367,61 +375,66 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getCharacterBounds() {
requiredMethod("getCharacterCount()");
+
boolean res = true;
int lastIndex = chCount;
if (LimitedBounds != null) {
- if ( LimitedBounds instanceof Integer) {
+ if (LimitedBounds instanceof Integer) {
lastIndex = ((Integer) LimitedBounds).intValue();
} else {
lastIndex = chCount - 1;
}
+
log.println(LimitedBounds);
}
-
try {
log.println("getCharacterBounds(-1)");
oObj.getCharacterBounds(-1);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
try {
- log.println("getCharacterBounds("+(lastIndex+1)+")");
- oObj.getCharacterBounds(lastIndex+1);
+ log.println("getCharacterBounds(" + (lastIndex + 1) + ")");
+ oObj.getCharacterBounds(lastIndex + 1);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
try {
- for ( int i = 0; i < lastIndex+1 ; i++ ) {
- log.println("getCharacterBounds("+i+")");
+ for (int i = 0; i < (lastIndex + 1); i++) {
+ log.println("getCharacterBounds(" + i + ")");
chBounds = oObj.getCharacterBounds(i);
+
boolean localres = true;
localres = chBounds.X >= 0;
- localres &= chBounds.Y >= 0;
- localres &= chBounds.X + chBounds.Width <= bounds.Width;
- localres &= chBounds.X + chBounds.Width > 0;
- localres &= chBounds.Y + chBounds.Height <= bounds.Height;
- localres &= chBounds.Y + chBounds.Height > 0;
- if (! localres) {
+ localres &= (chBounds.Y >= 0);
+ localres &= ((chBounds.X + chBounds.Width) <= bounds.Width);
+ localres &= ((chBounds.X + chBounds.Width) > 0);
+ localres &= ((chBounds.Y + chBounds.Height) <= bounds.Height);
+ localres &= ((chBounds.Y + chBounds.Height) > 0);
+
+ if (!localres) {
log.println("Character bounds outside component");
log.println("Character rect: " + chBounds.X + ", " +
- chBounds.Y + ", " + chBounds.Width + ", " + chBounds.Height);
- log.println("Component rect: " + bounds.X + ", " + bounds.Y + ", " +
- bounds.Width + ", " + bounds.Height);
+ chBounds.Y + ", " + chBounds.Width + ", " +
+ chBounds.Height);
+ log.println("Component rect: " + bounds.X + ", " +
+ bounds.Y + ", " + bounds.Width + ", " +
+ bounds.Height);
res &= localres;
}
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -430,8 +443,6 @@ public class _XAccessibleText extends MultiMethodTest {
tRes.tested("getCharacterBounds()", res);
}
- int chCount = 0;
-
/**
* Calls the method and stores a returned value to the variable
* <code>chCount</code>.
@@ -440,6 +451,7 @@ public class _XAccessibleText extends MultiMethodTest {
public void _getCharacterCount() {
chCount = oObj.getCharacterCount();
log.println("Character count:" + chCount);
+
boolean res = chCount == text.length();
tRes.tested("getCharacterCount()", res);
}
@@ -457,58 +469,59 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getIndexAtPoint() {
//requiredMethod("getCharacterBounds()");
-
boolean res = true;
log.print("getIndexAtPoint(-1, -1):");
+
Point pt = new Point(-1, -1);
int index = oObj.getIndexAtPoint(pt);
log.println(index);
- res &= index == -1;
+ res &= (index == -1);
int lastIndex = chCount;
if (LimitedBounds != null) {
- if ( LimitedBounds instanceof Integer) {
+ if (LimitedBounds instanceof Integer) {
lastIndex = ((Integer) LimitedBounds).intValue();
} else {
lastIndex = chCount - 1;
}
+
log.println(LimitedBounds);
}
- for ( int i = 0; i < lastIndex ; i++ )
- {
+ for (int i = 0; i < lastIndex; i++) {
Rectangle aRect = null;
- String text="empty";
- try {
- aRect = oObj.getCharacterBounds( i );
- text = oObj.getTextAtIndex(i,(short)1).SegmentText;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
-
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ String text = "empty";
+ try {
+ aRect = oObj.getCharacterBounds(i);
+ text = oObj.getTextAtIndex(i, (short) 1).SegmentText;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
}
- int x = aRect.X+aRect.Width/2;
- int y = aRect.Y+aRect.Height/2;
- Point aPoint = new Point( x,y);
- int nIndex = oObj.getIndexAtPoint( aPoint );
+
+ int x = aRect.X + (aRect.Width / 2);
+ int y = aRect.Y + (aRect.Height / 2);
+ Point aPoint = new Point(x, y);
+ int nIndex = oObj.getIndexAtPoint(aPoint);
int[] previous = (int[]) tEnv.getObjRelation("PreviousUsed");
+
if (previous != null) {
- for (int k=0;k<previous.length;k++) {
- if (i==previous[k]) {
+ for (int k = 0; k < previous.length; k++) {
+ if (i == previous[k]) {
nIndex++;
}
}
}
- if ( nIndex != i )
- {
- log.println("## Method didn't work for Point ("+x+","+y+")");
- log.println("Expected Index "+i);
- log.println("Gained Index: "+nIndex);
- log.println("CharacterAtIndex: "+text);
- res &= false;
+ if (nIndex != i) {
+ log.println("## Method didn't work for Point (" + x + "," + y +
+ ")");
+ log.println("Expected Index " + i);
+ log.println("Gained Index: " + nIndex);
+ log.println("CharacterAtIndex: " + text);
+ res &= false;
}
}
@@ -530,15 +543,17 @@ public class _XAccessibleText extends MultiMethodTest {
}
requiredMethod("setSelection()");
+
boolean res = true;
try {
log.println("setSelection(0, 0)");
oObj.setSelection(0, 0);
log.print("getSelectedText():");
+
String txt = oObj.getSelectedText();
log.println("'" + txt + "'");
- res &= txt.length() == 0;
+ res &= (txt.length() == 0);
log.println("setSelection(0, chCount)");
oObj.setSelection(0, chCount);
@@ -555,7 +570,7 @@ public class _XAccessibleText extends MultiMethodTest {
log.println("'" + txt + "'");
res &= txt.equals(text.substring(1, chCount - 1));
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -579,23 +594,25 @@ public class _XAccessibleText extends MultiMethodTest {
}
requiredMethod("setSelection()");
+
boolean res = true;
try {
log.println("setSelection(0, chCount)");
oObj.setSelection(0, chCount);
+
int start = oObj.getSelectionStart();
log.println("getSelectionStart():" + start);
- res &= start == 0;
+ 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;
+ res &= (start == 1);
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -619,23 +636,25 @@ public class _XAccessibleText extends MultiMethodTest {
}
requiredMethod("setSelection()");
+
boolean res = true;
try {
log.println("setSelection(0, chCount)");
oObj.setSelection(0, chCount);
+
int end = oObj.getSelectionEnd();
log.println("getSelectionEnd():" + end);
- res &= end == chCount;
+ 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;
+ res &= (end == (chCount - 1));
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -655,6 +674,7 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _setSelection() {
requiredMethod("getCharacterCount()");
+
boolean res = true;
boolean locRes = true;
@@ -668,7 +688,7 @@ public class _XAccessibleText extends MultiMethodTest {
locRes = oObj.setSelection(-1, chCount - 1);
log.println(locRes + " excepion was expected");
res &= !locRes;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
@@ -678,7 +698,7 @@ public class _XAccessibleText extends MultiMethodTest {
locRes = oObj.setSelection(0, chCount + 1);
log.println(locRes + " excepion was expected");
res &= !locRes;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
@@ -697,12 +717,12 @@ public class _XAccessibleText extends MultiMethodTest {
}
log.print("setSelection(0, chCount-1):");
- locRes = oObj.setSelection(0, chCount-1);
+ locRes = oObj.setSelection(0, chCount - 1);
log.println(locRes);
res &= locRes;
log.print("setSelection(chCount-1, 0):");
- locRes = oObj.setSelection(chCount-1, 0);
+ locRes = oObj.setSelection(chCount - 1, 0);
log.println(locRes);
res &= locRes;
@@ -710,7 +730,7 @@ public class _XAccessibleText extends MultiMethodTest {
locRes = oObj.setSelection(0, 0);
log.println(locRes);
res &= locRes;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -727,6 +747,7 @@ public class _XAccessibleText extends MultiMethodTest {
public void _getText() {
String txt = oObj.getText();
log.println("getText: " + txt);
+
boolean res = txt.equals(text);
tRes.tested("getText()", res);
}
@@ -744,30 +765,37 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getTextRange() {
requiredMethod("getCharacterCount()");
+
boolean res = true;
boolean locRes = true;
+ String txtRange = "";
+
try {
if (chCount > 3) {
log.print("getTextRange(1, chCount - 2): ");
- String txtRange = oObj.getTextRange(1, chCount - 2);
+
+ 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));
+ text.substring(1, chCount - 2));
}
}
log.print("getTextRange(0, chCount-1): ");
- String txtRange = oObj.getTextRange(0, chCount-1);
+
+ 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));
+ text.substring(0, chCount - 1));
}
log.print("getTextRange(chCount, 0): ");
@@ -780,10 +808,11 @@ public class _XAccessibleText extends MultiMethodTest {
log.println(txtRange);
locRes = txtRange.equals("");
res &= locRes;
+
if (!locRes) {
log.println("Empty string was expected");
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -791,30 +820,33 @@ public class _XAccessibleText extends MultiMethodTest {
try {
log.print("getTextRange(-1, chCount - 1): ");
- String txtRange = oObj.getTextRange(-1, chCount - 1);
+
+ txtRange = oObj.getTextRange(-1, chCount - 1);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
try {
log.print("getTextRange(0, chCount + 1): ");
- String txtRange = oObj.getTextRange(0, chCount + 1);
+
+ txtRange = oObj.getTextRange(0, chCount + 1);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
try {
log.print("getTextRange(chCount+1, -1): ");
- String txtRange = oObj.getTextRange(chCount+1, -1);
+
+ txtRange = oObj.getTextRange(chCount + 1, -1);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
@@ -835,55 +867,58 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getTextAtIndex() {
requiredMethod("getCharacterCount()");
+ TextSegment txt = null;
boolean res = true;
try {
log.print("getTextAtIndex(-1, AccessibleTextType.PARAGRAPH):");
- TextSegment txt = oObj.getTextAtIndex(-1, AccessibleTextType.PARAGRAPH);
+
+ txt = oObj.getTextAtIndex(-1,
+ AccessibleTextType.PARAGRAPH);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("UnExpected exception");
res &= false;
}
try {
log.print("getTextAtIndex(chCount+1," +
- " AccessibleTextType.PARAGRAPH):");
- TextSegment txt = oObj.getTextAtIndex(chCount + 1,
- AccessibleTextType.PARAGRAPH);
+ " AccessibleTextType.PARAGRAPH):");
+
+ txt = oObj.getTextAtIndex(chCount + 1,
+ AccessibleTextType.PARAGRAPH);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("UnExpected exception");
res &= false;
}
try {
log.print("getTextAtIndex(chCount," +
- " AccessibleTextType.PARAGRAPH):");
- String txt = oObj.getTextAtIndex(chCount,
- AccessibleTextType.PARAGRAPH).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.length() == 0;
+ " AccessibleTextType.WORD):");
+
+ txt = oObj.getTextAtIndex(chCount, AccessibleTextType.WORD);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareLength(0,txt.SegmentText);
log.print("getTextAtIndex(1," +
- " AccessibleTextType.PARAGRAPH):");
- txt = oObj.getTextAtIndex(1,
- AccessibleTextType.PARAGRAPH).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.equals(text);
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ " AccessibleTextType.PARAGRAPH):");
+ txt = oObj.getTextAtIndex(1, AccessibleTextType.PARAGRAPH);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareStrings(text,txt.SegmentText);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -905,78 +940,80 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getTextBeforeIndex() {
requiredMethod("getCharacterCount()");
+ TextSegment txt = null;
boolean res = true;
try {
log.print("getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH):");
- TextSegment txt = oObj.getTextBeforeIndex(-1,
- AccessibleTextType.PARAGRAPH);
+
+ txt = oObj.getTextBeforeIndex(-1,
+ AccessibleTextType.PARAGRAPH);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("UnExpected exception");
res &= false;
}
try {
log.print("getTextBeforeIndex(chCount+1, " +
- "AccessibleTextType.PARAGRAPH):");
- TextSegment txt = oObj.getTextBeforeIndex(chCount + 1,
- AccessibleTextType.PARAGRAPH);
+ "AccessibleTextType.PARAGRAPH):");
+
+ txt = oObj.getTextBeforeIndex(chCount + 1,
+ AccessibleTextType.PARAGRAPH);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("UnExpected exception");
res &= true;
}
try {
log.print("getTextBeforeIndex(chCount," +
- " AccessibleTextType.PARAGRAPH):");
- String txt = oObj.getTextBeforeIndex(chCount,
- AccessibleTextType.PARAGRAPH).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.length() == chCount ;
+ " AccessibleTextType.WORD):");
+
+ txt = oObj.getTextBeforeIndex(chCount,
+ AccessibleTextType.WORD);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareLength(chCount, txt.SegmentText);
log.print("getTextBeforeIndex(1," +
- " AccessibleTextType.PARAGRAPH):");
- txt = oObj.getTextBeforeIndex(1,
- AccessibleTextType.PARAGRAPH).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.length() == 0;
+ " AccessibleTextType.PARAGRAPH):");
+ txt = oObj.getTextBeforeIndex(1, AccessibleTextType.PARAGRAPH);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareLength(0, txt.SegmentText);
log.print("getTextBeforeIndex(chCount-1," +
- " AccessibleTextType.CHARACTER):");
+ " AccessibleTextType.CHARACTER):");
txt = oObj.getTextBeforeIndex(chCount - 1,
- AccessibleTextType.CHARACTER).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.equals(text.substring(chCount - 2, chCount - 1));
+ AccessibleTextType.CHARACTER);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareStrings(text.substring(chCount - 2, chCount - 1),
+ txt.SegmentText);
if (chCount > 2) {
log.print("getTextBeforeIndex(2," +
- " AccessibleTextType.CHARACTER):");
- txt = oObj.getTextBeforeIndex(2,
- AccessibleTextType.CHARACTER).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.equals(text.substring(1, 2));
+ " AccessibleTextType.CHARACTER):");
+ txt = oObj.getTextBeforeIndex(2, AccessibleTextType.CHARACTER);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareStrings(text.substring(1, 2), txt.SegmentText);
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
}
-
tRes.tested("getTextBeforeIndex()", res);
}
@@ -993,72 +1030,75 @@ public class _XAccessibleText extends MultiMethodTest {
*/
public void _getTextBehindIndex() {
requiredMethod("getCharacterCount()");
+ TextSegment txt = null;
boolean res = true;
try {
log.print("getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH):");
- TextSegment txt = oObj.getTextBehindIndex(-1,
- AccessibleTextType.PARAGRAPH);
+
+ txt = oObj.getTextBehindIndex(-1,
+ AccessibleTextType.PARAGRAPH);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("UnExpected exception");
res &= true;
}
try {
log.print("getTextBehindIndex(chCount+1, " +
- "AccessibleTextType.PARAGRAPH):");
- TextSegment txt = oObj.getTextBehindIndex(chCount + 1,
- AccessibleTextType.PARAGRAPH);
+ "AccessibleTextType.PARAGRAPH):");
+
+ txt = oObj.getTextBehindIndex(chCount + 1,
+ AccessibleTextType.PARAGRAPH);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("UnExpected exception");
res &= true;
}
try {
log.print("getTextBehindIndex(chCount," +
- " AccessibleTextType.PARAGRAPH):");
- String txt = oObj.getTextBehindIndex(chCount,
- AccessibleTextType.PARAGRAPH).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.length() == 0;
+ " AccessibleTextType.PARAGRAPH):");
+
+ txt = oObj.getTextBehindIndex(chCount,
+ AccessibleTextType.PARAGRAPH);
+ log.println("'" + txt.SegmentText + "'");
+ res &= (txt.SegmentText.length() == 0);
log.print("getTextBehindIndex(chCount-1," +
- " AccessibleTextType.PARAGRAPH):");
+ " AccessibleTextType.PARAGRAPH):");
txt = oObj.getTextBehindIndex(chCount - 1,
- AccessibleTextType.PARAGRAPH).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.length() == 0;
+ AccessibleTextType.PARAGRAPH);
+ log.println("'" + txt.SegmentText + "'");
+ res &= (txt.SegmentText.length() == 0);
log.print("getTextBehindIndex(1," +
- " AccessibleTextType.CHARACTER):");
- txt = oObj.getTextBehindIndex(1,
- AccessibleTextType.CHARACTER).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.equals(text.substring(2, 3));
+ " AccessibleTextType.CHARACTER):");
+ txt = oObj.getTextBehindIndex(1, AccessibleTextType.CHARACTER);
+ log.println("'" + txt.SegmentText + "'");
+ res &= txt.SegmentText.equals(text.substring(2, 3));
if (chCount > 2) {
log.print("getTextBehindIndex(chCount-2," +
- " AccessibleTextType.CHARACTER):");
+ " AccessibleTextType.CHARACTER):");
txt = oObj.getTextBehindIndex(chCount - 2,
- AccessibleTextType.CHARACTER).SegmentText;
- log.println("'" + txt + "'");
- res &= txt.equals(text.substring(chCount - 1, chCount));
+ AccessibleTextType.CHARACTER);
+ log.println("'" + txt.SegmentText + "'");
+ res &= txt.SegmentText.equals(text.substring(chCount - 1, chCount));
}
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
- } catch(com.sun.star.lang.IllegalArgumentException e) {
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -1088,7 +1128,7 @@ public class _XAccessibleText extends MultiMethodTest {
oObj.copyText(-1, chCount);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
@@ -1098,7 +1138,7 @@ public class _XAccessibleText extends MultiMethodTest {
oObj.copyText(0, chCount + 1);
log.println("Exception was expected");
res &= false;
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Expected exception");
res &= true;
}
@@ -1110,13 +1150,14 @@ public class _XAccessibleText extends MultiMethodTest {
res &= locRes;
String cbText = null;
+
try {
- cbText =
- util.SysUtils.getSysClipboardText((XMultiServiceFactory)tParam.getMSF());
+ cbText = util.SysUtils.getSysClipboardText((XMultiServiceFactory)tParam.getMSF());
} catch (com.sun.star.uno.Exception e) {
log.println("Couldn't access system clipboard :");
e.printStackTrace(log);
}
+
log.println("Clipboard: '" + cbText + "'");
res &= text.equals(cbText);
@@ -1136,8 +1177,7 @@ public class _XAccessibleText extends MultiMethodTest {
log.println("Clipboard: '" + cbText + "'");
res &= text.substring(1, chCount - 1).equals(cbText);
}
-
- } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Unexpected exception");
e.printStackTrace(log);
res &= false;
@@ -1145,4 +1185,28 @@ public class _XAccessibleText extends MultiMethodTest {
tRes.tested("copyText()", res);
}
-}
+
+ public boolean compareStrings(String expected, String getting) {
+ boolean res = expected.equals(getting);
+
+ if (!res) {
+ log.println("## The result isn't the expected:");
+ log.println("\tGetting: " + getting);
+ log.println("\tExpected: " + expected);
+ }
+
+ return res;
+ }
+
+ public boolean compareLength(int expected, String getting) {
+ boolean res = (expected == getting.length());
+
+ if (!res) {
+ log.println("## The result isn't the expected:");
+ log.println("\tGetting: " + getting.length());
+ log.println("\tExpected: " + expected);
+ }
+
+ return res;
+ }
+} \ No newline at end of file