Skip to content

Commit 97b31cc

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 more than 10 seconds (the previous timeout value) 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. Related to #1676
1 parent d8aaa2f commit 97b31cc

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ private <T> void waitForFutureToFinish(CompletableFuture<T> future) {
465465
private static void processNextOSMessage() {
466466
Display display = Display.getCurrent();
467467
MSG msg = new MSG();
468+
display.timerExec(100, () -> {});
468469
while (!OS.PeekMessage (msg, 0, 0, 0, OS.PM_NOREMOVE)) {
469470
display.sleep();
470471
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ public Test_org_eclipse_swt_browser_Browser(int swtBrowserSettings) {
161161
@BeforeClass
162162
public static void setupEnvironment() {
163163
// Reinitialize the display to start with a clean state
164-
Display.getCurrent().dispose();
165-
processUiEvents();
166-
Display.getDefault();
164+
Display.getDefault().dispose();
167165
// initialize Edge environment before any test runs to isolate environment setup
168166
if (SwtTestUtil.isWindows) {
169167
Shell shell = new Shell();
@@ -307,7 +305,7 @@ private int reportOpenedDescriptors() {
307305
}
308306

309307
private Browser createBrowser(Shell s, int flags) {
310-
long maximumBrowserCreationMilliseconds = 90_000;
308+
long maximumBrowserCreationMilliseconds = 10_000;
311309
long createStartTime = System.currentTimeMillis();
312310
Browser b = new Browser(s, flags);
313311
// Wait for asynchronous initialization via getting URL

0 commit comments

Comments
 (0)