use of org.eclipse.elk.alg.test.framework.algorithm.TestAlgorithm 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());
}
}
use of org.eclipse.elk.alg.test.framework.algorithm.TestAlgorithm in project elk by eclipse.
the class ExperimentStatement method evaluate.
@Override
public void evaluate() throws Throwable {
createTestGraph();
// Create a test controller if we have whitebox tests and the layout algorithm
TestController testController = null;
if (!this.experimentRunner.getParentRunner().getWhiteboxTests().isEmpty()) {
TestAlgorithm algorithm = experimentRunner.getExperimentalObject().getLayoutAlgorithm();
testController = new TestController(algorithm.getAlgorithmData().getId());
testController.addLayoutExecutionListener(this);
}
// Let the recursive graph layout engine run the layout algorithm (if we have a test controller, that will
// automatically cause white box tests to run)
RecursiveGraphLayoutEngine layoutEngine = new RecursiveGraphLayoutEngine();
layoutEngine.layout(testGraph, testController, new BasicProgressMonitor());
// Stop listening to the test controller
if (testController != null) {
testController.removeLayoutExecutionListener(this);
}
// Run blackbox tests now that the layout algorithm has finished
runBlackboxTests();
// Cleanly handle all whitebox tests that did not execute because their processors didn't run
simulateWhiteboxTestsForNotifiers();
testGraph = null;
}
Aggregations