use of com.intellij.execution.testframework.TestTreeView in project intellij-community by JetBrains.
the class GradleTestsExecutionConsoleManager method attachExecutionConsole.
@NotNull
@Override
public GradleTestsExecutionConsole attachExecutionConsole(@NotNull final ExternalSystemTask task, @NotNull final Project project, @NotNull final ExternalSystemRunConfiguration configuration, @NotNull final Executor executor, @NotNull final ExecutionEnvironment env, @NotNull final ProcessHandler processHandler) throws ExecutionException {
final GradleConsoleProperties consoleProperties = new GradleConsoleProperties(configuration, executor);
String testFrameworkName = configuration.getSettings().getExternalSystemId().getReadableName();
String splitterPropertyName = SMTestRunnerConnectionUtil.getSplitterPropertyName(testFrameworkName);
final GradleTestsExecutionConsole consoleView = new GradleTestsExecutionConsole(consoleProperties, splitterPropertyName);
consoleView.initTaskExecutionView(project, processHandler, task.getId());
SMTestRunnerConnectionUtil.initConsoleView(consoleView, testFrameworkName);
consoleView.attachToProcess(processHandler);
final TestTreeView testTreeView = consoleView.getResultsViewer().getTreeView();
if (testTreeView != null) {
TestTreeRenderer originalRenderer = ObjectUtils.tryCast(testTreeView.getCellRenderer(), TestTreeRenderer.class);
if (originalRenderer != null) {
originalRenderer.setAdditionalRootFormatter(new SMRootTestProxyFormatter() {
@Override
public void format(@NotNull SMTestProxy.SMRootTestProxy testProxy, @NotNull TestTreeRenderer renderer) {
final TestStateInfo.Magnitude magnitude = testProxy.getMagnitudeInfo();
if (magnitude == TestStateInfo.Magnitude.RUNNING_INDEX) {
renderer.clear();
renderer.append(GradleBundle.message("gradle.test.runner.ui.tests.tree.presentation.labels.waiting.tests"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
} else if (!testProxy.isInProgress() && testProxy.isEmptySuite()) {
renderer.clear();
renderer.append(GradleBundle.message("gradle.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
});
}
}
if (task instanceof ExternalSystemExecuteTaskTask) {
final ExternalSystemExecuteTaskTask executeTask = (ExternalSystemExecuteTaskTask) task;
if (executeTask.getArguments() == null || !StringUtil.contains(executeTask.getArguments(), "--tests")) {
executeTask.appendArguments("--tests *");
}
}
return consoleView;
}
use of com.intellij.execution.testframework.TestTreeView in project intellij-plugins by JetBrains.
the class JstdConsoleView method initUI.
@Override
public void initUI() {
super.initUI();
if (myServer == null) {
return;
}
TestTreeView treeView = this.getResultsViewer().getTreeView();
TestTreeRenderer originalRenderer = ObjectUtils.tryCast(treeView.getCellRenderer(), TestTreeRenderer.class);
if (originalRenderer != null) {
myFormatter = new JstdRootTestProxyFormatter(myServer, treeView);
originalRenderer.setAdditionalRootFormatter(myFormatter);
}
if (!myServer.isStopped() && myServer.getCapturedBrowsers().isEmpty()) {
myServer.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onServerStarted() {
print("To capture a browser open ", ConsoleViewContentType.SYSTEM_OUTPUT);
String url = myServer.getServerUrl() + "/capture";
printHyperlink(url, new OpenUrlHyperlinkInfo(url));
print("\n", ConsoleViewContentType.SYSTEM_OUTPUT);
}
}, this);
}
myServer.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onServerTerminated(int exitCode) {
print("JsTestDriver server finished with exit code " + exitCode + "\n", ConsoleViewContentType.SYSTEM_OUTPUT);
JstdToolWindowManager.getInstance(getProperties().getProject()).show();
}
}, this);
}
use of com.intellij.execution.testframework.TestTreeView in project intellij-community by JetBrains.
the class TestTreeRenderer method customizeCellRenderer.
public void customizeCellRenderer(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
myRow = row;
myDurationWidth = -1;
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
final Object userObj = node.getUserObject();
if (userObj instanceof SMTRunnerNodeDescriptor) {
final SMTRunnerNodeDescriptor desc = (SMTRunnerNodeDescriptor) userObj;
final SMTestProxy testProxy = desc.getElement();
if (testProxy instanceof SMTestProxy.SMRootTestProxy) {
SMTestProxy.SMRootTestProxy rootTestProxy = (SMTestProxy.SMRootTestProxy) testProxy;
if (node.isLeaf()) {
TestsPresentationUtil.formatRootNodeWithoutChildren(rootTestProxy, this);
} else {
TestsPresentationUtil.formatRootNodeWithChildren(rootTestProxy, this);
}
if (myAdditionalRootFormatter != null) {
myAdditionalRootFormatter.format(rootTestProxy, this);
}
} else {
TestsPresentationUtil.formatTestProxy(testProxy, this);
}
if (TestConsoleProperties.SHOW_INLINE_STATISTICS.value(myConsoleProperties)) {
String durationString = testProxy.getDurationString(myConsoleProperties);
if (durationString != null) {
durationString = " " + durationString;
myDurationWidth = getFontMetrics(getFont()).stringWidth(durationString);
if (((TestTreeView) myTree).isExpandableHandlerVisibleForCurrentRow(myRow)) {
append(durationString);
}
}
}
//Done
return;
}
//strange node
final String text = node.toString();
//no icon
append(text != null ? text : SPACE_STRING, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
Aggregations