mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-09-13 21:56:19 +00:00
Tests - Function Graph - added code for timing issues
This commit is contained in:
parent
25894ff9ae
commit
26acaa78eb
|
@ -17,6 +17,7 @@ package ghidra.app.plugin.core.functiongraph;
|
|||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
@ -70,6 +71,11 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
|
|||
private ProgramSelection currentProgramSelection;
|
||||
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 String disconnectedName;
|
||||
|
||||
|
@ -85,9 +91,10 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
|
|||
WeakDataStructureFactory.createCopyOnWriteWeakSet();
|
||||
private boolean isConnected;
|
||||
private ImageIcon navigatableIcon;
|
||||
private boolean disposed = false;
|
||||
// End Navigatable Fields
|
||||
|
||||
private boolean disposed = false;
|
||||
|
||||
public FGProvider(FunctionGraphPlugin plugin, boolean isConnected) {
|
||||
super(plugin.getTool(), FunctionGraphPlugin.FUNCTION_GRAPH_NAME, plugin.getName(),
|
||||
ListingActionContext.class);
|
||||
|
@ -1248,6 +1255,15 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
|
|||
tool.toFront(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocusedProvider() {
|
||||
return focusStatusDelegate.get();
|
||||
}
|
||||
|
||||
void setFocusStatusDelegate(Supplier<Boolean> focusStatusDelegate) {
|
||||
this.focusStatusDelegate = focusStatusDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
|
||||
// currently unsupported
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
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 java.awt.*;
|
||||
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
@ -777,13 +778,13 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
|
|||
// long start = System.nanoTime();
|
||||
|
||||
waitForSwing();
|
||||
|
||||
|
||||
int tryCount = 3;
|
||||
while (tryCount++ < 5 && updater.isBusy()) {
|
||||
while (tryCount++ < 5 && updater.isBusy()) {
|
||||
waitForConditionWithoutFailing(() -> !updater.isBusy());
|
||||
}
|
||||
waitForSwing();
|
||||
|
||||
|
||||
assertFalse(updater.isBusy());
|
||||
|
||||
// long end = System.nanoTime();
|
||||
|
@ -864,6 +865,11 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
|
|||
waitForBusyGraph();
|
||||
}
|
||||
|
||||
protected void setProviderAlwaysFocused() {
|
||||
Supplier<Boolean> focusDelegate = () -> true;
|
||||
runSwing(() -> graphProvider.setFocusStatusDelegate(focusDelegate));
|
||||
}
|
||||
|
||||
protected void assertSatelliteVisible(boolean visible) {
|
||||
boolean satelliteVisible = isSatelliteVisible();
|
||||
if (visible) {
|
||||
|
|
|
@ -109,6 +109,10 @@ public class FunctionGraphGroupVertices1Test extends AbstractFunctionGraphTest {
|
|||
assertEquals(maxAddress, vertex.getAddresses().getMaxAddress());
|
||||
|
||||
Point2D newLocation = getLocation(vertex);
|
||||
|
||||
// TODO debug - this has failed; suspected timing issue
|
||||
waitForCondition(() -> pointsAreSimilar(location, newLocation));
|
||||
|
||||
assertTrue(
|
||||
"Vertex location not restored to default after performing a relayout " +
|
||||
"original point: " + location + " - reloaded point: " + newLocation,
|
||||
|
@ -812,6 +816,7 @@ public class FunctionGraphGroupVertices1Test extends AbstractFunctionGraphTest {
|
|||
//==================================================================================================
|
||||
|
||||
// @formatter:off
|
||||
@Override
|
||||
protected void doTestGroupAndUngroupVertices() {
|
||||
FGData graphData = graphFunction("01002cf5");
|
||||
FunctionGraph functionGraph = graphData.getFunctionGraph();
|
||||
|
@ -843,6 +848,7 @@ public class FunctionGraphGroupVertices1Test extends AbstractFunctionGraphTest {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doTestRestoringWhenCodeBlocksHaveChanged_WillRegroup() {
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doTestSymbolAddedWhenGrouped_SymbolInsideOfGroupNode() {
|
||||
//
|
||||
// By default, if the FunctionGraph detects a symbol addition to one of the code blocks
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
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 java.awt.*;
|
||||
|
@ -639,6 +639,12 @@ public class FunctionGraphPlugin1Test extends AbstractFunctionGraphTest {
|
|||
// test that navigating a vertex updates the code browser's location
|
||||
@Test
|
||||
public void testNavigationFromVertexToCodeBrowser() {
|
||||
|
||||
//
|
||||
// This test covers navigation, which relies on the provider being focused to work
|
||||
//
|
||||
setProviderAlwaysFocused();
|
||||
|
||||
FGData graphData = getFunctionGraphData();
|
||||
assertNotNull(graphData);
|
||||
assertTrue("Unexpectedly received an empty FunctionGraphData", graphData.hasResults());
|
||||
|
@ -722,6 +728,12 @@ public class FunctionGraphPlugin1Test extends AbstractFunctionGraphTest {
|
|||
}
|
||||
|
||||
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
|
||||
// at the moved position.
|
||||
|
|
Loading…
Reference in a new issue