diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-10-22 12:24:31 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-10-22 12:24:31 +0200 |
commit | ee337e7ed61d1ee6fe37520eed30805329c44fb6 (patch) | |
tree | abbf4baa228d11c07a3bfd8c29725b34df74bb4c /qadevOOo | |
parent | e5f24e0c7c8f4799223c19359f4228f0b1a71461 (diff) |
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
Diffstat (limited to 'qadevOOo')
-rw-r--r-- | qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java index 0419b9e2ccf9..e9fea34ed9a8 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); - } - } } |