[Libreoffice-commits] core.git: qadevOOo/runner qadevOOo/tests

Stephan Bergmann sbergman at redhat.com
Tue May 21 07:56:59 PDT 2013


 qadevOOo/runner/util/AccessibilityTools.java                            |  100 +---------
 qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java |    4 
 qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java                 |    4 
 3 files changed, 18 insertions(+), 90 deletions(-)

New commits:
commit 89fbed7e29104bf189dc3d75dc11a8aadd362322
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue May 21 16:40:03 2013 +0200

    Revert "Java cleanup, AccessibilityTools.."
    
    This reverts commit d702dd4396161f8e2e7396f5c24554088b752fcb, which reproducibly
    broke JunitTest_sc_unoapi:
    
    java.lang.NullPointerException
     at util.AccessibilityTools.getAccessibleObjectForRole_(AccessibilityTools.java:177)
     at util.AccessibilityTools.getAccessibleObjectForRole(AccessibilityTools.java:95)
     at mod._sc.AccessibleEditableTextPara_PreviewCell.createTestEnvironment(AccessibleEditableTextPara_PreviewCell.java:149)
     at lib.TestCase.getTestEnvironment(TestCase.java:121)
     at base.java_fat.getTestEnvironment(java_fat.java:319)
     at base.java_fat.executeTest(java_fat.java:167)
     at org.openoffice.Runner.run(Runner.java:234)
     at org.openoffice.test.UnoApiTest.test(UnoApiTest.java:38)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:601)
     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
     at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
     at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
     at org.junit.runners.Suite.runChild(Suite.java:128)
     at org.junit.runners.Suite.runChild(Suite.java:24)
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
     at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
     at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
     at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
     at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
     at org.junit.runner.JUnitCore.runMain(JUnitCore.java:98)
     at org.junit.runner.JUnitCore.runMainAndExit(JUnitCore.java:53)
     at org.junit.runner.JUnitCore.main(JUnitCore.java:45)
    
    Change-Id: I3601fe24db21bd63f7dc6cdf0a1eb69f447d962a

diff --git a/qadevOOo/runner/util/AccessibilityTools.java b/qadevOOo/runner/util/AccessibilityTools.java
index c7cb483..85cd442 100644
--- a/qadevOOo/runner/util/AccessibilityTools.java
+++ b/qadevOOo/runner/util/AccessibilityTools.java
@@ -17,7 +17,6 @@
  */
 package util;
 
-import com.sun.star.accessibility.AccessibleStateType;
 import com.sun.star.accessibility.XAccessible;
 import com.sun.star.accessibility.XAccessibleComponent;
 import com.sun.star.accessibility.XAccessibleContext;
@@ -33,7 +32,7 @@ import java.io.PrintWriter;
 
 
 public class AccessibilityTools {
-    private XAccessible SearchedAccessible = null;
+    public static XAccessible SearchedAccessible = null;
     private static boolean debug = false;
 
     public AccessibilityTools() {
@@ -92,12 +91,15 @@ public class AccessibilityTools {
 
     public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
         short role) {
+        SearchedAccessible = null;
         return getAccessibleObjectForRole_(xacc, role);
     }
 
     public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
         short role,
         boolean ignoreShowing) {
+        SearchedAccessible = null;
+
         if (ignoreShowing) {
             return getAccessibleObjectForRoleIgnoreShowing_(xacc, role);
         } else {
@@ -105,49 +107,12 @@ public class AccessibilityTools {
         }
     }
 
-    public XAccessible getSearchedAccessibleObjectForRole(XAccessible xacc,
-        short role,
-        boolean ignoreShowing) {
-        SearchedAccessible = null;
-        getSearchedAccessibleObjectForRole_(xacc, role, ignoreShowing);
-        return SearchedAccessible;
-    }
-
-    private XAccessibleContext getSearchedAccessibleObjectForRole_(XAccessible xacc,
-            short role, boolean ignoreShowing) {
-        XAccessibleContext ac = xacc.getAccessibleContext();
-        boolean isShowing = isShowing(ac);
-
-        if ((ac.getAccessibleRole() == role) && (!ignoreShowing || isShowing)) {
-            SearchedAccessible = xacc;
-            return ac;
-        } else {
-            int k = ac.getAccessibleChildCount();
-
-            if (ac.getAccessibleChildCount() > 100) {
-                k = 50;
-            }
-
-            for (int i = 0; i < k; i++) {
-                try {
-                    XAccessibleContext ac2 = getSearchedAccessibleObjectForRole_(ac.getAccessibleChild(i), role, ignoreShowing);
-
-                    if (ac2 != null) {
-                        return ac2;
-                    }
-                } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
-                    System.out.println("Couldn't get Child");
-                }
-            }
-            return null;
-        }
-    }
-
     public static XAccessibleContext getAccessibleObjectForRoleIgnoreShowing_(XAccessible xacc,
         short role) {
         XAccessibleContext ac = xacc.getAccessibleContext();
 
         if (ac.getAccessibleRole() == role) {
+            SearchedAccessible = xacc;
             return ac;
         } else {
             int k = ac.getAccessibleChildCount();
@@ -175,9 +140,11 @@ public class AccessibilityTools {
     public static XAccessibleContext getAccessibleObjectForRole_(XAccessible xacc,
         short role) {
         XAccessibleContext ac = xacc.getAccessibleContext();
-        boolean isShowing = isShowing(ac);
+        boolean isShowing = ac.getAccessibleStateSet()
+        .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
 
         if ((ac.getAccessibleRole() == role) && isShowing) {
+            SearchedAccessible = xacc;
             return ac;
         } else {
             int k = ac.getAccessibleChildCount();
@@ -227,6 +194,7 @@ public class AccessibilityTools {
         if ((ac.getAccessibleRole() == role) &&
             (ac.getAccessibleName().indexOf(name) > -1) &&
             (utils.getImplName(ac).indexOf(implName) > -1)) {
+            SearchedAccessible = xacc;
 
             //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
             return ac;
@@ -260,7 +228,8 @@ public class AccessibilityTools {
         String name,
         String implName) {
         XAccessibleContext ac = xacc.getAccessibleContext();
-        boolean isShowing = isShowing(ac);
+        boolean isShowing = ac.getAccessibleStateSet()
+        .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
 
         // hotfix for i91828:
         // if role to search is 0 then ignore the role.
@@ -268,6 +237,7 @@ public class AccessibilityTools {
             (ac.getAccessibleName().indexOf(name) > -1) &&
             (utils.getImplName(ac).indexOf(implName) > -1) &&
             isShowing) {
+            SearchedAccessible = xacc;
             //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
             return ac;
         } else {
@@ -295,45 +265,6 @@ public class AccessibilityTools {
         return null;
     }
 
-    public XAccessible getSearchedAccessibleObjectForRole(XAccessible xacc,
-            short role,
-            String name,
-            String implName) {
-            XAccessibleContext ac = xacc.getAccessibleContext();
-            boolean isShowing = isShowing(ac);
-
-            // hotfix for i91828:
-            // if role to search is 0 then ignore the role.
-            if ( (role == 0 || ac.getAccessibleRole() == role) &&
-                (ac.getAccessibleName().indexOf(name) > -1) &&
-                (utils.getImplName(ac).indexOf(implName) > -1) &&
-                isShowing) {
-                SearchedAccessible = xacc;
-            } else {
-                int k = ac.getAccessibleChildCount();
-
-                if (ac.getAccessibleChildCount() > 100) {
-                    k = 50;
-                }
-
-                for (int i = 0; i < k; i++) {
-                    try {
-                        XAccessibleContext ac1 = getAccessibleObjectForRole(
-                            ac.getAccessibleChild(i),
-                            role, name, implName);
-
-                        if (ac1 != null) {
-                            break;
-                        }
-                    } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
-                        System.out.println("Couldn't get Child");
-                    }
-                }
-            }
-
-            return SearchedAccessible;
-        }
-
     /**
      * This methods retunrs the <CODE>XAccessibleContext</CODE> of a named Sheet-Cell like "G5".<p>
      * @param xSheetAcc The <CODE>XAccessibleContext</CODE> of a Sheet
@@ -414,7 +345,8 @@ public class AccessibilityTools {
             logging(log,indent + indent + bounds);
         }
 
-        boolean isShowing = isShowing(ac);
+        boolean isShowing = ac.getAccessibleStateSet()
+        .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
         logging(log,indent + indent + "StateType contains SHOWING: " +
             isShowing);
 
@@ -511,8 +443,4 @@ public class AccessibilityTools {
     private static void logging(PrintWriter log, String content){
         if (debug) log.println(content);
     }
-
-    private static boolean isShowing(XAccessibleContext ac) {
-        return ac.getAccessibleStateSet().contains(AccessibleStateType.SHOWING);
-    }
 }
\ No newline at end of file
diff --git a/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java
index fe26e25..ac90e5b 100644
--- a/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java
+++ b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java
@@ -142,7 +142,9 @@ public class AccessibleEditableTextPara_PreviewCell extends TestCase {
         XWindow xWindow = AccessibilityTools.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), xModel);
         XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
         //AccessibilityTools.printAccessibleTree(log,xRoot);
-        xRoot = new AccessibilityTools().getSearchedAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL,true);
+        AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL,true);
+
+        xRoot = AccessibilityTools.SearchedAccessible;
 
         //AccessibilityTools.printAccessibleTree(log,xRoot);
 
diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java
index efc02df..142a42a 100644
--- a/qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java
+++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java
@@ -169,10 +169,8 @@ public class AccessibleListBox extends TestCase {
 
         oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL, "",
                                              "com.sun.star.comp.toolkit.AccessibleListBox");
-        XAccessible searchedAccessible = new AccessibilityTools().getSearchedAccessibleObjectForRole(xRoot, AccessibleRole.PANEL, "",
-                "com.sun.star.comp.toolkit.AccessibleListBox");
 
-        Object list = AccessibilityTools.getAccessibleObjectForRole(searchedAccessible,
+        Object list = AccessibilityTools.getAccessibleObjectForRole(AccessibilityTools.SearchedAccessible,
                                                     AccessibleRole.LIST);
 
         log.println("ImplementationName " + utils.getImplName(oObj));


More information about the Libreoffice-commits mailing list