From 7d477d526dbf99ca2a533e77e9084d219b25705a Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Thu, 7 May 2026 11:00:26 -0400 Subject: [PATCH] Test fixes; plugin name fix --- Ghidra/Features/Base/certification.manifest | 6 +- .../Select_Bytes_Help.html} | 71 +++++++++--------- .../images/Dialog.png | Bin .../images/ToBadAddr.png | Bin ...lockDialog.java => SelectBytesDialog.java} | 21 +++--- ...lockPlugin.java => SelectBytesPlugin.java} | 38 ++++------ ...inTest.java => SelectBytesPluginTest.java} | 64 ++++++++-------- .../ByteViewerPlugin/The_Byte_Viewer.htm | 2 +- ...java => SelectBytesPluginScreenShots.java} | 20 ++--- 9 files changed, 107 insertions(+), 115 deletions(-) rename Ghidra/Features/Base/src/main/help/help/topics/{SelectBlockPlugin/Select_Block_Help.html => SelectBytesPlugin/Select_Bytes_Help.html} (74%) rename Ghidra/Features/Base/src/main/help/help/topics/{SelectBlockPlugin => SelectBytesPlugin}/images/Dialog.png (100%) rename Ghidra/Features/Base/src/main/help/help/topics/{SelectBlockPlugin => SelectBytesPlugin}/images/ToBadAddr.png (100%) rename Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/{SelectBlockDialog.java => SelectBytesDialog.java} (94%) rename Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/{SelectBlockPlugin.java => SelectBytesPlugin.java} (70%) rename Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/{SelectBlockPluginTest.java => SelectBytesPluginTest.java} (86%) rename Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/{SelectBlockPluginScreenShots.java => SelectBytesPluginScreenShots.java} (84%) diff --git a/Ghidra/Features/Base/certification.manifest b/Ghidra/Features/Base/certification.manifest index b35d3593a3..e3f1b99718 100644 --- a/Ghidra/Features/Base/certification.manifest +++ b/Ghidra/Features/Base/certification.manifest @@ -704,9 +704,9 @@ src/main/help/help/topics/Search/images/SearchMemoryRegex.png||GHIDRA||||END| src/main/help/help/topics/Search/images/SearchText.png||GHIDRA||||END| src/main/help/help/topics/Search/images/StringSearchDialog.png||GHIDRA||||END| src/main/help/help/topics/Search/images/StringSearchResults.png||GHIDRA||||END| -src/main/help/help/topics/SelectBlockPlugin/Select_Block_Help.html||GHIDRA||||END| -src/main/help/help/topics/SelectBlockPlugin/images/Dialog.png||GHIDRA||||END| -src/main/help/help/topics/SelectBlockPlugin/images/ToBadAddr.png||GHIDRA||||END| +src/main/help/help/topics/SelectBytesPlugin/Select_Bytes_Help.html||GHIDRA||||END| +src/main/help/help/topics/SelectBytesPlugin/images/Dialog.png||GHIDRA||||END| +src/main/help/help/topics/SelectBytesPlugin/images/ToBadAddr.png||GHIDRA||||END| src/main/help/help/topics/Selection/Selecting.htm||GHIDRA||||END| src/main/help/help/topics/SetHighlightPlugin/Highlighting.htm||GHIDRA||||END| src/main/help/help/topics/ShowInstructionInfoPlugin/ShowInstructionInfo.htm||GHIDRA||||END| diff --git a/Ghidra/Features/Base/src/main/help/help/topics/SelectBlockPlugin/Select_Block_Help.html b/Ghidra/Features/Base/src/main/help/help/topics/SelectBytesPlugin/Select_Bytes_Help.html similarity index 74% rename from Ghidra/Features/Base/src/main/help/help/topics/SelectBlockPlugin/Select_Block_Help.html rename to Ghidra/Features/Base/src/main/help/help/topics/SelectBytesPlugin/Select_Bytes_Help.html index ecf9289d9c..67dca2517d 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/SelectBlockPlugin/Select_Block_Help.html +++ b/Ghidra/Features/Base/src/main/help/help/topics/SelectBytesPlugin/Select_Bytes_Help.html @@ -10,81 +10,84 @@
+
This tool allows the user to select a range of bytes starting from the cursor position.
-
- ![]() |
+
-Select All:
+Select All:
-Makes a selection that covers all of the bytes in a file.
-
- To Address:
+Makes a selection that covers all of the bytes in a file. + + To Address:
Makes a selection from current cursor position to a selected address, if the address exists. If the address is an invalid address, the user is prompted to select another address. If the address is outside of the current program's memory, the selection will contain bytes from the cursor - position to the beginning or end of the program's memory.
-
- Select Forward:
+ position to the beginning or end of the program's memory. + + Select Forward:Default direction. Makes a selection of size n from - the cursor position to n-1 number of bytes.
-
- Select Backward:
+ the cursor position to n-1 number of bytes. + + Select Backward:Makes a selection of size m from the cursor position to m-1 - number of bytes.
+ number of bytes.
-Ending Address:
+Ending Address:
Enter an appropriate address that will be either the ending address of the bytes (if the selected address is greater than the current address) or the starting address of the bytes (if the selected address is lower than the current - address). This value may be in either hex or decimal
-Length:
+ address). This value may be in either hex or decimal +Length:
Enter an appropriate length (number of bytes to be contained in the selection) that will point to either the ending address of the bytes (if the selected address is greater than the current address) or the starting address of the bytes (if the selected address is lower than the current - address). This value may be in either hex or decimal
+ address). This value may be in either hex or decimal
--To Address Error Message:
--+
-To Address Error Message:
+ ++
This occurs only when an invalid address is entered. The -user is prompted to enter a valid address.
+ +
-
-
+user is prompted to enter a valid address.
+
Provided By: Select Block Plugin
+Provided By: Select Bytes Plugin
-- * Note: This plugin used to refer to selections as blocks instead of lengths - * of bytes. The GUI has been changed, but the internal comments and - * variable names have not. + * This plugin allows users to select bytes anywhere inside of the Code Browser and Byte Viewer. */ //@formatter:off @PluginInfo( @@ -43,16 +38,15 @@ import ghidra.util.HelpLocation; packageName = CorePluginPackage.NAME, category = PluginCategoryNames.COMMON, shortDescription = "Select Bytes", - description = "Allows the user to select different size " - + "lengths of bytes from the Byte Viewer " + description = "Allows the user to select different size lengths of bytes, " + "generally starting from the cursor position or entire file" ) //@formatter:on -public class SelectBlockPlugin extends Plugin { - private DockingAction toolBarAction; - private SelectBlockDialog dialog; +public class SelectBytesPlugin extends Plugin { + private DockingAction action; + private SelectBytesDialog dialog; - public SelectBlockPlugin(PluginTool tool) { + public SelectBytesPlugin(PluginTool tool) { super(tool); createActions(); } @@ -68,7 +62,7 @@ public class SelectBlockPlugin extends Plugin { private void createActions() { - toolBarAction = new NavigatableContextAction("SelectBlock", getName()) { + action = new NavigatableContextAction("SelectBytes", getName()) { @Override public void actionPerformed(NavigatableActionContext context) { showDialog(context.getComponentProvider(), context.getNavigatable()); @@ -84,13 +78,13 @@ public class SelectBlockPlugin extends Plugin { new MenuData(new String[] { ToolConstants.MENU_SELECTION, "Bytes..." }, null, "Select Group 2"); menuData.setMenuSubGroup("1"); - toolBarAction.setMenuBarData(menuData); - toolBarAction.addToWindowWhen(NavigatableActionContext.class); + action.setMenuBarData(menuData); + action.addToWindowWhen(NavigatableActionContext.class); - toolBarAction.setEnabled(false); - toolBarAction.setDescription("Allows user to select blocks of data."); - toolBarAction.setHelpLocation(new HelpLocation("SelectBlockPlugin", "Select_Block_Help")); - tool.addAction(toolBarAction); + action.setEnabled(false); + action.setDescription("Allows user to select bytes of data."); + action.setHelpLocation(new HelpLocation("SelectBytesPlugin", "Select_Bytes_Help")); + tool.addAction(action); } protected void updateNavigatable(ActionContext context) { @@ -109,7 +103,7 @@ public class SelectBlockPlugin extends Plugin { if (dialog != null) { dialog.close(); } - dialog = new SelectBlockDialog(tool, navigatable); + dialog = new SelectBytesDialog(tool, navigatable); dialog.show(provider); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/SelectBlockPluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/SelectBytesPluginTest.java similarity index 86% rename from Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/SelectBlockPluginTest.java rename to Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/SelectBytesPluginTest.java index 662d075616..d0f6a68fb3 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/SelectBlockPluginTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/select/SelectBytesPluginTest.java @@ -45,7 +45,7 @@ import ghidra.util.task.TaskMonitor; /** * Test class to test the Select Bytes dialog. */ -public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { +public class SelectBytesPluginTest extends AbstractGhidraHeadedIntegrationTest { private static final String SELECT_BYTES_BUTTON_NAME = "Select Bytes"; @@ -64,9 +64,9 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { configureTool(tool); browser = env.getPlugin(CodeBrowserPlugin.class); - SelectBlockPlugin plugin = env.getPlugin(SelectBlockPlugin.class); + SelectBytesPlugin plugin = env.getPlugin(SelectBytesPlugin.class); - showDialogAction = (DockingActionIf) getInstanceField("toolBarAction", plugin); + showDialogAction = getAction(plugin, "SelectBytes"); } @After @@ -97,7 +97,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { toolToConfigure.addPlugin(NextPrevAddressPlugin.class.getName()); toolToConfigure.addPlugin(CodeBrowserPlugin.class.getName()); toolToConfigure.addPlugin(GoToAddressLabelPlugin.class.getName()); - toolToConfigure.addPlugin(SelectBlockPlugin.class.getName()); + toolToConfigure.addPlugin(SelectBytesPlugin.class.getName()); } @Test @@ -107,7 +107,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { openProgram(); assertTrue(showDialogAction.isEnabledForContext(getContext())); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); closeProgram(); assertTrue(!showDialogAction.isEnabledForContext(getContext())); @@ -117,7 +117,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { @Test public void testSelectAll() throws Exception { openProgram(); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectAll(dialog); pressSelectBytes(dialog); @@ -132,7 +132,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { openProgram(); goTo(addr(0x1006420)); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectAll(dialog); assertAddressFieldDisabled(dialog); @@ -157,7 +157,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { openProgram(); goTo(addr(0x1006420)); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectForward(dialog); @@ -173,7 +173,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { openProgram(); goTo(addr(0x1006420)); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectBackward(dialog); @@ -192,7 +192,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { openProgram(); goTo(addr(0x1006420)); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectToAddress(dialog); @@ -216,7 +216,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { Address overlayEnd = block.getEnd(); goTo(overlayStart); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectForward(dialog); @@ -241,7 +241,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { Address overlayEnd = block.getEnd(); goTo(overlayStart); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectForward(dialog); @@ -266,7 +266,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { Address overlayEnd = block.getEnd(); goTo(overlayEnd); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectBackward(dialog); @@ -291,7 +291,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { Address overlayEnd = block.getEnd(); goTo(overlayEnd); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectBackward(dialog); @@ -311,7 +311,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { Address startAddress = addr(0x6420); goTo(startAddress); - SelectBlockDialog dialog = showDialog(); + SelectBytesDialog dialog = showDialog(); pressSelectAll(dialog); @@ -381,14 +381,14 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { // Private Methods //================================================================================================= - private void pressSelectToAddress(SelectBlockDialog dialog) { + private void pressSelectToAddress(SelectBytesDialog dialog) { JRadioButton toButton = (JRadioButton) findComponentByName(dialog, "toButton"); pressButton(toButton, true); } - private SelectBlockDialog showDialog() { + private SelectBytesDialog showDialog() { performAction(showDialogAction, getContext(), true); - SelectBlockDialog dialog = waitForDialogComponent(SelectBlockDialog.class); + SelectBytesDialog dialog = waitForDialogComponent(SelectBytesDialog.class); return dialog; } @@ -420,51 +420,49 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { } } - private void pressSelectBackward(SelectBlockDialog dialog) { + private void pressSelectBackward(SelectBytesDialog dialog) { JRadioButton backwardButton = (JRadioButton) findComponentByName(dialog, "backwardButton"); pressButton(backwardButton, true); } - private void setAddress(SelectBlockDialog dialog, String text) { + private void setAddress(SelectBytesDialog dialog, String text) { final JTextField addressInputField = (JTextField) getInstanceField("toAddressField", dialog); runSwing(() -> addressInputField.setText(text)); } - private void setLength(SelectBlockDialog dialog, int length) { - IntegerTextField inputField = - (IntegerTextField) getInstanceField("numberInputField", dialog); - runSwing(() -> inputField.setValue(length)); + private void setLength(SelectBytesDialog dialog, int length) { + runSwing(() -> dialog.setLength(length)); } - private void pressSelectForward(SelectBlockDialog dialog) { + private void pressSelectForward(SelectBytesDialog dialog) { JRadioButton forwardButton = (JRadioButton) findComponentByName(dialog, "forwardButton"); pressButton(forwardButton, true); } - private void assertLengthFieldDisabled(SelectBlockDialog dialog) { + private void assertLengthFieldDisabled(SelectBytesDialog dialog) { IntegerTextField inputField = - (IntegerTextField) getInstanceField("numberInputField", dialog); + (IntegerTextField) getInstanceField("lengthField", dialog); assertFalse(inputField.getComponent().isEnabled()); } - private void assertLengthFieldEnabled(SelectBlockDialog dialog) { + private void assertLengthFieldEnabled(SelectBytesDialog dialog) { IntegerTextField inputField = - (IntegerTextField) getInstanceField("numberInputField", dialog); + (IntegerTextField) getInstanceField("lengthField", dialog); assertTrue(inputField.getComponent().isEnabled()); } - private void assertAddressFieldDisabled(SelectBlockDialog dialog) { + private void assertAddressFieldDisabled(SelectBytesDialog dialog) { JTextField addressInputField = (JTextField) getInstanceField("toAddressField", dialog); assertFalse(addressInputField.isEnabled()); } - private void assertAddressFieldEnabled(SelectBlockDialog dialog) { + private void assertAddressFieldEnabled(SelectBytesDialog dialog) { JTextField addressInputField = (JTextField) getInstanceField("toAddressField", dialog); assertTrue(addressInputField.isEnabled()); } - private void pressSelectAll(SelectBlockDialog dialog) { + private void pressSelectAll(SelectBytesDialog dialog) { JRadioButton allButton = (JRadioButton) findComponentByName(dialog, "allButton"); pressButton(allButton, true); } @@ -477,7 +475,7 @@ public class SelectBlockPluginTest extends AbstractGhidraHeadedIntegrationTest { runSwing(() -> browser.getProvider().setSelection(null)); } - private void pressSelectBytes(final SelectBlockDialog dialog) { + private void pressSelectBytes(final SelectBytesDialog dialog) { executeOnSwingWithoutBlocking( () -> pressButtonByText(dialog, SELECT_BYTES_BUTTON_NAME, true)); diff --git a/Ghidra/Features/ByteViewer/src/main/help/help/topics/ByteViewerPlugin/The_Byte_Viewer.htm b/Ghidra/Features/ByteViewer/src/main/help/help/topics/ByteViewerPlugin/The_Byte_Viewer.htm index 0fe34d45ec..92795fdb26 100644 --- a/Ghidra/Features/ByteViewer/src/main/help/help/topics/ByteViewerPlugin/The_Byte_Viewer.htm +++ b/Ghidra/Features/ByteViewer/src/main/help/help/topics/ByteViewerPlugin/The_Byte_Viewer.htm @@ -399,7 +399,7 @@