Skip to content
Merged
Show file tree
Hide file tree
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 @@ -19,6 +19,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

Expand All @@ -30,6 +31,7 @@

import org.eclipse.text.tests.Accessor;

import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.viewers.ISelection;

import org.eclipse.jface.text.IFindReplaceTarget;
Expand Down Expand Up @@ -57,6 +59,27 @@ public OverlayAccess openUIFromTextViewer(TextViewer viewer) {
return uiAccess;
}

@Test
public void testShortcutHintReflectsFocusedInputField() {
initializeTextViewerWithFindReplaceUI("line");
OverlayAccess dialog= getDialog();

String searchForwardHint= KeyStroke.getInstance(SWT.CR).format();

// The search bar has focus right after opening: its own shortcut hint is shown.
assertTrue(dialog.getSearchForwardToolTipText().contains(searchForwardHint));

// Opening the replace bar moves focus there: the search-scoped hint disappears and the
// replace-scoped hint (which happens to reuse the same shortcut) appears instead.
dialog.openReplaceDialog();
assertFalse(dialog.getSearchForwardToolTipText().contains(searchForwardHint));
assertTrue(dialog.getReplaceToolTipText().contains(searchForwardHint));

// Closing the replace bar returns focus to the search bar: its hint is shown again.
dialog.closeReplaceDialog();
assertTrue(dialog.getSearchForwardToolTipText().contains(searchForwardHint));
}

@Test
public void testDirectionalSearchButtons() {
initializeTextViewerWithFindReplaceUI("line\nline\nline\nline");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ public void performReplace() {
replaceButton.notifyListeners(SWT.Selection, null);
}

public String getSearchForwardToolTipText() {
return searchForward.getToolTipText();
}

public String getReplaceToolTipText() {
return replaceButton != null ? replaceButton.getToolTipText() : null;
}

public boolean isReplaceDialogOpen() {
return replace != null;
}
Expand Down
Loading