use of org.eclipse.n4js.tester.domain.TestElement in project n4js by eclipse.
the class TestResultsView method onSingleClick.
/**
* Invoked when user double-clicks a result node in the UI.
*
* On invocation clears stack trace text are. If selection is a test case with stack trace, trace is shown in the
* trace area.
*/
protected void onSingleClick() {
stackTrace.setText("");
final ISelection selection = testTreeViewer.getSelection();
if (selection.isEmpty()) {
return;
}
if (selection instanceof IStructuredSelection) {
final Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof ResultNode) {
final ResultNode resultNode = (ResultNode) element;
final TestElement testElement = resultNode.getElement();
if (testElement instanceof TestCase) {
final TestCase testCase = (TestCase) testElement;
final TestResult result = testCase.getResult();
if (result != null) {
if (result.getTrace() != null && !result.getTrace().isEmpty()) {
final List<String> trace = newArrayList(result.getTrace());
final String firstLine = trace.get(0);
if ("Error".equals(firstLine) && !isNullOrEmpty(result.getMessage())) {
trace.set(0, result.getMessage());
}
final StringBuilder sb = new StringBuilder();
trace.forEach(line -> sb.append(line).append(lineSeparator()));
stackTrace.setText(sb.toString());
stackTrace.setSelection(0);
} else if ((SKIPPED_IGNORE.equals(result.getTestStatus()) || SKIPPED_FIXME.equals(result.getTestStatus())) && !isNullOrEmpty(result.getMessage())) {
stackTrace.setText(result.getMessage());
stackTrace.setSelection(0);
}
}
}
}
}
}
use of org.eclipse.n4js.tester.domain.TestElement in project n4js by eclipse.
the class TestResultsView method onDoubleClick.
/**
* Invoked when user double-clicks a result node in the UI.
*/
protected void onDoubleClick() {
final ISelection selection = testTreeViewer.getSelection();
final ResultNode resultNode = (ResultNode) ((IStructuredSelection) selection).getFirstElement();
if (resultNode == null) {
return;
}
TestElement testElement = resultNode.getElement();
if (testElement instanceof TestCase) {
final URI testCaseURI = ((TestCase) testElement).getURI();
if (testCaseURI == null) {
return;
}
final IN4JSEclipseProject project = core.findProject(testCaseURI).orNull();
if (null != project && project.exists()) {
final URI moduleLocation = testCaseURI.trimFragment();
final String[] projectRelativeSegments = moduleLocation.deresolve(project.getLocation()).segments();
final String path = Joiner.on(SEPARATOR).join(copyOfRange(projectRelativeSegments, 1, projectRelativeSegments.length));
final IFile module = project.getProject().getFile(path);
if (null != module && module.isAccessible()) {
uriOpener.open(testCaseURI, true);
} else {
openError(getShell(), "Cannot open editor", "Test class not found in selected project.");
}
} else {
openError(getShell(), "Cannot open editor", "The container project not found in the workspace.");
}
}
}
Aggregations