Kaydet (Commit) baa68e4e 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: I64389b817d91a2bed8dfe1b8d92bafec42eba21a
üst 5a10e33f
......@@ -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);
}
}
}
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