Skip to content

Commit d9dbf78

Browse files
vogellaclaude
andcommitted
Fix flaky HoverTest.testEnabledWhenHover() race condition
The testEnabledWhenHover test was failing randomly when trying to retrieve the hover shell for the second part of the test. Root cause: - The test has two parts: first with EnabledPropertyTester.setEnabled(true), then with setEnabled(false) - After the first hover is shown and checked, cleanFileAndEditor() is called - However, the hover shell from the first part may not be fully disposed when the second editor is opened and the second hover is triggered - This causes getHoverShell() to timeout waiting for the new hover shell Fix: - Capture a reference to the first hover shell before calling cleanFileAndEditor() - After cleanFileAndEditor(), explicitly wait for the first shell to be disposed using DisplayHelper.waitForCondition() with a 3000ms timeout - This ensures the hover state is fully reset before the second part begins This approach follows the pattern used in other recent flaky test fixes in this repository (e.g., ProgressContantsTest, ProgressViewTests) which use condition-based waiting to ensure proper cleanup between test phases. Fixes #926 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1a43fc1 commit d9dbf78

File tree

1 file changed

+7
-0
lines changed
  • tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests

1 file changed

+7
-0
lines changed

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.eclipse.swt.custom.StyledText;
3434
import org.eclipse.swt.widgets.Composite;
3535
import org.eclipse.swt.widgets.Control;
36+
import org.eclipse.swt.widgets.Display;
3637
import org.eclipse.swt.widgets.Event;
3738
import org.eclipse.swt.widgets.Label;
3839
import org.eclipse.swt.widgets.Link;
@@ -80,7 +81,13 @@ public void testEnabledWhenHover(TestInfo info) throws Exception {
8081
assertNotNull(findControl(shell, StyledText.class, AlrightyHoverProvider.LABEL));
8182
assertNull(findControl(shell, StyledText.class, WorldHoverProvider.LABEL));
8283

84+
// Capture the first shell and its display to wait for disposal
85+
Shell firstShell = shell;
86+
Display display = firstShell.getDisplay();
8387
cleanFileAndEditor();
88+
// Wait for the hover shell to be disposed after editor cleanup
89+
DisplayHelper.waitForCondition(display, 3000, () -> firstShell.isDisposed());
90+
8491
EnabledPropertyTester.setEnabled(false);
8592
createAndOpenFile("enabledWhen.txt", "bar 'bar'");
8693
shell= getHoverShell(info, triggerCompletionAndRetrieveInformationControlManager(), true);

0 commit comments

Comments
 (0)