Search in sources :

Example 1 with SMRootTestProxyFormatter

use of com.intellij.execution.testframework.sm.runner.ui.SMRootTestProxyFormatter 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;
}
Also used : SMTestProxy(com.intellij.execution.testframework.sm.runner.SMTestProxy) TestTreeRenderer(com.intellij.execution.testframework.sm.runner.ui.TestTreeRenderer) TestTreeView(com.intellij.execution.testframework.TestTreeView) SMRootTestProxyFormatter(com.intellij.execution.testframework.sm.runner.ui.SMRootTestProxyFormatter) ExternalSystemExecuteTaskTask(com.intellij.openapi.externalSystem.service.internal.ExternalSystemExecuteTaskTask) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TestTreeView (com.intellij.execution.testframework.TestTreeView)1 SMTestProxy (com.intellij.execution.testframework.sm.runner.SMTestProxy)1 SMRootTestProxyFormatter (com.intellij.execution.testframework.sm.runner.ui.SMRootTestProxyFormatter)1 TestTreeRenderer (com.intellij.execution.testframework.sm.runner.ui.TestTreeRenderer)1 ExternalSystemExecuteTaskTask (com.intellij.openapi.externalSystem.service.internal.ExternalSystemExecuteTaskTask)1 NotNull (org.jetbrains.annotations.NotNull)1