diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java index ed19c593e8..f469c92895 100644 --- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java +++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java @@ -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 focusStatusDelegate = () -> super.isFocusedProvider(); + private DecoratorPanel decorationPanel; private String disconnectedName; @@ -85,9 +91,10 @@ public class FGProvider extends VisualGraphComponentProvider focusStatusDelegate) { + this.focusStatusDelegate = focusStatusDelegate; + } + @Override public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) { // currently unsupported diff --git a/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/AbstractFunctionGraphTest.java b/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/AbstractFunctionGraphTest.java index 8865bb297c..66df958697 100644 --- a/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/AbstractFunctionGraphTest.java +++ b/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/AbstractFunctionGraphTest.java @@ -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 focusDelegate = () -> true; + runSwing(() -> graphProvider.setFocusStatusDelegate(focusDelegate)); + } + protected void assertSatelliteVisible(boolean visible) { boolean satelliteVisible = isSatelliteVisible(); if (visible) { diff --git a/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphGroupVertices1Test.java b/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphGroupVertices1Test.java index 5b6d8dec3a..56ac72f7cd 100644 --- a/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphGroupVertices1Test.java +++ b/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphGroupVertices1Test.java @@ -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 diff --git a/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin1Test.java b/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin1Test.java index 4983409609..eba90e69b5 100644 --- a/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin1Test.java +++ b/Ghidra/Features/FunctionGraph/src/test/java/ghidra/app/plugin/core/functiongraph/FunctionGraphPlugin1Test.java @@ -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.