mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-02 23:46:35 +08:00
Tests - Function Graph - added code for timing issues
This commit is contained in:
+17
-1
@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.functiongraph;
|
|||||||
|
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
@@ -70,6 +71,11 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
|
|||||||
private ProgramSelection currentProgramSelection;
|
private ProgramSelection currentProgramSelection;
|
||||||
private ProgramSelection currentProgramHighlight;
|
private ProgramSelection currentProgramHighlight;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A construct that allows tests to control the notion of whether this provider has focus
|
||||||
|
*/
|
||||||
|
private Supplier<Boolean> focusStatusDelegate = () -> super.isFocusedProvider();
|
||||||
|
|
||||||
private DecoratorPanel decorationPanel;
|
private DecoratorPanel decorationPanel;
|
||||||
private String disconnectedName;
|
private String disconnectedName;
|
||||||
|
|
||||||
@@ -85,9 +91,10 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
|
|||||||
WeakDataStructureFactory.createCopyOnWriteWeakSet();
|
WeakDataStructureFactory.createCopyOnWriteWeakSet();
|
||||||
private boolean isConnected;
|
private boolean isConnected;
|
||||||
private ImageIcon navigatableIcon;
|
private ImageIcon navigatableIcon;
|
||||||
private boolean disposed = false;
|
|
||||||
// End Navigatable Fields
|
// End Navigatable Fields
|
||||||
|
|
||||||
|
private boolean disposed = false;
|
||||||
|
|
||||||
public FGProvider(FunctionGraphPlugin plugin, boolean isConnected) {
|
public FGProvider(FunctionGraphPlugin plugin, boolean isConnected) {
|
||||||
super(plugin.getTool(), FunctionGraphPlugin.FUNCTION_GRAPH_NAME, plugin.getName(),
|
super(plugin.getTool(), FunctionGraphPlugin.FUNCTION_GRAPH_NAME, plugin.getName(),
|
||||||
ListingActionContext.class);
|
ListingActionContext.class);
|
||||||
@@ -1248,6 +1255,15 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
|
|||||||
tool.toFront(this);
|
tool.toFront(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFocusedProvider() {
|
||||||
|
return focusStatusDelegate.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFocusStatusDelegate(Supplier<Boolean> focusStatusDelegate) {
|
||||||
|
this.focusStatusDelegate = focusStatusDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
|
public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
|
||||||
// currently unsupported
|
// currently unsupported
|
||||||
|
|||||||
+7
-1
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.functiongraph;
|
package ghidra.app.plugin.core.functiongraph;
|
||||||
|
|
||||||
import static ghidra.graph.viewer.GraphViewerUtils.getGraphScale;
|
import static ghidra.graph.viewer.GraphViewerUtils.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -25,6 +25,7 @@ import java.io.IOException;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
@@ -864,6 +865,11 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
|
|||||||
waitForBusyGraph();
|
waitForBusyGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setProviderAlwaysFocused() {
|
||||||
|
Supplier<Boolean> focusDelegate = () -> true;
|
||||||
|
runSwing(() -> graphProvider.setFocusStatusDelegate(focusDelegate));
|
||||||
|
}
|
||||||
|
|
||||||
protected void assertSatelliteVisible(boolean visible) {
|
protected void assertSatelliteVisible(boolean visible) {
|
||||||
boolean satelliteVisible = isSatelliteVisible();
|
boolean satelliteVisible = isSatelliteVisible();
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
|||||||
+7
@@ -109,6 +109,10 @@ public class FunctionGraphGroupVertices1Test extends AbstractFunctionGraphTest {
|
|||||||
assertEquals(maxAddress, vertex.getAddresses().getMaxAddress());
|
assertEquals(maxAddress, vertex.getAddresses().getMaxAddress());
|
||||||
|
|
||||||
Point2D newLocation = getLocation(vertex);
|
Point2D newLocation = getLocation(vertex);
|
||||||
|
|
||||||
|
// TODO debug - this has failed; suspected timing issue
|
||||||
|
waitForCondition(() -> pointsAreSimilar(location, newLocation));
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
"Vertex location not restored to default after performing a relayout " +
|
"Vertex location not restored to default after performing a relayout " +
|
||||||
"original point: " + location + " - reloaded point: " + newLocation,
|
"original point: " + location + " - reloaded point: " + newLocation,
|
||||||
@@ -812,6 +816,7 @@ public class FunctionGraphGroupVertices1Test extends AbstractFunctionGraphTest {
|
|||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
@Override
|
||||||
protected void doTestGroupAndUngroupVertices() {
|
protected void doTestGroupAndUngroupVertices() {
|
||||||
FGData graphData = graphFunction("01002cf5");
|
FGData graphData = graphFunction("01002cf5");
|
||||||
FunctionGraph functionGraph = graphData.getFunctionGraph();
|
FunctionGraph functionGraph = graphData.getFunctionGraph();
|
||||||
@@ -843,6 +848,7 @@ public class FunctionGraphGroupVertices1Test extends AbstractFunctionGraphTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doTestRestoringWhenCodeBlocksHaveChanged_WillRegroup() {
|
protected void doTestRestoringWhenCodeBlocksHaveChanged_WillRegroup() {
|
||||||
//
|
//
|
||||||
// Tests the behavior of how group vertices are restored when one or more of the vertices
|
// Tests the behavior of how group vertices are restored when one or more of the vertices
|
||||||
@@ -924,6 +930,7 @@ public class FunctionGraphGroupVertices1Test extends AbstractFunctionGraphTest {
|
|||||||
assertNotNull(newlyCreatedVertex);
|
assertNotNull(newlyCreatedVertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void doTestSymbolAddedWhenGrouped_SymbolInsideOfGroupNode() {
|
protected void doTestSymbolAddedWhenGrouped_SymbolInsideOfGroupNode() {
|
||||||
//
|
//
|
||||||
// By default, if the FunctionGraph detects a symbol addition to one of the code blocks
|
// By default, if the FunctionGraph detects a symbol addition to one of the code blocks
|
||||||
|
|||||||
+13
-1
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.functiongraph;
|
package ghidra.app.plugin.core.functiongraph;
|
||||||
|
|
||||||
import static ghidra.graph.viewer.GraphViewerUtils.getGraphScale;
|
import static ghidra.graph.viewer.GraphViewerUtils.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -639,6 +639,12 @@ public class FunctionGraphPlugin1Test extends AbstractFunctionGraphTest {
|
|||||||
// test that navigating a vertex updates the code browser's location
|
// test that navigating a vertex updates the code browser's location
|
||||||
@Test
|
@Test
|
||||||
public void testNavigationFromVertexToCodeBrowser() {
|
public void testNavigationFromVertexToCodeBrowser() {
|
||||||
|
|
||||||
|
//
|
||||||
|
// This test covers navigation, which relies on the provider being focused to work
|
||||||
|
//
|
||||||
|
setProviderAlwaysFocused();
|
||||||
|
|
||||||
FGData graphData = getFunctionGraphData();
|
FGData graphData = getFunctionGraphData();
|
||||||
assertNotNull(graphData);
|
assertNotNull(graphData);
|
||||||
assertTrue("Unexpectedly received an empty FunctionGraphData", graphData.hasResults());
|
assertTrue("Unexpectedly received an empty FunctionGraphData", graphData.hasResults());
|
||||||
@@ -722,6 +728,12 @@ public class FunctionGraphPlugin1Test extends AbstractFunctionGraphTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void doTestRelayout(boolean fullReload) throws Exception {
|
protected void doTestRelayout(boolean fullReload) throws Exception {
|
||||||
|
|
||||||
|
//
|
||||||
|
// This test covers navigation, which relies on the provider being focused to work
|
||||||
|
//
|
||||||
|
setProviderAlwaysFocused();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test that we can move a node, call relayout and that the moved node will not be
|
// Test that we can move a node, call relayout and that the moved node will not be
|
||||||
// at the moved position.
|
// at the moved position.
|
||||||
|
|||||||
Reference in New Issue
Block a user