Skip to content

Commit 580cfee

Browse files
vogellaclaude
andcommitted
Fix UITestUtil.processEventsUntil causing test failures in RCPTestWorkbenchAdvisor
The previous implementation called UITestUtil.processEventsUntil() which internally calls PlatformUI.getWorkbench().getDisplay(). However, during postStartup(), the workbench display may not be reliably accessible via PlatformUI.getWorkbench(), causing the test to fail. This change replaces the UITestUtil calls with direct Display.getCurrent() usage and implements the same event processing logic inline. This ensures that: 1. We wait for async/sync operations with DisplayAccess to complete 2. We process remaining events to detect any regressions 3. We don't rely on PlatformUI.getWorkbench() during startup Fixes the following test failures: - Async run during startup - Sync from un-qualified thread ran during startup - Async from un-qualified thread ran during startup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7ae06e6 commit 580cfee

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/RCPTestWorkbenchAdvisor.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,29 @@ public void postStartup() {
234234
// Pump the event loop to ensure async runnables execute before marking as started
235235
// This prevents the original race condition where async variables might not be set yet
236236
// Wait until the variables that should be set during startup are actually set to TRUE
237-
UITestUtil.processEventsUntil(() -> Boolean.TRUE.equals(syncWithDisplayAccess) && Boolean.TRUE.equals(asyncWithDisplayAccess), 5000);
238-
// Process any remaining events to allow variables that should NOT be set during startup
239-
// to accidentally execute (to detect regression)
240-
UITestUtil.processEvents();
237+
Display display = Display.getCurrent();
238+
if (display != null) {
239+
long startTime = System.currentTimeMillis();
240+
while (!(Boolean.TRUE.equals(syncWithDisplayAccess) && Boolean.TRUE.equals(asyncWithDisplayAccess))) {
241+
if (System.currentTimeMillis() - startTime > 5000) {
242+
System.err.println("WARNING: Timeout waiting for sync/async operations with DisplayAccess");
243+
break;
244+
}
245+
if (!display.readAndDispatch()) {
246+
try {
247+
Thread.sleep(10);
248+
} catch (InterruptedException e) {
249+
Thread.currentThread().interrupt();
250+
break;
251+
}
252+
}
253+
}
254+
// Process any remaining events to allow variables that should NOT be set during startup
255+
// to accidentally execute (to detect regression)
256+
while (display.readAndDispatch()) {
257+
// Process all pending events
258+
}
259+
}
241260

242261
synchronized (RCPTestWorkbenchAdvisor.class) {
243262
started = true;

0 commit comments

Comments
 (0)