Skip to content

Commit f6bb7be

Browse files
committed
Browser tests: reduce timeout for instantiation to reasonable value
The timeout for browser instantiation in the browser tests has been increased to avoid flaky tests. However, browser instantiation taking that long is an indicator for something being wrong with the instantiation. There is no reason why instantiation may take that long during test execution but the same issue should never arise in productive use, thus such a case should be captured by tests and, if necessary, be fixed productively. In order to do so, this change reduces the test timeout value again to a more reasonable value. Since the first Edge browser instantiation takes rather long at least in the GitHub actions test environment, that instantiation is isolated in an execution before the test class. Related to #1676
1 parent ba89251 commit f6bb7be

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ private static void processOSMessagesUntil(Supplier<Boolean> condition, Display
464464
// The timer call also wakes up the display to avoid being stuck in display.sleep()
465465
display.timerExec((int) MAXIMUM_OPERATION_TIME.toMillis(), () -> timeoutOccurred.set(true));
466466
while (!display.isDisposed() && !condition.get() && !timeoutOccurred.get()) {
467-
if (OS.PeekMessage(msg, 0, 0, 0, OS.PM_NOREMOVE)) {
467+
if (OS.PeekMessage(msg, 0, 0, 0, OS.PM_NOREMOVE | OS.PM_QS_POSTMESSAGE)) {
468468
display.readAndDispatch();
469469
} else {
470470
display.sleep();

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,15 @@
102102
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
103103
public class Test_org_eclipse_swt_browser_Browser extends Test_org_eclipse_swt_widgets_Composite {
104104

105-
// TODO Reduce to reasonable value
106-
private static Duration MAXIMUM_BROWSER_CREATION_TIME = Duration.ofSeconds(90);
105+
private static Duration MAXIMUM_BROWSER_CREATION_TIME = Duration.ofSeconds(10);
107106

108107
static {
109108
try {
110109
printSystemEnv();
111110
} catch (Exception e) {
112111
e.printStackTrace();
113112
}
114-
System.setProperty("org.eclipse.swt.internal.win32.Edge.timeout", Long.toString(MAXIMUM_BROWSER_CREATION_TIME.toMillis()));
113+
System.setProperty("org.eclipse.swt.internal.win32.Edge.timeout", Long.toString(Duration.ofSeconds(90).toMillis()));
115114
}
116115

117116
// CONFIG

0 commit comments

Comments
 (0)