From 4e5e0bab5157d51162fe30466d2e4f12f0cd1569 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 3 Jul 2013 19:29:50 +0200 Subject: [PATCH] testng: unify notifications --- .../execution/testframework/TestsUIUtil.java | 2 +- .../configuration/TestNGRunnableState.java | 19 +------------------ .../testng/ui/TestNGResults.java | 5 +++++ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java index b341326a3c55..090ad93f45e5 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java @@ -226,7 +226,7 @@ public class TestsUIUtil { myType = MessageType.INFO; } if (myComment != null) { - myText += " (" + myComment + ")"; + myText += " " + myComment; } myBalloonText = myTitle + ": " + myText; } diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java index d64507eeb73f..d33ccaa8e1a2 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java @@ -161,25 +161,8 @@ public class TestNGRunnableState extends JavaCommandLineState { final TestConsoleProperties consoleProperties = console.getProperties(); if (consoleProperties == null) return; - final String testRunDebugId = consoleProperties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN; final TestNGResults resultsView = console.getResultsView(); - final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); - if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) { - final MessageType type = resultsView == null || resultsView.getStatus() == MessageHelper.SKIPPED_TEST - ? MessageType.WARNING - : (resultsView.getStatus() == MessageHelper.FAILED_TEST - ? MessageType.ERROR - : MessageType.INFO); - final String message; - if (resultsView == null) { - message = myStarted ? "Tests were interrupted" : "Tests were not started"; - } - else { - message = resultsView.getStatusLine(); - } - toolWindowManager.notifyByBalloon(testRunDebugId, type, message, null, null); - TestsUIUtil.NOTIFICATION_GROUP.createNotification(message, type).notify(project); - } + TestsUIUtil.notifyByBalloon(project, myStarted, console.getResultsView().getRoot(), consoleProperties, "in " + resultsView.getTime()); } }; SwingUtilities.invokeLater(notificationRunnable); diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java index 617d403f915d..73fc80ba7af2 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java +++ b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java @@ -209,6 +209,11 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn } return sb.toString(); } + + public String getTime() { + final long time = end - start; + return time == 0 ? "0.0 s" : NumberFormat.getInstance().format((double)time / 1000.0) + " s"; + } public TestProxy testStarted(TestResultMessage result) { return testStarted(result, true);