Skip to content

Commit

Permalink
GP-0 fixed unit tests for SearchList and ActionChooserDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ghidragon committed Mar 28, 2024
1 parent 74e402e commit 77923fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ ActionRunner getActionRunner() {
return actionRunner;
}

// for testing
void selectAction(DockingActionIf action) {
searchList.setSelectedItem(action);
}

@Override
public void dispose() {
super.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,20 @@ public void testFilteringOnKeybinding() {

@Test
public void testActivatingAction() {
addLocal(toolbar("Apple", ENABLED, contextA));
DockingActionIf appleAction = toolbar("Apple", ENABLED, contextA);
addLocal(appleAction);
addLocal(menuItem("Banana", ENABLED, contextA));
addLocal(popup("Pear", ENABLED, ADD_TO_POPUP, contextA));
addLocal(keyAction("Kiwi", ENABLED, contextA));

ActionsModel model = buildModel(contextA, ActionDisplayLevel.ALL);
ActionChooserDialog dialog = getSwing(() -> new ActionChooserDialog(model));
dialog.selectAction(appleAction);

assertEquals(0, triggeredActions.size());

pressReturn(dialog);

assertEquals(1, triggeredActions.size());
assertEquals("Apple", triggeredActions.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void testClearFilterRestores() {
@Test
public void testSelect() {
JTextField textField = searchList.getTextField();
triggerActionKey(textField, 0, KeyEvent.VK_DOWN);

assertNull(lastChoiceValue);
assertNull(lastChoiceCategory);
Expand Down

0 comments on commit 77923fa

Please sign in to comment.