Kaydet (Commit) ee337e7e authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
5b5c52a3 "Try make this more robust in slow
environments" plus b5dd2b42 "Also cope with
intermittend DisposedExceptions."

Change-Id: I4b0ca00c04c2b1c8ffbfe4aaf926305ee9b51f30
üst e5f24e0c
...@@ -38,6 +38,7 @@ import com.sun.star.frame.XController; ...@@ -38,6 +38,7 @@ import com.sun.star.frame.XController;
import com.sun.star.frame.XDispatch; import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XDispatchProvider; import com.sun.star.frame.XDispatchProvider;
import com.sun.star.frame.XModel; import com.sun.star.frame.XModel;
import com.sun.star.lang.DisposedException;
import com.sun.star.lang.XComponent; import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sheet.XSpreadsheet; import com.sun.star.sheet.XSpreadsheet;
...@@ -118,8 +119,6 @@ public class ScAccessiblePreviewHeaderCell extends TestCase { ...@@ -118,8 +119,6 @@ public class ScAccessiblePreviewHeaderCell extends TestCase {
*/ */
protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, protected synchronized TestEnvironment createTestEnvironment(TestParameters Param,
PrintWriter log) { PrintWriter log) {
XInterface oObj = null;
if (xSheetDoc != null) { if (xSheetDoc != null) {
XComponent oComp = UnoRuntime.queryInterface( XComponent oComp = UnoRuntime.queryInterface(
XComponent.class, xSheetDoc); XComponent.class, xSheetDoc);
...@@ -241,20 +240,37 @@ public class ScAccessiblePreviewHeaderCell extends TestCase { ...@@ -241,20 +240,37 @@ public class ScAccessiblePreviewHeaderCell extends TestCase {
throw new StatusException(Status.failed("Couldn't change mode")); throw new StatusException(Status.failed("Couldn't change mode"));
} }
shortWait(); XInterface oObj = null;
for (int i = 0;; ++i) {
AccessibilityTools at = new AccessibilityTools(); try {
Thread.sleep(500);
XWindow xWindow = AccessibilityTools.getCurrentWindow( (XMultiServiceFactory) Param.getMSF(), xModel); } catch (InterruptedException e) {
XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); throw new RuntimeException(e);
}
oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE, "A"); try {
XAccessible xRoot = AccessibilityTools.getAccessibleObject(
if (oObj == null) { AccessibilityTools.getCurrentWindow(
log.println("Version with a fixed #103863#"); (XMultiServiceFactory) Param.getMSF(), xModel));
oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, if (xRoot != null) {
AccessibleRole.TABLE_CELL, oObj = AccessibilityTools.getAccessibleObjectForRole(
true); 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)); log.println("ImplementationName " + utils.getImplName(oObj));
...@@ -269,16 +285,4 @@ public class ScAccessiblePreviewHeaderCell extends TestCase { ...@@ -269,16 +285,4 @@ public class ScAccessiblePreviewHeaderCell extends TestCase {
return tEnv; 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);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment