From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- .../tests/java/ifc/accessibility/_XAccessible.java | 48 + .../java/ifc/accessibility/_XAccessibleAction.java | 159 +++ .../ifc/accessibility/_XAccessibleComponent.java | 601 ++++++++++ .../ifc/accessibility/_XAccessibleContext.java | 342 ++++++ .../accessibility/_XAccessibleEditableText.java | 543 +++++++++ .../_XAccessibleEventBroadcaster.java | 208 ++++ .../_XAccessibleExtendedComponent.java | 114 ++ .../java/ifc/accessibility/_XAccessibleImage.java | 65 ++ .../ifc/accessibility/_XAccessibleSelection.java | 586 ++++++++++ .../java/ifc/accessibility/_XAccessibleTable.java | 1000 ++++++++++++++++ .../java/ifc/accessibility/_XAccessibleText.java | 1208 ++++++++++++++++++++ .../java/ifc/accessibility/_XAccessibleValue.java | 344 ++++++ 12 files changed, 5218 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessible.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleComponent.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleContext.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleEditableText.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleExtendedComponent.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleImage.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleSelection.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleTable.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleText.java create mode 100644 qadevOOo/tests/java/ifc/accessibility/_XAccessibleValue.java (limited to 'qadevOOo/tests/java/ifc/accessibility') diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessible.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessible.java new file mode 100644 index 000000000..329ecc6ab --- /dev/null +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessible.java @@ -0,0 +1,48 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.accessibility; + +import lib.MultiMethodTest; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; + +/** + * Testing com.sun.star.accessibility.XAccessible + * interface methods : + *

+ * @see com.sun.star.accessibility.XAccessible + */ +public class _XAccessible extends MultiMethodTest { + + + public XAccessible oObj = null; + + /** + * Just calls the method.

+ * Has OK 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 000000000..d83b231eb --- /dev/null +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleAction.java @@ -0,0 +1,159 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +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
+ * variable count. It is OK if no exception occurs + */ + + public void _getAccessibleActionCount() { + count = oObj.getAccessibleActionCount(); + tRes.tested("getAccessibleActionCount()",count > 0); + } + + /** + * calls the method with invalid argument and check if the
+ * expected Exception is thrown.
+ * Calls the method afterwards the first valid parameter.
+ * This is the last method called and the environment is disposed
+ * 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("Unexpected exception -- FAILED"); + res &= false; + } + + tRes.tested("doAccessibleAction()",res); + } + + /** + * calls the method with invalid argument and check if the
+ * expected Exception is thrown.
+ * Calls the method afterwards all valid parameters.
+ * 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 + * expected Exception is thrown.
+ * Calls the method afterwards all valid parameters.
+ * 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;icom.sun.star.accessibility.XAccessibleComponent + * interface methods : + *

+ * + * @see com.sun.star.accessibility.XAccessibleComponent + */ +public class _XAccessibleComponent extends MultiMethodTest { + + public XAccessibleComponent oObj = null; + private final ArrayList KnownBounds = new ArrayList(); + + + /** + * 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.

+ * + * Has OK status if inner bounds contain component points + * and outer bounds don't contain any component points.

+ * + * The following method tests are to be completed successfully before : + *

+ */ + public void _containsPoint() { + Rectangle bounds = oObj.getBounds(); + + boolean result = true; + + int curX = 0; + + while (!oObj.containsPoint(new Point(curX, 0)) && + (curX < bounds.Width)) { + curX++; + } + + 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.Height - 1)) && + (curX < bounds.Width)) { + log.println("containsPoint returns false for (" + curX + "," + + bounds.Height + ")"); + curX++; + } + + 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(0, curY)) && + (curY < bounds.Height)) { + curY++; + } + + 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.Width - 1, curY)) && + (curY < bounds.Height)) { + curY++; + } + + 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 + * XAccessibleComponent (if they exist) determines their + * boundaries and tries to get each child by getAccessibleAtPoint + * passing point which belongs to the child. + * Also the point is checked which doesn't belong to child boundary + * box.

+ * + * Has OK status if in the first cases the right children + * are returned, and in the second null or + * another child is returned. + */ + public void _getAccessibleAtPoint() { + boolean result = true; + XAccessibleComponent[] children = getChildrenComponents(); + + if (children.length == 0) { + log.println("There are no children supporting XAccessibleComponent"); + tRes.tested("getAccessibleAtPoint()", result); + return; + } + + 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 = 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) { + 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)) { + 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"); + + result = false; + } else { + XAccessible xAccCh = UnoRuntime.queryInterface( + XAccessible.class, + children[i]); + XAccessibleContext xAccC = 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 = 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; + } + } + } + + tRes.tested("getAccessibleAtPoint()", result); + } + + /** + * Retrieves the component bounds and discards it.

+ * + * Has OK status if boundary position (x,y) is not negative + * and size (Width, Height) is greater than 0. + */ + public void _getBounds() { + boolean result = true; + + Rectangle 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.

+ * + * Has OK status if the location is the same as location + * of boundary obtained by getBounds() method. + */ + public void _getLocation() { + Rectangle bounds = oObj.getBounds(); + Point loc = oObj.getLocation(); + boolean result = loc.X == bounds.X && loc.Y == bounds.Y; + log.println( + "loc.X=" + loc.X + " vs. bounds.X=" + bounds.X + ", loc.Y=" + + loc.Y + " vs. bounds.Y=" + bounds.Y); + tRes.tested("getLocation()", result); + } + + /** + * Get the screen location of the component and its parent + * (if it exists and supports XAccessibleComponent).

+ * + * Has OK status if component screen location equals + * to screen location of its parent plus location of the component + * relative to the parent.

+ */ + public void _getLocationOnScreen() { + XAccessibleComponent parent = getParentComponent(); + + boolean result = true; + Rectangle bounds = oObj.getBounds(); + 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.

+ * + * Has OK status if the size is the same as in bounds.

+ */ + public void _getSize() { + requiredMethod("getBounds()"); + + boolean result = true; + Rectangle bounds = oObj.getBounds(); + Size size = oObj.getSize(); + + result &= (size.Width == bounds.Width); + result &= (size.Height == bounds.Height); + + tRes.tested("getSize()", result); + } + + /** + * Just calls the method.

+ * + * Has OK status if no runtime exceptions occurred. + */ + 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 XAccessibleComponent. + * + * @return The array of children. Empty array returned if + * such children were not found or some error occurred. + */ + private XAccessibleComponent[] getChildrenComponents() { + XAccessible xAcc = 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; + } + + ArrayList childComp = new ArrayList(); + + for (int i = 0; i < cnt; i++) { + try { + XAccessible child = xAccCon.getAccessibleChild(i); + XAccessibleContext xAccConCh = child.getAccessibleContext(); + XAccessibleComponent xChAccComp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + xAccConCh); + + if (xChAccComp != null) { + childComp.add(xChAccComp); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + + return childComp.toArray( + new XAccessibleComponent[childComp.size()]); + } + + /** + * Gets the parent of the current component which support + * XAccessibleComponent. + * + * @return The parent or null if the component + * has no parent or some errors occurred. + */ + private XAccessibleComponent getParentComponent() { + XAccessible xAcc = 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 = 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. + */ + @Override + 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;kcom.sun.star.accessibility.XAccessibleContext + * interface methods : + *

+ * + * @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 + @Override + protected String getTestedClassName() { + return className; + } + + /** + * Calls the method and stores the number of children.

+ * Has OK 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.

+ * + * Has OK status if parent of every child + * and the tested component are the same objects. + * + * The following method tests are to be completed successfully before : + *

+ */ + 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.

+ * + * Has OK 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.

+ * + * Has OK status if the parent's child and the tested + * component are the same objects. + * + * The following method tests are to be completed successfully before : + *

+ */ + public void _getAccessibleIndexInParent() { + requiredMethod("getAccessibleParent()"); + + boolean bOK = true; + int idx = oObj.getAccessibleIndexInParent(); + + XAccessibleContext parentAC = parent.getAccessibleContext(); + + try { + XAccessible child = parentAC.getAccessibleChild(idx); + XAccessibleContext childAC = null; + if (child == null) { + log.println("Parent has no child with this index"); + bOK &= false; + } else { + childAC = child.getAccessibleContext(); + bOK &= AccessibilityTools.equals(childAC, oObj); + } + + if (!bOK) { + log.println("Expected: " + util.utils.getImplName(oObj)); + + if (childAC != null) { + log.println("Getting: " + util.utils.getImplName(childAC)); + } + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + bOK = false; + } + + tRes.tested("getAccessibleIndexInParent()", bOK); + } + + /** + * Get the accessible role of component.

+ * + * Has OK 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.

+ * + * Has OK 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.

+ * + * Has OK 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.

+ * + * Has OK status if the set is not null. + */ + public void _getAccessibleRelationSet() { + oObj.getAccessibleRelationSet(); + tRes.tested("getAccessibleRelationSet()", true); + } + + /** + * Just gets the set.

+ * + * Has OK 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.

+ * + * Has OK status if Country and + * Language 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 000000000..d8cb81adc --- /dev/null +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEditableText.java @@ -0,0 +1,543 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.accessibility; + +import lib.MultiMethodTest; +import util.ValueComparer; + +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.beans.PropertyValue; + +/** + * Testing com.sun.star.accessibility.XAccessibleEditableText + * interface methods : + *

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

+ * + * @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 restoring it in after. + */ + @Override + 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 pasteText. + * 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: + *

+ */ + 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: + * + */ + 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 = 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: + * + */ + 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: + * + */ + 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: + * + */ + 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; + } catch(com.sun.star.beans.UnknownPropertyException e) { + log.println("unexpected exception => FAILED"); + e.printStackTrace(log); + res &= false; + } + + 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 = Integer.valueOf(-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; + } catch(com.sun.star.beans.UnknownPropertyException 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. + */ + @Override + protected void after() { + oObj.setText(initialText); + } +} diff --git a/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java new file mode 100644 index 000000000..297166988 --- /dev/null +++ b/qadevOOo/tests/java/ifc/accessibility/_XAccessibleEventBroadcaster.java @@ -0,0 +1,208 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +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 + * com.sun.star.accessibility.XAccessibleEventBroadcaster + * interface methods : + *

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