mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-08-24 19:46:37 +00:00
GP-0 Additional test fixes
This commit is contained in:
parent
1be700742d
commit
6d7ac958d7
|
@ -54,12 +54,6 @@ public class WindowsResourceReferenceScriptTest extends AbstractGhidraHeadedInte
|
|||
pm.openProgram(program.getDomainFile());
|
||||
}
|
||||
|
||||
private void closeProgram() {
|
||||
ProgramManager pm = env.getTool().getService(ProgramManager.class);
|
||||
pm.closeProgram();
|
||||
waitForSwing();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
env.dispose();
|
||||
|
@ -102,7 +96,6 @@ public class WindowsResourceReferenceScriptTest extends AbstractGhidraHeadedInte
|
|||
//Check the reference type created is of type DATA
|
||||
assertTrue(type.equals(RefType.DATA));
|
||||
}
|
||||
closeProgram();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -135,8 +128,6 @@ public class WindowsResourceReferenceScriptTest extends AbstractGhidraHeadedInte
|
|||
//check the reference type created is of type DATA
|
||||
assertTrue(type.equals(RefType.DATA));
|
||||
}
|
||||
|
||||
closeProgram();
|
||||
}
|
||||
|
||||
private Address addr(long offset, Program program) {
|
||||
|
|
|
@ -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 AbstractGhidraHeadedIntegratio
|
|||
pressButtonByText(dialog, "OK");
|
||||
}
|
||||
|
||||
closeAllWindows();
|
||||
env.dispose();
|
||||
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -83,17 +88,39 @@ public class ByteViewerToolConnectionTest extends AbstractGhidraHeadedIntegratio
|
|||
|
||||
producerList.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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue