summaryrefslogtreecommitdiff
path: root/qadevOOo/tests/java/ifc/accessibility
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/tests/java/ifc/accessibility')
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessible.java57
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java167
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java651
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java354
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleEditableText.java542
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java212
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleExtendedComponent.java123
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleImage.java74
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java600
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java1010
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java1195
-rw-r--r--qadevOOo/tests/java/ifc/accessibility/_XAccessibleValue.java351
12 files changed, 5336 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessible.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessible.java
new file mode 100644
index 000000000000..f4f302114c9d
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessible.java
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessible</code>
+ * interface methods :
+ * <ul>
+ * <li><code> getAccessibleContext()</code></li>
+ * </ul> <p>
+ * @see com.sun.star.accessibility.XAccessible
+ */
+public class _XAccessible extends MultiMethodTest {
+
+
+ public XAccessible oObj = null;
+
+ /**
+ * Just calls the method. <p>
+ * Has <b> OK </b> status if not null value returned.
+ */
+ public void _getAccessibleContext() {
+ XAccessibleContext ac = oObj.getAccessibleContext();
+ tRes.tested("getAccessibleContext()",ac != null);
+ }
+
+}
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java
new file mode 100644
index 000000000000..f9ef9e52c1e6
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+import com.sun.star.accessibility.XAccessibleAction;
+
+public class _XAccessibleAction extends lib.MultiMethodTest {
+
+ public XAccessibleAction oObj = null;
+ public int count = 0;
+
+ /**
+ * calls the method and stores the result in the <br>
+ * variable count. Is OK if no excpetion occurs
+ */
+
+ public void _getAccessibleActionCount() {
+ count = oObj.getAccessibleActionCount();
+ tRes.tested("getAccessibleActionCount()",count > 0);
+ }
+
+ /**
+ * calls the method with invalid argument and check if the <br>
+ * expected Exception is thrown.<br>
+ * Calls the method afterwards the first valid parameter.<br>
+ * This is the last method called and the environment is disposed<br>
+ * afterwards.
+ */
+
+ public void _doAccessibleAction() {
+ requiredMethod("getAccessibleActionKeyBinding()");
+ boolean res = true;
+
+ log.println("Calling method with wrong argument");
+ try {
+ oObj.doAccessibleAction(count);
+ log.println("Exception expected -- FAILED");
+ res &= false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
+ log.println("Expected exception -- OK");
+ res &= true;
+ }
+
+ try {
+ boolean act = false;
+ for (int i = 0; i< count; i++) {
+ log.println("do Action "+ oObj.getAccessibleActionDescription(i));
+ act = oObj.doAccessibleAction(i);
+ log.println("Worked: "+act);
+ }
+ log.println("Did action: "+act);
+ res &= act ;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
+ log.println("Unexepected exception -- FAILED");
+ res &= false;
+ }
+
+ tRes.tested("doAccessibleAction()",res);
+ }
+
+ /**
+ * calls the method with invalid argument and check if the <br>
+ * expected Exception is thrown.<br>
+ * Calls the method afterwards all valid parameters.<br>
+ * Is ok if the exception is thrown and the resulting value
+ * for the calls with valid parameters aren't null.
+ */
+
+ public void _getAccessibleActionDescription() {
+ requiredMethod("getAccessibleActionCount()");
+ boolean res = true;
+
+ log.println("Calling method with wrong argument");
+ try {
+ oObj.getAccessibleActionDescription(count);
+ log.println("Exception expected -- FAILED");
+ res &= false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
+ log.println("Expected exception -- OK");
+ res &= true;
+ }
+
+ for (int i=0;i<count;i++) {
+ try {
+ String desc = oObj.getAccessibleActionDescription(i);
+ log.println("Found action: "+desc);
+ res &= desc!=null ;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
+ log.println("Unexepected exception -- FAILED");
+ res &= false;
+ }
+ }
+
+ tRes.tested("getAccessibleActionDescription()",res);
+ }
+
+ /**
+ * calls the method with invalid argument and check if the <br>
+ * expected Exception is thrown.<br>
+ * Calls the method afterwards all valid parameters.<br>
+ * Is ok if the exception is thrown and the resulting value
+ * for the calls with valid parameters aren't null.
+ */
+
+ public void _getAccessibleActionKeyBinding() {
+ requiredMethod("getAccessibleActionDescription()");
+ boolean res = true;
+
+ log.println("Calling method with wrong argument");
+ try {
+ oObj.getAccessibleActionKeyBinding(count);
+ log.println("Exception expected -- FAILED");
+ res &= false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
+ log.println("Expected exception -- OK");
+ res &= true;
+ }
+
+ for (int i=0;i<count;i++) {
+ try {
+ Object key = oObj.getAccessibleActionKeyBinding(i);
+ if (key != null ) {
+ log.println("Found key: "+key.toString());
+ }
+ res &= true;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) {
+ log.println("Unexepected exception -- FAILED");
+ res &= false;
+ }
+ }
+
+ tRes.tested("getAccessibleActionKeyBinding()",res);
+ }
+
+ /**
+ * Forces environment recreation.
+ */
+ protected void after() {
+ disposeEnvironment();
+ }
+
+}
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java
new file mode 100644
index 000000000000..c5e302451c21
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java
@@ -0,0 +1,651 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package ifc.accessibility;
+
+import java.util.Vector;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.Size;
+import com.sun.star.uno.UnoRuntime;
+
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleComponent</code>
+ * interface methods :
+ * <ul>
+ * <li><code> containsPoint()</code></li>
+ * <li><code> getAccessibleAtPoint()</code></li>
+ * <li><code> getBounds()</code></li>
+ * <li><code> getLocation()</code></li>
+ * <li><code> getLocationOnScreen()</code></li>
+ * <li><code> getSize()</code></li>
+ * <li><code> grabFocus()</code></li>
+ * <li><code> getAccessibleKeyBinding()</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.accessibility.XAccessibleComponent
+ */
+public class _XAccessibleComponent extends MultiMethodTest {
+
+ public XAccessibleComponent oObj = null;
+ private Rectangle bounds = null;
+ private Vector KnownBounds = new Vector();
+
+
+ /**
+ * First checks 4 inner bounds (upper, lower, left and right)
+ * of component bounding box to contain
+ * at least one point of the component. Second 4 outer bounds
+ * are checked to not contain any component points.<p>
+ *
+ * Has <b> OK </b> status if inner bounds contain component points
+ * and outer bounds don't contain any component points. <p>
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getBounds() </code> : to have size of a component.</li>
+ * </ul>
+ */
+ public void _containsPoint() {
+ requiredMethod("getBounds()");
+
+ boolean result = true;
+
+ int curX = 0;
+
+ //while (!oObj.containsPoint(new Point(curX, bounds.Y)) && curX < bounds.Width+bounds.X) {
+ while (!oObj.containsPoint(new Point(curX, 0)) &&
+ (curX < bounds.Width)) {
+ curX++;
+ }
+
+ ;
+
+ //if ((bounds.X <= curX) && (curX < bounds.Width+bounds.X)) {
+ if (curX < bounds.Width) {
+ log.println("Upper bound of box containsPoint point (" + curX +
+ ",0) - OK");
+ } else {
+ log.println(
+ "Upper bound of box containsPoint no component points - FAILED");
+ result = false;
+ }
+
+ curX = 0;
+
+ //while (!oObj.containsPoint(new Point(curX, bounds.Y+bounds.Height - 1))
+ while (!oObj.containsPoint(new Point(curX, bounds.Height - 1)) &&
+ (curX < bounds.Width)) {
+ log.println("containsPoint returns false for (" + curX + "," +
+ bounds.Height + ")");
+ curX++;
+ }
+
+ ;
+
+ //if ((bounds.X <= curX) && (curX < bounds.Width+bounds.X)) {
+ if (curX < bounds.Width) {
+ log.println("Lower bound of box containsPoint point (" + curX +
+ "," + (bounds.Height - 1) + ") - OK");
+ } else {
+ log.println(
+ "Lower bound of box containsPoint no component points - FAILED");
+ result = false;
+ }
+
+ int curY = 0;
+
+ //while (!oObj.containsPoint(new Point(bounds.X, curY)) && curY < bounds.Height+bounds.Y) {
+ while (!oObj.containsPoint(new Point(0, curY)) &&
+ (curY < bounds.Height)) {
+ curY++;
+ }
+
+ ;
+
+ //if ((bounds.Y <= curY) && (curY < bounds.Height+bounds.Y)) {
+ if (curY < bounds.Height) {
+ log.println("Left bound of box containsPoint point (0," + curY +
+ ") - OK");
+ } else {
+ log.println(
+ "Left bound of box containsPoint no component points - FAILED");
+ result = false;
+ }
+
+ curY = 0;
+
+ //while (!oObj.containsPoint(new Point(bounds.X+bounds.Width - 1, curY))
+ // && curY < bounds.Height+bounds.Y) {
+ while (!oObj.containsPoint(new Point(bounds.Width - 1, curY)) &&
+ (curY < bounds.Height)) {
+ curY++;
+ }
+
+ ;
+
+ //if ((bounds.Y <= curY) && (curY < bounds.Height + bounds.Y)) {
+ if (curY < bounds.Height) {
+ log.println("Right bound of box containsPoint point (" +
+ (bounds.Width - 1) + "," + curY + ") - OK");
+ } else {
+ log.println(
+ "Right bound of box containsPoint no component points - FAILED");
+ result = false;
+ }
+
+ boolean locRes = true;
+
+ for (int x = -1; x <= bounds.Width; x++) {
+ if (oObj.containsPoint(new Point(x, -1))) {
+ log.println(
+ "Outer upper and lower bounds CONTAIN some component point"
+ + " (" + x + ", -1) - FAILED");
+ locRes = false;
+ break;
+ }
+ if (oObj.containsPoint(new Point(x, bounds.Height + bounds.Y))) {
+ log.println(
+ "Outer upper and lower bounds CONTAIN some component point"
+ + " (" + x + ", " + bounds.Height + bounds.Y
+ + ") - FAILED");
+ locRes = false;
+ break;
+ }
+ }
+
+ if (locRes) {
+ log.println("Outer upper and lower bounds contain no component " +
+ "points - OK");
+ } else {
+ result = false;
+ }
+
+ locRes = true;
+
+ for (int y = -1; y <= bounds.Height; y++) {
+ if (oObj.containsPoint(new Point(-1, y))) {
+ log.println(
+ "Outer left and right bounds CONTAIN some component point"
+ + " (-1, " + y + ") - FAILED");
+ locRes = false;
+ break;
+ }
+ if (oObj.containsPoint(new Point(bounds.X + bounds.Width, y))) {
+ log.println(
+ "Outer left and right bounds CONTAIN some component point"
+ + " (" + bounds.X + bounds.Width + ", " + y + ") - FAILED");
+ locRes = false;
+ break;
+ }
+ }
+
+ if (locRes) {
+ log.println("Outer left and right bounds contain no component " +
+ "points - OK");
+ } else {
+ result = false;
+ }
+
+ tRes.tested("containsPoint()", result);
+ }
+
+ /**
+ * Iterates through all children which implement
+ * <code>XAccessibleComponent</code> (if they exist) determines their
+ * boundaries and tries to get each child by <code>getAccessibleAtPoint</code>
+ * passing point which belongs to the child.
+ * Also the point is checked which doesn't belong to child boundary
+ * box. <p>
+ *
+ * Has <b> OK </b> status if in the first cases the right children
+ * are returned, and in the second <code>null</code> or
+ * another child is returned.
+ */
+ public void _getAccessibleAtPoint() {
+ boolean result = true;
+ XAccessibleComponent[] children = getChildrenComponents();
+
+ if (children.length > 0) {
+ for (int i = 0; i < children.length; i++) {
+ Rectangle chBnd = children[i].getBounds();
+
+ if (chBnd.X == -1) {
+ continue;
+ }
+
+ log.println("Checking child with bounds " + "(" + chBnd.X +
+ "," + chBnd.Y + "),(" + chBnd.Width + "," +
+ chBnd.Height + "): " +
+ util.AccessibilityTools.accessibleToString(
+ children[i]));
+
+ XAccessibleContext xAc = (XAccessibleContext) UnoRuntime.queryInterface(
+ XAccessibleContext.class,
+ children[i]);
+
+ boolean MightBeCovered = false;
+ boolean isShowing = xAc.getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
+ log.println("\tStateType containsPoint SHOWING: " +
+ isShowing);
+
+ if (!isShowing) {
+ log.println("Child is invisible - OK");
+
+ continue;
+ }
+
+ log.println("finding the point which lies on the component");
+
+ int curX = chBnd.Width / 2;
+ int curY = chBnd.Height / 2;
+
+ while (!children[i].containsPoint(new Point(curX, curY)) &&
+ (curX > 0) && (curY > 0)) {
+ curX--;
+ curY--;
+ }
+
+ ;
+
+ if ((curX == chBnd.Width) && isShowing) {
+ log.println("Couldn't find a point with containsPoint");
+
+ continue;
+ }
+
+ // trying the point laying on child
+ XAccessible xAcc = oObj.getAccessibleAtPoint(
+ new Point(chBnd.X + curX,
+ chBnd.Y + curY));
+
+
+ Point p = new Point(chBnd.X + curX,chBnd.X + curX);
+
+ if (isCovered(p) && isShowing) {
+ log.println(
+ "Child might be covered by another and can't be reached");
+ MightBeCovered = true;
+ }
+
+ KnownBounds.add(chBnd);
+
+ if (xAcc == null) {
+ log.println("The child not found at point (" +
+ (chBnd.X + curX) + "," + (chBnd.Y + curY) +
+ ") - FAILED");
+
+ if (isShowing) {
+ result = false;
+ } else {
+ result &= true;
+ }
+ } else {
+ XAccessible xAccCh = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class,
+ children[i]);
+ XAccessibleContext xAccC = (XAccessibleContext) UnoRuntime.queryInterface(
+ XAccessibleContext.class,
+ children[i]);
+ log.println("Child found at point (" + (chBnd.X + curX) +
+ "," + (chBnd.Y + curY) + ") - OK");
+
+ boolean res = false;
+ int expIndex;
+ String expName;
+ String expDesc;
+
+ if (xAccCh != null) {
+ res = util.AccessibilityTools.equals(xAccCh, xAcc);
+ expIndex = xAccCh.getAccessibleContext()
+ .getAccessibleIndexInParent();
+ expName = xAccCh.getAccessibleContext()
+ .getAccessibleName();
+ expDesc = xAccCh.getAccessibleContext()
+ .getAccessibleDescription();
+ } else {
+ res = xAccC.getAccessibleName()
+ .equals(xAcc.getAccessibleContext()
+ .getAccessibleName());
+ expIndex = xAccC.getAccessibleIndexInParent();
+ expName = xAccC.getAccessibleName();
+ expDesc = xAccC.getAccessibleDescription();
+ }
+
+ if (!res) {
+ int gotIndex = xAcc.getAccessibleContext()
+ .getAccessibleIndexInParent();
+
+ if (expIndex < gotIndex) {
+ log.println("The children found is not the same");
+ log.println("The expected child " + expName);
+ log.print("is hidden behind the found Child ");
+ log.println(xAcc.getAccessibleContext()
+ .getAccessibleName() + " - OK");
+ } else {
+ log.println(
+ "The children found is not the same");
+ log.println("Expected: " + expName);
+ log.println("Description: " + expDesc);
+ log.println("Found: " +
+ xAcc.getAccessibleContext()
+ .getAccessibleName());
+ log.println("Description: " +
+ xAcc.getAccessibleContext()
+ .getAccessibleDescription());
+ if (MightBeCovered) {
+ log.println("... Child is covered by another - OK");
+ } else {
+ log.println("... FAILED");
+ result = false;
+ }
+
+ }
+ }
+ }
+
+
+ // trying the point NOT laying on child
+ xAcc = oObj.getAccessibleAtPoint(
+ new Point(chBnd.X - 1, chBnd.Y - 1));
+
+ if (xAcc == null) {
+ log.println("No children found at point (" +
+ (chBnd.X - 1) + "," + (chBnd.Y - 1) +
+ ") - OK");
+ result &= true;
+ } else {
+ XAccessible xAccCh = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class,
+ children[i]);
+ boolean res = util.AccessibilityTools.equals(xAccCh, xAcc);
+
+ if (res) {
+ log.println("The same child found outside " +
+ "its bounds at (" + (chBnd.X - 1) + "," +
+ (chBnd.Y - 1) + ") - FAILED");
+ result = false;
+ }
+ }
+ }
+ } else {
+ log.println("There are no children supporting " +
+ "XAccessibleComponent");
+ }
+
+ tRes.tested("getAccessibleAtPoint()", result);
+ }
+
+ /**
+ * Retrieves the component bounds and stores it. <p>
+ *
+ * Has <b> OK </b> status if boundary position (x,y) is not negative
+ * and size (Width, Height) is greater than 0.
+ */
+ public void _getBounds() {
+ boolean result = true;
+
+ bounds = oObj.getBounds();
+ result &= ((bounds != null) && (bounds.X >= 0) && (bounds.Y >= 0) && (bounds.Width > 0) && (bounds.Height > 0));
+
+ log.println("Bounds = " +
+ ((bounds != null)
+ ? ("(" + bounds.X + "," + bounds.Y + "),(" +
+ bounds.Width + "," + bounds.Height + ")") : "null"));
+
+ tRes.tested("getBounds()", result);
+ }
+
+ /**
+ * Gets the location. <p>
+ *
+ * Has <b> OK </b> status if the location is the same as location
+ * of boundary obtained by <code>getBounds()</code> method.
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getBounds() </code> : to have bounds </li>
+ * </ul>
+ */
+ public void _getLocation() {
+ requiredMethod("getBounds()");
+
+ boolean result = true;
+ Point loc = oObj.getLocation();
+
+ result &= ((loc.X == bounds.X) && (loc.Y == bounds.Y));
+
+ tRes.tested("getLocation()", result);
+ }
+
+ /**
+ * Get the screen location of the component and its parent
+ * (if it exists and supports <code>XAccessibleComponent</code>). <p>
+ *
+ * Has <b> OK </b> status if component screen location equals
+ * to screen location of its parent plus location of the component
+ * relative to the parent. <p>
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getBounds() </code> : to have location of the component
+ * relative to its parent</li>
+ * </ul>
+ */
+ public void _getLocationOnScreen() {
+ requiredMethod("getBounds()");
+
+ XAccessibleComponent parent = getParentComponent();
+
+ boolean result = true;
+ Point loc = oObj.getLocationOnScreen();
+ log.println("Location is (" + loc.X + "," + loc.Y + ")");
+
+ if (parent != null) {
+ Point parLoc = parent.getLocationOnScreen();
+ log.println("Parent location is (" + parLoc.X + "," + parLoc.Y +
+ ")");
+
+ result &= ((parLoc.X + bounds.X) == loc.X);
+ result &= ((parLoc.Y + bounds.Y) == loc.Y);
+ }
+
+ tRes.tested("getLocationOnScreen()", result);
+ }
+
+ /**
+ * Obtains the size of the component. <p>
+ *
+ * Has <b> OK </b> status if the size is the same as in bounds. <p>
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getBounds() </code> </li>
+ * </ul>
+ */
+ public void _getSize() {
+ requiredMethod("getBounds()");
+
+ boolean result = true;
+ Size size = oObj.getSize();
+
+ result &= (size.Width == bounds.Width);
+ result &= (size.Height == bounds.Height);
+
+ tRes.tested("getSize()", result);
+ }
+
+ /**
+ * Just calls the method. <p>
+ *
+ * Has <b> OK </b> status if no runtime exceptions occured.
+ */
+ public void _grabFocus() {
+ boolean result = true;
+ oObj.grabFocus();
+
+ tRes.tested("grabFocus()", result);
+ }
+
+ /**
+ * Retrieves all children (not more than 50) of the current
+ * component which support <code>XAccessibleComponent</code>.
+ *
+ * @return The array of children. Empty array returned if
+ * such children were not found or some error occured.
+ */
+ private XAccessibleComponent[] getChildrenComponents() {
+ XAccessible xAcc = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class, oObj);
+
+ if (xAcc == null) {
+ log.println("Component doesn't support XAccessible.");
+
+ return new XAccessibleComponent[0];
+ }
+
+ XAccessibleContext xAccCon = xAcc.getAccessibleContext();
+ int cnt = xAccCon.getAccessibleChildCount();
+
+ // for cases when too many children exist checking only first 50
+ if (cnt > 50) {
+ cnt = 50;
+ }
+
+ Vector childComp = new Vector();
+
+ for (int i = 0; i < cnt; i++) {
+ try {
+ XAccessible child = xAccCon.getAccessibleChild(i);
+ XAccessibleContext xAccConCh = child.getAccessibleContext();
+ XAccessibleComponent xChAccComp = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class,
+ xAccConCh);
+
+ if (xChAccComp != null) {
+ childComp.add(xChAccComp);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ }
+ }
+
+ return (XAccessibleComponent[]) childComp.toArray(
+ new XAccessibleComponent[childComp.size()]);
+ }
+
+ /**
+ * Gets the parent of the current component which support
+ * <code>XAccessibleComponent</code>.
+ *
+ * @return The parent or <code>null</code> if the component
+ * has no parent or some errors occured.
+ */
+ private XAccessibleComponent getParentComponent() {
+ XAccessible xAcc = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class, oObj);
+
+ if (xAcc == null) {
+ log.println("Component doesn't support XAccessible.");
+
+ return null;
+ }
+
+ XAccessibleContext xAccCon = xAcc.getAccessibleContext();
+ XAccessible xAccPar = xAccCon.getAccessibleParent();
+
+ if (xAccPar == null) {
+ log.println("Component has no accessible parent.");
+
+ return null;
+ }
+
+ XAccessibleContext xAccConPar = xAccPar.getAccessibleContext();
+ XAccessibleComponent parent = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class,
+ xAccConPar);
+
+ if (parent == null) {
+ log.println(
+ "Accessible parent doesn't support XAccessibleComponent");
+
+ return null;
+ }
+
+ return parent;
+ }
+
+ /**
+ * Just calls the method.
+ */
+ public void _getForeground() {
+ int forColor = oObj.getForeground();
+ log.println("getForeground(): " + forColor);
+ tRes.tested("getForeground()", true);
+ }
+
+ /**
+ * Just calls the method.
+ */
+ public void _getBackground() {
+ int backColor = oObj.getBackground();
+ log.println("getBackground(): " + backColor);
+ tRes.tested("getBackground()", true);
+ }
+
+ /**
+ * Restores initial component text.
+ */
+ protected void after() {
+ if (tEnv.getObjRelation("Destroy") != null) {
+ disposeEnvironment();
+ }
+ }
+
+ private boolean isCovered(Point p) {
+ int elements = KnownBounds.size();
+ boolean Covered = false;
+ for (int k=0;k<elements;k++) {
+ Rectangle known = (Rectangle) KnownBounds.get(k);
+ Covered = (known.X < p.X);
+ Covered &= (known.Y < p.Y);
+ Covered &= (p.Y < known.Y+known.Height);
+ Covered &= (p.X < known.X+known.Width);
+
+ if (Covered) {
+ break;
+ }
+ }
+ return Covered;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java
new file mode 100644
index 000000000000..47b24a337f2c
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java
@@ -0,0 +1,354 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package ifc.accessibility;
+
+import com.sun.star.accessibility.IllegalAccessibleComponentStateException;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleRelationSet;
+import com.sun.star.accessibility.XAccessibleStateSet;
+import com.sun.star.lang.Locale;
+
+import lib.MultiMethodTest;
+
+import util.AccessibilityTools;
+
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleContext</code>
+ * interface methods :
+ * <ul>
+ * <li><code> getAccessibleChildCount()</code></li>
+ * <li><code> getAccessibleChild()</code></li>
+ * <li><code> getAccessibleParent()</code></li>
+ * <li><code> getAccessibleIndexInParent()</code></li>
+ * <li><code> getAccessibleRole()</code></li>
+ * <li><code> getAccessibleDescription()</code></li>
+ * <li><code> getAccessibleName()</code></li>
+ * <li><code> getAccessibleRelationSet()</code></li>
+ * <li><code> getAccessibleStateSet()</code></li>
+ * <li><code> getLocale()</code></li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.accessibility.XAccessibleContext
+ */
+public class _XAccessibleContext extends MultiMethodTest {
+ private static final String className = "com.sun.star.accessibility.XAccessibleContext";
+ public XAccessibleContext oObj = null;
+ private int childCount = 0;
+ private XAccessible parent = null;
+
+ // temporary while accessibility package is in com.sun.star
+ protected String getTestedClassName() {
+ return className;
+ }
+
+ /**
+ * Calls the method and stores the number of children. <p>
+ * Has <b> OK </b> status if non-negative number rutrned.
+ */
+ public void _getAccessibleChildCount() {
+ childCount = oObj.getAccessibleChildCount();
+ log.println("" + childCount + " children found.");
+ tRes.tested("getAccessibleChildCount()", childCount > -1);
+ }
+
+ /**
+ * Tries to get every child and checks its parent. <p>
+ *
+ * Has <b> OK </b> status if parent of every child
+ * and the tested component are the same objects.
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getAccessibleChildCount() </code> : to have a number of
+ * children </li>
+ * </ul>
+ */
+ public void _getAccessibleChild() {
+ requiredMethod("getAccessibleChildCount()");
+
+ log.println("testing 'getAccessibleChild()'...");
+
+ boolean bOK = true;
+ int counter = childCount;
+
+ if (childCount > 500) {
+ counter = 500;
+ }
+
+ for (int i = 0; i < counter; i++) {
+ try {
+ XAccessible ch = oObj.getAccessibleChild(i);
+ XAccessibleContext chAC = ch.getAccessibleContext();
+
+ log.println("## Child " + i + ": " +
+ chAC.getAccessibleDescription());
+
+ if (!AccessibilityTools.equals(chAC.getAccessibleParent()
+ .getAccessibleContext(),
+ oObj)) {
+ log.println("The parent of child and component " +
+ "itself differ.");
+ log.println("\tRole:");
+ log.println("Getting: " +
+ chAC.getAccessibleParent()
+ .getAccessibleContext()
+ .getAccessibleRole());
+ log.println("Expected: " + oObj.getAccessibleRole());
+
+ log.println("\tImplementationName:");
+ log.println("Getting: " +
+ util.utils.getImplName(
+ chAC.getAccessibleParent()
+ .getAccessibleContext()));
+ log.println("Expected: " + util.utils.getImplName(oObj));
+
+ log.println("\tAccessibleDescription:");
+ log.println("Getting(Description): " +
+ chAC.getAccessibleParent()
+ .getAccessibleContext()
+ .getAccessibleDescription());
+ log.println("Expected(Description): " +
+ oObj.getAccessibleDescription());
+
+ log.println("\tAccessibleName:");
+ log.println("Getting(Name): " +
+ chAC.getAccessibleParent()
+ .getAccessibleContext()
+ .getAccessibleName());
+ log.println("Expected(Name): " +
+ oObj.getAccessibleName());
+
+ log.println("\tChildCount:");
+ log.println("Getting: " +
+ chAC.getAccessibleParent()
+ .getAccessibleContext()
+ .getAccessibleChildCount());
+ log.println("Expected: " +
+ oObj.getAccessibleChildCount());
+
+ log.println("\tParentName:");
+ log.println("Getting (Name): " +
+ chAC.getAccessibleParent()
+ .getAccessibleContext()
+ .getAccessibleParent()
+ .getAccessibleContext()
+ .getAccessibleName());
+ log.println("Expected(Name): " +
+ oObj.getAccessibleParent()
+ .getAccessibleContext()
+ .getAccessibleName());
+
+ log.println("##");
+ bOK = false;
+ } else {
+ log.println("Role: " + chAC.getAccessibleRole());
+ log.println("Name: " + chAC.getAccessibleName());
+ log.println("IndexInParent: " +
+ chAC.getAccessibleIndexInParent());
+ log.println("ImplementationName: " +
+ util.utils.getImplName(chAC));
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ e.printStackTrace(log);
+ bOK = false;
+ }
+ }
+
+ tRes.tested("getAccessibleChild()", bOK);
+ }
+
+ /**
+ * Just gets the parent. <p>
+ *
+ * Has <b> OK </b> status if parent is not null.
+ */
+ public void _getAccessibleParent() {
+ // assume that the component is not ROOT
+ parent = oObj.getAccessibleParent();
+ tRes.tested("getAccessibleParent()", parent != null);
+ }
+
+ /**
+ * Retrieves the index of tested component in its parent.
+ * Then gets the parent's child by this index and compares
+ * it with tested component.<p>
+ *
+ * Has <b> OK </b> status if the parent's child and the tested
+ * component are the same objects.
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getAccessibleParent() </code> : to have a parent </li>
+ * </ul>
+ */
+ public void _getAccessibleIndexInParent() {
+ requiredMethod("getAccessibleParent()");
+
+ boolean bOK = true;
+ int idx = oObj.getAccessibleIndexInParent();
+
+ XAccessibleContext parentAC = parent.getAccessibleContext();
+
+ try {
+ if (parentAC.getAccessibleChild(idx) == null) {
+ log.println("Parent has no child with this index");
+ bOK &= false;
+ } else {
+ bOK &= AccessibilityTools.equals(parentAC.getAccessibleChild(
+ idx)
+ .getAccessibleContext(),
+ oObj);
+ }
+
+ if (!bOK) {
+ log.println("Expected: " + util.utils.getImplName(oObj));
+
+ if (parentAC.getAccessibleChild(idx) != null) {
+ log.println("Getting: " +
+ util.utils.getImplName(
+ parentAC.getAccessibleChild(idx)
+ .getAccessibleContext()));
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ e.printStackTrace(log);
+ bOK = false;
+ }
+
+ tRes.tested("getAccessibleIndexInParent()", bOK);
+ }
+
+ /**
+ * Get the accessible role of component. <p>
+ *
+ * Has <b> OK </b> status if non-negative number rutrned.
+ */
+ public void _getAccessibleRole() {
+ short role = oObj.getAccessibleRole();
+ log.println("The role is " + role);
+ tRes.tested("getAccessibleRole()", role > -1);
+ }
+
+ /**
+ * Get the accessible name of the component. <p>
+ *
+ * Has <b> OK </b> status if the name has non-zero length.
+ */
+ public void _getAccessibleName() {
+ String name = oObj.getAccessibleName();
+ log.println("The name is '" + name + "'");
+ tRes.tested("getAccessibleName()", name != null);
+ }
+
+ /**
+ * Get the accessible description of the component. <p>
+ *
+ * Has <b> OK </b> status if the description has non-zero length.
+ */
+ public void _getAccessibleDescription() {
+ String descr = oObj.getAccessibleDescription();
+ log.println("The description is '" + descr + "'");
+ tRes.tested("getAccessibleDescription()", descr != null);
+ }
+
+ /**
+ * Just gets the set. <p>
+ *
+ * Has <b> OK </b> status if the set is not null.
+ */
+ public void _getAccessibleRelationSet() {
+ XAccessibleRelationSet set = oObj.getAccessibleRelationSet();
+ tRes.tested("getAccessibleRelationSet()", true);
+ }
+
+ /**
+ * Just gets the set. <p>
+ *
+ * Has <b> OK </b> status if the set is not null.
+ */
+ public void _getAccessibleStateSet() {
+ XAccessibleStateSet set = oObj.getAccessibleStateSet();
+ boolean res = true;
+ String[] expectedStateNames = (String[]) tEnv.getObjRelation(
+ "expectedStateNames");
+ short[] expectedStates = (short[]) tEnv.getObjRelation(
+ "expectedStates");
+
+ if ((expectedStateNames != null) && (expectedStates != null)) {
+ res = checkStates(expectedStateNames, expectedStates, set);
+ } else {
+ res = set != null;
+ }
+
+ tRes.tested("getAccessibleStateSet()", res);
+ }
+
+ /**
+ * Gets the locale. <p>
+ *
+ * Has <b> OK </b> status if <code>Country</code> and
+ * <code>Language</code> fields of locale structure
+ * are not empty.
+ */
+ public void _getLocale() {
+ Locale loc = null;
+
+ try {
+ loc = oObj.getLocale();
+ log.println("The locale is " + loc.Language + "," + loc.Country);
+ } catch (IllegalAccessibleComponentStateException e) {
+ e.printStackTrace(log);
+ }
+
+ tRes.tested("getLocale()",
+ (loc != null) && (loc.Language.length() > 0));
+ }
+
+ protected boolean checkStates(String[] expectedStateNames,
+ short[] expectedStates,
+ XAccessibleStateSet set) {
+ boolean works = true;
+
+ for (int k = 0; k < expectedStateNames.length; k++) {
+ boolean contains = set.contains(expectedStates[k]);
+
+ if (contains) {
+ log.println("Set contains " + expectedStateNames[k] +
+ " ... OK");
+ works &= true;
+ } else {
+ log.println("Set doesn't contain " + expectedStateNames[k] +
+ " ... FAILED");
+ works &= false;
+ }
+ }
+
+ return works;
+ }
+}
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEditableText.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEditableText.java
new file mode 100644
index 000000000000..eac528b41121
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEditableText.java
@@ -0,0 +1,542 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+import lib.MultiMethodTest;
+import util.ValueComparer;
+
+import com.sun.star.accessibility.XAccessibleEditableText;
+import com.sun.star.beans.PropertyValue;
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleEditableText</code>
+ * interface methods :
+ * <ul>
+ * <li><code> cutText()</code></li>
+ * <li><code> pasteText()</code></li>
+ * <li><code> deleteText()</code></li>
+ * <li><code> insertText()</code></li>
+ * <li><code> replaceText()</code></li>
+ * <li><code> setAttributes()</code></li>
+ * <li><code> setText()</code></li>
+ * </ul> <p>
+ *
+ * This test needs the following object relations :
+ * <ul>
+ * <li> <code>'XAccessibleEditableText.hasAttr'</code>
+ * (of type <code>Boolean</code>):
+ * Indicates whether or not the text has changeable attributes.
+ * E.g. text within writer document have attributes which can
+ * be changed, while the text within edit field has fixed
+ * attributes. <p>
+ * If the relation is <code>false</code> then the component
+ * has fixed text attributes. </li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.accessibility.XAccessibleEditableText
+ */
+public class _XAccessibleEditableText extends MultiMethodTest {
+
+ public XAccessibleEditableText oObj = null;
+
+
+ String pasteText = null;
+
+ String initialText = "";
+
+ /**
+ * Indicates whether or not the text has changeable attributes.
+ * E.g. text within writer document have attributes which can
+ * be changed, while the text within edit field has fixed
+ * attributes.
+ */
+ private boolean changeableAttr = true;
+
+ /**
+ * Retrieves object relation. Stores initial component text
+ * for restoding it in <code>after</code>.
+ */
+ protected void before() {
+ Boolean b = (Boolean)
+ tEnv.getObjRelation("XAccessibleEditableText.hasAttr");
+ if (b != null) {
+ changeableAttr = b.booleanValue();
+ }
+
+ initialText = oObj.getText();
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct indexes.
+ * Stores cutted text in the variable <code>pasteText</code>.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct indexes.
+ */
+ public void _cutText() {
+ boolean res = true;
+ boolean locRes = true;
+ String curText = null;
+
+ String oldText = oObj.getText();
+ log.println("Text: '" + oldText + "'");
+ int length = oObj.getCharacterCount();
+ log.println("Character count: " + length);
+
+ try {
+ log.print("cutText(-1," + (length-1) + "): ");
+ locRes = oObj.cutText(-1, length - 1);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(oldText);
+ }
+
+ try {
+ log.print("cutText(0," + (length+1) + "): ");
+ locRes = oObj.cutText(0, length + 1);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(oldText);
+ }
+
+ try {
+ pasteText = oldText;
+ log.print("cutText(0," + length + "): ");
+ locRes = oObj.cutText(0, length);
+ log.println(locRes);
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.length() == 0 && locRes;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("cutText()", res);
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct indexes.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct indexes and if cutted text was
+ * pasted.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>cutText()</code> </li>
+ * </ul>
+ */
+ public void _pasteText() {
+ requiredMethod("cutText()");
+ boolean res = true;
+ boolean locRes = true;
+ String curText = null;
+
+ String text = oObj.getText();
+ log.println("Text: '" + text + "'");
+ int length = oObj.getCharacterCount();
+ log.println("Character count: " + length);
+
+ try {
+ log.print("pasteText(-1): ");
+ locRes = oObj.pasteText(-1);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ log.print("pasteText(" + (length+1) + "): ");
+ locRes = oObj.pasteText(length + 1);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ log.print("pasteText(" + (length) + "): ");
+ locRes = oObj.pasteText(length);
+ log.println(locRes);
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text + pasteText) && locRes;
+ log.println("Expected text: '" + text + pasteText + "'");
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("pasteText()", res);
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct indexes,
+ * checks text after method call.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct indexes and if deleted string
+ * was really deleted from the text.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>insertText()</code> </li>
+ * </ul>
+ */
+ public void _deleteText() {
+ executeMethod("insertText()");
+ boolean res = true;
+ boolean locRes = true;
+ String curText = null;
+
+ String text = oObj.getText();
+ log.println("Text: '" + text + "'");
+ int length = oObj.getCharacterCount();
+ log.println("Character count: " + length);
+
+ try {
+ log.print("deleteText(-1," + length + "): ");
+ locRes = oObj.deleteText(-1, length);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ log.print("deleteText(0," + (length+1) + "): ");
+ locRes = oObj.deleteText(0, length + 1);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ if (length >= 1) {
+ log.print("deleteText(" + (length-1) + "," + (length) + "): ");
+ locRes = oObj.deleteText(length - 1, length);
+ log.println(locRes);
+ String expStr = expStr = text.substring(0, length - 1);
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(expStr);
+ log.println("Expected text: '" + expStr + "'");
+ }
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("deleteText()", res);
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct indexes,
+ * checks text after method call.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct indexes and if inserted string
+ * was really inserted into the text.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>pasteText()</code> </li>
+ * </ul>
+ */
+ public void _insertText() {
+ executeMethod("pasteText()");
+ boolean res = true;
+ boolean locRes = true;
+ String curText = null;
+
+ String text = oObj.getText();
+ log.println("Text: '" + text + "'");
+ int length = oObj.getCharacterCount();
+ log.println("Character count: " + length);
+
+ final String insStr = "Inserted string";
+
+ try {
+ log.print("insertText(insStr, -1): ");
+ locRes = oObj.insertText(insStr, -1);
+ log.println(locRes);
+ log.println("exception was expected=> FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ log.print("insertText(insStr," + (length+1) + "): ");
+ locRes = oObj.insertText(insStr, length+1);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ log.print("insertText(insStr," + length + "): ");
+ locRes = oObj.insertText(insStr, length);
+ log.println(locRes);
+ curText = oObj.getText();
+ res &= curText.equals(text + insStr);
+ log.println("Current text: '" + curText + "'");
+ log.println("Expected text: '" + text + insStr + "'");
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("unexpected exception => FAILED");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("insertText()", res);
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct indexes,
+ * checks text after method call.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct indexes and if part of text
+ * was really replaced by the specified replacement string.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>deleteText()</code> </li>
+ * </ul>
+ */
+ public void _replaceText() {
+ executeMethod("deleteText()");
+ boolean res = true;
+ boolean locRes = true;
+ String curText = null;
+
+ final String sReplacement = "String for replace";
+ String oldText = oObj.getText();
+ int startIndx = oldText.length();
+ oObj.setText(oldText + " part of string for replace");
+
+ String text = oObj.getText();
+ log.println("Text: '" + text + "'");
+ int length = oObj.getCharacterCount();
+ log.println("Character count: " + length);
+
+ try {
+ log.print("replaceText(-1," + length + "): ");
+ locRes = oObj.replaceText(-1, length, sReplacement);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ log.print("replaceText(0," + (length+1) + "): ");
+ locRes = oObj.replaceText(0, length + 1, sReplacement);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ res &= curText.equals(text);
+ }
+
+ try {
+ log.print("replaceText(" + startIndx + "," + length + "): ");
+ locRes = oObj.replaceText(startIndx, length, sReplacement);
+ log.println(locRes);
+ curText = oObj.getText();
+ log.println("Current text: '" + curText + "'");
+ log.println("Expected text: '" + oldText + sReplacement + "'");
+ res &= curText.equals(oldText + sReplacement);
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("replaceText()", res);
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct indexes,
+ * checks attributes after method call.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct indexes and if attributes
+ * of text was changed.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>replaceText()</code> </li>
+ * </ul>
+ */
+ public void _setAttributes() {
+ executeMethod("replaceText()");
+ boolean res = true;
+ boolean locRes = true;
+
+ String text = oObj.getText();
+ log.println("Text: '" + text + "'");
+ int length = oObj.getCharacterCount();
+ log.println("Length: " + length);
+
+ PropertyValue[] attrs = null;
+
+ try {
+ attrs = oObj.getCharacterAttributes(0, new String[]{""});
+ log.print("setAttributes(-1," + (length - 1) + "):");
+ locRes = oObj.setAttributes(-1, length - 1, attrs);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ res &= true;
+ }
+
+ try {
+ log.print("setAttributes(0," + (length+1) + "):");
+ locRes = oObj.setAttributes(0, length + 1, attrs);
+ log.println(locRes);
+ log.println("exception was expected => FAILED");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception => OK");
+ res &= true;
+ }
+
+ //change old attributes set
+ for(int i = 0; i < attrs.length; i++) {
+ if (attrs[i].Name.equals("CharColor")) {
+ attrs[i].Value = new Integer(-2);
+ }
+ }
+
+ try {
+ log.print("setAttributes(0," + length + "):");
+ locRes = oObj.setAttributes(0, length, attrs);
+ log.println(locRes);
+ res &= (changeableAttr && locRes)
+ || (!changeableAttr && !locRes);
+ if (changeableAttr) {
+ log.print("checking that new attributes was set...");
+ PropertyValue[] newAttrs = oObj.getCharacterAttributes(0, new String[]{""});
+ locRes = ValueComparer.equalValue(attrs, newAttrs);
+ log.println(locRes);
+ res &= locRes;
+ } else {
+ log.println("Text attributes can't be changed.");
+ }
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("unexpected exception => FAILED");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("setAttributes()", res);
+ }
+
+ /**
+ * Calls the method with different parameters and checks text.
+ */
+ public void _setText() {
+ executeMethod("setAttributes()");
+ boolean res = true;
+ boolean locRes = true;
+
+ String oldText = oObj.getText();
+ log.println("Current text: '" + oldText + "'");
+
+ String newText = "New text";
+ log.print("setText('" + newText + "'): ");
+ locRes = oObj.setText(newText);
+ log.println(locRes);
+ String newCurText = oObj.getText();
+ log.println("getText(): '" + newCurText + "'");
+ res &= locRes && newCurText.equals(newText);
+
+ newText = "";
+ log.print("setText('" + newText + "'): ");
+ locRes = oObj.setText(newText);
+ log.println(locRes);
+ newCurText = oObj.getText();
+ log.println("getText(): '" + newCurText + "'");
+ res &= locRes && newCurText.equals(newText);
+
+ log.print("setText('" + oldText + "'): ");
+ locRes = oObj.setText(oldText);
+ log.println(locRes);
+ newCurText = oObj.getText();
+ log.println("getText(): '" + newCurText + "'");
+ res &= locRes && newCurText.equals(oldText);
+
+ tRes.tested("setText()", res);
+ }
+
+ /**
+ * Restores initial component text.
+ */
+ protected void after() {
+ oObj.setText(initialText);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java
new file mode 100644
index 000000000000..c1cb7302efce
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+import lib.MultiMethodTest;
+import lib.Status;
+import lib.StatusException;
+
+import com.sun.star.accessibility.AccessibleEventObject;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleEventBroadcaster;
+import com.sun.star.accessibility.XAccessibleEventListener;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Testing <code>
+ * com.sun.star.accessibility.XAccessibleEventBroadcaster</code>
+ * interface methods :
+ * <ul>
+ * <li><code> addEventListener()</code></li>
+ * <li><code> removeEventListener()</code></li>
+ * </ul> <p>
+ *
+ * This test needs the following object relations :
+ * <ul>
+ * <li> <code>'EventProducer'</code> (of type
+ * <code>ifc.accessibility._XAccessibleEventBroadcaster.EventProducer</code>):
+ * this must be an implementation of the interface which could perform
+ * some actions for generating any kind of <code>AccessibleEvent</code></li>
+ * <ul> <p>
+ *
+ * @see com.sun.star.accessibility.XAccessibleEventBroadcaster
+ */
+public class _XAccessibleEventBroadcaster extends MultiMethodTest {
+
+ public static interface EventProducer {
+ void fireEvent();
+ }
+
+ public XAccessibleEventBroadcaster oObj = null;
+ public String EventMsg = "";
+ public boolean destroy = false;
+
+
+ /**
+ * Listener implementation which registers listener calls.
+ */
+ private class EvListener implements XAccessibleEventListener {
+ public AccessibleEventObject notifiedEvent = null ;
+ public void notifyEvent(AccessibleEventObject ev) {
+ log.println("Listener, Event : " + ev.EventId);
+ System.out.println("EventID: " + ev.EventId);
+ Object old=ev.OldValue;
+ if (old instanceof com.sun.star.accessibility.XAccessible) {
+ System.out.println("Old: "+((XAccessible)old).getAccessibleContext().getAccessibleName());
+ }
+
+ Object nev=ev.NewValue;
+ if (nev instanceof com.sun.star.accessibility.XAccessible) {
+ System.out.println("New: "+((XAccessible)nev).getAccessibleContext().getAccessibleName());
+ }
+ notifiedEvent = ev;
+ }
+
+ public void disposing(EventObject ev) {}
+ }
+
+ /**
+ * Retrieves relation.
+ * @throws StatusException If the relation is not found.
+ */
+ public void before() {
+ prod = (EventProducer) tEnv.getObjRelation("EventProducer") ;
+ if (prod == null) {
+ throw new StatusException(Status.failed("Relation missed."));
+ }
+ EventMsg = (String) tEnv.getObjRelation("EventMsg");
+ Object dp = tEnv.getObjRelation("Destroy");
+ if (dp != null) {
+ destroy=true;
+ }
+ }
+
+ EventProducer prod = null ;
+ EvListener list = new EvListener();
+
+ /**
+ * Adds two listeners and fires event by mean of object relation. <p>
+ * Has <b> OK </b> status if both listeners were called
+ */
+ public void _addEventListener() {
+ log.println("adding listener");
+ oObj.addEventListener(list);
+ boolean isTransient = chkTransient(tEnv.getTestObject());
+ log.println("fire event");
+ prod.fireEvent() ;
+
+ try {
+ Thread.sleep(3000);
+ }
+ catch (InterruptedException ex) {
+ }
+
+ boolean works = true;
+
+ if (list.notifiedEvent == null) {
+ if (!isTransient) {
+ log.println("listener wasn't called");
+ works = false;
+ } else {
+ log.println("Object is Transient, listener isn't expected to be called");
+ }
+ oObj.removeEventListener(list);
+ }
+
+ if (EventMsg != null) {
+ log.println(EventMsg);
+ tRes.tested("addEventListener()", Status.skipped(true) );
+ return;
+ }
+
+ tRes.tested("addEventListener()", works );
+ }
+
+ /**
+ * Removes one of two listeners added before and and fires event
+ * by mean of object relation. <p>
+ *
+ * Has <b> OK </b> status if the removed listener wasn't called. <p>
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code>addEventListener()</code> : to have added listeners </li>
+ * </ul>
+ */
+ public void _removeEventListener() {
+ requiredMethod("addEventListener()");
+
+ list.notifiedEvent = null;
+
+ log.println("remove listener");
+ oObj.removeEventListener(list);
+
+ log.println("fire event");
+ prod.fireEvent() ;
+
+ try {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException ex) {
+ }
+
+ if (list.notifiedEvent == null) {
+ log.println("listener wasn't called -- OK");
+ }
+
+ tRes.tested("removeEventListener()", list.notifiedEvent == null);
+
+ }
+
+ protected static boolean chkTransient(Object Testcase) {
+ boolean ret = false;
+ XAccessibleContext accCon = (XAccessibleContext)
+ UnoRuntime.queryInterface(XAccessibleContext.class,Testcase);
+ if (accCon.getAccessibleStateSet().contains(
+ com.sun.star.accessibility.AccessibleStateType.TRANSIENT)){
+ if (!accCon.getAccessibleParent().getAccessibleContext().getAccessibleStateSet().contains(
+ com.sun.star.accessibility.AccessibleStateType.MANAGES_DESCENDANTS)) {
+ throw new lib.StatusException(lib.Status.failed("Parent doesn't manage descendents"));
+ }
+ ret=true;
+ }
+ return ret;
+ }
+
+ /**
+ * Forces environment recreation.
+ */
+ protected void after() {
+ if (destroy) disposeEnvironment();
+ }
+
+
+}
+
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleExtendedComponent.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleExtendedComponent.java
new file mode 100644
index 000000000000..422cfa96e334
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleExtendedComponent.java
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.accessibility.XAccessibleExtendedComponent;
+import com.sun.star.awt.XFont;
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleExtendedComponent</code>
+ * interface methods :
+ * <ul>
+ * <li><code> getForeground()</code></li>
+ * <li><code> getBackground()</code></li>
+ * <li><code> getFont()</code></li>
+ * <li><code> isEnabled()</code></li>
+ * <li><code> getTitledBorderText()</code></li>
+ * <li><code> getToolTipText()</code></li>
+ * </ul> <p>
+ * @see com.sun.star.accessibility.XAccessibleExtendedComponent
+ */
+public class _XAccessibleExtendedComponent extends MultiMethodTest {
+
+ public XAccessibleExtendedComponent oObj = null;
+
+ /**
+ * Just calls the method.
+ * deprecated from version srx644g 29.10.02 on
+ *
+ public void _getForeground() {
+ int forColor = oObj.getForeground();
+ log.println("getForeground(): " + forColor);
+ tRes.tested("getForeground()", true);
+ }
+
+ /**
+ * Just calls the method.
+ * deprecated from version srx644g 29.10.02 on
+ *
+ public void _getBackground() {
+ int backColor = oObj.getBackground();
+ log.println("getBackground(): " + backColor);
+ tRes.tested("getBackground()", true);
+ }
+
+ /**
+ * Just calls the method.
+ */
+ public void _getFont() {
+ XFont font = oObj.getFont();
+ log.println("getFont(): " + font);
+ tRes.tested("getFont()", true);
+ }
+
+ /**
+ * Calls the method and compares returned value with value that was
+ * returned by the method
+ * <code>XAccessibleStateSet.contains(AccessibleStateType.ENABLED)</code>.
+ * Has OK status if returned values are equal.
+ * deprecated from version srx644g 29.10.02 on
+ *
+ public void _isEnabled() {
+ boolean isEnabled = oObj.isEnabled();
+ log.println("isEnabled(): " + isEnabled);
+
+ boolean res = true;
+
+ XAccessibleStateSet accStateSet = (XAccessibleStateSet)
+ UnoRuntime.queryInterface(XAccessibleStateSet.class, oObj);
+
+ if (accStateSet != null) {
+ res = accStateSet.contains(AccessibleStateType.ENABLED)==isEnabled;
+ }
+
+ tRes.tested("isEnabled()", res);
+ }
+
+ /**
+ * Calls the method and checks returned value.
+ * Has OK status if returned value isn't null.
+ */
+ public void _getTitledBorderText() {
+ String titleBorderText = oObj.getTitledBorderText();
+ log.println("getTitledBorderText(): '" + titleBorderText + "'");
+ tRes.tested("getTitledBorderText()", titleBorderText != null);
+ }
+
+ /**
+ * Calls the method and checks returned value.
+ * Has OK status if returned value isn't null.
+ */
+ public void _getToolTipText() {
+ String toolTipText = oObj.getToolTipText();
+ log.println("getToolTipText(): '" + toolTipText + "'");
+ tRes.tested("getToolTipText()", toolTipText != null);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleImage.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleImage.java
new file mode 100644
index 000000000000..7a4dfafff615
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleImage.java
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.accessibility.XAccessibleImage;
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleImage</code>
+ * interface methods :
+ * <ul>
+ * <li><code>getAccessibleImageDescription()</code></li>
+ * <li><code>getAccessibleImageHeight()</code></li>
+ * <li><code>getAccessibleImageWidth()</code></li>
+ * </ul> <p>
+ * @see com.sun.star.accessibility.XAccessibleImage
+ */
+public class _XAccessibleImage extends MultiMethodTest {
+
+ public XAccessibleImage oObj = null;
+
+ /**
+ * Just calls the method.
+ */
+ public void _getAccessibleImageDescription() {
+ String descr = oObj.getAccessibleImageDescription();
+ log.println("getAccessibleImageDescription(): '" + descr + "'");
+ tRes.tested("getAccessibleImageDescription()", descr != null);
+ }
+
+ /**
+ * Just calls the method.
+ */
+ public void _getAccessibleImageHeight() {
+ int height = oObj.getAccessibleImageHeight();
+ log.println("getAccessibleImageHeight(): " + height);
+ tRes.tested("getAccessibleImageHeight()", true);
+ }
+
+ /**
+ * Just calls the method.
+ */
+ public void _getAccessibleImageWidth() {
+ int width = oObj.getAccessibleImageWidth();
+ log.println("getAccessibleImageWidth(): " + width);
+ tRes.tested("getAccessibleImageWidth()", true);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java
new file mode 100644
index 000000000000..e575e332845b
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java
@@ -0,0 +1,600 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package ifc.accessibility;
+
+import com.sun.star.accessibility.AccessibleRole;
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleSelection;
+import com.sun.star.uno.UnoRuntime;
+
+import lib.MultiMethodTest;
+import lib.Status;
+import lib.StatusException;
+
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleSelection</code>
+ * interface methods :
+ * <ul>
+ * <li><code>selectAccessibleChild()</code></li>
+ * <li><code>isAccessibleChildSelected()</code></li>
+ * <li><code>clearAccessibleSelection()</code></li>
+ * <li><code>selectAllAccessibleChildren()</code></li>
+ * <li><code>getSelectedAccessibleChildCount()</code></li>
+ * <li><code>getSelectedAccessibleChild()</code></li>
+ * <li><code>deselectAccessibleChild()</code></li>
+ * </ul> <p>
+ *
+ * This test needs the following object relations :
+ * <ul>
+ * <li> <code>'XAccessibleSelection.multiSelection'</code>
+ * (of type <code>Boolean</code>) <b> optional </b>:
+ * Indicates whether or not mutiply children could be selected.
+ * If the relation is <code>false</code> then more than 1 child
+ * couldn't be selected. </li>
+ * </ul> <p>
+ *
+ * @see com.sun.star.accessibility.XAccessibleSelection
+ */
+public class _XAccessibleSelection extends MultiMethodTest {
+ private static final String className = "com.sun.star.accessibility.XAccessibleSelection";
+ public XAccessibleSelection oObj = null;
+ XAccessibleContext xAC = null;
+ int childCount;
+ protected boolean multiSelection = true;
+ protected boolean OneAlwaysSelected = false;
+
+ // temporary while accessibility package is in com.sun.star
+ protected String getTestedClassName() {
+ return className;
+ }
+
+ /**
+ * Retrieves the interface <code>XAccessibleContext</code>
+ * and object relation.
+ * @see com.sun.star.accessibility.XAccessibleContext
+ * @see ifc.accessibility.XAccessibleContext
+ */
+ protected void before() {
+ xAC = (XAccessibleContext) UnoRuntime.queryInterface(
+ XAccessibleContext.class, oObj);
+
+ if (xAC == null) {
+ throw new StatusException(Status.failed(
+ "Couldn't query XAccessibleContext. Test must be modified"));
+ }
+
+ Boolean b = (Boolean) tEnv.getObjRelation(
+ "XAccessibleSelection.multiSelection");
+
+ if (b != null) {
+ multiSelection = b.booleanValue();
+ }
+
+ Boolean b2 = (Boolean) tEnv.getObjRelation(
+ "XAccessibleSelection.OneAlwaysSelected");
+
+ if (b2 != null) {
+ OneAlwaysSelected = b2.booleanValue();
+ }
+
+ childCount = xAC.getAccessibleChildCount();
+ log.println("Child count: " + childCount);
+ }
+
+ /**
+ * Selects accessible child with index some wrong indexes
+ * and with legal index.
+ * Has OK status if exception was thrown for wrong indexes
+ * and if exception wasn't thrown for correct index.
+ */
+ public void _selectAccessibleChild() {
+ boolean res = true;
+
+ try {
+ log.println("Try to select child with index " + childCount);
+ oObj.selectAccessibleChild(childCount);
+ log.println("Exception was expected");
+ res = false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res = true;
+ }
+
+ try {
+ log.println("Try to select child with index -1");
+ oObj.selectAccessibleChild(-1);
+ log.println("Exception was expected");
+ res = false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ log.println("ChildCount: " + childCount);
+
+ int usedChilds = childCount;
+
+ if (childCount > 500) {
+ log.println("Restricting to 500");
+ usedChilds = 500;
+ }
+
+ if (usedChilds > 0) {
+ try {
+ for (int i = 0; i < usedChilds; i++) {
+ log.print("Trying to select child with index " + i + ": ");
+
+ if (isSelectable(tEnv.getTestObject(), i)) {
+ oObj.selectAccessibleChild(i);
+ log.println("OK");
+ } else {
+ log.println("Child isn't selectable");
+ }
+ }
+
+ res &= true;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res = false;
+ }
+ }
+
+ tRes.tested("selectAccessibleChild()", res);
+ }
+
+ /**
+ * Calls the method with the wrong index and with the correct index.
+ * Has OK status if exception was thrown for wrong index and
+ * if exception wasn't thrown for the correct index.
+ */
+ public void _isAccessibleChildSelected() {
+ executeMethod("selectAccessibleChild()");
+
+ boolean res = true;
+ boolean isSelected = false;
+
+ try {
+ log.print("isAccessibleChildSelected(-1)? ");
+ isSelected = oObj.isAccessibleChildSelected(-1);
+ log.println(res);
+ log.println("Exception was expected");
+ res = false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res = true;
+ }
+
+ try {
+ log.print("isAccessibleChildSelected(" + childCount + ")? ");
+ isSelected = oObj.isAccessibleChildSelected(childCount);
+ log.println(isSelected);
+ log.println("Exception was expected");
+ res = false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ int SelectableChildCount = chkSelectable(tEnv.getTestObject());
+
+ if (SelectableChildCount > 500) {
+ SelectableChildCount = 500;
+ }
+
+ log.println("SelectableChildCount: " + SelectableChildCount);
+
+ if (SelectableChildCount > 0) {
+ try {
+ oObj.selectAllAccessibleChildren();
+
+ for (int k = 0; k < SelectableChildCount; k++) {
+ log.println("Trying to select child with index " + k);
+
+ if (isSelectable(tEnv.getTestObject(), k)) {
+ oObj.selectAccessibleChild(k);
+ shortWait();
+ isSelected = oObj.isAccessibleChildSelected(k);
+ log.println("isAccessibleChildSelected - " +
+ isSelected);
+ res &= isSelected;
+ } else {
+ log.println("Child isn't selectable");
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res = false;
+ }
+ }
+
+ tRes.tested("isAccessibleChildSelected()", res);
+ }
+
+ /**
+ * Calls the method.
+ * Has OK status if the method <code>isAccessibleChildSelected()</code>
+ * returned <code>false</code>.
+ */
+ public void _clearAccessibleSelection() {
+ executeMethod("isAccessibleChildSelected()");
+
+ boolean res = true;
+
+ log.println("clearAccessibleSelection");
+ oObj.clearAccessibleSelection();
+
+
+ // clearAccessibleSelection() call is oneway so we need
+ // some waiting
+ shortWait();
+
+ if ((childCount > 0) && !OneAlwaysSelected) {
+ try {
+ log.print("isAccessibleChildSelected(" + (childCount - 1) +
+ ")? ");
+
+ boolean isSel = oObj.isAccessibleChildSelected(childCount - 1);
+ log.println(isSel);
+ res = !isSel;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res = false;
+ }
+ } else if (OneAlwaysSelected) {
+ log.println("Can't clear selection, one child is always selected");
+ }
+
+ tRes.tested("clearAccessibleSelection()", res);
+ }
+
+ /**
+ * Calls the method.
+ * Has OK status if the method <code>isAccessibleChildSelected()</code>
+ * returns <code>true</code> for first and for last accessible child
+ * or if multiselection is not allowed.
+ */
+ public void _selectAllAccessibleChildren() {
+ executeMethod("clearAccessibleSelection()");
+
+ log.println("selectAllAccessibleChildren...");
+ oObj.selectAllAccessibleChildren();
+
+
+ // selectAllAccessibleChildren() call is oneway so we need
+ // some waiting
+ shortWait();
+
+ boolean res = true;
+ boolean isSelected = true;
+
+ int SelectableChildCount = chkSelectable(tEnv.getTestObject());
+
+ if ((SelectableChildCount > 0) && multiSelection) {
+ try {
+ log.print("isAccessibleChildSelected(1)? ");
+ isSelected = oObj.isAccessibleChildSelected(1);
+ log.println(isSelected);
+ res = isSelected;
+
+ log.print("isAccessibleChildSelected(" + (childCount - 1) +
+ ")? ");
+ isSelected = oObj.isAccessibleChildSelected(childCount - 1);
+ log.println(isSelected);
+ res &= isSelected;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res = false;
+ }
+ }
+
+ tRes.tested("selectAllAccessibleChildren()", res);
+ }
+
+ /**
+ * Calls the method. Clears accessible selection and calls the method again.
+ * <p>
+ * Has OK status if the method returns number equal to number of accessible
+ * child count after first call if multiselection allowed, or
+ * 1 returned if multiselection not allowed.
+ * And if the method returns a zero after clearing selection.
+ */
+ public void _getSelectedAccessibleChildCount() {
+ log.println("getSelectedAccessibleChildCount():");
+
+ if (multiSelection) {
+ oObj.selectAllAccessibleChildren();
+ } else {
+ int usedChilds = childCount;
+
+ if (childCount > 500) {
+ log.println("Restricting to 500");
+ usedChilds = 500;
+ }
+
+ if (usedChilds > 0) {
+ try {
+ for (int i = 0; i < usedChilds; i++) {
+
+ if (isSelectable(tEnv.getTestObject(), i)) {
+ log.print("Trying to select child with index "+i+": ");
+ oObj.selectAccessibleChild(i);
+ long curtime = System.currentTimeMillis();
+ long checktime = System.currentTimeMillis();
+
+ while (!oObj.isAccessibleChildSelected(i) && (checktime-curtime<5000)) {
+ checktime = System.currentTimeMillis();
+ }
+
+ log.println("OK");
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ }
+ }
+ }
+
+ int sCount = chkSelectable(tEnv.getTestObject());
+ log.println("Found " + sCount + " selectable Childs");
+
+ int selectedCount = oObj.getSelectedAccessibleChildCount();
+ log.println("After selecting all accessible " + selectedCount +
+ " are selected");
+
+ boolean res = true;
+
+ if (multiSelection) {
+ res &= (selectedCount == sCount);
+ } else {
+ res &= (selectedCount == 1);
+ }
+
+ log.println("clearAccessibleSelection...");
+ oObj.clearAccessibleSelection();
+ log.print("getSelectedAccessibleChildCount: ");
+ selectedCount = oObj.getSelectedAccessibleChildCount();
+ log.println(selectedCount);
+
+ if (OneAlwaysSelected) {
+ res &= (selectedCount == 1);
+ } else {
+ res &= (selectedCount == 0);
+ }
+
+ tRes.tested("getSelectedAccessibleChildCount()", res);
+ }
+
+ /**
+ * Calls the method with wrong and correct indexes.
+ * Has OK status if exception was thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if the method have returned a not null for the correct index.
+ */
+ public void _getSelectedAccessibleChild() {
+ executeMethod("getSelectedAccessibleChildCount()");
+
+ boolean res = true;
+ int selectedCount = oObj.getSelectedAccessibleChildCount();
+ log.println("getSelectedAccessibleChildCount: " + selectedCount);
+
+ try {
+ log.println("getSelectedAccessibleChild(-1)");
+ oObj.getSelectedAccessibleChild(-1);
+ log.println("Exception was expected");
+ res = false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res = true;
+ }
+
+ try {
+ log.println("getSelectedAccessibleChild(" + selectedCount + ")");
+ oObj.getSelectedAccessibleChild(selectedCount);
+ log.println("Exception was expected");
+ res &= false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ int SelectableChildCount = chkSelectable(tEnv.getTestObject());
+
+ if (SelectableChildCount > 500) {
+ SelectableChildCount = 500;
+ }
+
+ if (SelectableChildCount > 0) {
+ int k = 0;
+ try {
+ for (k = 0; k < SelectableChildCount; k++) {
+ log.println("Trying to select child with index " + k);
+
+ if (isSelectable(tEnv.getTestObject(), k)) {
+ oObj.selectAccessibleChild(k);
+ shortWait();
+ log.println("selected child count: " +
+ oObj.getSelectedAccessibleChildCount());
+ XAccessible selChild = oObj.getSelectedAccessibleChild(0);
+ res &= (selChild != null);
+ log.println("valid child - " + (selChild != null));
+ } else {
+ log.println("Child isn't selectable");
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception: Last relevant calls:\n " +
+ "\toObj.selectAccessibleChild("+k+")\n" +
+ "\toObj.getSelectedAccessibleChild(0)");
+ e.printStackTrace(log);
+ res = false;
+ }
+ }
+
+ tRes.tested("getSelectedAccessibleChild()", res);
+ }
+
+ /**
+ * Calls the method with wrong and with correct indexes.
+ * Has OK status if exceptions were thrown for the calls with
+ * the wrong indexes, if exception wasn't thrown for the call
+ * with correct index and if number of selected child was
+ * decreased after the correct call.
+ */
+ public void _deselectAccessibleChild() {
+ executeMethod("getSelectedAccessibleChild()");
+
+ boolean res = true;
+ int selCount = oObj.getSelectedAccessibleChildCount();
+ log.println("getSelectedAccessibleChildCount():" + selCount);
+
+ try {
+ log.println("deselectAccessibleChild(-1)");
+ oObj.deselectAccessibleChild(-1);
+ log.println("Exception was expected");
+ res = false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ try {
+ log.println("deselectAccessibleChild(" + (childCount + 1) + ")");
+ oObj.deselectAccessibleChild(childCount + 1);
+ log.println("Exception was expected");
+ res = false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ log.println("#################");
+ log.println("Selecting all accessible");
+ oObj.selectAllAccessibleChildren();
+ selCount = oObj.getSelectedAccessibleChildCount();
+ log.println("getSelectedAccessibleChildCount():" + selCount);
+
+ if ((childCount > 0) && (selCount > 0)) {
+ try {
+ int maxCount = chkSelectable(tEnv.getTestObject());
+
+ if (childCount > 100) {
+ maxCount = 100;
+ }
+
+ for (int k = 0; k < maxCount; k++) {
+ log.println("deselectAccessibleChild(" + k + ")");
+
+ if (oObj.isAccessibleChildSelected(k)) {
+ oObj.deselectAccessibleChild(k);
+ }
+ }
+
+ int newSelCount = oObj.getSelectedAccessibleChildCount();
+ log.println("getSelectedAccessibleChildCount():" +
+ newSelCount);
+
+ if (OneAlwaysSelected && (selCount == 1)) {
+ log.println("One Child is always selected");
+ res &= true;
+ } else {
+ res &= (selCount > newSelCount);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res = false;
+ }
+ }
+
+ tRes.tested("deselectAccessibleChild()", res);
+ }
+
+ protected static int chkSelectable(Object Testcase) {
+ int ret = 0;
+ XAccessibleContext accCon = (XAccessibleContext) UnoRuntime.queryInterface(
+ XAccessibleContext.class, Testcase);
+ int cc = accCon.getAccessibleChildCount();
+
+ if (cc > 500) {
+ return cc;
+ }
+
+ for (int i = 0; i < cc; i++) {
+ try {
+ if (accCon.getAccessibleChild(i).getAccessibleContext()
+ .getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SELECTABLE)) {
+ ret = ret + 1;
+ System.out.println("Child " + i + " is selectable");
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException iab) {
+ }
+ }
+
+ return ret;
+ }
+
+ protected static boolean isSelectable(Object Testcase, int index) {
+ XAccessibleContext accCon = (XAccessibleContext) UnoRuntime.queryInterface(
+ XAccessibleContext.class, Testcase);
+ boolean res = false;
+
+ try {
+ if (accCon.getAccessibleChild(index).getAccessibleContext()
+ .getAccessibleStateSet()
+ .contains(com.sun.star.accessibility.AccessibleStateType.SELECTABLE)) {
+ res = true;
+ }
+
+ //selecting menuitems or the separator will lead to closing the menu
+ if ((accCon.getAccessibleChild(index).getAccessibleContext()
+ .getAccessibleRole() == AccessibleRole.MENU_ITEM) ||
+ (accCon.getAccessibleChild(index).getAccessibleContext()
+ .getAccessibleRole() == AccessibleRole.SEPARATOR)) {
+ res = false;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ System.out.println("Exception while checking for selectability");
+ }
+
+ return res;
+ }
+
+ private void shortWait() {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ex) {
+ }
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java
new file mode 100644
index 000000000000..fa851bb79ea2
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java
@@ -0,0 +1,1010 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+import lib.MultiMethodTest;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleSelection;
+import com.sun.star.accessibility.XAccessibleTable;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleTable</code>
+ * interface methods :
+ * <ul>
+ * <li><code>getAccessibleRowCount()</code></li>
+ * <li><code>getAccessibleColumnCount()</code></li>
+ * <li><code>getAccessibleRowDescription()</code></li>
+ * <li><code>getAccessibleColumnDescription()</code></li>
+ * <li><code>getAccessibleRowExtentAt()</code></li>
+ * <li><code>getAccessibleColumnExtentAt()</code></li>
+ * <li><code>getAccessibleRowHeaders()</code></li>
+ * <li><code>getAccessibleColumnHeaders()</code></li>
+ * <li><code>getSelectedAccessibleRows()</code></li>
+ * <li><code>getSelectedAccessibleColumns()</code></li>
+ * <li><code>isAccessibleRowSelected()</code></li>
+ * <li><code>isAccessibleColumnSelected()</code></li>
+ * <li><code>getAccessibleCellAt()</code></li>
+ * <li><code>getAccessibleCaption()</code></li>
+ * <li><code>getAccessibleSummary()</code></li>
+ * <li><code>isAccessibleSelected()</code></li>
+ * <li><code>getAccessibleIndex()</code></li>
+ * <li><code>getAccessibleRow()</code></li>
+ * <li><code>getAccessibleColumn()</code></li>
+ * </ul> <p>
+ * @see com.sun.star.accessibility.XAccessibleTable
+ */
+public class _XAccessibleTable extends MultiMethodTest {
+
+ public XAccessibleTable oObj = null;
+ XAccessibleSelection xASel = null;
+ XAccessibleContext xACont = null;
+
+ protected void before() {
+ xASel = (XAccessibleSelection)
+ UnoRuntime.queryInterface(XAccessibleSelection.class, oObj);
+ if (xASel == null) {
+ log.println("The component doesn't implement the interface " +
+ "XAccessibleSelection.");
+ log.println("This interface is required for more detailed tests.");
+ }
+
+ xACont = (XAccessibleContext)
+ UnoRuntime.queryInterface(XAccessibleContext.class, oObj);
+ }
+
+ int rowCount = 0;
+
+ /**
+ * Calls the method and stores the returned value to the variable
+ * <code>rowCount</code>.
+ */
+ public void _getAccessibleRowCount() {
+ rowCount = oObj.getAccessibleRowCount();
+ log.println("Accessible row count: " + rowCount);
+ tRes.tested("getAccessibleRowCount()", true);
+ }
+
+ int colCount = 0;
+
+ /**
+ * Calls the method and stores the returned value to the variable
+ * <code>colCount</code>.
+ */
+ public void _getAccessibleColumnCount() {
+ colCount = oObj.getAccessibleColumnCount();
+ log.println("Accessible column count: " + colCount);
+ tRes.tested("getAccessibleColumnCount()", true);
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct index,
+ * checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if returned value isn't <code>null</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleRowDescription() {
+ requiredMethod("getAccessibleRowCount()");
+ boolean res = true;
+
+ try {
+ log.print("getAccessibleRowDescription(-1): ");
+ String descr = oObj.getAccessibleRowDescription(-1);
+ log.println("'" + descr + "'");
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRowDescription(" + rowCount + "): ");
+ String descr = oObj.getAccessibleRowDescription(rowCount);
+ log.println("'" + descr + "'");
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRowDescription(" + (rowCount - 1) + "): ");
+ String descr =
+ oObj.getAccessibleRowDescription(rowCount - 1);
+ res &= descr != null;
+ log.println("'" + descr + "'");
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleRowDescription()", res);
+ }
+
+ /**
+ * Calls the method with the wrong indexes and with the correct index,
+ * checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if returned value isn't <code>null</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleColumnCount()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleColumnDescription() {
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+
+ try {
+ log.print("getAccessibleColumnDescription(-1): ");
+ String descr = oObj.getAccessibleColumnDescription(-1);
+ log.println("'" + descr + "'");
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumnDescription(" + colCount + "): ");
+ String descr = oObj.getAccessibleColumnDescription(colCount);
+ log.println("'" + descr + "'");
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumnDescription(" + (colCount - 1) + "): ");
+ String descr =
+ oObj.getAccessibleColumnDescription(colCount - 1);
+ res &= descr != null;
+ log.println("'" + descr + "'");
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleColumnDescription()", res);
+ }
+
+
+ /**
+ * Calls the method with the wrong parameters and with the correct
+ * parameters, checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if returned value is greater than or is equal to 1.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleColumnCount()</code> </li>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleRowExtentAt() {
+ requiredMethod("getAccessibleRowCount()");
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+
+ try {
+ log.print("getAccessibleRowExtentAt(-1," + (colCount-1) + "):");
+ int ext = oObj.getAccessibleRowExtentAt(-1, colCount - 1);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRowExtentAt(" + (rowCount-1) + ",-1):");
+ int ext = oObj.getAccessibleRowExtentAt(rowCount - 1, -1);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRowExtentAt(0," + colCount + "):");
+ int ext = oObj.getAccessibleRowExtentAt(0, colCount);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRowExtentAt(" + rowCount + ",0):");
+ int ext = oObj.getAccessibleRowExtentAt(rowCount, 0);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRowExtentAt(" +
+ (rowCount-1) + "," + (colCount-1) + "):");
+ int ext = oObj.getAccessibleRowExtentAt(rowCount-1, colCount - 1);
+ log.println(ext);
+ res &= ext >= 1;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleRowExtentAt()", res);
+ }
+
+ /**
+ * Calls the method with the wrong parameters and with the correct
+ * parameters, checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if returned value is greater than or is equal to 1.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleColumnCount()</code> </li>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleColumnExtentAt() {
+ requiredMethod("getAccessibleRowCount()");
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+
+ try {
+ log.print("getAccessibleColumnExtentAt(-1," + (colCount-1) + "):");
+ int ext = oObj.getAccessibleColumnExtentAt(-1, colCount - 1);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumnExtentAt(" + (rowCount-1) + ",-1):");
+ int ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, -1);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumnExtentAt(0," + colCount + "):");
+ int ext = oObj.getAccessibleColumnExtentAt(0, colCount);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumnExtentAt(" + rowCount + ",0):");
+ int ext = oObj.getAccessibleColumnExtentAt(rowCount, 0);
+ log.println(ext);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumnExtentAt(" +
+ (rowCount-1) + "," + (colCount-1) + "):");
+ int ext = oObj.getAccessibleColumnExtentAt(rowCount-1,colCount - 1);
+ log.println(ext);
+ res &= ext >= 1;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleColumnExtentAt()", res);
+ }
+
+ /**
+ * Calls the method and checks a returned value.
+ * Has OK status if returned value isn't <code>null</code>.
+ */
+ public void _getAccessibleRowHeaders() {
+ XAccessibleTable rowHeaders = oObj.getAccessibleRowHeaders();
+ log.println("getAccessibleRowHeaders(): " + rowHeaders);
+ tRes.tested("getAccessibleRowHeaders()", true);
+ }
+
+ /**
+ * Calls the method and checks a returned value.
+ * Has OK status if returned value isn't <code>null</code>.
+ */
+ public void _getAccessibleColumnHeaders() {
+ XAccessibleTable colHeaders = oObj.getAccessibleColumnHeaders();
+ log.println("getAccessibleColumnHeaders(): " + colHeaders);
+ tRes.tested("getAccessibleColumnHeaders()", true);
+ }
+
+ /**
+ * If the interface <code>XAccessibleSelection</code> is supported by
+ * the component than selects all accessible childs.
+ * Calls the method and checks a returned sequence.
+ * Has OK status if a returned sequince is in ascending order.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _getSelectedAccessibleRows() {
+ requiredMethod("getAccessibleRowCount()");
+ boolean res = true;
+ boolean locRes = true;
+ int selRows[] = null;
+
+ if (xASel != null) {
+ log.println("XAccessibleSelection.selectAllAccessibleChildren()");
+ xASel.selectAllAccessibleChildren();
+ }
+
+ log.println("getSelectedAccessibleRows()");
+ selRows = oObj.getSelectedAccessibleRows();
+ log.println("Length of the returned sequince: " + selRows.length);
+ if (xASel != null) {
+ res &= selRows.length == rowCount;
+ } else {
+ res &= selRows.length == 0;
+ }
+
+ if (selRows.length > 0) {
+ log.println("Checking that returned sequence is" +
+ " in ascending order");
+ }
+
+ for(int i = 1; i < selRows.length; i++) {
+ locRes &= selRows[i] >= selRows[i - 1];
+ res &= locRes;
+ if (!locRes) {
+ log.println("Element #" + i + ":" + selRows[i] +
+ " is less than element #" + (i-1) + ": " +
+ selRows[i-1]);
+ break;
+ }
+ }
+
+ tRes.tested("getSelectedAccessibleRows()", res);
+ }
+
+ /**
+ * If the interface <code>XAccessibleSelection</code> is supported by
+ * the component than selects all accessible childs.
+ * Calls the method and checks a returned sequence.
+ * Has OK status if a returned sequince is in ascending order.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleColumnCount()</code> </li>
+ * </ul>
+ */
+ public void _getSelectedAccessibleColumns() {
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+ boolean locRes = true;
+ int selCols[] = null;
+
+ if (xASel != null) {
+ log.println("XAccessibleSelection.selectAllAccessibleChildren()");
+ xASel.selectAllAccessibleChildren();
+ }
+
+ log.println("getSelectedAccessibleColumns()");
+ selCols = oObj.getSelectedAccessibleColumns();
+ log.println("Length of the returned sequince: " + selCols.length);
+
+ if (xASel != null) {
+ res &= selCols.length == colCount;
+ } else {
+ res &= selCols.length == 0;
+ }
+
+ if (selCols.length > 0) {
+ log.println("Checking that returned sequence is" +
+ " in ascending order");
+ }
+
+ for(int i = 1; i < selCols.length; i++) {
+ locRes &= selCols[i] >= selCols[i - 1];
+ res &= locRes;
+ if (!locRes) {
+ log.println("Element #" + i + ":" + selCols[i] +
+ " is less than element #" + (i-1) + ": " +
+ selCols[i-1]);
+ break;
+ }
+ }
+
+ tRes.tested("getSelectedAccessibleColumns()", res);
+ }
+
+ /**
+ * Calls the method with invalid indexes.
+ * If the interface <code>XAccessibleSelection</code> is supported by
+ * the component than selects all accessible childs.
+ * Calls the method for every row and checks returned values.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _isAccessibleRowSelected() {
+ requiredMethod("getAccessibleRowCount()");
+ boolean res = true;
+ boolean locRes = true;
+
+ try {
+ log.print("isAccessibleRowSelected(-1): ");
+ locRes = oObj.isAccessibleRowSelected(-1);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("isAccessibleRowSelected(" + rowCount + "): ");
+ locRes = oObj.isAccessibleRowSelected(rowCount);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ if (xASel != null) {
+ log.println("XAccessibleSelection.selectAllAccessibleChildren()");
+ xASel.selectAllAccessibleChildren();
+ }
+
+ try {
+ log.println("Checking of every row selection...");
+ for(int i = 0; i < rowCount; i++) {
+ boolean isSel = oObj.isAccessibleRowSelected(i);
+ locRes = (xASel == null) ? !isSel : isSel;
+ res &= locRes;
+ if (!locRes) {
+ log.println("isAccessibleRowSelected(" + i + "): " + isSel);
+ break;
+ }
+ }
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("isAccessibleRowSelected()", res);
+ }
+
+ /**
+ * Calls the method with invalid indexes.
+ * If the interface <code>XAccessibleSelection</code> is supported by
+ * the component than selects all accessible childs.
+ * Calls the method for every column and checks returned values.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _isAccessibleColumnSelected() {
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+ boolean locRes = true;
+
+ try {
+ log.print("isAccessibleColumnSelected(-1): ");
+ locRes = oObj.isAccessibleColumnSelected(-1);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("isAccessibleColumnSelected(" + colCount + "): ");
+ locRes = oObj.isAccessibleColumnSelected(colCount);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ if (xASel != null) {
+ log.println("XAccessibleSelection.selectAllAccessibleChildren()");
+ xASel.selectAllAccessibleChildren();
+ }
+
+ try {
+ log.println("Checking of every column selection...");
+ for(int i = 0; i < colCount; i++) {
+ boolean isSel = oObj.isAccessibleColumnSelected(i);
+ locRes = (xASel == null) ? !isSel : isSel;
+ res &= locRes;
+ if (!locRes) {
+ log.println("isAccessibleColumnSelected(" + i + "): " + isSel);
+ break;
+ }
+ }
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("isAccessibleColumnSelected()", res);
+ }
+
+ XAccessible xCellAc = null;
+
+ /**
+ * Calls the method with the wrong parameters and with the correct
+ * parameter, checks a returned value and stores it to the variable
+ * <code>xCellAc</code>.
+ * Has OK status if exceptions were 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:
+ * <ul>
+ * <li> <code>getAccessibleColumnCount()</code> </li>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleCellAt() {
+ requiredMethod("getAccessibleRowCount()");
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+
+ try {
+ log.print("getAccessibleCellAt(-1," + (colCount-1) + "):");
+ xCellAc = oObj.getAccessibleCellAt(-1, colCount - 1);
+ log.println(xCellAc);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleCellAt(" + (rowCount-1) + ",-1):");
+ xCellAc = oObj.getAccessibleCellAt(rowCount - 1, -1);
+ log.println(xCellAc);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleCellAt(0, " + colCount + "):");
+ xCellAc = oObj.getAccessibleCellAt(0, colCount);
+ log.println(xCellAc);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleCellAt(" + rowCount + ",0):");
+ XAccessible xCellAc = oObj.getAccessibleCellAt(rowCount, 0);
+ log.println(xCellAc);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleCellAt(" + (rowCount-1) + "," +
+ (colCount-1) + "): ");
+ xCellAc = oObj.getAccessibleCellAt(
+ rowCount - 1, colCount - 1);
+ log.println(xCellAc);
+ res &= xCellAc != null;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleCellAt()", res);
+ }
+
+ /**
+ * Just calls the method.
+ */
+ public void _getAccessibleCaption() {
+ XAccessible caption = oObj.getAccessibleCaption();
+ log.println("getAccessibleCaption(): " + caption);
+ tRes.tested("getAccessibleCaption()", true);
+ }
+
+ /**
+ * Just calls the method.
+ */
+ public void _getAccessibleSummary() {
+ XAccessible summary = oObj.getAccessibleSummary();
+ log.println("getAccessibleSummary(): " + summary);
+ tRes.tested("getAccessibleSummary()", true);
+ }
+
+ /**
+ * Calls the method with the wrong parameters and with the correct
+ * parameter, checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleColumnCount()</code> </li>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _isAccessibleSelected() {
+ requiredMethod("getAccessibleRowCount()");
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+ boolean locRes = true;
+
+ try {
+ log.print("isAccessibleSelected(-1," + (colCount-1) + "):");
+ locRes = oObj.isAccessibleSelected(-1, colCount - 1);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("isAccessibleSelected(" + (rowCount-1) + ",-1):");
+ locRes = oObj.isAccessibleSelected(rowCount - 1, -1);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("isAccessibleSelected(0, " + colCount + "):");
+ locRes = oObj.isAccessibleSelected(0, colCount);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("isAccessibleSelected(" + rowCount + ",0):");
+ locRes = oObj.isAccessibleSelected(rowCount, 0);
+ log.println(locRes);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ if (xASel != null) {
+ log.println("XAccessibleSelection.selectAllAccessibleChildren()");
+ xASel.selectAllAccessibleChildren();
+ }
+
+ try {
+ log.print("isAccessibleSelected(" + (rowCount-1) + "," +
+ (colCount-1) + "): ");
+ boolean isSel = oObj.isAccessibleSelected(
+ rowCount - 1, colCount - 1);
+ log.println(isSel);
+ locRes = (xASel == null) ? !isSel : isSel ;
+ res &= locRes;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("isAccessibleSelected()", res);
+ }
+
+ /**
+ * Calls the method with the wrong parameters and with the correct
+ * parameter, checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if returned value is equal to value returned by calling
+ * <code>XAccessibleContext::getAccessibleIndexInParent</code> for the cell.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleCellAt()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleIndex() {
+ executeMethod("getAccessibleCellAt()");
+ boolean res = true;
+
+ try {
+ log.print("getAccessibleIndex(-1," + (colCount-1) + "):");
+ int indx = oObj.getAccessibleIndex(-1, colCount - 1);
+ log.println(indx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleIndex(" + (rowCount-1) + ",-1):");
+ int indx = oObj.getAccessibleIndex(rowCount - 1, -1);
+ log.println(indx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleIndex(0," + colCount + "):");
+ int indx = oObj.getAccessibleIndex(0, colCount);
+ log.println(indx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleIndex(" + rowCount + ",0):");
+ int indx = oObj.getAccessibleIndex(rowCount, 0);
+ log.println(indx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleIndex(" + (rowCount-1) + "," +
+ (colCount-1) + "): ");
+ int indx = oObj.getAccessibleIndex(
+ rowCount - 1, colCount - 1);
+ log.println(indx);
+ if (xCellAc != null) {
+ XAccessibleContext xAC = xCellAc.getAccessibleContext();
+ int expIndx = xAC.getAccessibleIndexInParent();
+ log.println("Expected index: " + expIndx);
+ res &= expIndx == indx;
+ } else {
+ res &= true;
+ }
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleIndex()", res);
+ }
+
+ /**
+ * Receives an accessible child count using the interface
+ * <code>XAccessibleContext</code>.
+ * Calls the method with the wrong parameters and with the correct
+ * parameter, checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if returned value is greater than zero and is less than
+ * accessible row count.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleRowCount()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleRow() {
+ requiredMethod("getAccessibleRowCount()");
+ boolean res = true;
+
+ if (xACont != null) {
+ int childCount = xACont.getAccessibleChildCount();
+ log.println("accessible child count: " + childCount);
+
+ try {
+ log.print("getAccessibleRow(" + childCount + "): ");
+ int rowIndx = oObj.getAccessibleRow(childCount);
+ log.println(rowIndx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRow(" + (childCount-1) + "): ");
+ int rowIndx = oObj.getAccessibleRow(childCount - 1);
+ log.println(rowIndx);
+ res &= (rowIndx >= 0 && rowIndx <= rowCount);
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+ }
+
+ try {
+ log.print("getAccessibleRow(-1): ");
+ int rowIndx = oObj.getAccessibleRow(-1);
+ log.println(rowIndx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleRow(0): ");
+ int rowIndx = oObj.getAccessibleRow(0);
+ log.println(rowIndx);
+ res &= (rowIndx >= 0 && rowIndx <= rowCount);
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleRow()", res);
+ }
+
+ /**
+ * Receives an accessible child count using the interface
+ * <code>XAccessibleContext</code>.
+ * Calls the method with the wrong parameters and with the correct
+ * parameter, checks a returned value.
+ * Has OK status if exceptions were thrown for the wrong indexes,
+ * if exception wasn't thrown for the correct index and
+ * if returned value is greater than zero and is less than
+ * accessible column count.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getAccessibleColumnCount()</code> </li>
+ * </ul>
+ */
+ public void _getAccessibleColumn() {
+ requiredMethod("getAccessibleColumnCount()");
+ boolean res = true;
+
+ if (xACont != null) {
+ int childCount = xACont.getAccessibleChildCount();
+ log.println("accessible child count: " + childCount);
+
+ try {
+ log.print("getAccessibleColumn(" + childCount + "): ");
+ int colIndx = oObj.getAccessibleColumn(childCount);
+ log.println(colIndx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumn(" + (childCount-1) + "): ");
+ int colIndx = oObj.getAccessibleColumn(childCount - 1);
+ log.println(colIndx);
+ res &= (colIndx >= 0 && colIndx <= colCount);
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+ }
+
+ try {
+ log.print("getAccessibleColumn(-1): ");
+ int colIndx = oObj.getAccessibleColumn(-1);
+ log.println(colIndx);
+ log.println("Exception was expected");
+ res &= false;
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getAccessibleColumn(0): ");
+ int colIndx = oObj.getAccessibleColumn(0);
+ log.println(colIndx);
+ res &= (colIndx >= 0 && colIndx <= rowCount);
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getAccessibleColumn()", res);
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java
new file mode 100644
index 000000000000..c72c25590396
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java
@@ -0,0 +1,1195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package ifc.accessibility;
+
+import lib.MultiMethodTest;
+import lib.Status;
+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;
+
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleText</code>
+ * interface methods :
+ * <ul>
+ * <li><code> getCaretPosition()</code></li>
+ * <li><code> setCaretPosition()</code></li>
+ * <li><code> getCharacter()</code></li>
+ * <li><code> getCharacterAttributes()</code></li>
+ * <li><code> getCharacterBounds()</code></li>
+ * <li><code> getCharacterCount()</code></li>
+ * <li><code> getIndexAtPoint()</code></li>
+ * <li><code> getSelectedText()</code></li>
+ * <li><code> getSelectionStart()</code></li>
+ * <li><code> getSelectionEnd()</code></li>
+ * <li><code> setSelection()</code></li>
+ * <li><code> getText()</code></li>
+ * <li><code> getTextRange()</code></li>
+ * <li><code> getTextAtIndex()</code></li>
+ * <li><code> getTextBeforeIndex()</code></li>
+ * <li><code> getTextBehindIndex()</code></li>
+ * <li><code> copyText()</code></li>
+ * </ul> <p>
+ * This test needs the following object relations :
+ * <ul>
+ * <li> <code>'XAccessibleText.Text'</code> (of type <code>String</code>)
+ * <b> optional </b> :
+ * the string presentation of component's text. If the relation
+ * is not specified, then text from method <code>getText()</code>
+ * is used.
+ * </li>
+ * </ul> <p>
+ * @see com.sun.star.accessibility.XAccessibleText
+ */
+public class _XAccessibleText extends MultiMethodTest {
+
+ public XAccessibleText oObj = null;
+ protected com.sun.star.awt.Rectangle bounds = null;
+ String text = null;
+ String editOnly = null;
+ Object LimitedBounds = null;
+ Rectangle chBounds = null;
+ int chCount = 0;
+
+
+ /**
+ * Retrieves a string representation of the component's text.
+ * The length of retrieved string must be greater than zero.
+ */
+ protected void before() {
+ Object xat = tEnv.getObjRelation("XAccessibleText");
+
+ XAccessibleComponent component = null;
+
+ if (xat != null) {
+ oObj = (XAccessibleText) UnoRuntime.queryInterface(
+ XAccessibleText.class, xat);
+ component = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xat);
+ }
+
+ 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"));
+ }
+
+ editOnly = (String) tEnv.getObjRelation("EditOnly");
+ LimitedBounds = tEnv.getObjRelation("LimitedBounds");
+
+ if (component == null) {
+ component = (XAccessibleComponent) UnoRuntime.queryInterface(
+ XAccessibleComponent.class,
+ tEnv.getTestObject());
+ }
+
+ bounds = component.getBounds();
+
+ log.println("Text is '" + text + "'");
+ System.out.println("############################");
+ }
+
+ /**
+ * Calls the method and checks returned value.
+ * Has OK status if returned value is equal to <code>chCount - 1</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>setCaretPosition()</code> </li>
+ * </ul>
+ */
+ public void _getCaretPosition() {
+ requiredMethod("getCharacterCount()");
+
+ if (editOnly != null) {
+ log.println(editOnly);
+ throw new StatusException(Status.skipped(true));
+ }
+
+ 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");
+ res = carPos == -1;
+ }
+
+ tRes.tested("getCaretPosition()", res);
+ }
+
+ /**
+ * Calls the method with the wrong index and with the correct index
+ * <code>chCount - 1</code>.
+ * 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:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _setCaretPosition() {
+ requiredMethod("getCharacterCount()");
+
+ boolean res = true;
+
+ try {
+ log.print("setCaretPosition(-1):");
+ oObj.setCaretPosition(-1);
+ res &= false;
+ log.println("exception was expected ... FAILED");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("setCaretPosition(chCount+1):");
+ oObj.setCaretPosition(chCount + 1);
+ res &= false;
+ log.println("exception was expected ... FAILED");
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("expected exception");
+ res &= true;
+ }
+
+ try {
+ log.println("setCaretPosition(chCount - 1)");
+ oObj.setCaretPosition(chCount - 1);
+ res &= true;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("unexpected exception ... FAILED");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("setCaretPosition()", 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:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _getCharacter() {
+ requiredMethod("getCharacterCount()");
+
+ 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(log);
+ res &= false;
+ }
+
+ tRes.tested("getCharacter()", 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 <code>null</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _getCharacterAttributes() {
+ requiredMethod("getCharacterCount()");
+
+ boolean res = true;
+ String[] attr = new String[] { "" };
+
+ try {
+ log.println("getCharacterAttributes(-1)");
+ oObj.getCharacterAttributes(-1, attr);
+ 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, attr);
+ 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-1)");
+
+ 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;
+ }
+
+ tRes.tested("getCharacterAttributes()", 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 <code>null</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _getCharacterBounds() {
+ requiredMethod("getCharacterCount()");
+
+ boolean res = true;
+
+ int lastIndex = chCount;
+
+ if (LimitedBounds != null) {
+ 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) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ try {
+ log.println("getCharacterBounds(" + (lastIndex + 1) + ")");
+ oObj.getCharacterBounds(lastIndex + 1);
+ log.println("Exception was expected");
+ res &= false;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ try {
+ for (int i = 0; i < lastIndex; 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) {
+ log.println("Text at this place: "+oObj.getCharacter(i));
+ 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);
+ res &= localres;
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getCharacterBounds()", res);
+ }
+
+ /**
+ * Calls the method and stores a returned value to the variable
+ * <code>chCount</code>.
+ * Has OK status if a returned value is equal to the text length.
+ */
+ public void _getCharacterCount() {
+ chCount = oObj.getCharacterCount();
+ log.println("Character count:" + chCount);
+
+ boolean res = chCount == text.length();
+ tRes.tested("getCharacterCount()", res);
+ }
+
+ /**
+ * Calls the method for an invalid point and for the point of rectangle
+ * returned by the method <code>getCharacterBounds()</code>.
+ * Has OK status if returned value is equal to <code>-1</code> for an
+ * invalid point and if returned value is equal to <code>chCount-1</code>
+ * for a valid point.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>getCharacterBounds()</code> </li>
+ * </ul>
+ */
+ 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);
+
+ int lastIndex = chCount;
+
+ if (LimitedBounds != null) {
+ if (LimitedBounds instanceof Integer) {
+ lastIndex = ((Integer) LimitedBounds).intValue();
+ } else {
+ lastIndex = chCount - 1;
+ }
+
+ log.println(LimitedBounds);
+ }
+
+ 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) {
+ }
+
+ 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);
+
+ x = aRect.X;
+ y = aRect.Y + (aRect.Height / 2);
+ aPoint = new Point(x, y);
+ int left = oObj.getIndexAtPoint(aPoint);
+
+
+
+ int[] previous = (int[]) tEnv.getObjRelation("PreviousUsed");
+
+ if (previous != null) {
+ for (int k = 0; k < previous.length; k++) {
+ if (i == previous[k]) {
+ nIndex++;
+ }
+ }
+ }
+
+ if (nIndex != i) {
+ // for some letters the center of the rectangle isn't recognised
+ // in this case we are happy if the left border of the rectangle
+ // returns the correct value.
+ if (left !=i) {
+ log.println("## Method didn't work for Point (" + x + "," + y +
+ ")");
+ log.println("Expected Index " + i);
+ log.println("Gained Index: " + nIndex);
+ log.println("Left Border: "+left);
+ log.println("CharacterAtIndex: " + text);
+ res &= false;
+ }
+ }
+ }
+
+ tRes.tested("getIndexAtPoint()", res);
+ }
+
+ /**
+ * Checks a returned values after different calls of the method
+ * <code>setSelection()</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>setSelection()</code> </li>
+ * </ul>
+ */
+ public void _getSelectedText() {
+ if (editOnly != null) {
+ log.println(editOnly);
+ throw new StatusException(Status.skipped(true));
+ }
+
+ 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);
+
+ log.println("setSelection(0, chCount)");
+ oObj.setSelection(0, chCount);
+ log.print("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.print("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(log);
+ res &= false;
+ }
+
+ tRes.tested("getSelectedText()", res);
+ }
+
+ /**
+ * Checks a returned values after different calls of the method
+ * <code>setSelection()</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>setSelection()</code> </li>
+ * </ul>
+ */
+ public void _getSelectionStart() {
+ if (editOnly != null) {
+ log.println(editOnly);
+ throw new StatusException(Status.skipped(true));
+ }
+
+ 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);
+
+ 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(log);
+ res &= false;
+ }
+
+ tRes.tested("getSelectionStart()", res);
+ }
+
+ /**
+ * Checks a returned values after different calls of the method
+ * <code>setSelection()</code>.
+ * The following method tests are to be executed before:
+ * <ul>
+ * <li> <code>setSelection()</code> </li>
+ * </ul>
+ */
+ public void _getSelectionEnd() {
+ if (editOnly != null) {
+ log.println(editOnly);
+ throw new StatusException(Status.skipped(true));
+ }
+
+ 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);
+
+ 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(log);
+ res &= false;
+ }
+
+ tRes.tested("getSelectionEnd()", 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:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _setSelection() {
+ requiredMethod("getCharacterCount()");
+
+ boolean res = true;
+ boolean locRes = true;
+
+ if (editOnly != null) {
+ log.println(editOnly);
+ throw new StatusException(Status.skipped(true));
+ }
+
+ try {
+ log.print("setSelection(-1, chCount-1):");
+ locRes = oObj.setSelection(-1, chCount - 1);
+ log.println(locRes + " excepion was expected");
+ res &= !locRes;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Expected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("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.print("setSelection(1, chCount-1):");
+ locRes = oObj.setSelection(1, chCount - 1);
+ log.println(locRes);
+ res &= locRes;
+
+ log.print("setSelection(chCount-1, 1):");
+ locRes = oObj.setSelection(chCount - 1, 1);
+ log.println(locRes);
+ res &= locRes;
+ }
+
+ log.print("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);
+ log.println(locRes);
+ res &= locRes;
+
+ log.print("setSelection(0, 0):");
+ locRes = oObj.setSelection(0, 0);
+ log.println(locRes);
+ res &= locRes;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("setSelection()", res);
+ }
+
+ /**
+ * Calls the method and checks returned value.
+ * Has OK status if returned string is equal to string
+ * received from relation.
+ */
+ public void _getText() {
+ String txt = oObj.getText();
+ log.println("getText: " + txt);
+
+ boolean res = txt.equals(text);
+ tRes.tested("getText()", 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:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _getTextRange() {
+ requiredMethod("getCharacterCount()");
+
+ boolean res = true;
+ boolean locRes = true;
+
+ String txtRange = "";
+
+ try {
+ if (chCount > 3) {
+ log.print("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));
+ }
+ }
+
+ log.print("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));
+ }
+
+ log.print("getTextRange(chCount, 0): ");
+ txtRange = oObj.getTextRange(chCount, 0);
+ log.println(txtRange);
+ res &= txtRange.equals(text);
+
+ log.print("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(log);
+ res &= false;
+ }
+
+ try {
+ log.print("getTextRange(-1, chCount - 1): ");
+
+ 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.print("getTextRange(0, chCount + 1): ");
+
+ 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.print("getTextRange(chCount+1, -1): ");
+
+ 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;
+ }
+
+ tRes.tested("getTextRange()", 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:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _getTextAtIndex() {
+ requiredMethod("getCharacterCount()");
+ TextSegment txt = null;
+ boolean res = true;
+
+ try {
+ log.print("getTextAtIndex(-1, AccessibleTextType.PARAGRAPH):");
+
+ 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("UnExpected exception");
+ res &= false;
+ }
+
+ try {
+ log.print("getTextAtIndex(chCount+1," +
+ " AccessibleTextType.PARAGRAPH):");
+
+ 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("UnExpected exception");
+ res &= false;
+ }
+
+ try {
+ log.print("getTextAtIndex(chCount," +
+ " AccessibleTextType.WORD):");
+
+ txt = oObj.getTextAtIndex(chCount, AccessibleTextType.WORD);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareLength(0,txt.SegmentText);
+ if (!tEnv.getTestCase().getObjectName().equals("SmGraphicAccessible")) {
+ log.print("getTextAtIndex(1," +
+ " 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) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getTextAtIndex()", 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:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _getTextBeforeIndex() {
+ requiredMethod("getCharacterCount()");
+ TextSegment txt = null;
+ boolean res = true;
+
+ try {
+ log.print("getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH):");
+
+ 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("UnExpected exception");
+ res &= false;
+ }
+
+ try {
+ log.print("getTextBeforeIndex(chCount+1, " +
+ "AccessibleTextType.PARAGRAPH):");
+
+ 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("UnExpected exception");
+ res &= true;
+ }
+
+ try {
+ if (!tEnv.getTestCase().getObjectName().equals("SmGraphicAccessible")) {
+ log.print("getTextBeforeIndex(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);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareLength(0, txt.SegmentText);
+
+ log.print("getTextBeforeIndex(chCount-1," +
+ " AccessibleTextType.CHARACTER):");
+ txt = oObj.getTextBeforeIndex(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);
+ log.println("'" + txt.SegmentText + "'");
+ res &= compareStrings(text.substring(1, 2), 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) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getTextBeforeIndex()", 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:
+ * <ul>
+ * <li> <code>getCharacterCount()</code> </li>
+ * </ul>
+ */
+ public void _getTextBehindIndex() {
+ requiredMethod("getCharacterCount()");
+ TextSegment txt = null;
+ boolean res = true;
+
+ try {
+ log.print("getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH):");
+
+ 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("UnExpected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getTextBehindIndex(chCount+1, " +
+ "AccessibleTextType.PARAGRAPH):");
+
+ 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("UnExpected exception");
+ res &= true;
+ }
+
+ try {
+ log.print("getTextBehindIndex(chCount," +
+ " AccessibleTextType.PARAGRAPH):");
+
+ txt = oObj.getTextBehindIndex(chCount,
+ AccessibleTextType.PARAGRAPH);
+ log.println("'" + txt.SegmentText + "'");
+ res &= (txt.SegmentText.length() == 0);
+
+ log.print("getTextBehindIndex(chCount-1," +
+ " AccessibleTextType.PARAGRAPH):");
+ txt = oObj.getTextBehindIndex(chCount - 1,
+ AccessibleTextType.PARAGRAPH);
+ log.println("'" + txt.SegmentText + "'");
+ res &= (txt.SegmentText.length() == 0);
+
+ log.print("getTextBehindIndex(1," +
+ " 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):");
+ 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(log);
+ res &= false;
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ tRes.tested("getTextBehindIndex()", 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 <code>true</code>.
+ */
+ public void _copyText() {
+ boolean res = true;
+ boolean locRes = true;
+
+ if (editOnly != null) {
+ log.println(editOnly);
+ throw new StatusException(Status.skipped(true));
+ }
+
+ try {
+ log.print("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.print("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.print("copyText(0,chCount):");
+ locRes = oObj.copyText(0, chCount);
+ log.println(locRes);
+ res &= locRes;
+
+ String cbText = null;
+
+ try {
+ 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);
+
+ if (chCount > 2) {
+ log.print("copyText(1,chCount-1):");
+ locRes = oObj.copyText(1, chCount - 1);
+ log.println(locRes);
+ res &= locRes;
+
+ try {
+ 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.substring(1, chCount - 1).equals(cbText);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ log.println("Unexpected exception");
+ e.printStackTrace(log);
+ res &= false;
+ }
+
+ 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
diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleValue.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleValue.java
new file mode 100644
index 000000000000..201d5675ff0c
--- /dev/null
+++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleValue.java
@@ -0,0 +1,351 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package ifc.accessibility;
+
+
+import lib.MultiMethodTest;
+import lib.Status;
+import lib.StatusException;
+
+import com.sun.star.accessibility.XAccessibleValue;
+
+/**
+ * Testing <code>com.sun.star.accessibility.XAccessibleValue</code>
+ * interface methods :
+ * <ul>
+ * <li><code> getCurrentValue()</code></li>
+ * <li><code> setCurrentValue()</code></li>
+ * <li><code> getMaximumValue()</code></li>
+ * <li><code> getMinimumValue()</code></li>
+ * </ul> <p>
+ *
+ * This test needs the following object relations :
+ * <ul>
+ * <li> <code>'XAccessibleValue.anotherFromGroup'</code>
+ * (of type <code>XAccessibleValue</code>) <b> optional </b>:
+ * another component from the group(e.g. radio button group)</li>
+ * </ul><p>
+ * @see com.sun.star.accessibility.XAccessibleValue
+ */
+public class _XAccessibleValue extends MultiMethodTest {
+
+ public XAccessibleValue oObj = null;
+
+ private double minVal = 0;
+ private double maxVal = 0;
+ private double curVal = 0;
+ private Object val = null;
+ XAccessibleValue anotherFromGroup = null;
+
+ protected void before() {
+ anotherFromGroup = (XAccessibleValue)tEnv.getObjRelation(
+ "XAccessibleValue.anotherFromGroup");
+ }
+
+ /**
+ * Gets current value and stores it as double. <p>
+ *
+ * Has <b> OK </b> status if the current value is between Min and Max
+ * values. <p>
+ *
+ * The following method tests are to be executed before :
+ * <ul>
+ * <li> <code> getMaximumValue </code> </li>
+ * <li> <code> getMinimumValue </code> </li>
+ * </ul>
+ */
+ public void _getCurrentValue() {
+ executeMethod("getMaximumValue()");
+ executeMethod("getMinimumValue()");
+
+ boolean result = true;
+
+ double curVal ;
+ val = oObj.getCurrentValue() ;
+ if (util.utils.isVoid(val)) {
+ val = new Integer(0);
+ curVal = 0;
+ } else {
+ curVal = getDoubleValue(val);
+ }
+
+ if (curVal < minVal || maxVal < curVal) {
+ log.println("" + (curVal - minVal) + "," + (maxVal - curVal));
+ log.println("Current value " + curVal + " is not in range ["
+ + minVal + "," + maxVal + "]");
+ result = false;
+ }
+
+ tRes.tested("getCurrentValue()", result) ;
+ }
+
+ /**
+ * Performs testing for following cases :
+ * <ul>
+ * <li> Creates new value in valid range and sets it. </li>
+ * <li> Sets maximum and minimum values. </li>
+ * <li> Sets Min - 1, and Max + 1 values </li>
+ * </ul> <p>
+ *
+ * Has <b> OK </b> status if for the first case the value returned
+ * is the same as was set and the method <code>setCurrentValue</code>
+ * returns <code>true</code>.
+ *
+ * In the second if Max and Min values are set and method
+ * <code>setCurrentValue</code> returns <code>true</code>.
+ *
+ * In the third case invalid values are truncated to Min and Max
+ * values accordingly. <p>
+ *
+ * The following method tests are to be executed before :
+ * <ul>
+ * <li> <code> getCurrentValue() </code> </li>
+ * </ul>
+ */
+ public void _setCurrentValue() {
+ executeMethod("getCurrentValue()");
+
+ boolean result = true ;
+ boolean partResult=true;
+ String noMax = "com.sun.star.comp.toolkit.AccessibleScrollBar";
+ String implName = util.utils.getImplName(oObj);
+
+ if (tEnv.getObjRelation("ValueNotPersitent")!=null) {
+ log.println("Excluded since it works like AccessibleAction");
+ tRes.tested("setCurrentValue()",Status.skipped(true));
+ return;
+ }
+
+ if (anotherFromGroup == null) {
+ double newVal = curVal + 1;
+ if (newVal > maxVal) newVal -= 2;
+ if (newVal < minVal) newVal += 1;
+
+ log.println("New value is " + newVal);
+
+ Object setVal = getObjectValue(newVal, val.getClass());
+
+ result &= oObj.setCurrentValue(setVal);
+
+ if (!result) {
+ log.println("The value can't be set");
+ throw new StatusException(Status.skipped(true));
+ }
+
+ double resVal = getDoubleValue(oObj.getCurrentValue());
+ log.println("Res value is " + resVal);
+
+ result &= Math.abs(newVal - resVal) < 0.00001;
+
+ log.println("Checking min/max values");
+ result &= oObj.setCurrentValue(getObjectValue(minVal, val.getClass()));
+ log.println("Setting to "+ getObjectValue(minVal, val.getClass()));
+ resVal = getDoubleValue(oObj.getCurrentValue());
+ log.println("Result min value is " + resVal);
+ result &= Math.abs(minVal - resVal) < 0.00001;
+ log.println("\t works: "+(Math.abs(minVal - resVal) < 0.00001));
+
+ result &= oObj.setCurrentValue(getObjectValue(maxVal, val.getClass()));
+ log.println("Setting to "+ getObjectValue(maxVal, val.getClass()));
+ resVal = getDoubleValue(oObj.getCurrentValue());
+ log.println("Result max value is " + resVal);
+ partResult = Math.abs(maxVal - resVal) < 0.00001;
+
+ if (implName.equals(noMax)) {
+ log.println("If one sets the maximum value of a scroll bar with XScrollBar::setMaximum(),"+
+ "then XScrollBar::getValue() returns the maximum value minus the visible size of"+
+ "the thumb");
+ //using abitrary Value, since we can't determine the resulting value
+ partResult = resVal > 10;
+ }
+
+ result &=partResult;
+ log.println("\t works: "+partResult);
+
+ log.println("Checking truncating of min/max values");
+ oObj.setCurrentValue(getObjectValue(minVal - 1, val.getClass()));
+ log.println("Setting to "+ getObjectValue(minVal -1 , val.getClass()));
+ resVal = getDoubleValue(oObj.getCurrentValue());
+ log.println("Result min value is " + resVal);
+ result &= Math.abs(minVal - resVal) < 0.00001;
+ log.println("\t works: "+(Math.abs(minVal - resVal) < 0.00001));
+
+ oObj.setCurrentValue(getObjectValue(maxVal + 1, val.getClass()));
+ log.println("Setting to "+ getObjectValue(maxVal +1 , val.getClass()));
+ resVal = getDoubleValue(oObj.getCurrentValue());
+ log.println("Result max value is " + resVal);
+ partResult = Math.abs(maxVal - resVal) < 0.00001;
+ if (implName.equals(noMax)) {
+ log.println("If one sets the maximum value of a scroll bar with XScrollBar::setMaximum(),"+
+ "then XScrollBar::getValue() returns the maximum value minus the visible size of"+
+ "the thumb");
+ //using abitrary Value, since we can't determine the resulting value
+ partResult = resVal > 10;
+ }
+
+ result &=partResult;
+ log.println("\t works: "+partResult);
+ } else {
+ int curValBase = getIntegerValue(val);
+ Object valAnotherFromGroup = anotherFromGroup.getCurrentValue();
+ int curValAnother = getIntegerValue(valAnotherFromGroup);
+ log.println("Current value of base component: " + curValBase);
+ log.println("Current value of another component from group: " +
+ curValAnother);
+ log.println("Set value of base component to " + curValAnother);
+ if (tEnv.getTestCase().getObjectName().equals("AccessibleRadioButton")) {
+ anotherFromGroup.setCurrentValue(new Integer(curValBase));
+ } else {
+ oObj.setCurrentValue(valAnotherFromGroup);
+ }
+ log.println("Checking of values...");
+ int newValBase = getIntegerValue(oObj.getCurrentValue());
+ int newValAnother = getIntegerValue(
+ anotherFromGroup.getCurrentValue());
+ log.println("New value of base component: " + newValBase);
+ log.println("Expected value of base component: " + curValAnother);
+ log.println("New value of another component from group: " +
+ newValAnother);
+ log.println("Expected value of another component from group: " +
+ curValBase);
+
+ result = (newValBase == curValAnother) &&
+ (newValAnother == curValBase);
+ }
+
+ tRes.tested("setCurrentValue()", result);
+ }
+
+ /**
+ * Gets and stores maximal value. <p>
+ *
+ * Has <b> OK </b> status if non empty value returned and
+ * Max value is greater than Min value.
+ *
+ * The following method tests are to be completed successfully before :
+ * <ul>
+ * <li> <code> getMinimumValue() </code> : to compare with </li>
+ * </ul>
+ */
+ public void _getMaximumValue() {
+ requiredMethod("getMinimumValue()");
+
+ boolean result = true ;
+
+ Object val = oObj.getMaximumValue();
+ if (util.utils.isVoid(val)) {
+ maxVal = Double.MAX_VALUE ;
+ result = false;
+ } else {
+ maxVal = getDoubleValue(val);
+ }
+ log.println("Max is " + val.getClass()+ " = " + maxVal);
+
+ result &= maxVal >= minVal;
+
+ tRes.tested("getMaximumValue()", result) ;
+ }
+
+ /**
+ * Gets and stores minimal value. <p>
+ *
+ * Has <b> OK </b> status if non empty value returned. <p>
+ *
+ */
+ public void _getMinimumValue() {
+ boolean result = true ;
+
+ Object val = oObj.getMinimumValue() ;
+ if (util.utils.isVoid(val)) {
+ minVal = - Double.MAX_VALUE ;
+ result = false;
+ } else {
+ minVal = getDoubleValue(val);
+ }
+ log.println("Min is " + val.getClass()+ " = " + minVal);
+
+ tRes.tested("getMinimumValue()", result) ;
+ }
+
+ private int getIntegerValue(Object val) {
+ if (val instanceof Integer) {
+ return ((Integer) val).intValue();
+ } else {
+ throw new StatusException
+ (Status.failed("Unexpected value type: " + val.getClass()));
+ }
+ }
+
+ private double getDoubleValue(Object val) {
+ if (val instanceof Integer) {
+ return ((Integer) val).doubleValue();
+ }
+ else if (val instanceof Short) {
+ return ((Short) val).doubleValue();
+ }
+ else if (val instanceof Float) {
+ return ((Float) val).doubleValue();
+ }
+ else if (val instanceof Double) {
+ return ((Double) val).doubleValue();
+ }
+ else if (util.utils.isVoid(val)) {
+ return Double.NaN;
+ }
+ else {
+ throw new StatusException
+ (Status.failed("Undetected value type: " + val.getClass()));
+ }
+ }
+
+ private Object getObjectValue(double val, Class clazz) {
+ if (clazz.equals(Integer.class)) {
+ return new Integer((int)val);
+ }
+ else if (clazz.equals(Short.class)) {
+ return new Short((short)val);
+ }
+ else if (clazz.equals(Float.class)) {
+ return new Float((float)val);
+ }
+ else if (clazz.equals(Double.class)) {
+ return new Double(val);
+ }
+ else {
+ throw new StatusException
+ (Status.failed("Unexpected class: " + clazz));
+ }
+ }
+
+ /**
+ * Disposes test environment.
+ */
+ protected void after() {
+ disposeEnvironment();
+ }
+}