summaryrefslogtreecommitdiff
path: root/qadevOOo
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-11-01 09:41:30 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-11-01 09:41:30 +0100
commitbaa68e4e89c81b20f79576734cdbfa63665b3ff5 (patch)
tree5c75f55b43062678964d2794d14b482b990cdc2f /qadevOOo
parent5a10e33f4ddc718f05a64629c4133a607ec9b29e (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: I64389b817d91a2bed8dfe1b8d92bafec42eba21a
Diffstat (limited to 'qadevOOo')
-rw-r--r--qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java46
1 files changed, 28 insertions, 18 deletions
diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java
index e0897dd82a81..d56f8e846b10 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);
- }
- }
}