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

Stephan Bergmann sbergman at redhat.com
Fri Nov 1 09:42:36 CET 2013


 qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java |   46 +++++++++------
 1 file changed, 28 insertions(+), 18 deletions(-)

New commits:
commit baa68e4e89c81b20f79576734cdbfa63665b3ff5
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Nov 1 09:41:30 2013 +0100

    Try make this more robust in slow environments
    
    ...where the previous .uno:PrintPreview request has not yet been processed, the
    same way it had been made more robust for ScAccessiblePageHeader.java in
    5b5c52a3a4d048bba8c18dfb06ffca25c670d099 "Try make this more robust in slow
    environments" plus b5dd2b4218f966e177d880bcc29fa5fba3bfe1c1 "Also cope with
    intermittend DisposedExceptions."
    
    Change-Id: I64389b817d91a2bed8dfe1b8d92bafec42eba21a

diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java
index e0897dd..d56f8e8 100644
--- a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java
+++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java
@@ -37,6 +37,7 @@ import com.sun.star.frame.XController;
 import com.sun.star.frame.XDispatch;
 import com.sun.star.frame.XDispatchProvider;
 import com.sun.star.frame.XModel;
+import com.sun.star.lang.DisposedException;
 import com.sun.star.lang.XComponent;
 import com.sun.star.lang.XMultiServiceFactory;
 import com.sun.star.sheet.XSpreadsheet;
@@ -109,8 +110,6 @@ public class ScAccessiblePreviewCell extends TestCase {
      * Obtains the accessible object for a one of cell in preview mode.
      */
     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
-
-        XInterface oObj = null;
         XCell xCell = null;
 
         try {
@@ -160,14 +159,33 @@ public class ScAccessiblePreviewCell extends TestCase {
             throw new StatusException(Status.failed("Couldn't change mode"));
         }
 
-        shortWait();
-
-        AccessibilityTools at = new AccessibilityTools();
-
-        XWindow xWindow = AccessibilityTools.getCurrentWindow((XMultiServiceFactory)Param.getMSF(), xModel);
-        XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
-
-        oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL, true);
+        XInterface oObj = null;
+        for (int i = 0;; ++i) {
+            try {
+                Thread.sleep(500);
+            } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+            }
+            try {
+                XAccessible xRoot = AccessibilityTools.getAccessibleObject(
+                    AccessibilityTools.getCurrentWindow(
+                        (XMultiServiceFactory) Param.getMSF(), xModel));
+                if (xRoot != null) {
+                    oObj = AccessibilityTools.getAccessibleObjectForRole(
+                        xRoot, AccessibleRole.TABLE_CELL, true);
+                    if (oObj != null) {
+                        break;
+                    }
+                }
+            } catch (DisposedException e) {
+                log.println("Ignoring DisposedException");
+            }
+            if (i == 20) { // give up after 10 sec
+                throw new RuntimeException(
+                    "Couldn't get AccessibleRole.TABLE_CELL object");
+            }
+            log.println("No TABLE_CELL found yet, retrying");
+        }
 
         log.println("ImplementationName " + utils.getImplName(oObj));
 
@@ -182,12 +200,4 @@ public class ScAccessiblePreviewCell extends TestCase {
 
         return tEnv;
     }
-
-    protected void shortWait() {
-        try {
-            Thread.sleep(1000) ;
-        } catch (InterruptedException e) {
-            System.out.println("While waiting :" + e);
-        }
-    }
 }


More information about the Libreoffice-commits mailing list