From 5b3e41ff1b79cd334825e1a2e76ff00260acbeee Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Mon, 24 Jan 2022 18:18:38 -0500 Subject: [PATCH] Test fixes --- .../actions/OpenFunctionTableAction.java | 6 ++-- .../src/main/java/ghidra/test/TestEnv.java | 30 +++++++++---------- .../CompareFunctionsSlowTest.java | 18 +++++------ .../generic/test/AbstractGenericTest.java | 2 +- gradle/javaTestProject.gradle | 2 +- gradle/root/test.gradle | 2 +- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java index 186e336b19..3d8a3f4adb 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java @@ -24,7 +24,7 @@ import javax.swing.ImageIcon; import docking.ActionContext; 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.MultiFunctionComparisonPanel; import ghidra.app.plugin.core.functionwindow.FunctionRowObject; @@ -108,8 +108,8 @@ public class OpenFunctionTableAction extends DockingAction { FunctionTableModel model = new FunctionTableModel(tool, currentProgram); model.reload(programManagerService.getCurrentProgram()); - TableChooserDialog diag = - new TableChooserDialog<>("Select Functions: " + currentProgram.getName(), + TableSelectionDialog diag = + new TableSelectionDialog<>("Select Functions: " + currentProgram.getName(), model, true); tool.showDialog(diag); List rows = diag.getSelectionItems(); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java b/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java index 45282934de..5e0d2b2982 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java @@ -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. * - *

If you have not created a tool using this env, then the default + *

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 * is used. In the following example, the given plugin is added to the default tool: *

 	 * 		TestEnv env = new TestEnv();
 	 * 		env.launchDefaultTool();
 	 * 		FooPlugin foo = env.addPlugin(FooPlugin.class);
-	 * 
+ * * * * @param c the plugin class * @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 addPlugin(Class c) throws PluginException { 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 - * been created. + * Shows any previously created tool, creating a simple empty tool if not tool has yet + * been created. * - *

This method is considered sub-standard and users should prefer instead + *

This method is considered sub-standard and users should prefer instead * {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}. * * @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. * - *

This method is considered sub-standard and users should prefer instead + *

This method is considered sub-standard and users should prefer instead * {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}. * * @param p the program @@ -403,11 +403,11 @@ public class TestEnv { } 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 // so that tests will have the default tool as needed. - // + // Project project = gp.getProject(); ToolChest toolChest = project.getLocalToolChest(); ToolTemplate template = getToolTemplate(AbstractGenericTest.DEFAULT_TEST_TOOL_NAME); @@ -430,7 +430,7 @@ public class TestEnv { tool.addPlugin(ProgramManagerPlugin.class.getName()); } catch (PluginException e) { - e.printStackTrace(); + Msg.error(TestEnv.class, "Problem initializing test tool", e); } }, true); @@ -565,7 +565,7 @@ public class TestEnv { script = scriptProvider.getScriptInstance(resourceFile, writer); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - e.printStackTrace(); + Msg.error(TestEnv.class, "Problem creating script", e); } if (script == null) { @@ -1152,7 +1152,7 @@ public class TestEnv { 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 // the managers will dispose the managers. // diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java index 45313c0e52..c66f6f9cb8 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java @@ -27,7 +27,7 @@ import org.junit.*; import docking.ActionContext; import docking.action.DockingActionIf; -import docking.widgets.dialogs.TableChooserDialog; +import docking.widgets.dialogs.TableSelectionDialog; import docking.widgets.table.GFilterTable; import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin; import ghidra.app.plugin.core.function.FunctionPlugin; @@ -43,7 +43,7 @@ import ghidra.test.AbstractGhidraHeadedIntegrationTest; import ghidra.test.TestEnv; /** - * Tests for the {@link FunctionComparisonPlugin function comparison plugin} + * Tests for the {@link FunctionComparisonPlugin function comparison plugin} * that involve the GUI */ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTest { @@ -182,8 +182,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes Set functions = CompareFunctionsTestUtility.getFunctionsAsSet(foo); provider = compareFunctions(functions); - // Must do this or there will be no "active" provider in the actions - // initiated below + // Must do this or there will be no "active" provider in the actions initiated below clickComponentProvider(provider); assertEquals(provider.getModel().getSourceFunctions().size(), 1); @@ -192,11 +191,12 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes DockingActionIf openTableAction = getAction(plugin, "Add Functions To Comparison"); performAction(openTableAction, false); - TableChooserDialog chooser = - waitForDialogComponent(TableChooserDialog.class); + TableSelectionDialog chooser = + waitForDialogComponent(TableSelectionDialog.class); GFilterTable table = (GFilterTable) getInstanceField("gFilterTable", chooser); - assertEquals(table.getModel().getRowCount(), 2); + + waitForCondition(() -> table.getModel().getRowCount() == 2); clickTableCell(table.getTable(), 1, 0, 1); pressButtonByText(chooser, "OK"); @@ -246,7 +246,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes builder.createMemory(".text", "0x1001000", 0x6600); builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent - // functions + // functions DataType dt = new ByteDataType(); Parameter p = new ParameterImpl(null, dt, builder.getProgram()); foo = builder.createEmptyFunction("Foo", "10018cf", 10, null, p); @@ -264,7 +264,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes builder.createMemory(".text", "0x1001000", 0x6600); builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent - // functions + // functions DataType dt = new ByteDataType(); Parameter p = new ParameterImpl(null, dt, builder.getProgram()); bar = builder.createEmptyFunction("Bar", "10018cf", 10, null, p); diff --git a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java index de7beb67e8..d148103b4b 100644 --- a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java +++ b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java @@ -286,7 +286,7 @@ public abstract class AbstractGenericTest extends AbstractGTest { return new File(uri); } catch (URISyntaxException e) { - e.printStackTrace(); + Msg.error(this, "Unable to convert URL to URI", e); } return null; } diff --git a/gradle/javaTestProject.gradle b/gradle/javaTestProject.gradle index d2fb80849e..eb29dba044 100644 --- a/gradle/javaTestProject.gradle +++ b/gradle/javaTestProject.gradle @@ -159,7 +159,7 @@ def initTestJVM(Task task, String rootDirName) { task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage, '-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage, - '-Dlog4j.configuration=' + logPropertiesUrl, + '-Dlog4j.configurationFile=' + logPropertiesUrl, '-Dghidra.test.property.batch.mode=true', '-Dghidra.test.property.parallel.mode=' + parallelMode, '-Dghidra.test.property.output.dir=' + testOutputDir, diff --git a/gradle/root/test.gradle b/gradle/root/test.gradle index cd50d17fb6..641b721b72 100644 --- a/gradle/root/test.gradle +++ b/gradle/root/test.gradle @@ -327,7 +327,7 @@ def initTestJVM(Task task, String rootDirName) { task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage, '-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage, - '-Dlog4j.configuration=' + logPropertiesUrl, + '-Dlog4j.configurationFile=' + logPropertiesUrl, '-Dghidra.test.property.batch.mode=true', '-Dghidra.test.property.parallel.mode=' + parallelMode, '-Dghidra.test.property.output.dir=' + testOutputDir,