Search in sources :

Example 1 with TestTreeRenderer

use of com.intellij.execution.testframework.sm.runner.ui.TestTreeRenderer 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)

Example 2 with TestTreeRenderer

use of com.intellij.execution.testframework.sm.runner.ui.TestTreeRenderer 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);
}
Also used : TestTreeRenderer(com.intellij.execution.testframework.sm.runner.ui.TestTreeRenderer) OpenUrlHyperlinkInfo(com.intellij.ide.browsers.OpenUrlHyperlinkInfo) TestTreeView(com.intellij.execution.testframework.TestTreeView) JstdServerLifeCycleAdapter(com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter)

Aggregations

TestTreeView (com.intellij.execution.testframework.TestTreeView)2 TestTreeRenderer (com.intellij.execution.testframework.sm.runner.ui.TestTreeRenderer)2 JstdServerLifeCycleAdapter (com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter)1 SMTestProxy (com.intellij.execution.testframework.sm.runner.SMTestProxy)1 SMRootTestProxyFormatter (com.intellij.execution.testframework.sm.runner.ui.SMRootTestProxyFormatter)1 OpenUrlHyperlinkInfo (com.intellij.ide.browsers.OpenUrlHyperlinkInfo)1 ExternalSystemExecuteTaskTask (com.intellij.openapi.externalSystem.service.internal.ExternalSystemExecuteTaskTask)1 NotNull (org.jetbrains.annotations.NotNull)1