Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test fixes for action name change

dragonmacherc35a598aec5c
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java
index 43bd7b795d..5f0bdc977b 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java
@@ -69,15 +69,14 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
@After
public void tearDown() throws Exception {
- env.release(program);
env.dispose();
}
@Test
public void testEnumFields() throws Exception {
Category c = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = createEnum(c, "TestEnum", 1);
edit(enumm);
@@ -100,7 +99,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
JTextField catField = getTextField(panel, "Category");
assertNotNull(catField);
assertEquals("notepad/Category1", catField.getText());
- assertTrue(!catField.isEditable());
+ assertFalse(catField.isEditable());
// size should be "1"
@SuppressWarnings("unchecked")
@@ -114,12 +113,12 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
// add action should be enabled
// apply action should be disabled
// delete action should be disabled
- DockingActionIf addAction = getAction(plugin, "Add Enum Value");
+ DockingActionIf addAction = getAddAction();
assertTrue(addAction.isEnabled());
- DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
- assertTrue(!applyAction.isEnabled());
- DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
- assertTrue(!deleteAction.isEnabled());
+ DockingActionIf applyAction = getApplyAction();
+ assertFalse(applyAction.isEnabled());
+ DockingActionIf deleteAction = getDeleteAction();
+ assertFalse(deleteAction.isEnabled());
// sort column should be on the value column
JTable table = (JTable) findContainer(panel, JTable.class);
@@ -130,8 +129,8 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testEnumSize1() throws Exception {
Category category = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = createEnum(category, "TestEnum", 1);
edit(enumm);
@@ -141,7 +140,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
addEnumValue();
waitForSwing();
- DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
+ DockingActionIf applyAction = getApplyAction();
assertTrue(applyAction.isEnabled());
assertTrue(panel.needsSave());
@@ -181,8 +180,8 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
public void testEnumSize1BadInput() throws Exception {
// test entering too large a value
Category category = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = createEnum(category, "TestEnum", 1);
edit(enumm);
@@ -192,7 +191,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
addEnumValue();
waitForSwing();
- DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
+ DockingActionIf applyAction = getApplyAction();
assertTrue(applyAction.isEnabled());
assertTrue(panel.needsSave());
@@ -224,8 +223,8 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testEnumSize4BadInput() throws Exception {
Category category = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = createEnum(category, "MyTestEnum", 4);
edit(enumm);
@@ -243,12 +242,12 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
addEnumValue();
waitForSwing();
- DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
+ DockingActionIf applyAction = getApplyAction();
assertTrue(applyAction.isEnabled());
assertTrue(panel.needsSave());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
assertEquals("New_Name", model.getValueAt(0, NAME_COL));
assertEquals(0L, model.getValueAt(0, VALUE_COL));
@@ -275,14 +274,14 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testBadInputForValue() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = createEnum(cat, "TestEnum", 1);
edit(enumm);
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
addEnumValue();
waitForSwing();
@@ -304,8 +303,8 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
public void testEditExistingEnum1() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
final Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 1);
@@ -368,8 +367,8 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testValueForNewEntry() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
final Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0x10);
enumm.add("Green", 0x20);
@@ -389,7 +388,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
runSwing(() -> {
int lastRow = model.getRowCount() - 1;
table.addRowSelectionInterval(lastRow, lastRow);
- DockingActionIf addAction = getAction(plugin, "Add Enum Value");
+ DockingActionIf addAction = getAddAction();
addAction.actionPerformed(new DefaultActionContext());
});
waitForSwing();
@@ -762,12 +761,11 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
public void testChangeEnumSizeAndInStructure() throws Exception {
Category category = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = createEnum(category, "EnumX", 2);
- int transactionID = program.startTransaction("Test");
- try {
+ tx(program, () -> {
enumm.add("Zero", 0);
enumm.add("One", 1);
@@ -783,10 +781,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
structY.add(new ByteDataType());
structY.add(enumm);
category.addDataType(structY, DataTypeConflictHandler.DEFAULT_HANDLER);
- }
- finally {
- program.endTransaction(transactionID, true);
- }
+ });
edit(enumm);
@@ -832,12 +827,11 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
public void testChangeEnumDescriptionEtcAndInStructure() throws Exception {
Category category = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = createEnum(category, "EnumX", 2);
- int transactionID = program.startTransaction("Test");
- try {
+ tx(program, () -> {
enumm.add("Zero", 0);
enumm.add("One", 1);
enumm.setDescription("ABCD");
@@ -854,10 +848,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
structY.add(new ByteDataType());
structY.add(enumm);
category.addDataType(structY, DataTypeConflictHandler.DEFAULT_HANDLER);
- }
- finally {
- program.endTransaction(transactionID, true);
- }
+ });
edit(enumm);
@@ -1140,8 +1131,8 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
private Enum createRedGreenBlueEnum() {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
final Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 1);
@@ -1165,7 +1156,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
private void apply() {
runSwing(() -> {
- DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
+ DockingActionIf applyAction = getApplyAction();
applyAction.actionPerformed(new DefaultActionContext());
}, false);
program.flushEvents();
@@ -1290,12 +1281,10 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
}
private void editValueInTable(int row, String newValue) {
-
editCellInTable(row, VALUE_COL, newValue);
}
private void editNameInTable(int row, String newValue) {
-
editCellInTable(row, NAME_COL, newValue);
}
@@ -1331,11 +1320,23 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest {
private void addEnumValue() {
runSwing(() -> {
- DockingActionIf addAction = getAction(plugin, "Add Enum Value");
+ DockingActionIf addAction = getAddAction();
addAction.actionPerformed(new DefaultActionContext());
});
}
+ private DockingActionIf getAddAction() {
+ return getAction(plugin, DataTypeEditorManager.EDIT_ACTION_PREFIX + "Add Enum Value");
+ }
+
+ private DockingActionIf getApplyAction() {
+ return getAction(plugin, DataTypeEditorManager.EDIT_ACTION_PREFIX + "Apply Enum Changes");
+ }
+
+ private DockingActionIf getDeleteAction() {
+ return getAction(plugin, DataTypeEditorManager.EDIT_ACTION_PREFIX + "Delete Enum Value");
+ }
+
private int getRowFor(String theName) {
JTable table = getEditTable();
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java
index 45e38970c0..1a36ee27db 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java
@@ -57,7 +57,6 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
@After
public void tearDown() throws Exception {
- env.release(program);
env.dispose();
}
@@ -65,15 +64,15 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
public void testInsertRow() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
- final Enum enumm = new EnumDataType("Colors", 1);
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 0x10);
enumm.add("Blue", 0x20);
int transactionID = program.startTransaction("Test");
- final Enum enumDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
+ Enum enumDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
program.endTransaction(transactionID, true);
program.flushEvents();
waitForSwing();
@@ -82,8 +81,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
// add an entry with a value of 15
addEntry(table, model, "Gold", 0x15);
@@ -101,15 +100,15 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testSortColumns() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
- final Enum enumm = new EnumDataType("Colors", 1);
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 0x10);
enumm.add("Blue", 0x20);
int transactionID = program.startTransaction("Test");
- final Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
+ Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
program.endTransaction(transactionID, true);
program.flushEvents();
waitForSwing();
@@ -118,8 +117,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
// sort by Name
JTableHeader header = table.getTableHeader();
@@ -145,8 +144,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
public void testSortOnComments() {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0, "1");
enumm.add("Green", 0x10, "3");
@@ -184,15 +183,15 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testSortOrder() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
- final Enum enumm = new EnumDataType("Colors", 1);
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 0x10);
enumm.add("Blue", 0x20);
int transactionID = program.startTransaction("Test");
- final Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
+ Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
program.endTransaction(transactionID, true);
program.flushEvents();
waitForSwing();
@@ -201,8 +200,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
// sort Descending
JTableHeader header = table.getTableHeader();
@@ -229,15 +228,15 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testInsertRowByName() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
- final Enum enumm = new EnumDataType("Colors", 1);
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 0x10);
enumm.add("Blue", 0x20);
int transactionID = program.startTransaction("Test");
- final Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
+ Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
program.endTransaction(transactionID, true);
program.flushEvents();
waitForSwing();
@@ -246,8 +245,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
// sort by Name
JTableHeader header = table.getTableHeader();
@@ -265,21 +264,21 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enummDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
// select rows 2 and 4 ("Purple" and "Blue")
table.setRowSelectionInterval(2, 2);
table.addRowSelectionInterval(4, 4);
- final DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
+ DockingActionIf deleteAction = getDeleteAction();
assertTrue(deleteAction.isEnabled());
runSwing(() -> deleteAction.actionPerformed(new DefaultActionContext()));
waitForSwing();
assertTrue(table.isRowSelected(3));
- final DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
+ DockingActionIf applyAction = getApplyAction();
assertTrue(applyAction.isEnabled());
runSwing(() -> applyAction.actionPerformed(new DefaultActionContext()));
@@ -295,9 +294,9 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enummDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
- final DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
+ DockingActionIf deleteAction = getDeleteAction();
int count = enummDt.getCount();
table.setRowSelectionInterval(count - 1, count - 1);
@@ -317,9 +316,9 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enummDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
- final DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
+ DockingActionIf deleteAction = getDeleteAction();
int count = enummDt.getCount();
table.setRowSelectionInterval(count - 1, count - 1);
@@ -331,7 +330,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
}
applyChanges(true);
Window w = windowForComponent(table);
- String str = findLabelStr(w, "Tool Status");
+ String str = findLabelText(w, "Tool Status");
assertEquals("Empty enum is not allowed", str);
// add an entry so the tear down works properly
@@ -343,9 +342,9 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enummDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
- final DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
+ DockingActionIf deleteAction = getDeleteAction();
int count = enummDt.getCount();
table.setRowSelectionInterval(count - 1, count - 1);
@@ -356,7 +355,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
}
- final ComponentProvider provider = waitForComponentProvider(EnumEditorProvider.class);
+ ComponentProvider provider = waitForComponentProvider(EnumEditorProvider.class);
assertNotNull(provider);
runSwingLater(() -> provider.closeComponent());
waitForSwing();
@@ -367,7 +366,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
assertTrue(tool.isVisible(provider));
- String str = findLabelStr(w, "Tool Status");
+ String str = findLabelText(w, "Tool Status");
assertEquals("Empty enum is not allowed", str);
// add an entry so the tear down works properly
@@ -379,8 +378,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enummDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
+ JTable table = panel.getTable();
+ DockingActionIf deleteAction = getDeleteAction();
int count = enummDt.getCount();
table.setRowSelectionInterval(count - 1, count - 1);
@@ -391,7 +390,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
}
- final ComponentProvider provider = waitForComponentProvider(EnumEditorProvider.class);
+ ComponentProvider provider = waitForComponentProvider(EnumEditorProvider.class);
assertNotNull(provider);
runSwingLater(() -> provider.closeComponent());
waitForSwing();
@@ -399,7 +398,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
assertNotNull(d);
pressButtonByText(d.getComponent(), "No");
waitForSwing();
- assertTrue(!tool.isVisible(provider));
+ assertFalse(tool.isVisible(provider));
}
@Test
@@ -407,9 +406,9 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enummDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
- final DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
+ DockingActionIf deleteAction = getDeleteAction();
int count = enummDt.getCount();
table.setRowSelectionInterval(count - 1, count - 1);
@@ -420,7 +419,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
waitForSwing();
}
- final ComponentProvider provider = waitForComponentProvider(EnumEditorProvider.class);
+ ComponentProvider provider = waitForComponentProvider(EnumEditorProvider.class);
assertNotNull(provider);
runSwingLater(() -> provider.closeComponent());
waitForSwing();
@@ -440,12 +439,12 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enummDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
// select first row ("Red");
table.setRowSelectionInterval(0, 0);
- final DockingActionIf deleteAction = getAction(plugin, "Delete Enum Value");
+ DockingActionIf deleteAction = getDeleteAction();
assertTrue(deleteAction.isEnabled());
runSwing(() -> deleteAction.actionPerformed(new DefaultActionContext()));
@@ -453,7 +452,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
assertTrue(table.isRowSelected(0));
- final DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
+ DockingActionIf applyAction = getApplyAction();
assertTrue(applyAction.isEnabled());
runSwing(() -> applyAction.actionPerformed(new DefaultActionContext()));
@@ -468,7 +467,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
public void testEditName() throws Exception {
Enum enummDt = editSampleEnum();
- final EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
+ EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
runSwing(() -> {
JTextField nameField = getTextField(panel, "Name");
@@ -483,9 +482,9 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
public void testDuplicateName() throws Exception {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
- final Enum enumm = new EnumDataType("Colors", 1);
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 0x10);
enumm.add("Blue", 0x20);
@@ -499,7 +498,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
en2.add("Topaz", 10);
int transactionID = program.startTransaction("Test");
- final Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
+ Enum enummDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
cat.addDataType(en2, DataTypeConflictHandler.DEFAULT_HANDLER);
program.endTransaction(transactionID, true);
@@ -525,7 +524,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
close(dialog);
waitForSwing();
- assertFalse(getAction(plugin, "Apply Enum Changes").isEnabled());
+ assertFalse(getApplyAction().isEnabled());
}
@@ -534,13 +533,13 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
editSampleEnum();
- final EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
addEntry(table, model, "MYColor", 3);
// change value to an existing value
- final int row = model.getRow("MYColor");
+ int row = model.getRow("MYColor");
Rectangle rect = table.getCellRect(1, EnumTableModel.VALUE_COL, true);
clickMouse(table, 1, rect.x, rect.y, 1, 0);
@@ -559,7 +558,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
});
waitForSwing();
Window w = windowForComponent(table);
- String str = findLabelStr(w, "Tool Status");
+ String str = findLabelText(w, "Tool Status");
// assertEquals("Colors enum value 0 already assigned", str);
// duplicate values are now allowed
assertEquals("", str);
@@ -570,8 +569,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enumDt = editSampleEnum();
- final EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTextField descField = getTextField(panel, "Description");
+ EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
+ JTextField descField = getTextField(panel, "Description");
assertEquals("This is a set of Colors", descField.getText());
runSwing(() -> descField.setText("My Favorite colors"));
@@ -586,8 +585,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enumDt = editSampleEnum();
- final EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTextField descField = getTextField(panel, "Description");
+ EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
+ JTextField descField = getTextField(panel, "Description");
runSwing(() -> descField.setText(""));
waitForSwing();
@@ -601,8 +600,8 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
editSampleEnum();
- final EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
+ EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
+ JTable table = panel.getTable();
runSwing(() -> {
TableColumnModel colModel = table.getColumnModel();
@@ -628,13 +627,13 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
Enum enumDt = editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
+ JTable table = panel.getTable();
EnumTableModel model = (EnumTableModel) table.getModel();
// delete a row
table.setRowSelectionInterval(0, 0);
runSwing(() -> {
- DockingActionIf action = getAction(plugin, "Delete Enum Value");
+ DockingActionIf action = getDeleteAction();
action.actionPerformed(new DefaultActionContext());
});
applyChanges(true);
@@ -654,12 +653,12 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
+ JTable table = panel.getTable();
EnumTableModel model = (EnumTableModel) table.getModel();
int origRowCount = model.getRowCount();
runSwing(() -> {
- DockingActionIf action = getAction(plugin, "Add Enum Value");
+ DockingActionIf action = getAddAction();
action.actionPerformed(new DefaultActionContext());
action.actionPerformed(new DefaultActionContext());
});
@@ -667,7 +666,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
applyChanges(true);
// make more changes
runSwing(() -> {
- DockingActionIf action = getAction(plugin, "Add Enum Value");
+ DockingActionIf action = getAddAction();
action.actionPerformed(new DefaultActionContext());
action.actionPerformed(new DefaultActionContext());
});
@@ -676,7 +675,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
OptionDialog d = waitForDialogComponent(OptionDialog.class);
assertNotNull(d);
// yes to reload the enum data type
- final JButton button = findButtonByText(d.getComponent(), "Yes");
+ JButton button = findButtonByText(d.getComponent(), "Yes");
assertNotNull(button);
runSwing(() -> button.getActionListeners()[0].actionPerformed(null));
waitForSwing();
@@ -689,15 +688,15 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
editSampleEnum();
EnumEditorPanel panel = findEditorPanel(tool.getToolFrame());
- final JTable table = panel.getTable();
- final EnumTableModel model = (EnumTableModel) table.getModel();
+ JTable table = panel.getTable();
+ EnumTableModel model = (EnumTableModel) table.getModel();
runSwing(() -> {
int lastRow = model.getRowCount() - 1;
if (lastRow >= 0) {
table.addRowSelectionInterval(lastRow, lastRow);
}
- DockingActionIf action = getAction(plugin, "Add Enum Value");
+ DockingActionIf action = getAddAction();
action.actionPerformed(new DefaultActionContext());
action.actionPerformed(new DefaultActionContext());
});
@@ -709,7 +708,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
if (lastRow >= 0) {
table.addRowSelectionInterval(lastRow, lastRow);
}
- DockingActionIf action = getAction(plugin, "Add Enum Value");
+ DockingActionIf action = getAddAction();
action.actionPerformed(new DefaultActionContext());
action.actionPerformed(new DefaultActionContext());
});
@@ -719,7 +718,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
OptionDialog d = waitForDialogComponent(OptionDialog.class);
assertNotNull(d);
// not to not reload the enum data type
- final JButton button = findButtonByText(d.getComponent(), "No");
+ JButton button = findButtonByText(d.getComponent(), "No");
assertNotNull(button);
runSwing(() -> button.getActionListeners()[0].actionPerformed(null));
waitForSwing();
@@ -776,18 +775,18 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
return null;
}
- private void addEntry(final JTable table, final EnumTableModel model, final String name,
- final long value) throws Exception {
+ private void addEntry(JTable table, EnumTableModel model, String name,
+ long value) throws Exception {
runSwing(() -> {
int lastRow = model.getRowCount() - 1;
if (lastRow >= 0) {
table.addRowSelectionInterval(lastRow, lastRow);
}
- DockingActionIf addAction = getAction(plugin, "Add Enum Value");
+ DockingActionIf addAction = getAddAction();
addAction.actionPerformed(new DefaultActionContext());
});
waitForSwing();
- final int newRow = model.getRowCount() - 1;
+ int newRow = model.getRowCount() - 1;
// change entry
runSwing(() -> table.addRowSelectionInterval(newRow, newRow));
Rectangle rect = table.getCellRect(newRow, EnumTableModel.NAME_COL, true);
@@ -821,7 +820,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
private void applyChanges(boolean doWait) throws Exception {
- final DockingActionIf applyAction = getAction(plugin, "Apply Enum Changes");
+ DockingActionIf applyAction = getApplyAction();
assertTrue(applyAction.isEnabled());
Runnable r = () -> applyAction.actionPerformed(new DefaultActionContext());
if (doWait) {
@@ -835,7 +834,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
}
- private String findLabelStr(Container container, String name) {
+ private String findLabelText(Container container, String name) {
Component[] c = container.getComponents();
for (Component element : c) {
if (element instanceof JLabel) {
@@ -844,7 +843,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
}
}
if (element instanceof Container) {
- String str = findLabelStr((Container) element, name);
+ String str = findLabelText((Container) element, name);
if (str != null) {
return str;
}
@@ -853,11 +852,23 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
return null;
}
+ private DockingActionIf getAddAction() {
+ return getAction(plugin, DataTypeEditorManager.EDIT_ACTION_PREFIX + "Add Enum Value");
+ }
+
+ private DockingActionIf getApplyAction() {
+ return getAction(plugin, DataTypeEditorManager.EDIT_ACTION_PREFIX + "Apply Enum Changes");
+ }
+
+ private DockingActionIf getDeleteAction() {
+ return getAction(plugin, DataTypeEditorManager.EDIT_ACTION_PREFIX + "Delete Enum Value");
+ }
+
private Enum editSampleEnum() {
Category cat = program.getListing()
- .getDataTypeManager()
- .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
- final Enum enumm = new EnumDataType("Colors", 1);
+ .getDataTypeManager()
+ .getCategory(new CategoryPath(CategoryPath.ROOT, "Category1"));
+ Enum enumm = new EnumDataType("Colors", 1);
enumm.add("Red", 0);
enumm.add("Green", 0x10);
enumm.add("Blue", 0x20);
@@ -867,7 +878,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest {
enumm.setDescription("This is a set of Colors");
int transactionID = program.startTransaction("Test");
- final Enum enumDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
+ Enum enumDt = (Enum) cat.addDataType(enumm, DataTypeConflictHandler.DEFAULT_HANDLER);
program.endTransaction(transactionID, true);
program.flushEvents();
waitForSwing();