Skip to content

Commit 3cc77fd

Browse files
committed
Find/Replace overlay tests: use correct simulated event character for CR
The tests for find/replace overlay (and dialog) also simulate specific keyboard interactions. This especially contains tests for pressing the Return button. The created events currently only have the keyCode set, whereas the actual events that are generated by human keyboard interactions also contain the key character. In case of pressing any of the Return buttons, the character is `\r`. This is not only an incomplete simulation (which currently has no negative effect) but also leads to test failures once key bindings for the find/replace overlay are implemented via the Eclipse command infrastructure and the according key binding dispatcher, as that one relies on the `\r` character for also mapping they numpad Return to a configured key binding for the Return (CR) button. This enhances the simulated key events for find/replace UI tests accordingly. It adds the proper character value for Return presses to correctly reflect the event structure that is generated upon a real keyboard interaction.
1 parent 0fcade6 commit 3cc77fd

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/internal/findandreplace/overlay/OverlayAccess.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ public void simulateKeyboardInteractionInFindInputField(int keyCode, boolean shi
143143
if (shiftPressed) {
144144
event.stateMask= SWT.SHIFT;
145145
}
146+
if (keyCode == SWT.CR | keyCode == SWT.KEYPAD_CR) {
147+
event.character= '\r';
148+
}
146149
event.keyCode= keyCode;
147150
find.getTextBar().notifyListeners(SWT.KeyDown, event);
148151
runEventQueue();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ public void simulateKeyboardInteractionInFindInputField(int keyCode, boolean shi
175175
if (shiftPressed) {
176176
event.stateMask= SWT.SHIFT;
177177
}
178+
if (keyCode == SWT.CR | keyCode == SWT.KEYPAD_CR) {
179+
event.character= '\r';
180+
}
178181
event.keyCode= keyCode;
179182
findCombo.traverse(SWT.TRAVERSE_RETURN, event);
180183
runEventQueue();

0 commit comments

Comments
 (0)