Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test fixes

dragonmacher33b9315c1838
diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/DockingWindowManagerTest.java b/Ghidra/Features/Base/src/test.slow/java/docking/DockingWindowManagerTest.java
index fb547c7d9b..c4900a2269 100644
--- a/Ghidra/Features/Base/src/test.slow/java/docking/DockingWindowManagerTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/docking/DockingWindowManagerTest.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.
@@ -30,7 +30,6 @@ import org.junit.Test;
import docking.test.AbstractDockingTest;
import docking.widgets.label.GDLabel;
-import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.test.DummyTool;
public class DockingWindowManagerTest extends AbstractDockingTest {
@@ -597,12 +596,12 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
}
}
- class MyProvider extends ComponentProviderAdapter {
+ private class MyProvider extends ComponentProvider {
JLabel label = new GDLabel();
public MyProvider(String owner, String name, String group, String title,
WindowPosition defaultWindowPosition) {
- super(null, name, owner);
+ super(DockingWindowManagerTest.this.tool, name, owner);
setWindowGroup(group);
setDefaultWindowPosition(defaultWindowPosition);
setTitle(title);
diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.java b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.java
index 9053f5ec93..b376f3fa63 100644
--- a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.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.
@@ -51,8 +51,9 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
filteredModel = filterPanel.getTableFilterModel();
table.setAutoLookupColumn(4);
- winMgr = new DockingWindowManager(new DummyTool(), null);
- winMgr.addComponent(new TestTableComponentProvider());
+ DummyTool tool = new DummyTool();
+ winMgr = new DockingWindowManager(tool, null);
+ winMgr.addComponent(new TestTableComponentProvider(tool));
winMgr.setVisible(true);
}
@@ -421,8 +422,8 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
private class TestTableComponentProvider extends ComponentProvider {
- public TestTableComponentProvider() {
- super(null, "Test", "Test");
+ public TestTableComponentProvider(DummyTool tool) {
+ super(tool, "Test", "Test");
setDefaultWindowPosition(WindowPosition.STACK);
setTabText("Test");
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeEventTest.java b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeEventTest.java
index 687e766169..3a1bfc9597 100644
--- a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeEventTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeEventTest.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.
@@ -44,8 +44,9 @@ public class GTreeEventTest extends AbstractDockingTest {
gTree = new GTree(root);
gTree.getModel().addTreeModelListener(new TestTreeModelListener());
- DockingWindowManager winMgr = new DockingWindowManager(new DummyTool(), null);
- winMgr.addComponent(new TestTreeComponentProvider(gTree));
+ DummyTool tool = new DummyTool();
+ DockingWindowManager winMgr = new DockingWindowManager(tool, null);
+ winMgr.addComponent(new TestTreeComponentProvider(tool, gTree));
winMgr.setVisible(true);
waitForTree();
diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.java b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.java
index 48611f1352..e6c48779f9 100644
--- a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.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.
@@ -43,8 +43,9 @@ public class GTreeFilterTest extends AbstractDockingTest {
filterField = (FilterTextField) gTree.getFilterField();
- winMgr = new DockingWindowManager(new DummyTool(), null);
- winMgr.addComponent(new TestTreeComponentProvider(gTree));
+ DummyTool tool = new DummyTool();
+ winMgr = new DockingWindowManager(tool, null);
+ winMgr.addComponent(new TestTreeComponentProvider(tool, gTree));
winMgr.setVisible(true);
waitForTree();
diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/TestTreeComponentProvider.java b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/TestTreeComponentProvider.java
index 416e7a2ee2..a3d187fa68 100644
--- a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/TestTreeComponentProvider.java
+++ b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/TestTreeComponentProvider.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.
@@ -17,15 +17,14 @@ package docking.widgets.tree;
import javax.swing.JComponent;
-import docking.ComponentProvider;
-import docking.WindowPosition;
+import docking.*;
class TestTreeComponentProvider extends ComponentProvider {
private GTree gTree;
- public TestTreeComponentProvider(GTree gTree) {
- super(null, "Test", "Test");
+ public TestTreeComponentProvider(Tool tool, GTree gTree) {
+ super(tool, "Test", "Test");
this.gTree = gTree;
setDefaultWindowPosition(WindowPosition.STACK);
setTabText("Test");
diff --git a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.java b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.java
index 6a5d56a991..6af1f03675 100644
--- a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.java
+++ b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerNavigationTest.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.
@@ -17,6 +17,9 @@ package ghidra.app.plugin.core.decompile;
import static org.junit.Assert.*;
+import java.util.function.BooleanSupplier;
+import java.util.function.Supplier;
+
import org.junit.Before;
import org.junit.Test;
@@ -232,11 +235,17 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
codeBrowser.updateNow();
waitForSwing();
- waitForCondition(() -> {
+ BooleanSupplier success = () -> {
ProgramLocation loc = codeBrowser.getCurrentLocation();
Address actual = loc.getAddress();
return expected.equals(actual);
- }, "Listing is not at the expected address");
+ };
+
+ Supplier<String> failureMessage =
+ () -> "Listing is not at the expected address. Current location: " +
+ codeBrowser.getCurrentLocation();
+
+ waitForCondition(success, failureMessage);
}
private void focusDecompiler() {
diff --git a/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffApplyMergeTest.java b/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffApplyMergeTest.java
index 449663f1b4..7d00337006 100644
--- a/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffApplyMergeTest.java
+++ b/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffApplyMergeTest.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.
@@ -33,7 +33,7 @@ import ghidra.util.exception.InvalidInputException;
public class DiffApplyMergeTest extends DiffApplyTestAdapter {
@Override
- public void tearDown() {
+ public void tearDown() throws Exception {
closeAllWindows();
super.tearDown();
diff --git a/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffTestAdapter.java b/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffTestAdapter.java
index 9b5de8d40c..99c669683c 100644
--- a/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffTestAdapter.java
+++ b/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DiffTestAdapter.java
@@ -501,13 +501,15 @@ public class DiffTestAdapter extends AbstractGhidraHeadedIntegrationTest {
}
@After
- public void tearDown() {
+ public void tearDown() throws Exception {
Window win = getWindow("Select Other Program");
if (win != null) {
pressButton(win, "Cancel");
}
+ closeDiff();
+
env.dispose();
}
@@ -516,8 +518,16 @@ public class DiffTestAdapter extends AbstractGhidraHeadedIntegrationTest {
performAction(setView, context, true);
}
+ protected boolean isDiffActive() {
+ return runSwing(() -> diffPlugin.isDiffActive());
+ }
+
void closeDiff() throws Exception {
+ if (!isDiffActive()) {
+ return;
+ }
+
closeDiffByAction();
DialogComponentProvider dialogProvider = waitForDialogComponent("Close Diff Session");
assertNotNull("Did not get confirmation dialog", dialogProvider);
diff --git a/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DualProgramTest.java b/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DualProgramTest.java
index ba81c1b4e5..c1876e50cc 100644
--- a/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DualProgramTest.java
+++ b/Ghidra/Features/ProgramDiff/src/test.slow/java/ghidra/app/plugin/core/diff/DualProgramTest.java
@@ -230,9 +230,6 @@ public class DualProgramTest extends DiffTestAdapter {
ProgramDB otherProgram = otherBuilder.getProgram();
otherBuilder.createMemory(".stuff", "0x1004000", 0x300);
- Window win;
- Component comp;
- //InfoWindow.showSplashScreen();
showTool(frontEndTool);
env.showTool();
@@ -241,9 +238,9 @@ public class DualProgramTest extends DiffTestAdapter {
launchDiffByAction();
waitForSwing();
- win = waitForWindow("Select Other Program");
+ Window win = waitForWindow("Select Other Program");
assertNotNull(win);
- comp = getComponentOfType(win, JComboBox.class);
+ Component comp = getComponentOfType(win, JComboBox.class);
assertNotNull(comp);
JTree tree = findComponent(win, JTree.class);
diff --git a/Ghidra/Framework/Docking/src/test/java/docking/PlaceholderSetTest.java b/Ghidra/Framework/Docking/src/test/java/docking/PlaceholderSetTest.java
index cb86a83aa6..bfd3330e22 100644
--- a/Ghidra/Framework/Docking/src/test/java/docking/PlaceholderSetTest.java
+++ b/Ghidra/Framework/Docking/src/test/java/docking/PlaceholderSetTest.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.
@@ -24,14 +24,12 @@ import javax.swing.JLabel;
import org.junit.Test;
+import docking.test.AbstractDockingTest;
import docking.widgets.label.GDLabel;
-import generic.test.AbstractGenericTest;
-public class PlaceholderSetTest extends AbstractGenericTest {
+public class PlaceholderSetTest extends AbstractDockingTest {
- public PlaceholderSetTest() {
- super();
- }
+ private Tool tool = new FakeDockingTool();
@Test
public void testDedupingRestoredPlaceholders_OnlyOneHidden() {
@@ -118,7 +116,7 @@ public class PlaceholderSetTest extends AbstractGenericTest {
JLabel label = new GDLabel();
public TestProvider() {
- super(null, null, null);
+ super(PlaceholderSetTest.this.tool, null, null);
}
@Override