Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.internal.decorators.DecorationResult;
Expand All @@ -44,6 +45,21 @@ private String getDecorationTextFor(Object object) {
return result.decorateWithText("Default label");
}

/**
* Waits for all decorator-related jobs to complete.
* This ensures that decorator enablement changes have been fully processed
* before tests check decoration results.
*/
private void waitForDecoratorJobs() {
try {
Job.getJobManager().join(DecoratorManager.FAMILY_DECORATE, null);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
// Also process any pending UI events
UITestUtil.processEvents();
}

private void assertDecorated(String testSubName, String[] expectedSuffixes, Object[] elements,
boolean shouldHaveMatches) {
for (Object object : elements) {
Expand All @@ -65,9 +81,9 @@ public void doSetUp() throws Exception {
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceDecoratorContributor.ID, true);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceMappingDecoratorContributor.ID, true);

// Process all pending UI events to ensure decorator enablement has completed
// This prevents race conditions where decorators may not be fully registered yet
UITestUtil.processEvents();
// Wait for all decorator jobs to complete after enabling decorators
// This prevents race conditions where decorators may not be fully initialized yet
waitForDecoratorJobs();
}

@After
Expand All @@ -77,8 +93,8 @@ public void doTearDown() throws Exception {
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceDecoratorContributor.ID, false);
PlatformUI.getWorkbench().getDecoratorManager().setEnabled(TestResourceMappingDecoratorContributor.ID, false);

// Process all pending UI events to ensure clean state for next test
UITestUtil.processEvents();
// Wait for all decorator jobs to complete to ensure clean state for next test
waitForDecoratorJobs();
}

/**
Expand Down
Loading