testng: show root node status with respect to already passed tests (IDEA-128289)

This commit is contained in:
Anna Kozlova
2014-08-26 21:00:47 +04:00
parent fe17f8c960
commit 30c5947318
4 changed files with 17 additions and 7 deletions
@@ -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();
@@ -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);
@@ -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) {
@@ -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) {