Search in sources :

Example 1 with IWhiteBoxTestable

use of org.eclipse.elk.core.testing.IWhiteBoxTestable 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

TestAlgorithm (org.eclipse.elk.alg.test.framework.algorithm.TestAlgorithm)1 AbstractLayoutProvider (org.eclipse.elk.core.AbstractLayoutProvider)1 LayoutAlgorithmData (org.eclipse.elk.core.data.LayoutAlgorithmData)1 IWhiteBoxTestable (org.eclipse.elk.core.testing.IWhiteBoxTestable)1