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 in5b5c52a3a4
"Try make this more robust in slow environments" plusb5dd2b4218
"Also cope with intermittend DisposedExceptions." Change-Id: I4b0ca00c04c2b1c8ffbfe4aaf926305ee9b51f30
This commit is contained in:
@@ -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 {
|
|||||||
*/
|
*/
|
||||||
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 {
|
|||||||
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(
|
||||||
|
AccessibilityTools.getCurrentWindow(
|
||||||
|
(XMultiServiceFactory) Param.getMSF(), xModel));
|
||||||
|
if (xRoot != null) {
|
||||||
|
oObj = AccessibilityTools.getAccessibleObjectForRole(
|
||||||
|
xRoot, AccessibleRole.TABLE, "A");
|
||||||
if (oObj == null) {
|
if (oObj == null) {
|
||||||
log.println("Version with a fixed #103863#");
|
log.println("Version with a fixed #103863#?");
|
||||||
oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot,
|
oObj = AccessibilityTools.getAccessibleObjectForRole(
|
||||||
AccessibleRole.TABLE_CELL,
|
xRoot, AccessibleRole.TABLE_CELL, true);
|
||||||
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 {
|
|||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user