1 package com
.intellij
.execution
.testframework
.sm
.runner
.ui
;
3 import com
.intellij
.execution
.testframework
.TestConsoleProperties
;
4 import com
.intellij
.execution
.testframework
.sm
.runner
.SMTRunnerEventsAdapter
;
5 import com
.intellij
.execution
.testframework
.sm
.runner
.SMTestProxy
;
6 import com
.intellij
.execution
.testframework
.sm
.runner
.states
.TestStateInfo
;
7 import com
.intellij
.openapi
.project
.Project
;
8 import com
.intellij
.openapi
.ui
.MessageType
;
9 import com
.intellij
.openapi
.util
.Comparing
;
10 import com
.intellij
.openapi
.wm
.ToolWindowId
;
11 import com
.intellij
.openapi
.wm
.ToolWindowManager
;
12 import org
.jetbrains
.annotations
.NotNull
;
17 * @author Roman Chernyatchik
19 public class SMTRunnerNotificationsHandler
extends SMTRunnerEventsAdapter
{
20 private final TestConsoleProperties myConsoleProperties
;
21 //private boolean myFirstDefectWasFound;
23 public SMTRunnerNotificationsHandler(@NotNull final TestConsoleProperties consoleProperties
) {
24 myConsoleProperties
= consoleProperties
;
27 public void onTestingStarted(@NotNull SMTestProxy testsRoot
) {
28 //myFirstDefectWasFound = false;
31 public void onTestingFinished(@NotNull SMTestProxy testsRoot
) {
33 final MessageType type
;
35 final TestStateInfo
.Magnitude magnitude
= testsRoot
.getMagnitudeInfo();
39 msg
= "Tests skipped";
40 type
= MessageType
.WARNING
;
44 msg
= "Tests were not started";
45 type
= MessageType
.WARNING
;
51 type
= MessageType
.ERROR
;
56 type
= MessageType
.INFO
;
69 public void onTestFailed(@NotNull SMTestProxy test
) {
70 // TODO : if user doesn't close this balloon then user will not see 'tests failed' balloon
71 //if (!myFirstDefectWasFound) {
72 // // notify about defect on the fly
73 // if (test.isDefect()) {
74 // final TestStateInfo.Magnitude magnitude = test.getMagnitudeInfo();
75 // //noinspection EnumSwitchStatementWhichMissesCases
76 // switch (magnitude) {
79 // myFirstDefectWasFound = true;
80 // notify("Tests will fail", MessageType.WARNING);
89 private void notify(final String msg
, final MessageType type
) {
90 SwingUtilities
.invokeLater(new Runnable() {
92 final Project project
= myConsoleProperties
.getProject();
93 if ( project
.isDisposed()) {
97 if (myConsoleProperties
== null) {
100 final String testRunDebugId
= myConsoleProperties
.isDebug() ? ToolWindowId
.DEBUG
: ToolWindowId
.RUN
;
101 final ToolWindowManager toolWindowManager
= ToolWindowManager
.getInstance(project
);
102 if (!Comparing
.strEqual(toolWindowManager
.getActiveToolWindowId(), testRunDebugId
)) {
103 toolWindowManager
.notifyByBalloon(testRunDebugId
, type
, msg
, null, null);