Tests - fixed tests failing due to graph job not correctly notifying its

listener
This commit is contained in:
dragonmacher 2019-12-03 15:51:51 -05:00
parent dba6e117b8
commit dee6e0cd4d
5 changed files with 21 additions and 17 deletions

View file

@ -20,9 +20,8 @@ import ghidra.graph.job.GraphJob;
import ghidra.graph.job.GraphJobListener;
/**
* A dummy job that is designed to simply call the
* {@link FunctionGraphUtils#ungroupAllVertices(FGController)}. We use this job
* to know when the previous job is finished.
* A dummy job that is designed to simply call the {@link FGController#ungroupAllVertices()}.
* We use this job to know when the previous job is finished.
*/
public class UngroupAllVertexFunctionGraphJob implements GraphJob {

View file

@ -1305,8 +1305,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* @param count the number of rows to select
* @throws Exception if there's a problem simulating the click
*/
public static void clickListRange(final JList list, final int row, int count)
throws Exception {
public static void clickListRange(final JList list, final int row, int count) throws Exception {
waitForSwing();
for (int i = row; i < row + count; i++) {
Rectangle rect = list.getCellBounds(i, i);
@ -1315,7 +1314,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
}
waitForSwing();
}
/**
* Clicks a range of items in a table (simulates holding SHIFT and selecting
* each item in the range)

View file

@ -73,6 +73,11 @@ public class FitGraphToViewJob<V extends VisualVertex, E extends VisualEdge<V>>
@Override
public void execute(GraphJobListener listener) {
doExecute();
listener.jobFinished(this);
}
private void doExecute() {
if (isFinished) {
return;
}
@ -90,7 +95,6 @@ public class FitGraphToViewJob<V extends VisualVertex, E extends VisualEdge<V>>
}
isFinished = true;
listener.jobFinished(this);
}
private boolean graphIsEmpty() {

View file

@ -262,8 +262,8 @@ public class GraphComponentTest extends AbstractVisualGraphTest {
Shape edgeShape =
GraphViewerUtils.getEdgeShapeInGraphSpace(graphComponent.getPrimaryViewer(), e);
Rectangle bounds = edgeShape.getBounds();
assertTrue("Edge width not initialized", bounds.width > 1);
assertTrue("Edge height not initialized", bounds.height > 1);
assertTrue("Edge width not initialized - width: " + bounds.width, bounds.width > 1);
assertTrue("Edge height not initialized - height: " + bounds.height, bounds.height > 1);
}
@Test

View file

@ -15,8 +15,7 @@
*/
package ghidra.graph.viewer.edge;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import java.util.*;
@ -650,13 +649,16 @@ public class VisualGraphPathHighlighterTest extends AbstractVisualGraphTest {
// First, find the exact instance of the vertex in the graph, as it may have state
// applied to it that we need to verify for testing.
//
LabelTestVertex v = new LabelTestVertex(Integer.toString(id));
Collection<AbstractTestVertex> vertices = graph.getVertices();
for (AbstractTestVertex vertex : vertices) {
if (v.equals(vertex)) {
return vertex;
AbstractTestVertex v = runSwing(() -> {
LabelTestVertex labelVertex = new LabelTestVertex(Integer.toString(id));
Collection<AbstractTestVertex> vertices = graph.getVertices();
for (AbstractTestVertex vertex : vertices) {
if (labelVertex.equals(vertex)) {
return vertex;
}
}
}
return labelVertex;
});
graph.addVertex(v);
return v;