Skip to content

Commit 9c171a0

Browse files
vogellaclaude
andcommitted
Fix race condition in DecoratorAdaptableTests by adding event loop processing
Fixes eclipse-platform#868 The tests testAdaptables, testNonAdaptableContributions, and testContributorResourceAdapter were experiencing intermittent failures due to a race condition. After enabling decorators in the @before method, the decorator manager schedules asynchronous updates that may not have completed before the test assertions ran. This commit adds calls to UITestUtil.processEvents() in both @before and @after methods to ensure all pending UI events are processed before tests run and after tests complete. This is a standard pattern for preventing race conditions in Eclipse UI tests. The processEvents() method processes all pending events in the Display event queue, ensuring that decorator registration and enablement updates have completed before the test proceeds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent a43f1a4 commit 9c171a0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/decorators/DecoratorAdaptableTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.eclipse.ui.internal.decorators.DecorationResult;
2626
import org.eclipse.ui.internal.decorators.DecoratorManager;
2727
import org.eclipse.ui.internal.decorators.LightweightDecoratorManager;
28+
import org.eclipse.ui.tests.harness.util.UITestUtil;
2829
import org.eclipse.ui.tests.menus.ObjectContributionClasses;
2930
import org.junit.After;
3031
import org.junit.Before;
@@ -63,6 +64,10 @@ public void doSetUp() throws Exception {
6364
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestUnadaptableDecoratorContributor.ID, true);
6465
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceDecoratorContributor.ID, true);
6566
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceMappingDecoratorContributor.ID, true);
67+
68+
// Process all pending UI events to ensure decorator enablement has completed
69+
// This prevents race conditions where decorators may not be fully registered yet
70+
UITestUtil.processEvents();
6671
}
6772

6873
@After
@@ -71,6 +76,9 @@ public void doTearDown() throws Exception {
7176
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestUnadaptableDecoratorContributor.ID, false);
7277
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceDecoratorContributor.ID, false);
7378
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceMappingDecoratorContributor.ID, false);
79+
80+
// Process all pending UI events to ensure clean state for next test
81+
UITestUtil.processEvents();
7482
}
7583

7684
/**

0 commit comments

Comments
 (0)