| Index: chrome/browser/task_manager/task_manager_notification_browsertest.cc
|
| diff --git a/chrome/browser/task_manager/task_manager_notification_browsertest.cc b/chrome/browser/task_manager/task_manager_notification_browsertest.cc
|
| index c9ee629de203d82b6eacd49358f108062ebefd6f..89ad1985b0ce38f636869bcbb8ba84bdea68dd09 100644
|
| --- a/chrome/browser/task_manager/task_manager_notification_browsertest.cc
|
| +++ b/chrome/browser/task_manager/task_manager_notification_browsertest.cc
|
| @@ -18,22 +18,25 @@
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
| #include "content/public/common/content_switches.h"
|
| +#include "grit/generated_resources.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| +#include "ui/message_center/message_center_switches.h"
|
| #include "ui/message_center/message_center_util.h"
|
|
|
| +using task_manager::browsertest_util::WaitForTaskManagerRows;
|
| +
|
| class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest {
|
| - public:
|
| - TaskManagerModel* model() const {
|
| - return TaskManager::GetInstance()->model();
|
| - }
|
| protected:
|
| virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
|
| ExtensionBrowserTest::SetUpCommandLine(command_line);
|
| + }
|
|
|
| - // Do not prelaunch the GPU process for these tests because it will show
|
| - // up in task manager but whether it appears before or after the new tab
|
| - // renderer process is not well defined.
|
| - command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch);
|
| + // Returns the text we expect to see in the TaskManager for a given
|
| + // notification.
|
| + base::string16 GetTitle(const char* ascii_name) {
|
| + return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NOTIFICATION_PREFIX,
|
| + base::ASCIIToUTF16(ascii_name));
|
| }
|
| };
|
|
|
| @@ -45,18 +48,11 @@ class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest {
|
| #endif
|
| IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest,
|
| MAYBE_NoticeNotificationChanges) {
|
| - // These tests do not apply with Message Center platforms
|
| + // These tests do not apply with Message Center-only platforms (e.g. Ash)
|
| // where notifications do not instantiate a new renderer.
|
| if (message_center::IsRichNotificationEnabled())
|
| return;
|
|
|
| - EXPECT_EQ(0, model()->ResourceCount());
|
| -
|
| - // Show the task manager.
|
| - chrome::ShowTaskManager(browser());
|
| - // Expect to see the browser and the New Tab Page renderer.
|
| - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
|
| -
|
| // Show a notification.
|
| NotificationUIManager* notifications =
|
| g_browser_process->notification_ui_manager();
|
| @@ -65,6 +61,19 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest,
|
| GURL(), base::ASCIIToUTF16("Hello World!"), base::string16(),
|
| blink::WebTextDirectionDefault);
|
|
|
| + // Show an initial notification before popping up the task manager.
|
| + scoped_refptr<NotificationDelegate> del0(new MockNotificationDelegate("n0"));
|
| + Notification n0(
|
| + GURL(), GURL(content), base::ASCIIToUTF16("Test 0"), base::string16(),
|
| + del0.get());
|
| + notifications->Add(n0, browser()->profile());
|
| +
|
| + // Show the task manager.
|
| + chrome::ShowTaskManager(browser());
|
| +
|
| + // This notification should show up in the task manager.
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0")));
|
| +
|
| scoped_refptr<NotificationDelegate> del1(new MockNotificationDelegate("n1"));
|
| Notification n1(
|
| GURL(), GURL(content), base::ASCIIToUTF16("Test 1"), base::string16(),
|
| @@ -74,12 +83,30 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest,
|
| GURL(), GURL(content), base::ASCIIToUTF16("Test 2"), base::string16(),
|
| del2.get());
|
|
|
| + // Show two more notifications with the task manager running, then cancel
|
| + // all three notifications.
|
| notifications->Add(n1, browser()->profile());
|
| - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 1")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 2")));
|
| +
|
| notifications->Add(n2, browser()->profile());
|
| - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 1")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 2")));
|
| +
|
| notifications->CancelById(n1.notification_id());
|
| - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 1")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 2")));
|
| +
|
| + notifications->CancelById(n0.notification_id());
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 0")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 1")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 2")));
|
| +
|
| notifications->CancelById(n2.notification_id());
|
| - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 0")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 1")));
|
| + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 2")));
|
| }
|
|
|