diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-10-08 10:52:56 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-10-08 10:55:32 +0200 |
commit | dcee4cfcdc0adab82eec1bd68b68dea7eeee549c (patch) | |
tree | 035eb875ac31eafd5a56ba8bee0c5821ee9ecd0c | |
parent | f52d78bf7cc0ae5fcaf1b693e5bfa98bb015c569 (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: I4d429a96b7b595776aaf3fa20e3e03b00ca886bc
-rw-r--r-- | qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java index 535e92d11cda..26e9ff14449b 100644 --- a/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java +++ b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.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; @@ -86,7 +87,6 @@ public class AccessibleEditableTextPara_PreviewCell extends TestCase { */ protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { - XAccessibleContext oObj = null; XCell xCell = null; try { @@ -136,19 +136,38 @@ public class AccessibleEditableTextPara_PreviewCell extends TestCase { throw new StatusException(Status.failed("Couldn't change mode")); } - shortWait(); - - - XWindow xWindow = AccessibilityTools.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), xModel); - XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); - //AccessibilityTools.printAccessibleTree(log,xRoot); - AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL,true); - - xRoot = AccessibilityTools.SearchedAccessible; - - //AccessibilityTools.printAccessibleTree(log,xRoot); - - oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot,AccessibleRole.PARAGRAPH); + XAccessibleContext 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) { + AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TABLE_CELL, true); + xRoot = AccessibilityTools.SearchedAccessible; + if (xRoot != null) { + oObj = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.PARAGRAPH); + 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 AccessibleRoot.HEADER object"); + } + log.println("No TABLE_CELL/PARAGRAPH found yet, retrying"); + } log.println("ImplementationName " + utils.getImplName(oObj)); log.println("AccessibleName " + oObj.getAccessibleName()); @@ -169,12 +188,4 @@ public class AccessibleEditableTextPara_PreviewCell extends TestCase { return tEnv; } - - protected void shortWait() { - try { - Thread.sleep(1000) ; - } catch (InterruptedException e) { - System.out.println("While waiting :" + e); - } - } } |