From 30c59473187573eca01c8b260fb743597e07ee1d Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 26 Aug 2014 19:22:23 +0400 Subject: [PATCH] testng: show root node status with respect to already passed tests (IDEA-128289) --- .../execution/testframework/TestTreeView.java | 4 ++++ .../testng/ui/ResultTreeRenderer.java | 14 ++++++++------ .../theoryinpractice/testng/ui/TestNGResults.java | 4 ++++ .../testng/ui/TestNGTestTreeView.java | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java b/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java index 2ecb0fca32cd..839568b4c2a9 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestTreeView.java @@ -52,6 +52,10 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro public abstract AbstractTestProxy getSelectedTest(@NotNull TreePath selectionPath); + protected TestFrameworkRunningModel getTestFrameworkRunningModel() { + return myModel; + } + @Nullable public AbstractTestProxy getSelectedTest() { TreePath[] paths = getSelectionPaths(); diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/ResultTreeRenderer.java b/plugins/testng/src/com/theoryinpractice/testng/ui/ResultTreeRenderer.java index ba30f43b66f0..9ea4429447fe 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/ui/ResultTreeRenderer.java +++ b/plugins/testng/src/com/theoryinpractice/testng/ui/ResultTreeRenderer.java @@ -16,6 +16,7 @@ package com.theoryinpractice.testng.ui; import com.intellij.execution.testframework.PoolOfTestIcons; +import com.intellij.execution.testframework.TestFrameworkRunningModel; import com.intellij.icons.AllIcons; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; @@ -34,10 +35,11 @@ import javax.swing.tree.DefaultMutableTreeNode; */ public class ResultTreeRenderer extends ColoredTreeCellRenderer { - private final TestNGConsoleProperties consoleProperties; - public ResultTreeRenderer(TestNGConsoleProperties consoleProperties) { - this.consoleProperties = consoleProperties; + private TestFrameworkRunningModel model; + + public ResultTreeRenderer(TestFrameworkRunningModel model) { + this.model = model; } @Override @@ -47,7 +49,7 @@ public class ResultTreeRenderer extends ColoredTreeCellRenderer TestProxy proxy = ((TestNodeDescriptor) node.getUserObject()).getElement(); if (node == tree.getModel().getRoot()) { TreeRootNode root = (TreeRootNode) proxy; - if (node.getChildCount() == 0) { + if (node.getChildCount() == 0 && !((TestNGResults)model).hasFinishedTests()) { if ((root.isStarted() && root.isInProgress()) || (root.isInProgress() && !root.isStarted())) { setIcon(PoolOfTestIcons.NOT_RAN); append("Instantiating tests... ", SimpleTextAttributes.REGULAR_ATTRIBUTES); @@ -64,13 +66,13 @@ public class ResultTreeRenderer extends ColoredTreeCellRenderer append(root.isInProgress() ? "Running tests..." : "Test Results", SimpleTextAttributes.REGULAR_ATTRIBUTES); } - if (consoleProperties.isPaused()) { + if (model.getProperties().isPaused()) { setIcon(AllIcons.RunConfigurations.TestPaused); } } else { if (proxy.getResultMessage() != null) { final TestResultMessage result = proxy.getResultMessage(); - final String name = TestProxy.toDisplayText(result, consoleProperties.getProject()); + final String name = TestProxy.toDisplayText(result, model.getProperties().getProject()); append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES); } else { append(proxy.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java index 442e03440ac5..35b76d3e8367 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java +++ b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java @@ -466,6 +466,10 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn this.failedToStart = failedToStart; } + public boolean hasFinishedTests() { + return count > 0; + } + private class OpenSourceSelectionListener implements TreeSelectionListener { public void valueChanged(TreeSelectionEvent e) { diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGTestTreeView.java b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGTestTreeView.java index 48f252d828ee..7e5b7995af0c 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGTestTreeView.java +++ b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGTestTreeView.java @@ -33,7 +33,7 @@ import javax.swing.tree.TreeSelectionModel; public class TestNGTestTreeView extends TestTreeView { protected TreeCellRenderer getRenderer(final TestConsoleProperties properties) { - return new ResultTreeRenderer((TestNGConsoleProperties)properties); + return new ResultTreeRenderer(getTestFrameworkRunningModel()); } public TestProxy getSelectedTest(@NotNull TreePath treepath) {