Ghidra is a software reverse engineering (SRE) framework
GP-0 Additional test fixes
ghidra16d7ac958d783
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/script/WindowsResourceReferenceScriptTest.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/script/WindowsResourceReferenceScriptTest.javaindex b6b41f6b4c..5df3d11bf7 100644--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/script/WindowsResourceReferenceScriptTest.java+++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/plugin/core/script/WindowsResourceReferenceScriptTest.java@@ -54,12 +54,6 @@ public class WindowsResourceReferenceScriptTest extends AbstractGhidraHeadedIntepm.openProgram(program.getDomainFile());}- private void closeProgram() {- ProgramManager pm = env.getTool().getService(ProgramManager.class);- pm.closeProgram();- waitForSwing();- }-@Afterpublic void tearDown() throws Exception {env.dispose();@@ -102,7 +96,6 @@ public class WindowsResourceReferenceScriptTest extends AbstractGhidraHeadedInte//Check the reference type created is of type DATAassertTrue(type.equals(RefType.DATA));}- closeProgram();}@Test@@ -135,8 +128,6 @@ public class WindowsResourceReferenceScriptTest extends AbstractGhidraHeadedInte//check the reference type created is of type DATAassertTrue(type.equals(RefType.DATA));}-- closeProgram();}private Address addr(long offset, Program program) {diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ByteViewerToolConnectionTest.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ByteViewerToolConnectionTest.javaindex dddfa64e0b..ecbbf4e5ab 100644--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ByteViewerToolConnectionTest.java+++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ByteViewerToolConnectionTest.java@@ -28,13 +28,17 @@ import org.junit.*;import docking.DefaultActionContext;import docking.action.DockingActionIf;import docking.test.AbstractDockingTest;+import ghidra.app.events.OpenProgramPluginEvent;import ghidra.app.plugin.core.byteviewer.ByteViewerPlugin;+import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;import ghidra.app.services.ProgramManager;import ghidra.framework.plugintool.Plugin;import ghidra.framework.plugintool.PluginTool;import ghidra.framework.plugintool.util.PluginException;import ghidra.program.database.ProgramBuilder;+import ghidra.program.model.address.Address;import ghidra.program.model.listing.Program;+import ghidra.program.util.ProgramLocation;import ghidra.test.AbstractGhidraHeadedIntegrationTest;import ghidra.test.TestEnv;@@ -61,8 +65,9 @@ public class ByteViewerToolConnectionTest extends AbstractGhidraHeadedIntegratiopressButtonByText(dialog, "OK");}- closeAllWindows();env.dispose();++ closeAllWindows();}@Test@@ -83,17 +88,39 @@ public class ByteViewerToolConnectionTest extends AbstractGhidraHeadedIntegratioproducerList.setSelectedIndex(0);consumerList.setSelectedIndex(1);- clickRow(eventList, 1);+ int eventCount = eventList.getModel().getSize();+ for (int i = 0; i < eventCount; i++) {+ clickRow(eventList, i);+ }Program p = buildProgram();ProgramManager pm = cbTool.getService(ProgramManager.class);- SwingUtilities.invokeAndWait(() -> pm.openProgram(p.getDomainFile()));+ runSwing(() -> pm.openProgram(p.getDomainFile()));++ waitForSwing();ProgramManager pm2 = cbTool2.getService(ProgramManager.class);+ assertNull(pm2.getCurrentProgram());++ // open same program in second tool - cannot rely on tool connection for this+ cbTool2.firePluginEvent(new OpenProgramPluginEvent("Test", p));++ waitForSwing();+assertEquals(p, pm2.getCurrentProgram());- env.release(p);+ Address a = p.getAddressFactory().getDefaultAddressSpace().getAddress(0x1001010);++ CodeBrowserPlugin cb1 = getPlugin(cbTool, CodeBrowserPlugin.class);+ cb1.goTo(new ProgramLocation(p, a), true);++ waitForSwing();++ CodeBrowserPlugin cb2 = getPlugin(cbTool2, CodeBrowserPlugin.class);+ ProgramLocation loc = cb2.getCurrentLocation();+ assertNotNull(loc);+ assertEquals(a, loc.getAddress());}private void clickRow(JList<?> list, int row) {diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ToolConnectionTest.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ToolConnectionTest.javaindex b22e8d63cb..072d13d784 100644--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ToolConnectionTest.java+++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/ToolConnectionTest.java@@ -27,13 +27,17 @@ import org.junit.*;import docking.DefaultActionContext;import docking.action.DockingActionIf;+import ghidra.app.events.OpenProgramPluginEvent;import ghidra.app.plugin.core.byteviewer.ByteViewerPlugin;+import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;import ghidra.app.services.ProgramManager;import ghidra.framework.plugintool.Plugin;import ghidra.framework.plugintool.PluginTool;import ghidra.framework.plugintool.util.PluginException;import ghidra.program.database.ProgramBuilder;+import ghidra.program.model.address.Address;import ghidra.program.model.listing.Program;+import ghidra.program.util.ProgramLocation;import ghidra.test.AbstractGhidraHeadedIntegrationTest;import ghidra.test.TestEnv;@@ -75,9 +79,9 @@ public class ToolConnectionTest extends AbstractGhidraHeadedIntegrationTest {close(dialog);}- closeAllWindows();-env.dispose();++ closeAllWindows();}@Test@@ -85,21 +89,42 @@ public class ToolConnectionTest extends AbstractGhidraHeadedIntegrationTest {connectTools();- clickListRow(eventList, 1);+ int eventCount = eventList.getModel().getSize();+ for (int i = 0; i < eventCount; i++) {+ clickListRow(eventList, i);+ }+pressButtonByText(dialog, "OK");Program p = buildNotepad();ProgramManager pm = tool1.getService(ProgramManager.class);- ProgramManager pm2 = tool2.getService(ProgramManager.class);runSwing(() -> pm.openProgram(p.getDomainFile()));- waitForCondition(() -> pm2.getCurrentProgram() != null,- "Tool 2 did not open a proagram when one was opened in tool1");+ waitForSwing();++ ProgramManager pm2 = tool2.getService(ProgramManager.class);+ assertNull(pm2.getCurrentProgram());++ // open same program in second tool - cannot rely on tool connection for this+ tool2.firePluginEvent(new OpenProgramPluginEvent("Test", p));++ waitForSwing();assertEquals(p, pm2.getCurrentProgram());- env.release(p);+ Address a = p.getAddressFactory().getDefaultAddressSpace().getAddress(0x1001010);++ CodeBrowserPlugin cb1 = getPlugin(tool1, CodeBrowserPlugin.class);+ cb1.goTo(new ProgramLocation(p, a), true);++ waitForSwing();++ CodeBrowserPlugin cb2 = getPlugin(tool2, CodeBrowserPlugin.class);+ ProgramLocation loc = cb2.getCurrentLocation();+ assertNotNull(loc);+ assertEquals(a, loc.getAddress());+}@Test