From 8fc03ec705a1464104027aac6a381eec8b446e40 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Thu, 12 Nov 2009 00:31:21 +0300 Subject: [PATCH] fixed [IDEADEV-41319] test runner: do not show green balloon and green progress bar if no tests were found --- .../openapi/progress/util/ColorProgressBar.java | 4 + .../runner/ui/SMTRunnerNotificationsHandler.java | 7 ++ .../sm/runner/ui/SMTestRunnerResultsForm.java | 8 ++ .../runner/ui/SMTRunnerUIActionsHandlerTest.java | 114 +++++++++++++++++++++ .../sm/runner/ui/SMTestRunnerResultsFormTest.java | 22 +++- .../execution/testframework/ui/TestStatusLine.java | 4 + 6 files changed, 158 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java index 0da4cb0dc0..b93d42c055 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ColorProgressBar.java @@ -211,6 +211,10 @@ public class ColorProgressBar extends JComponent { return dimension; } + public Color getColor() { + return myColor; + } + @SuppressWarnings({"HardCodedStringLiteral"}) public static void main(String[] args) { JFrame frame = new JFrame("ColorProgressBar Test"); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerNotificationsHandler.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerNotificationsHandler.java index e1ddd11800..442b67fdbb 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerNotificationsHandler.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerNotificationsHandler.java @@ -16,6 +16,7 @@ package com.intellij.execution.testframework.sm.runner.ui; import com.intellij.execution.testframework.TestConsoleProperties; +import com.intellij.execution.testframework.sm.SMTestsRunnerBundle; import com.intellij.execution.testframework.sm.runner.SMTRunnerEventsAdapter; import com.intellij.execution.testframework.sm.runner.SMTestProxy; import com.intellij.execution.testframework.sm.runner.states.TestStateInfo; @@ -66,6 +67,12 @@ public class SMTRunnerNotificationsHandler extends SMTRunnerEventsAdapter { type = MessageType.ERROR; break; case COMPLETE_INDEX: + if (testsRoot.getChildren().size() == 0) { + msg = SMTestsRunnerBundle.message("sm.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found"); + type = MessageType.ERROR; + break; + } + // else same as: PASSED_INDEX case PASSED_INDEX: msg = "Tests passed"; type = MessageType.INFO; diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java index 7dfaff2867..3ebd4baa0c 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsForm.java @@ -216,6 +216,10 @@ public class SMTestRunnerResultsForm extends TestResultsPanel implements TestFra } updateStatusLabel(); + if (myTestsRootNode.getChildren().size() == 0) { + // no tests found + myStatusLine.setStatusColor(ColorProgressBar.RED); + } myAnimator.stopMovie(); myTreeBuilder.updateFromRoot(); @@ -374,6 +378,10 @@ public class SMTestRunnerResultsForm extends TestResultsPanel implements TestFra return myTestsFailuresCount; } + protected Color getTestsStatusColor() { + return myStatusLine.getStatusColor(); + } + protected int getTestsTotal() { return myTestsTotal; } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java index 1964c0a211..76d35f4543 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTRunnerUIActionsHandlerTest.java @@ -171,6 +171,120 @@ public class SMTRunnerUIActionsHandlerTest extends BaseSMTRunnerTestCase { } + public void testSelectFirstDeffect_Priority_Error() { + // Priority: error -> failure -> pending + TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, true); + mySuite.setStarted(); + + final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite); + testsSuite.setStarted(); + + // pending test + final SMTestProxy testPending = createTestProxy("testPending", testsSuite); + testPending.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending); + testPending.setTestIgnored("", ""); + + //failed test + final SMTestProxy testFailed = createTestProxy("testFailed", testsSuite); + testFailed.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testFailed); + testFailed.setTestFailed("", "", false); + + //error test + final SMTestProxy testError = createTestProxy("testError", testsSuite); + testError.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testError); + testError.setTestFailed("", "", true); + + // Second error test just to check that first failed will be selected + final SMTestProxy testError2 = createTestProxy("testError2", testsSuite); + testError2.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testError2); + testError2.setTestFailed("", "", true); + + // finish suite + testsSuite.setFinished(); + assertNull(mySelectedTestProxy); + + //testing finished + mySuite.setFinished(); + assertNull(mySelectedTestProxy); + + myUIActionsHandler.onTestingFinished(myResultsViewer); + assertEquals(testError, mySelectedTestProxy); + } + + public void testSelectFirstDeffect_Priority_Failure() { + // Priority: error -> failure -> pending + TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, true); + mySuite.setStarted(); + + final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite); + testsSuite.setStarted(); + + // pending test + final SMTestProxy testPending = createTestProxy("testPending", testsSuite); + testPending.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending); + testPending.setTestIgnored("", ""); + + //failed test + final SMTestProxy testFailed = createTestProxy("testFailed", testsSuite); + testFailed.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testFailed); + testFailed.setTestFailed("", "", false); + + // Second failed test just to check that first failed will be selected + final SMTestProxy testFailed2 = createTestProxy("testFailed2", testsSuite); + testFailed2.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testFailed2); + testFailed2.setTestFailed("", "", false); + + // finish suite + testsSuite.setFinished(); + assertNull(mySelectedTestProxy); + + //testing finished + mySuite.setFinished(); + assertNull(mySelectedTestProxy); + + myUIActionsHandler.onTestingFinished(myResultsViewer); + assertEquals(testFailed, mySelectedTestProxy); + } + + public void testSelectFirstDeffect_Priority_Pending() { + // Priority: error -> failure -> pending + TestConsoleProperties.SELECT_FIRST_DEFECT.set(myProperties, true); + mySuite.setStarted(); + + final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite); + testsSuite.setStarted(); + + // pending test + final SMTestProxy testPending = createTestProxy("testPending", testsSuite); + testPending.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending); + testPending.setTestIgnored("", ""); + + // Second pending test just to check that first failed will be selected + final SMTestProxy testPending2 = createTestProxy("testPending2", testsSuite); + testPending2.setStarted(); + myUIActionsHandler.onTestNodeAdded(myResultsViewer, testPending2); + testPending2.setTestIgnored("", ""); + + // finish suite + testsSuite.setFinished(); + assertNull(mySelectedTestProxy); + + //testing finished + mySuite.setFinished(); + assertNull(mySelectedTestProxy); + + myUIActionsHandler.onTestingFinished(myResultsViewer); + assertEquals(testPending, mySelectedTestProxy); + } + public void testTrackRunningTest() { TestConsoleProperties.TRACK_RUNNING_TEST.set(myProperties, true); mySuite.setStarted(); diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java index 72efb172db..aa25e75e99 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/SMTestRunnerResultsFormTest.java @@ -21,6 +21,7 @@ import com.intellij.execution.testframework.sm.Marker; import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase; import com.intellij.execution.testframework.sm.runner.GeneralToSMTRunnerEventsConvertor; import com.intellij.execution.testframework.sm.runner.SMTestProxy; +import com.intellij.openapi.progress.util.ColorProgressBar; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Ref; import org.jetbrains.annotations.NotNull; @@ -338,6 +339,26 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase { myResultsViewer.onCustomProgressTestFailed(); assertEquals(1, myResultsViewer.getTestsFailuresCount()); + + assertEquals(ColorProgressBar.RED, myResultsViewer.getTestsStatusColor()); + } + + public void testCustomProgress_Terminated() { + myResultsViewer.onTestingStarted(myTestsRootNode); + + final SMTestProxy test1 = createTestProxy("some_test1", myTestsRootNode); + myResultsViewer.onTestStarted(test1); + + myResultsViewer.onTestingFinished(myTestsRootNode); + + assertEquals(ColorProgressBar.GREEN, myResultsViewer.getTestsStatusColor()); + } + + public void testCustomProgress_NotRun() { + myResultsViewer.onTestingStarted(myTestsRootNode); + myResultsViewer.onTestingFinished(myTestsRootNode); + + assertEquals(ColorProgressBar.RED, myResultsViewer.getTestsStatusColor()); } public void testCustomProgress_UnSetCount() { @@ -482,5 +503,4 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase { myResultsViewer.onTestStarted(createTestProxy("some_test1", myTestsRootNode)); assertEquals(4, myResultsViewer.getTestsCurrentCount()); } - } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java index afae1cc0e6..7e8a7fd6be 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestStatusLine.java @@ -41,6 +41,10 @@ public class TestStatusLine extends JPanel { myProgressBar.setColor(color); } + public Color getStatusColor() { + return myProgressBar.getColor(); + } + public void setFraction(double v) { myProgressBar.setFraction(v); } -- 2.11.4.GIT