Search in sources :

Example 1 with TestAfterProcessor

use of org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor in project elk by eclipse.

the class InLayerConstraintProcessorTest method testValidNodeOrder.

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests
@TestAfterProcessor(InLayerConstraintProcessor.class)
public void testValidNodeOrder(final Object graph) {
    LGraph lGraph = (LGraph) graph;
    for (Layer layer : lGraph) {
        InLayerConstraint lastConstraint = null;
        for (LNode node : layer) {
            InLayerConstraint currentConstraint = node.getProperty(InternalProperties.IN_LAYER_CONSTRAINT);
            if (lastConstraint != null && currentConstraint != lastConstraint) {
                // if the value changes check valid transitions
                String error = "Invalid constraint transition: " + lastConstraint.name() + " -> " + currentConstraint.name();
                if (currentConstraint == InLayerConstraint.NONE) {
                    assertTrue(error, lastConstraint == InLayerConstraint.TOP);
                } else if (currentConstraint == InLayerConstraint.BOTTOM) {
                    assertTrue(error, lastConstraint == InLayerConstraint.TOP || lastConstraint == InLayerConstraint.NONE);
                }
                lastConstraint = currentConstraint;
            }
            lastConstraint = currentConstraint;
        }
    }
}
Also used : InLayerConstraint(org.eclipse.elk.alg.layered.options.InLayerConstraint) LNode(org.eclipse.elk.alg.layered.graph.LNode) LGraph(org.eclipse.elk.alg.layered.graph.LGraph) Layer(org.eclipse.elk.alg.layered.graph.Layer) TestAfterProcessor(org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)

Example 2 with TestAfterProcessor

use of org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor in project elk by eclipse.

the class SortByInputModelProcessorTest method preserveNodeAndEdgeOrder.

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests
@TestAfterProcessor(LayerSweepCrossingMinimizer.class)
public void preserveNodeAndEdgeOrder(final Object graph) {
    LGraph lgraph = (LGraph) graph;
    int layerIndex = 0;
    for (Layer layer : lgraph) {
        int nodeIndex = 0;
        for (LNode node : layer.getNodes()) {
            if (node.getType() == NodeType.NORMAL) {
                assertEquals("A node is on an unexpected position.", "n_l" + layerIndex + "p" + nodeIndex, node.toString());
            }
            nodeIndex++;
        }
        layerIndex++;
    }
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) LGraph(org.eclipse.elk.alg.layered.graph.LGraph) Layer(org.eclipse.elk.alg.layered.graph.Layer) TestAfterProcessor(org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)

Example 3 with TestAfterProcessor

use of org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor in project elk by eclipse.

the class LayerConstraintProcessorTest method noEmptyLayers.

/**
 * All labels on ports and edges have an assigned {@link LabelSide}.
 */
@TestAfterProcessor(LayerConstraintPostprocessor.class)
public void noEmptyLayers(Object graph) {
    LGraph lGraph = (LGraph) graph;
    lGraph.getLayers().stream().forEach(layer -> assertTrue(!layer.getNodes().isEmpty()));
}
Also used : LGraph(org.eclipse.elk.alg.layered.graph.LGraph) TestAfterProcessor(org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)

Example 4 with TestAfterProcessor

use of org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor in project elk by eclipse.

the class BasicLayerAssignmentTest method testEdgesPointTowardsNextLayers.

@TestAfterProcessor(CoffmanGrahamLayerer.class)
@TestAfterProcessor(InteractiveLayerer.class)
@TestAfterProcessor(LongestPathLayerer.class)
@TestAfterProcessor(MinWidthLayerer.class)
@TestAfterProcessor(NetworkSimplexLayerer.class)
@TestAfterProcessor(StretchWidthLayerer.class)
public void testEdgesPointTowardsNextLayers(final Object graph) {
    LGraph lGraph = (LGraph) graph;
    // Assign increasing IDs to the layers
    int nextLayerId = 0;
    for (Layer layer : lGraph) {
        layer.id = nextLayerId++;
    }
    for (Layer layer : lGraph) {
        for (LNode node : layer) {
            int nodeLayerId = node.getLayer().id;
            for (LEdge edge : node.getOutgoingEdges()) {
                assertTrue(nodeLayerId < edge.getTarget().getNode().getLayer().id);
            }
        }
    }
}
Also used : LEdge(org.eclipse.elk.alg.layered.graph.LEdge) LNode(org.eclipse.elk.alg.layered.graph.LNode) LGraph(org.eclipse.elk.alg.layered.graph.LGraph) Layer(org.eclipse.elk.alg.layered.graph.Layer) TestAfterProcessor(org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)

Example 5 with TestAfterProcessor

use of org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor in project elk by eclipse.

the class BasicLayerAssignmentTest method testNoLayerlessNodes.

// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tests
@TestAfterProcessor(CoffmanGrahamLayerer.class)
@TestAfterProcessor(InteractiveLayerer.class)
@TestAfterProcessor(LongestPathLayerer.class)
@TestAfterProcessor(MinWidthLayerer.class)
@TestAfterProcessor(NetworkSimplexLayerer.class)
@TestAfterProcessor(StretchWidthLayerer.class)
public void testNoLayerlessNodes(final Object graph) {
    LGraph lGraph = (LGraph) graph;
    assertTrue(lGraph.getLayerlessNodes().isEmpty());
}
Also used : LGraph(org.eclipse.elk.alg.layered.graph.LGraph) TestAfterProcessor(org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)

Aggregations

TestAfterProcessor (org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)20 LGraph (org.eclipse.elk.alg.layered.graph.LGraph)19 LNode (org.eclipse.elk.alg.layered.graph.LNode)16 Layer (org.eclipse.elk.alg.layered.graph.Layer)13 LEdge (org.eclipse.elk.alg.layered.graph.LEdge)6 Lists (com.google.common.collect.Lists)3 HashSet (java.util.HashSet)3 List (java.util.List)3 LayeredOptions (org.eclipse.elk.alg.layered.options.LayeredOptions)3 LayoutTestRunner (org.eclipse.elk.alg.test.framework.LayoutTestRunner)3 Algorithm (org.eclipse.elk.alg.test.framework.annotations.Algorithm)3 DefaultConfiguration (org.eclipse.elk.alg.test.framework.annotations.DefaultConfiguration)3 GraphResourceProvider (org.eclipse.elk.alg.test.framework.annotations.GraphResourceProvider)3 AbstractResourcePath (org.eclipse.elk.alg.test.framework.io.AbstractResourcePath)3 ModelResourcePath (org.eclipse.elk.alg.test.framework.io.ModelResourcePath)3 RunWith (org.junit.runner.RunWith)3 Deque (java.util.Deque)2 LinkedList (java.util.LinkedList)2 Random (java.util.Random)2 Collectors (java.util.stream.Collectors)2