mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GT-2925-2 - Key Bindings - Support Window Menu Provider Key Bindings -
test and review fixes
This commit is contained in:
parent
21db705ecc
commit
dabdc38ea9
11 changed files with 90 additions and 21 deletions
|
@ -43,7 +43,7 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
private final Icon ICON = ResourceManager.loadImage("images/refresh.png");
|
||||
private static final String PROVIDER_NAME = "Test Action Provider";
|
||||
private static final KeyStroke CONTROL_T =
|
||||
KeyStroke.getKeyStroke(Character.valueOf('t'), DockingUtils.CONTROL_KEY_MODIFIER_MASK);
|
||||
KeyStroke.getKeyStroke(Character.valueOf('T'), DockingUtils.CONTROL_KEY_MODIFIER_MASK);
|
||||
|
||||
private TestEnv env;
|
||||
private PluginTool tool;
|
||||
|
@ -160,6 +160,19 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
assertMenuItemHasKeyStroke(newKs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetKeyBinding_ViaDialog_FromWindowMenu_ThenFireKeyEventToShowProvider() {
|
||||
|
||||
showProvider();
|
||||
|
||||
KeyStroke newKs = CONTROL_T;
|
||||
setKeyBindingViaF4Dialog_FromWindowsMenu(newKs);
|
||||
|
||||
hideProvider();
|
||||
pressKey(CONTROL_T);
|
||||
assertProviderIsActive();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetKeyBinding_ViaDialog_FromWindowMenu_ToAlreadyBoundAction() {
|
||||
|
||||
|
@ -326,6 +339,11 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
waitForSwing();
|
||||
}
|
||||
|
||||
private void hideProvider() {
|
||||
tool.showComponentProvider(provider, false);
|
||||
waitForSwing();
|
||||
}
|
||||
|
||||
private void setDefaultKeyBinding(KeyStroke defaultKs) {
|
||||
runSwing(() -> provider.setKeyBinding(new KeyBindingData(defaultKs)));
|
||||
}
|
||||
|
@ -341,6 +359,14 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
});
|
||||
}
|
||||
|
||||
private void pressKey(KeyStroke ks) {
|
||||
int modifiers = ks.getModifiers();
|
||||
char keyChar = ks.getKeyChar();
|
||||
int keyCode = ks.getKeyCode();
|
||||
JFrame toolFrame = tool.getToolFrame();
|
||||
triggerKey(toolFrame, modifiers, keyCode, keyChar);
|
||||
}
|
||||
|
||||
private DockingActionIf getShowProviderAction() {
|
||||
|
||||
DockingActionIf showProviderAction =
|
||||
|
@ -389,6 +415,11 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
waitForSwing();
|
||||
}
|
||||
|
||||
private void assertProviderIsActive() {
|
||||
assertTrue("The test provider is not showing and focused",
|
||||
runSwing(() -> tool.isActive(provider)));
|
||||
}
|
||||
|
||||
private void assertNoToolbarAction() {
|
||||
assertNull("No toolbar action found for provider", getToolbarShowProviderAction());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue