diff --git a/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java b/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java index 8bf2aa2fa41..a52be637056 100644 --- a/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java +++ b/tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java @@ -33,6 +33,7 @@ import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; @@ -80,7 +81,13 @@ public void testEnabledWhenHover(TestInfo info) throws Exception { assertNotNull(findControl(shell, StyledText.class, AlrightyHoverProvider.LABEL)); assertNull(findControl(shell, StyledText.class, WorldHoverProvider.LABEL)); + // Capture the first shell and its display to wait for disposal + Shell firstShell = shell; + Display display = firstShell.getDisplay(); cleanFileAndEditor(); + // Wait for the hover shell to be disposed after editor cleanup + DisplayHelper.waitForCondition(display, 3000, () -> firstShell.isDisposed()); + EnabledPropertyTester.setEnabled(false); createAndOpenFile("enabledWhen.txt", "bar 'bar'"); shell= getHoverShell(info, triggerCompletionAndRetrieveInformationControlManager(), true);