mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Test fixes
This commit is contained in:
parent
051a0b3405
commit
33b9315c18
10 changed files with 61 additions and 46 deletions
|
@ -30,7 +30,6 @@ import org.junit.Test;
|
||||||
|
|
||||||
import docking.test.AbstractDockingTest;
|
import docking.test.AbstractDockingTest;
|
||||||
import docking.widgets.label.GDLabel;
|
import docking.widgets.label.GDLabel;
|
||||||
import ghidra.framework.plugintool.ComponentProviderAdapter;
|
|
||||||
import ghidra.test.DummyTool;
|
import ghidra.test.DummyTool;
|
||||||
|
|
||||||
public class DockingWindowManagerTest extends AbstractDockingTest {
|
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();
|
JLabel label = new GDLabel();
|
||||||
|
|
||||||
public MyProvider(String owner, String name, String group, String title,
|
public MyProvider(String owner, String name, String group, String title,
|
||||||
WindowPosition defaultWindowPosition) {
|
WindowPosition defaultWindowPosition) {
|
||||||
super(null, name, owner);
|
super(DockingWindowManagerTest.this.tool, name, owner);
|
||||||
setWindowGroup(group);
|
setWindowGroup(group);
|
||||||
setDefaultWindowPosition(defaultWindowPosition);
|
setDefaultWindowPosition(defaultWindowPosition);
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
|
|
|
@ -51,8 +51,9 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
filteredModel = filterPanel.getTableFilterModel();
|
filteredModel = filterPanel.getTableFilterModel();
|
||||||
table.setAutoLookupColumn(4);
|
table.setAutoLookupColumn(4);
|
||||||
|
|
||||||
winMgr = new DockingWindowManager(new DummyTool(), null);
|
DummyTool tool = new DummyTool();
|
||||||
winMgr.addComponent(new TestTableComponentProvider());
|
winMgr = new DockingWindowManager(tool, null);
|
||||||
|
winMgr.addComponent(new TestTableComponentProvider(tool));
|
||||||
winMgr.setVisible(true);
|
winMgr.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,8 +422,8 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
|
|
||||||
private class TestTableComponentProvider extends ComponentProvider {
|
private class TestTableComponentProvider extends ComponentProvider {
|
||||||
|
|
||||||
public TestTableComponentProvider() {
|
public TestTableComponentProvider(DummyTool tool) {
|
||||||
super(null, "Test", "Test");
|
super(tool, "Test", "Test");
|
||||||
setDefaultWindowPosition(WindowPosition.STACK);
|
setDefaultWindowPosition(WindowPosition.STACK);
|
||||||
setTabText("Test");
|
setTabText("Test");
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,9 @@ public class GTreeEventTest extends AbstractDockingTest {
|
||||||
gTree = new GTree(root);
|
gTree = new GTree(root);
|
||||||
gTree.getModel().addTreeModelListener(new TestTreeModelListener());
|
gTree.getModel().addTreeModelListener(new TestTreeModelListener());
|
||||||
|
|
||||||
DockingWindowManager winMgr = new DockingWindowManager(new DummyTool(), null);
|
DummyTool tool = new DummyTool();
|
||||||
winMgr.addComponent(new TestTreeComponentProvider(gTree));
|
DockingWindowManager winMgr = new DockingWindowManager(tool, null);
|
||||||
|
winMgr.addComponent(new TestTreeComponentProvider(tool, gTree));
|
||||||
winMgr.setVisible(true);
|
winMgr.setVisible(true);
|
||||||
|
|
||||||
waitForTree();
|
waitForTree();
|
||||||
|
|
|
@ -43,8 +43,9 @@ public class GTreeFilterTest extends AbstractDockingTest {
|
||||||
|
|
||||||
filterField = (FilterTextField) gTree.getFilterField();
|
filterField = (FilterTextField) gTree.getFilterField();
|
||||||
|
|
||||||
winMgr = new DockingWindowManager(new DummyTool(), null);
|
DummyTool tool = new DummyTool();
|
||||||
winMgr.addComponent(new TestTreeComponentProvider(gTree));
|
winMgr = new DockingWindowManager(tool, null);
|
||||||
|
winMgr.addComponent(new TestTreeComponentProvider(tool, gTree));
|
||||||
winMgr.setVisible(true);
|
winMgr.setVisible(true);
|
||||||
|
|
||||||
waitForTree();
|
waitForTree();
|
||||||
|
|
|
@ -17,15 +17,14 @@ package docking.widgets.tree;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import docking.ComponentProvider;
|
import docking.*;
|
||||||
import docking.WindowPosition;
|
|
||||||
|
|
||||||
class TestTreeComponentProvider extends ComponentProvider {
|
class TestTreeComponentProvider extends ComponentProvider {
|
||||||
|
|
||||||
private GTree gTree;
|
private GTree gTree;
|
||||||
|
|
||||||
public TestTreeComponentProvider(GTree gTree) {
|
public TestTreeComponentProvider(Tool tool, GTree gTree) {
|
||||||
super(null, "Test", "Test");
|
super(tool, "Test", "Test");
|
||||||
this.gTree = gTree;
|
this.gTree = gTree;
|
||||||
setDefaultWindowPosition(WindowPosition.STACK);
|
setDefaultWindowPosition(WindowPosition.STACK);
|
||||||
setTabText("Test");
|
setTabText("Test");
|
||||||
|
|
|
@ -17,6 +17,9 @@ package ghidra.app.plugin.core.decompile;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -232,11 +235,17 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
||||||
codeBrowser.updateNow();
|
codeBrowser.updateNow();
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
|
|
||||||
waitForCondition(() -> {
|
BooleanSupplier success = () -> {
|
||||||
ProgramLocation loc = codeBrowser.getCurrentLocation();
|
ProgramLocation loc = codeBrowser.getCurrentLocation();
|
||||||
Address actual = loc.getAddress();
|
Address actual = loc.getAddress();
|
||||||
return expected.equals(actual);
|
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() {
|
private void focusDecompiler() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import ghidra.util.exception.InvalidInputException;
|
||||||
public class DiffApplyMergeTest extends DiffApplyTestAdapter {
|
public class DiffApplyMergeTest extends DiffApplyTestAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tearDown() {
|
public void tearDown() throws Exception {
|
||||||
|
|
||||||
closeAllWindows();
|
closeAllWindows();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
|
|
|
@ -501,13 +501,15 @@ public class DiffTestAdapter extends AbstractGhidraHeadedIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() throws Exception {
|
||||||
|
|
||||||
Window win = getWindow("Select Other Program");
|
Window win = getWindow("Select Other Program");
|
||||||
if (win != null) {
|
if (win != null) {
|
||||||
pressButton(win, "Cancel");
|
pressButton(win, "Cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeDiff();
|
||||||
|
|
||||||
env.dispose();
|
env.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,8 +518,16 @@ public class DiffTestAdapter extends AbstractGhidraHeadedIntegrationTest {
|
||||||
performAction(setView, context, true);
|
performAction(setView, context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isDiffActive() {
|
||||||
|
return runSwing(() -> diffPlugin.isDiffActive());
|
||||||
|
}
|
||||||
|
|
||||||
void closeDiff() throws Exception {
|
void closeDiff() throws Exception {
|
||||||
|
|
||||||
|
if (!isDiffActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
closeDiffByAction();
|
closeDiffByAction();
|
||||||
DialogComponentProvider dialogProvider = waitForDialogComponent("Close Diff Session");
|
DialogComponentProvider dialogProvider = waitForDialogComponent("Close Diff Session");
|
||||||
assertNotNull("Did not get confirmation dialog", dialogProvider);
|
assertNotNull("Did not get confirmation dialog", dialogProvider);
|
||||||
|
|
|
@ -230,9 +230,6 @@ public class DualProgramTest extends DiffTestAdapter {
|
||||||
ProgramDB otherProgram = otherBuilder.getProgram();
|
ProgramDB otherProgram = otherBuilder.getProgram();
|
||||||
otherBuilder.createMemory(".stuff", "0x1004000", 0x300);
|
otherBuilder.createMemory(".stuff", "0x1004000", 0x300);
|
||||||
|
|
||||||
Window win;
|
|
||||||
Component comp;
|
|
||||||
//InfoWindow.showSplashScreen();
|
|
||||||
showTool(frontEndTool);
|
showTool(frontEndTool);
|
||||||
env.showTool();
|
env.showTool();
|
||||||
|
|
||||||
|
@ -241,9 +238,9 @@ public class DualProgramTest extends DiffTestAdapter {
|
||||||
|
|
||||||
launchDiffByAction();
|
launchDiffByAction();
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
win = waitForWindow("Select Other Program");
|
Window win = waitForWindow("Select Other Program");
|
||||||
assertNotNull(win);
|
assertNotNull(win);
|
||||||
comp = getComponentOfType(win, JComboBox.class);
|
Component comp = getComponentOfType(win, JComboBox.class);
|
||||||
assertNotNull(comp);
|
assertNotNull(comp);
|
||||||
|
|
||||||
JTree tree = findComponent(win, JTree.class);
|
JTree tree = findComponent(win, JTree.class);
|
||||||
|
|
|
@ -24,14 +24,12 @@ import javax.swing.JLabel;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import docking.test.AbstractDockingTest;
|
||||||
import docking.widgets.label.GDLabel;
|
import docking.widgets.label.GDLabel;
|
||||||
import generic.test.AbstractGenericTest;
|
|
||||||
|
|
||||||
public class PlaceholderSetTest extends AbstractGenericTest {
|
public class PlaceholderSetTest extends AbstractDockingTest {
|
||||||
|
|
||||||
public PlaceholderSetTest() {
|
private Tool tool = new FakeDockingTool();
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDedupingRestoredPlaceholders_OnlyOneHidden() {
|
public void testDedupingRestoredPlaceholders_OnlyOneHidden() {
|
||||||
|
@ -118,7 +116,7 @@ public class PlaceholderSetTest extends AbstractGenericTest {
|
||||||
JLabel label = new GDLabel();
|
JLabel label = new GDLabel();
|
||||||
|
|
||||||
public TestProvider() {
|
public TestProvider() {
|
||||||
super(null, null, null);
|
super(PlaceholderSetTest.this.tool, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue