Search in sources :

Example 16 with LayoutAlgorithmData

use of org.eclipse.elk.core.data.LayoutAlgorithmData in project elk by eclipse.

the class LayoutTestRunner method initializeAlgorithms.

/**
 * Loads all algorithms configured in the test class.
 */
private void initializeAlgorithms(final TestClass testClass, final List<Throwable> errors) {
    testAlgorithms.addAll(TestAlgorithm.fromTestClass(testClass, errors));
    // If we have whitebox tests, we need to check stuff
    if (!whiteboxTests.isEmpty()) {
        // Ensure that there is at least one specific layout algorithm
        if (testAlgorithms.isEmpty() || testAlgorithms.get(0).getAlgorithmData() == null) {
            errors.add(new Exception("Whitebox tests require explicit @Algorithm annotations."));
        } else {
            // Ensure that all algorithms are whitebox testable
            for (TestAlgorithm algorithm : testAlgorithms) {
                LayoutAlgorithmData algorithmData = algorithm.getAlgorithmData();
                AbstractLayoutProvider layoutProvider = algorithmData.getInstancePool().fetch();
                if (!(layoutProvider instanceof IWhiteBoxTestable)) {
                    errors.add(new Exception("Algorithm " + algorithmData.getId() + " is not whitebox testable."));
                }
                algorithmData.getInstancePool().release(layoutProvider);
            }
        }
    }
    if (testAlgorithms.isEmpty()) {
        testAlgorithms.add(TestAlgorithm.identity());
    }
}
Also used : LayoutAlgorithmData(org.eclipse.elk.core.data.LayoutAlgorithmData) TestAlgorithm(org.eclipse.elk.alg.test.framework.algorithm.TestAlgorithm) IWhiteBoxTestable(org.eclipse.elk.core.testing.IWhiteBoxTestable) AbstractLayoutProvider(org.eclipse.elk.core.AbstractLayoutProvider)

Aggregations

LayoutAlgorithmData (org.eclipse.elk.core.data.LayoutAlgorithmData)16 ElkNode (org.eclipse.elk.graph.ElkNode)5 AbstractLayoutProvider (org.eclipse.elk.core.AbstractLayoutProvider)4 LayoutMetaDataService (org.eclipse.elk.core.data.LayoutMetaDataService)4 List (java.util.List)2 Graph (org.eclipse.elk.alg.spore.graph.Graph)2 LayoutCategoryData (org.eclipse.elk.core.data.LayoutCategoryData)2 ElkUtil (org.eclipse.elk.core.util.ElkUtil)2 ElkBendPoint (org.eclipse.elk.graph.ElkBendPoint)2 Sets (com.google.common.collect.Sets)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 TEdge (org.eclipse.elk.alg.common.TEdge)1 IOverlapHandler (org.eclipse.elk.alg.common.spore.IOverlapHandler)1 InternalProperties (org.eclipse.elk.alg.common.spore.InternalProperties)1 ScanlineOverlapCheck (org.eclipse.elk.alg.common.spore.ScanlineOverlapCheck)1 SVGImage (org.eclipse.elk.alg.common.utils.SVGImage)1 ElkGraphTransformer (org.eclipse.elk.alg.disco.transform.ElkGraphTransformer)1