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

Stephan Bergmann sbergman at redhat.com
Tue Oct 22 03:25:11 PDT 2013


 qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java |   60 +++++-----
 1 file changed, 32 insertions(+), 28 deletions(-)

New commits:
commit ee337e7ed61d1ee6fe37520eed30805329c44fb6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 22 12:24:31 2013 +0200

    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: I4b0ca00c04c2b1c8ffbfe4aaf926305ee9b51f30

diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java
index 0419b9e..e9fea34 100644
--- a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java
+++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java
@@ -38,6 +38,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;
@@ -118,8 +119,6 @@ public class ScAccessiblePreviewHeaderCell extends TestCase {
      */
     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
                                                                  PrintWriter log) {
-        XInterface oObj = null;
-
         if (xSheetDoc != null) {
             XComponent oComp = UnoRuntime.queryInterface(
                                        XComponent.class, xSheetDoc);
@@ -241,20 +240,37 @@ public class ScAccessiblePreviewHeaderCell 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, "A");
-
-        if (oObj == null) {
-            log.println("Version with a fixed #103863#");
-            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, "A");
+                    if (oObj == null) {
+                        log.println("Version with a fixed #103863#?");
+                        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 AccessibleRolte.TABLE/TABLE_CELL object");
+            }
+            log.println("No TABLE/TABLE_CELL found yet, retrying");
         }
 
         log.println("ImplementationName " + utils.getImplName(oObj));
@@ -269,16 +285,4 @@ public class ScAccessiblePreviewHeaderCell extends TestCase {
 
         return tEnv;
     }
-
-    /**
-    * Sleeps for 0.5 sec. to allow StarOffice to react on <code>
-    * reset</code> call.
-    */
-    private void shortWait() {
-        try {
-            Thread.sleep(500);
-        } catch (InterruptedException e) {
-            System.out.println("While waiting :" + e);
-        }
-    }
 }


More information about the Libreoffice-commits mailing list