Test fixes

This commit is contained in:
dragonmacher 2022-01-24 18:18:38 -05:00
parent c56961f06b
commit 5b3e41ff1b
6 changed files with 30 additions and 30 deletions

View file

@ -24,7 +24,7 @@ import javax.swing.ImageIcon;
import docking.ActionContext; import docking.ActionContext;
import docking.action.*; import docking.action.*;
import docking.widgets.dialogs.TableChooserDialog; import docking.widgets.dialogs.TableSelectionDialog;
import ghidra.app.plugin.core.functioncompare.FunctionComparisonProvider; import ghidra.app.plugin.core.functioncompare.FunctionComparisonProvider;
import ghidra.app.plugin.core.functioncompare.MultiFunctionComparisonPanel; import ghidra.app.plugin.core.functioncompare.MultiFunctionComparisonPanel;
import ghidra.app.plugin.core.functionwindow.FunctionRowObject; import ghidra.app.plugin.core.functionwindow.FunctionRowObject;
@ -108,8 +108,8 @@ public class OpenFunctionTableAction extends DockingAction {
FunctionTableModel model = new FunctionTableModel(tool, currentProgram); FunctionTableModel model = new FunctionTableModel(tool, currentProgram);
model.reload(programManagerService.getCurrentProgram()); model.reload(programManagerService.getCurrentProgram());
TableChooserDialog<FunctionRowObject> diag = TableSelectionDialog<FunctionRowObject> diag =
new TableChooserDialog<>("Select Functions: " + currentProgram.getName(), new TableSelectionDialog<>("Select Functions: " + currentProgram.getName(),
model, true); model, true);
tool.showDialog(diag); tool.showDialog(diag);
List<FunctionRowObject> rows = diag.getSelectionItems(); List<FunctionRowObject> rows = diag.getSelectionItems();

View file

@ -289,21 +289,21 @@ public class TestEnv {
} }
/** /**
* Adds and returns the plugin to this env's tool for the given class. * Adds and returns the plugin to this env's tool for the given class.
* *
* <P>If you have not created a tool using this env, then the default * <P>If you have not created a tool using this env, then the default
* tool from {@link #lazyTool()} is used. If you have launched a tool, then that tool * tool from {@link #lazyTool()} is used. If you have launched a tool, then that tool
* is used. In the following example, the given plugin is added to the default tool: * is used. In the following example, the given plugin is added to the default tool:
* <pre> * <pre>
* TestEnv env = new TestEnv(); * TestEnv env = new TestEnv();
* env.launchDefaultTool(); * env.launchDefaultTool();
* FooPlugin foo = env.addPlugin(FooPlugin.class); * FooPlugin foo = env.addPlugin(FooPlugin.class);
* </pre> * </pre>
* *
* *
* @param c the plugin class * @param c the plugin class
* @return the plugin instance * @return the plugin instance
* @throws PluginException if there is an exception adding the given tool * @throws PluginException if there is an exception adding the given tool
*/ */
public <T extends Plugin> T addPlugin(Class<T> c) throws PluginException { public <T extends Plugin> T addPlugin(Class<T> c) throws PluginException {
PluginTool defaultTool = lazyTool(); PluginTool defaultTool = lazyTool();
@ -312,10 +312,10 @@ public class TestEnv {
} }
/** /**
* Shows any previously created tool, creating a simple empty tool if not tool has yet * Shows any previously created tool, creating a simple empty tool if not tool has yet
* been created. * been created.
* *
* <P>This method is considered sub-standard and users should prefer instead * <P>This method is considered sub-standard and users should prefer instead
* {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}. * {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}.
* *
* @return the newly shown tool * @return the newly shown tool
@ -325,10 +325,10 @@ public class TestEnv {
} }
/** /**
* Shows any previously created tool, creating a simple empty tool if not tool has yet * Shows any previously created tool, creating a simple empty tool if not tool has yet
* been created. The given program will be opened in the tool. * been created. The given program will be opened in the tool.
* *
* <P>This method is considered sub-standard and users should prefer instead * <P>This method is considered sub-standard and users should prefer instead
* {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}. * {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}.
* *
* @param p the program * @param p the program
@ -403,11 +403,11 @@ public class TestEnv {
} }
private static void installDefaultTool(GhidraProject gp) { private static void installDefaultTool(GhidraProject gp) {
// //
// Unusual Code Alert: The default tool is not always found in the testing environment, // Unusual Code Alert: The default tool is not always found in the testing environment,
// depending upon where the test lives. This code maps the test tool to that tool name // depending upon where the test lives. This code maps the test tool to that tool name
// so that tests will have the default tool as needed. // so that tests will have the default tool as needed.
// //
Project project = gp.getProject(); Project project = gp.getProject();
ToolChest toolChest = project.getLocalToolChest(); ToolChest toolChest = project.getLocalToolChest();
ToolTemplate template = getToolTemplate(AbstractGenericTest.DEFAULT_TEST_TOOL_NAME); ToolTemplate template = getToolTemplate(AbstractGenericTest.DEFAULT_TEST_TOOL_NAME);
@ -430,7 +430,7 @@ public class TestEnv {
tool.addPlugin(ProgramManagerPlugin.class.getName()); tool.addPlugin(ProgramManagerPlugin.class.getName());
} }
catch (PluginException e) { catch (PluginException e) {
e.printStackTrace(); Msg.error(TestEnv.class, "Problem initializing test tool", e);
} }
}, true); }, true);
@ -565,7 +565,7 @@ public class TestEnv {
script = scriptProvider.getScriptInstance(resourceFile, writer); script = scriptProvider.getScriptInstance(resourceFile, writer);
} }
catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
e.printStackTrace(); Msg.error(TestEnv.class, "Problem creating script", e);
} }
if (script == null) { if (script == null) {
@ -1152,7 +1152,7 @@ public class TestEnv {
private void disposeAllSwingUpdateManagers() { private void disposeAllSwingUpdateManagers() {
// //
// Cleanup all statically tracked SwingUpdateManagers. If we do not do this, then as // Cleanup all statically tracked SwingUpdateManagers. If we do not do this, then as
// tools are launched, the number of tracked managers increases, as not all clients of // tools are launched, the number of tracked managers increases, as not all clients of
// the managers will dispose the managers. // the managers will dispose the managers.
// //

View file

@ -27,7 +27,7 @@ import org.junit.*;
import docking.ActionContext; import docking.ActionContext;
import docking.action.DockingActionIf; import docking.action.DockingActionIf;
import docking.widgets.dialogs.TableChooserDialog; import docking.widgets.dialogs.TableSelectionDialog;
import docking.widgets.table.GFilterTable; import docking.widgets.table.GFilterTable;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin; import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.function.FunctionPlugin; import ghidra.app.plugin.core.function.FunctionPlugin;
@ -43,7 +43,7 @@ import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.TestEnv; import ghidra.test.TestEnv;
/** /**
* Tests for the {@link FunctionComparisonPlugin function comparison plugin} * Tests for the {@link FunctionComparisonPlugin function comparison plugin}
* that involve the GUI * that involve the GUI
*/ */
public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTest { public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTest {
@ -182,8 +182,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
Set<Function> functions = CompareFunctionsTestUtility.getFunctionsAsSet(foo); Set<Function> functions = CompareFunctionsTestUtility.getFunctionsAsSet(foo);
provider = compareFunctions(functions); provider = compareFunctions(functions);
// Must do this or there will be no "active" provider in the actions // Must do this or there will be no "active" provider in the actions initiated below
// initiated below
clickComponentProvider(provider); clickComponentProvider(provider);
assertEquals(provider.getModel().getSourceFunctions().size(), 1); assertEquals(provider.getModel().getSourceFunctions().size(), 1);
@ -192,11 +191,12 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
DockingActionIf openTableAction = getAction(plugin, "Add Functions To Comparison"); DockingActionIf openTableAction = getAction(plugin, "Add Functions To Comparison");
performAction(openTableAction, false); performAction(openTableAction, false);
TableChooserDialog<FunctionTableModel> chooser = TableSelectionDialog<FunctionTableModel> chooser =
waitForDialogComponent(TableChooserDialog.class); waitForDialogComponent(TableSelectionDialog.class);
GFilterTable<FunctionRowObject> table = GFilterTable<FunctionRowObject> table =
(GFilterTable<FunctionRowObject>) getInstanceField("gFilterTable", chooser); (GFilterTable<FunctionRowObject>) getInstanceField("gFilterTable", chooser);
assertEquals(table.getModel().getRowCount(), 2);
waitForCondition(() -> table.getModel().getRowCount() == 2);
clickTableCell(table.getTable(), 1, 0, 1); clickTableCell(table.getTable(), 1, 0, 1);
pressButtonByText(chooser, "OK"); pressButtonByText(chooser, "OK");
@ -246,7 +246,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
builder.createMemory(".text", "0x1001000", 0x6600); builder.createMemory(".text", "0x1001000", 0x6600);
builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent
// functions // functions
DataType dt = new ByteDataType(); DataType dt = new ByteDataType();
Parameter p = new ParameterImpl(null, dt, builder.getProgram()); Parameter p = new ParameterImpl(null, dt, builder.getProgram());
foo = builder.createEmptyFunction("Foo", "10018cf", 10, null, p); foo = builder.createEmptyFunction("Foo", "10018cf", 10, null, p);
@ -264,7 +264,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
builder.createMemory(".text", "0x1001000", 0x6600); builder.createMemory(".text", "0x1001000", 0x6600);
builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent
// functions // functions
DataType dt = new ByteDataType(); DataType dt = new ByteDataType();
Parameter p = new ParameterImpl(null, dt, builder.getProgram()); Parameter p = new ParameterImpl(null, dt, builder.getProgram());
bar = builder.createEmptyFunction("Bar", "10018cf", 10, null, p); bar = builder.createEmptyFunction("Bar", "10018cf", 10, null, p);

View file

@ -286,7 +286,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
return new File(uri); return new File(uri);
} }
catch (URISyntaxException e) { catch (URISyntaxException e) {
e.printStackTrace(); Msg.error(this, "Unable to convert URL to URI", e);
} }
return null; return null;
} }

View file

@ -159,7 +159,7 @@ def initTestJVM(Task task, String rootDirName) {
task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage, task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage,
'-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage, '-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage,
'-Dlog4j.configuration=' + logPropertiesUrl, '-Dlog4j.configurationFile=' + logPropertiesUrl,
'-Dghidra.test.property.batch.mode=true', '-Dghidra.test.property.batch.mode=true',
'-Dghidra.test.property.parallel.mode=' + parallelMode, '-Dghidra.test.property.parallel.mode=' + parallelMode,
'-Dghidra.test.property.output.dir=' + testOutputDir, '-Dghidra.test.property.output.dir=' + testOutputDir,

View file

@ -327,7 +327,7 @@ def initTestJVM(Task task, String rootDirName) {
task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage, task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage,
'-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage, '-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage,
'-Dlog4j.configuration=' + logPropertiesUrl, '-Dlog4j.configurationFile=' + logPropertiesUrl,
'-Dghidra.test.property.batch.mode=true', '-Dghidra.test.property.batch.mode=true',
'-Dghidra.test.property.parallel.mode=' + parallelMode, '-Dghidra.test.property.parallel.mode=' + parallelMode,
'-Dghidra.test.property.output.dir=' + testOutputDir, '-Dghidra.test.property.output.dir=' + testOutputDir,