From a25d360b3e08751ea24f1c5ae4dea799d38a668b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 4 Nov 2013 18:24:25 +0100 Subject: [PATCH] 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: I5244e8f8af9560ae986ed3a836bdf9571574420f --- .../mod/_sc/ScAccessiblePreviewTable.java | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewTable.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewTable.java index 7b93d2764f9a..9f5b3b0ac233 100644 --- a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewTable.java +++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewTable.java @@ -39,6 +39,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; @@ -113,7 +114,6 @@ public class ScAccessiblePreviewTable extends TestCase { */ protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { - XInterface oObj = null; XCell xCell = null; try { @@ -163,16 +163,34 @@ public class ScAccessiblePreviewTable extends TestCase { throw new StatusException(Status.failed("Couldn't change mode")); } - shortWait(); - - AccessibilityTools at = new AccessibilityTools(); - - XWindow xWindow = AccessibilityTools.getCurrentContainerWindow((XMultiServiceFactory)Param.getMSF(), xModel); - XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); - - AccessibilityTools.printAccessibleTree(log,xRoot, Param.getBool(PropertyName.DEBUG_IS_ACTIVE)); - - oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE); + XAccessible xRoot; + XInterface oObj; + for (int i = 0;; ++i) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + try { + xRoot = AccessibilityTools.getAccessibleObject( + AccessibilityTools.getCurrentContainerWindow( + (XMultiServiceFactory)Param.getMSF(), xModel)); + if (xRoot != null) { + oObj = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TABLE); + 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/PUSH_BUTTON object"); + } + log.println("No TABLE/PUSH_BUTTON found yet, retrying"); + } log.println("ImplementationName " + utils.getImplName(oObj)); @@ -195,12 +213,4 @@ public class ScAccessiblePreviewTable extends TestCase { return tEnv; } - - protected void shortWait() { - try { - Thread.sleep(1000) ; - } catch (InterruptedException e) { - System.out.println("While waiting :" + e); - } - } }