Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test timing fixes

dragonmacher8f92db6ec084
diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java
index d5209338f7..a76c030308 100644
--- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java
+++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerMemoryBytesProviderTest.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +15,7 @@
*/
package ghidra.app.plugin.core.debug.gui.memory;
-import static ghidra.lifecycle.Unfinished.TODO;
+import static ghidra.lifecycle.Unfinished.*;
import static org.junit.Assert.*;
import java.awt.*;
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapPluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapPluginTest.java
index e2d2467796..c5a55a290e 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapPluginTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapPluginTest.java
@@ -41,7 +41,7 @@ import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.TestEnv;
-import ghidra.util.task.TaskMonitorAdapter;
+import ghidra.util.task.TaskMonitor;
/**
* Test the MemoryMapPlugin for domain object events.
@@ -157,15 +157,11 @@ public class MemoryMapPluginTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testOverlayBlockNameChanged() throws Exception {
- int transactionID = program.startTransaction("create overlay");
- try {
+
+ tx(program, () -> {
memory.createInitializedBlock("Ovl1", program.getMinAddress(), 0x100L, (byte) 0x0, null,
true);
- }
- finally {
- program.endTransaction(transactionID, true);
- }
- program.flushEvents();
+ });
JTable table = provider.getTable();
editNameCell(table, "Ovl1");
@@ -245,14 +241,13 @@ public class MemoryMapPluginTest extends AbstractGhidraHeadedIntegrationTest {
MemoryBlock[] blocks = memory.getBlocks();
- int transactionID = program.startTransaction("test");
- MemoryBlock blockOne =
- memory.createInitializedBlock(".test1", getAddr(0), 0x100, (byte) 0, null, false);
- MemoryBlock blockTwo =
- memory.createInitializedBlock(".test2", getAddr(0x100), 0x200, (byte) 0, null, false);
- program.getMemory().join(blockOne, blockTwo);
- program.endTransaction(transactionID, true);
- program.flushEvents();
+ tx(program, () -> {
+ MemoryBlock blockOne =
+ memory.createInitializedBlock(".test1", getAddr(0), 0x100, (byte) 0, null, false);
+ MemoryBlock blockTwo = memory.createInitializedBlock(".test2", getAddr(0x100), 0x200,
+ (byte) 0, null, false);
+ program.getMemory().join(blockOne, blockTwo);
+ });
JTable table = provider.getTable();
assertEquals(blocks.length + 1, table.getModel().getRowCount());
@@ -269,10 +264,11 @@ public class MemoryMapPluginTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals(".test", table.getModel().getValueAt(0, MemoryMapModel.NAME));
assertEquals("Default", table.getModel().getValueAt(0, MemoryMapModel.BLOCK_TYPE));
assertTrue(!((Boolean) table.getModel().getValueAt(0, MemoryMapModel.INIT)).booleanValue());
- int transactionID = program.startTransaction("test");
- memory.convertToInitialized(memory.getBlock(getAddr(0)), (byte) 0xff);
- program.endTransaction(transactionID, true);
- program.flushEvents();
+
+ tx(program, () -> {
+ memory.convertToInitialized(memory.getBlock(getAddr(0)), (byte) 0xff);
+ });
+
assertTrue(((Boolean) table.getModel().getValueAt(0, MemoryMapModel.INIT)).booleanValue());
assertEquals(blocks.length + 1, table.getModel().getRowCount());
@@ -287,10 +283,10 @@ public class MemoryMapPluginTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals(blocks.length + 1, table.getModel().getRowCount());
MemoryBlock block = memory.getBlock(getAddr(0));
- int transactionID = program.startTransaction("test");
- memory.split(block, getAddr(0x20));
- program.endTransaction(transactionID, true);
- program.flushEvents();
+
+ tx(program, () -> {
+ memory.split(block, getAddr(0x20));
+ });
assertEquals(blocks.length + 2, table.getModel().getRowCount());
assertEquals(getAddr(0x20).toString(),
@@ -304,10 +300,9 @@ public class MemoryMapPluginTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals(blocks.length, table.getModel().getRowCount());
MemoryBlock block = memory.getBlock(memory.getMinAddress());
- int transactionID = program.startTransaction("test");
- memory.moveBlock(block, getAddr(0x100), TaskMonitorAdapter.DUMMY_MONITOR);
- program.endTransaction(transactionID, true);
- program.flushEvents();
+ tx(program, () -> {
+ memory.moveBlock(block, getAddr(0x100), TaskMonitor.DUMMY);
+ });
assertEquals(blocks.length, table.getModel().getRowCount());
@@ -315,7 +310,6 @@ public class MemoryMapPluginTest extends AbstractGhidraHeadedIntegrationTest {
table.getModel().getValueAt(0, MemoryMapModel.START));
}
- /////////////////////////////////////////////////////////////////////////
private void showProvider() {
DockingActionIf action = getAction(plugin, "Memory Map");
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider1Test.java
index 9026d5f2e3..353c6abdb5 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider1Test.java
@@ -17,7 +17,8 @@ package ghidra.app.plugin.core.memory;
import static org.junit.Assert.*;
-import java.awt.*;
+import java.awt.Component;
+import java.awt.Rectangle;
import java.util.*;
import javax.swing.*;
@@ -27,7 +28,6 @@ import javax.swing.table.TableCellEditor;
import org.junit.*;
import docking.action.DockingActionIf;
-import docking.widgets.MultiLineLabel;
import docking.widgets.OptionDialog;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
@@ -57,10 +57,6 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
private JTable table;
private MemoryMapModel model;
- public MemoryMapProvider1Test() {
- super();
- }
-
private Program buildProgram(String programName) throws Exception {
ProgramBuilder builder = new ProgramBuilder(programName, ProgramBuilder._TOY);
MemoryBlock[] blocks = new MemoryBlock[5];
@@ -214,7 +210,7 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
clickMouse(table, 1, rect.x, rect.y, 2, 0);
waitForPostedSwingRunnables();
- NumberInputDialog dialog = waitForDialogComponent(null, NumberInputDialog.class, 1000);
+ NumberInputDialog dialog = waitForDialogComponent(NumberInputDialog.class);
assertNotNull(dialog);
invokeInstanceMethod("okCallback", dialog);
waitForPostedSwingRunnables();
@@ -235,7 +231,7 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
clickMouse(table, 1, rect.x, rect.y, 2, 0);
waitForPostedSwingRunnables();
- OptionDialog dialog = waitForDialogComponent(null, OptionDialog.class, 1000);
+ OptionDialog dialog = waitForDialogComponent(OptionDialog.class);
assertNotNull(dialog);
invokeInstanceMethod("okCallback", dialog);
waitForPostedSwingRunnables();
@@ -325,7 +321,7 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMoveColumns() {
// move the end column and make sure navigation is still correct
- // on the end column
+ // on the end column
// move column 2 to 1
JTableHeader header = table.getTableHeader();
Rectangle rect1 = header.getHeaderRect(MemoryMapModel.END);
@@ -483,10 +479,10 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
public void testSortBlockType() throws Exception {
// add a bit overlay block, live block, and an unitialized block
- int transactionID = program.startTransaction("test");
- memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
- memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
- program.endTransaction(transactionID, true);
+ tx(program, () -> {
+ memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
+ memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
+ });
JTableHeader header = table.getTableHeader();
// ascending
@@ -509,10 +505,10 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testSortBlockTypeDescending() throws Exception {
// add a bit overlay block, live block, and an unitialized block
- int transactionID = program.startTransaction("test");
- memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
- memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
- program.endTransaction(transactionID, true);
+ tx(program, () -> {
+ memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
+ memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
+ });
JTableHeader header = table.getTableHeader();
// ascending
@@ -540,13 +536,13 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testSortSource() throws Exception {
//
- int transactionID = program.startTransaction("test");
- MemoryBlock block =
- memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
- block.setSourceName("this is a test");
- block = memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
- block.setSourceName("other source");
- program.endTransaction(transactionID, true);
+ tx(program, () -> {
+ MemoryBlock block =
+ memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
+ block.setSourceName("this is a test");
+ block = memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
+ block.setSourceName("other source");
+ });
JTableHeader header = table.getTableHeader();
// ascending
@@ -580,14 +576,13 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testSortSourceDescending() throws Exception {
- //
- int transactionID = program.startTransaction("test");
- MemoryBlock block =
- memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
- block.setSourceName("this is a test");
- block = memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
- block.setSourceName("other source");
- program.endTransaction(transactionID, true);
+ tx(program, () -> {
+ MemoryBlock block =
+ memory.createBitMappedBlock(".Bit", getAddr(0), getAddr(0x01001000), 0x100, false);
+ block.setSourceName("this is a test");
+ block = memory.createUninitializedBlock(".Uninit", getAddr(0x3000), 0x200, false);
+ block.setSourceName("other source");
+ });
JTableHeader header = table.getTableHeader();
// ascending
@@ -672,8 +667,6 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
}
}
- /////////////////////////////////////////////////////////////////////
-
private void showProvider() {
DockingActionIf action = getAction(plugin, "Memory Map");
performAction(action, true);
@@ -688,36 +681,8 @@ public class MemoryMapProvider1Test extends AbstractGhidraHeadedIntegrationTest
return program.getMinAddress().getNewAddress(offset);
}
- private String findMessage(Container container) {
- Component[] c = container.getComponents();
- for (Component element : c) {
- if (element instanceof MultiLineLabel) {
- return ((MultiLineLabel) element).getLabel();
- }
- if (element instanceof Container) {
- String str = findMessage((Container) element);
- if (str != null) {
- return str;
- }
- }
- }
- return null;
- }
-
-// private class AddrComparator implements Comparator {
-// /* (non Javadoc)
-// * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
-// */
-// public int compare(Object o1, Object o2) {
-// Address a1 = (Address)o1;
-// Address a2 = (Address)o2;
-// return a1.compareTo(a2);
-// }
-// }
private class StringComparator implements Comparator<String> {
- /* (non Javadoc)
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
+
@Override
public int compare(String s1, String s2) {
if (s1 == null) {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider2Test.java
index a60b30bb6f..39f7bf95e1 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider2Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider2Test.java
@@ -157,12 +157,9 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertNotNull(comboBox);
assertEquals(MemoryBlockType.DEFAULT, comboBox.getSelectedItem());
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox readCB = (JCheckBox) findComponentByName(d.getComponent(), "Read");
JCheckBox writeCB = (JCheckBox) findComponentByName(d.getComponent(), "Write");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
@@ -237,15 +234,11 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
// find the dialog for the add
AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
- AddressInput addrField =
- (AddressInput) findComponentByName(d.getComponent(), "Start Addr");
-
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ AddressInput addrField = (AddressInput) findComponentByName(d.getComponent(), "Start Addr");
+
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox readCB = (JCheckBox) findComponentByName(d.getComponent(), "Read");
JCheckBox writeCB = (JCheckBox) findComponentByName(d.getComponent(), "Write");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
@@ -311,18 +304,13 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- AddBlockDialog d =
- waitForDialogComponent(AddBlockDialog.class);
+ AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
- AddressInput addrField =
- (AddressInput) findComponentByName(d.getComponent(), "Start Addr");
-
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ AddressInput addrField = (AddressInput) findComponentByName(d.getComponent(), "Start Addr");
+
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
RegisterField initialValue =
(RegisterField) findComponentByName(d.getComponent(), "Initial Value");
@@ -351,18 +339,13 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- AddBlockDialog d =
- waitForDialogComponent(AddBlockDialog.class);
+ AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
- AddressInput addrField =
- (AddressInput) findComponentByName(d.getComponent(), "Start Addr");
-
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ AddressInput addrField = (AddressInput) findComponentByName(d.getComponent(), "Start Addr");
+
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
RegisterField initialValue =
(RegisterField) findComponentByName(d.getComponent(), "Initial Value");
@@ -393,10 +376,8 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
// find the dialog for the add
AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
RegisterField initialValue =
(RegisterField) findComponentByName(d.getComponent(), "Initial Value");
@@ -423,13 +404,10 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- AddBlockDialog d =
- waitForDialogComponent(AddBlockDialog.class);
+ AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
JRadioButton uninitializedRB =
(JRadioButton) findComponentByName(d.getComponent(), "Uninitialized");
@@ -456,13 +434,10 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- AddBlockDialog d =
- waitForDialogComponent(AddBlockDialog.class);
+ AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
JRadioButton initializedRB =
(JRadioButton) findComponentByName(d.getComponent(), "Initialized");
@@ -497,14 +472,11 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- AddBlockDialog d =
- waitForDialogComponent(AddBlockDialog.class);
+ AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
JTextField lengthField = (JTextField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
RegisterField initialValue =
(RegisterField) findComponentByName(d.getComponent(), "Initial Value");
@@ -536,12 +508,9 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
JRadioButton uninitRB =
(JRadioButton) findComponentByName(d.getComponent(), "Uninitialized");
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox readCB = (JCheckBox) findComponentByName(d.getComponent(), "Read");
JCheckBox writeCB = (JCheckBox) findComponentByName(d.getComponent(), "Write");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
@@ -600,12 +569,9 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
GhidraComboBox<?> comboBox = findComponent(d.getComponent(), GhidraComboBox.class);
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox readCB = (JCheckBox) findComponentByName(d.getComponent(), "Read");
JCheckBox writeCB = (JCheckBox) findComponentByName(d.getComponent(), "Write");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
@@ -671,8 +637,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertEquals(Boolean.TRUE, model.getValueAt(row, MemoryMapModel.WRITE));
assertEquals(Boolean.TRUE, model.getValueAt(row, MemoryMapModel.EXECUTE));
assertEquals(Boolean.TRUE, model.getValueAt(row, MemoryMapModel.OVERLAY));
- assertEquals(
- MemoryBlockType.DEFAULT.toString(),
+ assertEquals(MemoryBlockType.DEFAULT.toString(),
model.getValueAt(row, MemoryMapModel.BLOCK_TYPE));
assertEquals(Boolean.TRUE, model.getValueAt(row, MemoryMapModel.INIT));
assertEquals("", model.getValueAt(row, MemoryMapModel.SOURCE));
@@ -690,12 +655,9 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
GhidraComboBox<?> comboBox = findComponent(d.getComponent(), GhidraComboBox.class);
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox readCB = (JCheckBox) findComponentByName(d.getComponent(), "Read");
JCheckBox writeCB = (JCheckBox) findComponentByName(d.getComponent(), "Write");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
@@ -754,8 +716,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertEquals(Boolean.TRUE, model.getValueAt(row, MemoryMapModel.WRITE));
assertEquals(Boolean.TRUE, model.getValueAt(row, MemoryMapModel.EXECUTE));
assertEquals(Boolean.TRUE, model.getValueAt(row, MemoryMapModel.OVERLAY));
- assertEquals(
- MemoryBlockType.DEFAULT.toString(),
+ assertEquals(MemoryBlockType.DEFAULT.toString(),
model.getValueAt(row, MemoryMapModel.BLOCK_TYPE));
assertEquals(Boolean.FALSE, model.getValueAt(row, MemoryMapModel.INIT));
assertEquals("", model.getValueAt(row, MemoryMapModel.SOURCE));
@@ -779,12 +740,9 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
GhidraComboBox<?> comboBox = findComponent(d.getComponent(), GhidraComboBox.class);
assertNotNull(comboBox);
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox readCB = (JCheckBox) findComponentByName(d.getComponent(), "Read");
JCheckBox writeCB = (JCheckBox) findComponentByName(d.getComponent(), "Write");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
@@ -858,12 +816,9 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
AddBlockDialog d = waitForDialogComponent(AddBlockDialog.class);
GhidraComboBox<?> comboBox = findComponent(d.getComponent(), GhidraComboBox.class);
assertNotNull(comboBox);
- JTextField nameField =
- (JTextField) findComponentByName(d.getComponent(), "Block Name");
- RegisterField lengthField =
- (RegisterField) findComponentByName(d.getComponent(), "Length");
- JTextField commentField =
- (JTextField) findComponentByName(d.getComponent(), "Comment");
+ JTextField nameField = (JTextField) findComponentByName(d.getComponent(), "Block Name");
+ RegisterField lengthField = (RegisterField) findComponentByName(d.getComponent(), "Length");
+ JTextField commentField = (JTextField) findComponentByName(d.getComponent(), "Comment");
JCheckBox readCB = (JCheckBox) findComponentByName(d.getComponent(), "Read");
JCheckBox writeCB = (JCheckBox) findComponentByName(d.getComponent(), "Write");
JCheckBox executeCB = (JCheckBox) findComponentByName(d.getComponent(), "Execute");
@@ -989,12 +944,11 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMoveBlockNotAllowed() throws Exception {
// create an overlay block
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".overlay", getAddr(0), 0x100, (byte) 0xa,
- TaskMonitor.DUMMY, true);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".overlay", getAddr(0), 0x100, (byte) 0xa,
+ TaskMonitor.DUMMY, true);
+ });
+
int row = table.getModel().getRowCount() - 1;
table.setRowSelectionInterval(row, row);
@@ -1008,12 +962,10 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMoveBlock() throws Exception {
// add a block at 0, length 0x100
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0,
- TaskMonitor.DUMMY, false);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0, TaskMonitor.DUMMY,
+ false);
+ });
table.setRowSelectionInterval(0, 0);
@@ -1022,8 +974,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
waitForSwing();
- MoveBlockDialog d =
- waitForDialogComponent(MoveBlockDialog.class);
+ MoveBlockDialog d = waitForDialogComponent(MoveBlockDialog.class);
assertNotNull(d);
assertEquals("Move Memory Block", d.getTitle());
@@ -1045,14 +996,12 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertNotNull(lengthLabel);
assertEquals("256 (0x100)", lengthLabel.getText());
- AddressInput startField =
- (AddressInput) findComponentByName(d.getComponent(), "newStart");
+ AddressInput startField = (AddressInput) findComponentByName(d.getComponent(), "newStart");
assertNotNull(startField);
assertEquals(getAddr(0), startField.getAddress());
- AddressInput endField =
- (AddressInput) findComponentByName(d.getComponent(), "newEnd");
+ AddressInput endField = (AddressInput) findComponentByName(d.getComponent(), "newEnd");
assertNotNull(endField);
assertEquals(getAddr(0xffL), endField.getAddress());
@@ -1083,12 +1032,10 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMoveBlockInvalidStart() throws Exception {
// add a block at 0, length 0x100
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0,
- TaskMonitor.DUMMY, false);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0, TaskMonitor.DUMMY,
+ false);
+ });
table.setRowSelectionInterval(0, 0);
@@ -1097,8 +1044,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
waitForSwing();
- MoveBlockDialog d =
- waitForDialogComponent(MoveBlockDialog.class);
+ MoveBlockDialog d = waitForDialogComponent(MoveBlockDialog.class);
assertNotNull(d);
assertEquals("Move Memory Block", d.getTitle());
@@ -1120,14 +1066,12 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertNotNull(lengthLabel);
assertEquals("256 (0x100)", lengthLabel.getText());
- AddressInput startField =
- (AddressInput) findComponentByName(d.getComponent(), "newStart");
+ AddressInput startField = (AddressInput) findComponentByName(d.getComponent(), "newStart");
assertNotNull(startField);
assertEquals(getAddr(0), startField.getAddress());
- AddressInput endField =
- (AddressInput) findComponentByName(d.getComponent(), "newEnd");
+ AddressInput endField = (AddressInput) findComponentByName(d.getComponent(), "newEnd");
assertNotNull(endField);
assertEquals(getAddr(0xffL), endField.getAddress());
@@ -1136,8 +1080,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertFalse(okButton.isEnabled());
// enter an invalid address
- runSwing(
- () -> startField.setValue(getAddr(0x0300).toString() + "gggg"));
+ runSwing(() -> startField.setValue(getAddr(0x0300).toString() + "gggg"));
assertFalse(okButton.isEnabled());
String msg = findLabelStr(d.getComponent(), "statusLabel");
assertEquals("Invalid Address", msg);
@@ -1147,12 +1090,10 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMoveBlockInvalidEnd() throws Exception {
// add a block at 0, length 0x100
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0,
- TaskMonitor.DUMMY, false);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0, TaskMonitor.DUMMY,
+ false);
+ });
table.setRowSelectionInterval(0, 0);
@@ -1161,8 +1102,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
waitForSwing();
- MoveBlockDialog d =
- waitForDialogComponent(MoveBlockDialog.class);
+ MoveBlockDialog d = waitForDialogComponent(MoveBlockDialog.class);
assertNotNull(d);
assertEquals("Move Memory Block", d.getTitle());
@@ -1184,14 +1124,12 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertNotNull(lengthLabel);
assertEquals("256 (0x100)", lengthLabel.getText());
- AddressInput startField =
- (AddressInput) findComponentByName(d.getComponent(), "newStart");
+ AddressInput startField = (AddressInput) findComponentByName(d.getComponent(), "newStart");
assertNotNull(startField);
assertEquals(getAddr(0), startField.getAddress());
- AddressInput endField =
- (AddressInput) findComponentByName(d.getComponent(), "newEnd");
+ AddressInput endField = (AddressInput) findComponentByName(d.getComponent(), "newEnd");
assertNotNull(endField);
assertEquals(getAddr(0xffL), endField.getAddress());
@@ -1210,12 +1148,10 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMoveBlockEndTooSmall() throws Exception {
// add a block at 0, length 0x100
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0,
- TaskMonitor.DUMMY, false);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0, TaskMonitor.DUMMY,
+ false);
+ });
table.setRowSelectionInterval(0, 0);
@@ -1224,8 +1160,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
waitForSwing();
- MoveBlockDialog d =
- waitForDialogComponent(MoveBlockDialog.class);
+ MoveBlockDialog d = waitForDialogComponent(MoveBlockDialog.class);
assertNotNull(d);
assertEquals("Move Memory Block", d.getTitle());
@@ -1247,14 +1182,12 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertNotNull(lengthLabel);
assertEquals("256 (0x100)", lengthLabel.getText());
- AddressInput startField =
- (AddressInput) findComponentByName(d.getComponent(), "newStart");
+ AddressInput startField = (AddressInput) findComponentByName(d.getComponent(), "newStart");
assertNotNull(startField);
assertEquals(getAddr(0), startField.getAddress());
- AddressInput endField =
- (AddressInput) findComponentByName(d.getComponent(), "newEnd");
+ AddressInput endField = (AddressInput) findComponentByName(d.getComponent(), "newEnd");
assertNotNull(endField);
assertEquals(getAddr(0xffL), endField.getAddress());
@@ -1276,12 +1209,10 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMoveBlockOverlap() throws Exception {
// add a block at 0, length 0x100
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0,
- TaskMonitor.DUMMY, false);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".test", getAddr(0), 0x100, (byte) 0, TaskMonitor.DUMMY,
+ false);
+ });
table.setRowSelectionInterval(0, 0);
@@ -1290,8 +1221,7 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
waitForSwing();
- MoveBlockDialog d =
- waitForDialogComponent(MoveBlockDialog.class);
+ MoveBlockDialog d = waitForDialogComponent(MoveBlockDialog.class);
assertNotNull(d);
assertEquals("Move Memory Block", d.getTitle());
@@ -1313,14 +1243,12 @@ public class MemoryMapProvider2Test extends AbstractGhidraHeadedIntegrationTest
assertNotNull(lengthLabel);
assertEquals("256 (0x100)", lengthLabel.getText());
- AddressInput startField =
- (AddressInput) findComponentByName(d.getComponent(), "newStart");
+ AddressInput startField = (AddressInput) findComponentByName(d.getComponent(), "newStart");
assertNotNull(startField);
assertEquals(getAddr(0), startField.getAddress());
- AddressInput endField =
- (AddressInput) findComponentByName(d.getComponent(), "newEnd");
+ AddressInput endField = (AddressInput) findComponentByName(d.getComponent(), "newEnd");
assertNotNull(endField);
assertEquals(getAddr(0xffL), endField.getAddress());
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider3Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider3Test.java
index da34955615..9174df1489 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider3Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider3Test.java
@@ -97,8 +97,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
assertNotNull(d);
JTextField blockOneName =
(JTextField) findComponentByName(d.getComponent(), "BlockOneName");
@@ -152,8 +151,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
JButton cancelButton = findButton(d.getComponent(), "Cancel");
- runSwing(
- () -> cancelButton.getActionListeners()[0].actionPerformed(null));
+ runSwing(() -> cancelButton.getActionListeners()[0].actionPerformed(null));
}
@Test
@@ -165,8 +163,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
JTextField blockOneName =
(JTextField) findComponentByName(d.getComponent(), "BlockOneName");
assertNotNull(blockOneName);
@@ -183,8 +180,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertNotNull(blockTwoName);
AddressInput blockTwoStart =
(AddressInput) findComponentByName(d.getComponent(), "BlockTwoStart");
- JTextField blockTwoEnd =
- (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
+ JTextField blockTwoEnd = (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
RegisterField blockTwoLength =
(RegisterField) findComponentByName(d.getComponent(), "BlockTwoLength");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -220,8 +216,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
AddressInput blockOneEnd =
(AddressInput) findComponentByName(d.getComponent(), "BlockOneEnd");
RegisterField blockOneLength =
@@ -229,8 +224,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
AddressInput blockTwoStart =
(AddressInput) findComponentByName(d.getComponent(), "BlockTwoStart");
- JTextField blockTwoEnd =
- (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
+ JTextField blockTwoEnd = (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
RegisterField blockTwoLength =
(RegisterField) findComponentByName(d.getComponent(), "BlockTwoLength");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -267,8 +261,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
AddressInput blockOneEnd =
(AddressInput) findComponentByName(d.getComponent(), "BlockOneEnd");
@@ -277,8 +270,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
AddressInput blockTwoStart =
(AddressInput) findComponentByName(d.getComponent(), "BlockTwoStart");
- JTextField blockTwoEnd =
- (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
+ JTextField blockTwoEnd = (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
RegisterField blockTwoLength =
(RegisterField) findComponentByName(d.getComponent(), "BlockTwoLength");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -314,15 +306,13 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
AddressInput blockOneEnd =
(AddressInput) findComponentByName(d.getComponent(), "BlockOneEnd");
RegisterField blockOneLength =
(RegisterField) findComponentByName(d.getComponent(), "BlockOneLength");
- JTextField blockTwoEnd =
- (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
+ JTextField blockTwoEnd = (JTextField) findComponentByName(d.getComponent(), "BlockTwoEnd");
RegisterField blockTwoLength =
(RegisterField) findComponentByName(d.getComponent(), "BlockTwoLength");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -360,8 +350,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
AddressInput blockOneEnd =
(AddressInput) findComponentByName(d.getComponent(), "BlockOneEnd");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -382,8 +371,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
AddressInput blockTwoStart =
(AddressInput) findComponentByName(d.getComponent(), "BlockTwoStart");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -404,8 +392,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
RegisterField blockOneLength =
(RegisterField) findComponentByName(d.getComponent(), "BlockOneLength");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -426,8 +413,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- SplitBlockDialog d =
- waitForDialogComponent(SplitBlockDialog.class);
+ SplitBlockDialog d = waitForDialogComponent(SplitBlockDialog.class);
JTextField blockTwoName =
(JTextField) findComponentByName(d.getComponent(), "BlockTwoName");
@@ -449,18 +435,16 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testSplitNotAllowed() throws Exception {
// create an overlay block
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".overlay", getAddr(0), 0x100, (byte) 0xa,
- TaskMonitor.DUMMY, true);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".overlay", getAddr(0), 0x100, (byte) 0xa,
+ TaskMonitor.DUMMY, true);
+ });
+
int row = table.getModel().getRowCount() - 1;
table.setRowSelectionInterval(row, row);
DockingActionIf action = getAction(plugin, "Split Block");
performAction(action, false);
- OptionDialog d =
- waitForDialogComponent(OptionDialog.class);
+ OptionDialog d = waitForDialogComponent(OptionDialog.class);
assertNotNull(d);
assertEquals("Split Overlay Block Not Allowed", d.getTitle());
close(d);
@@ -469,18 +453,16 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testExpandBlockNotAllowed() throws Exception {
// create an overlay block
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock(".overlay", getAddr(0), 0x100, (byte) 0xa,
- TaskMonitor.DUMMY, true);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock(".overlay", getAddr(0), 0x100, (byte) 0xa,
+ TaskMonitor.DUMMY, true);
+ });
+
int row = table.getModel().getRowCount() - 1;
table.setRowSelectionInterval(row, row);
DockingActionIf action = getAction(plugin, "Expand Block Up");
performAction(action, false);
- OptionDialog d =
- waitForDialogComponent(OptionDialog.class);
+ OptionDialog d = waitForDialogComponent(OptionDialog.class);
assertNotNull(d);
assertEquals("Expand Overlay Block Not Allowed", d.getTitle());
close(d);
@@ -488,8 +470,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
action = getAction(plugin, "Expand Block Down");
performAction(action, false);
- OptionDialog d2 =
- waitForDialogComponent(OptionDialog.class);
+ OptionDialog d2 = waitForDialogComponent(OptionDialog.class);
assertNotNull(d2);
assertEquals("Expand Overlay Block Not Allowed", d2.getTitle());
runSwing(() -> d2.close());
@@ -505,16 +486,14 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
assertNotNull(d);
assertEquals("Expand Block Up", d.getTitle());
AddressInput start =
(AddressInput) findComponentByName(d.getComponent(), "NewStartAddress");
JTextField end = (JTextField) findComponentByName(d.getComponent(), "EndAddress");
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
assertNotNull(start);
@@ -541,15 +520,13 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput start =
(AddressInput) findComponentByName(d.getComponent(), "NewStartAddress");
JTextField end = (JTextField) findComponentByName(d.getComponent(), "EndAddress");
assertNotNull(end);
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
runSwing(() -> start.setValue("00002000"));
@@ -588,13 +565,11 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput start =
(AddressInput) findComponentByName(d.getComponent(), "NewStartAddress");
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
assertNotNull(length);
JButton okButton = findButton(d.getComponent(), "OK");
@@ -616,13 +591,11 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput start =
(AddressInput) findComponentByName(d.getComponent(), "NewStartAddress");
JTextField end = (JTextField) findComponentByName(d.getComponent(), "EndAddress");
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
runSwing(() -> length.setText("0x7600"));
@@ -662,14 +635,12 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput start =
(AddressInput) findComponentByName(d.getComponent(), "NewStartAddress");
assertNotNull(start);
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
runSwing(() -> length.setText("0x1000"));
@@ -692,8 +663,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput start =
(AddressInput) findComponentByName(d.getComponent(), "NewStartAddress");
@@ -721,15 +691,13 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
assertTrue(action.isEnabled());
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
assertNotNull(d);
assertEquals("Expand Block Down", d.getTitle());
JTextField start = (JTextField) findComponentByName(d.getComponent(), "StartAddress");
AddressInput end = (AddressInput) findComponentByName(d.getComponent(), "EndAddress");
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
assertNotNull(start);
@@ -755,12 +723,10 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput end = (AddressInput) findComponentByName(d.getComponent(), "EndAddress");
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
runSwing(() -> end.setValue("01007700"));
@@ -784,12 +750,10 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput end = (AddressInput) findComponentByName(d.getComponent(), "EndAddress");
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
runSwing(() -> length.setText("0x6700"));
@@ -815,8 +779,7 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
AddressInput end = (AddressInput) findComponentByName(d.getComponent(), "EndAddress");
JButton okButton = findButton(d.getComponent(), "OK");
@@ -837,11 +800,9 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
runSwing(() -> length.setText("0x670"));
@@ -860,11 +821,9 @@ public class MemoryMapProvider3Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
// find the dialog for the add
- ExpandBlockDialog d =
- waitForDialogComponent(ExpandBlockDialog.class);
+ ExpandBlockDialog d = waitForDialogComponent(ExpandBlockDialog.class);
- RegisterField length =
- (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
+ RegisterField length = (RegisterField) findComponentByName(d.getComponent(), "BlockLength");
JButton okButton = findButton(d.getComponent(), "OK");
runSwing(() -> length.setText("0x7600"));
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider4Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider4Test.java
index 89865a832f..26b62219a5 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider4Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/memory/MemoryMapProvider4Test.java
@@ -95,8 +95,8 @@ public class MemoryMapProvider4Test extends AbstractGhidraHeadedIntegrationTest
public void testMergeBlocks() throws Exception {
// create 4 blocks: 0-0f, 10-1f, 20-20f, 40-4f.
tx(program, () -> {
- memory.createInitializedBlock("block1", getAddr(0), 0x10, (byte) 0,
- TaskMonitor.DUMMY, false);
+ memory.createInitializedBlock("block1", getAddr(0), 0x10, (byte) 0, TaskMonitor.DUMMY,
+ false);
memory.createInitializedBlock("block2", getAddr(0x10), 0x10, (byte) 0,
TaskMonitor.DUMMY, false);
memory.createInitializedBlock("block3", getAddr(0x20), 0x10, (byte) 0,
@@ -162,8 +162,8 @@ public class MemoryMapProvider4Test extends AbstractGhidraHeadedIntegrationTest
public void testMergeBlocksFarApart() throws Exception {
tx(program, () -> {
- memory.createInitializedBlock("block1", getAddr(0), 0x50, (byte) 0,
- TaskMonitor.DUMMY, false);
+ memory.createInitializedBlock("block1", getAddr(0), 0x50, (byte) 0, TaskMonitor.DUMMY,
+ false);
});
// select rows 0 and 1
@@ -206,12 +206,10 @@ public class MemoryMapProvider4Test extends AbstractGhidraHeadedIntegrationTest
@Test
public void testMergeBlocksFarApartCancel() throws Exception {
- int transactionID = program.startTransaction("test");
- memory.createInitializedBlock("block1", getAddr(0), 0x50, (byte) 0,
- TaskMonitor.DUMMY, false);
- program.endTransaction(transactionID, true);
- program.flushEvents();
- waitForSwing();
+ tx(program, () -> {
+ memory.createInitializedBlock("block1", getAddr(0), 0x50, (byte) 0, TaskMonitor.DUMMY,
+ false);
+ });
// select rows 0 and 1
table.setRowSelectionInterval(0, 1);
@@ -221,8 +219,8 @@ public class MemoryMapProvider4Test extends AbstractGhidraHeadedIntegrationTest
performAction(action, false);
OptionDialog d = waitForDialogComponent(OptionDialog.class);
assertEquals("Merge Memory Blocks", d.getTitle());
- assertTrue(findMessage(d.getComponent()).startsWith(
- "Merging these blocks will create 16387K extra bytes in memory"));
+ assertTrue(findMessage(d.getComponent())
+ .startsWith("Merging these blocks will create 16387K extra bytes in memory"));
JButton b = findButton(d.getComponent(), "Cancel");
assertNotNull(b);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/programtree/ProgramTreePlugin1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/programtree/ProgramTreePlugin1Test.java
index 60e76cba54..7ee99ac8ef 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/programtree/ProgramTreePlugin1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/programtree/ProgramTreePlugin1Test.java
@@ -104,8 +104,8 @@ public class ProgramTreePlugin1Test extends AbstractProgramTreePluginTest {
int childCount = root.getChildCount();
addCodeUnits(root, set);
- // wait for events to get processed
- program.flushEvents();
+
+ waitForProgram(program);
assertEquals(childCount + 1, root.getChildCount());
ProgramNode node = (ProgramNode) root.getChildAt(childCount);
@@ -614,8 +614,8 @@ public class ProgramTreePlugin1Test extends AbstractProgramTreePluginTest {
nodes = findNodes(m2.getName());
assertEquals(5, nodes.length);
ArrayList<?> nodeList = tree.getNodeList();
- for (int i = 0; i < nodeList.size(); i++) {
- node = (ProgramNode) nodeList.get(i);
+ for (Object element : nodeList) {
+ node = (ProgramNode) element;
if (node.getAllowsChildren() && !node.isLeaf()) {
assertTrue(tree.isExpanded(node.getTreePath()));
}
@@ -660,8 +660,8 @@ public class ProgramTreePlugin1Test extends AbstractProgramTreePluginTest {
collapseNode(root);
buildNodeList();
ArrayList<?> nodeList = tree.getNodeList();
- for (int i = 0; i < nodeList.size(); i++) {
- node = (ProgramNode) nodeList.get(i);
+ for (Object element : nodeList) {
+ node = (ProgramNode) element;
if (node.getAllowsChildren() && !node.isLeaf()) {
assertTrue(!tree.isExpanded(node.getTreePath()));
}
@@ -860,8 +860,8 @@ public class ProgramTreePlugin1Test extends AbstractProgramTreePluginTest {
runSwing(() -> tree.removeFromView(finalNode.getTreePath()));
int row = getRowForPath(node.getTreePath());
- Component comp = tree.getCellRenderer().getTreeCellRendererComponent(tree, node, true,
- false, true, row, false);
+ Component comp = tree.getCellRenderer()
+ .getTreeCellRendererComponent(tree, node, true, false, true, row, false);
assertEquals(ResourceManager.loadImage(DnDTreeCellRenderer.CLOSED_FOLDER),
((JLabel) comp).getIcon());
}
@@ -960,8 +960,8 @@ public class ProgramTreePlugin1Test extends AbstractProgramTreePluginTest {
assertTrue(getView().hasSameAddresses(viewMgrService.getCurrentView()));
int row = getRowForPath(child.getTreePath());
- Component comp = tree.getCellRenderer().getTreeCellRendererComponent(tree, child, true,
- false, true, row, false);
+ Component comp = tree.getCellRenderer()
+ .getTreeCellRendererComponent(tree, child, true, false, true, row, false);
assertEquals(ResourceManager.loadImage(DnDTreeCellRenderer.VIEWED_FRAGMENT),
((JLabel) comp).getIcon());