Skip to content

Commit 60ee73f

Browse files
committed
Fix flaky FindReplaceDialogTest focus tests
Replaced immediate assertTrue checks with waitForFocus to handle timing issues in testFocusNotChangedWhenEnterPressed and testFocusNotChangedWhenButtonMnemonicPressed.
1 parent 22fd647 commit 60ee73f

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ public void testFocusNotChangedWhenEnterPressed() {
6868
dialog.getFindCombo().setFocus();
6969
dialog.setFindText("line");
7070
dialog.simulateKeyboardInteractionInFindInputField(SWT.CR, false);
71-
assertTrue(dialog.getFindCombo().isFocusControl());
71+
waitForFocus(dialog.getFindCombo()::isFocusControl, testName.getMethodName());
7272

7373
Button wrapCheckBox= dialog.getButtonForSearchOption(SearchOptions.WRAP);
7474
Button globalRadioButton= dialog.getButtonForSearchOption(SearchOptions.GLOBAL);
7575
wrapCheckBox.setFocus();
7676
dialog.simulateKeyboardInteractionInFindInputField(SWT.CR, false);
77-
assertTrue(wrapCheckBox.isFocusControl());
77+
waitForFocus(wrapCheckBox::isFocusControl, testName.getMethodName());
7878

7979
globalRadioButton.setFocus();
8080
dialog.simulateKeyboardInteractionInFindInputField(SWT.CR, false);
81-
assertTrue(globalRadioButton.isFocusControl());
81+
waitForFocus(globalRadioButton::isFocusControl, testName.getMethodName());
8282
}
8383

8484
@Test
@@ -97,23 +97,20 @@ public void testFocusNotChangedWhenButtonMnemonicPressed() {
9797
event.character= 'n';
9898
event.doit= false;
9999
wrapCheckBox.traverse(SWT.TRAVERSE_MNEMONIC, event);
100-
runEventQueue();
101-
assertTrue(wrapCheckBox.isFocusControl());
100+
waitForFocus(wrapCheckBox::isFocusControl, testName.getMethodName());
102101

103102
Button globalRadioButton= dialog.getButtonForSearchOption(SearchOptions.GLOBAL);
104103
globalRadioButton.setFocus();
105104
event.detail= SWT.TRAVERSE_MNEMONIC;
106105
event.doit= false;
107106
globalRadioButton.traverse(SWT.TRAVERSE_MNEMONIC, event);
108-
runEventQueue();
109-
assertTrue(globalRadioButton.isFocusControl());
107+
waitForFocus(globalRadioButton::isFocusControl, testName.getMethodName());
110108

111109
event.detail= SWT.TRAVERSE_MNEMONIC;
112110
event.character= 'r';
113111
event.doit= false;
114112
globalRadioButton.traverse(SWT.TRAVERSE_MNEMONIC, event);
115-
runEventQueue();
116-
assertTrue(globalRadioButton.isFocusControl());
113+
waitForFocus(globalRadioButton::isFocusControl, testName.getMethodName());
117114
}
118115

119116
@Test

0 commit comments

Comments
 (0)