| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 10 #include "chrome/browser/notifications/desktop_notification_service.h" | 10 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 11 #include "chrome/browser/notifications/notification.h" | 11 #include "chrome/browser/notifications/notification.h" |
| 12 #include "chrome/browser/notifications/notification_test_util.h" | 12 #include "chrome/browser/notifications/notification_test_util.h" |
| 13 #include "chrome/browser/notifications/notification_ui_manager.h" | 13 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 14 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 14 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_dialogs.h" | 16 #include "chrome/browser/ui/browser_dialogs.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 #include "ui/message_center/message_center_util.h" |
| 23 #if !defined(ENABLE_MESSAGE_CENTER) | |
| 24 // These tests do not apply with Message Center platforms | |
| 25 // where notifications do not instantiate a new renderer. | |
| 26 | 23 |
| 27 class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest { | 24 class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest { |
| 28 public: | 25 public: |
| 29 TaskManagerModel* model() const { | 26 TaskManagerModel* model() const { |
| 30 return TaskManager::GetInstance()->model(); | 27 return TaskManager::GetInstance()->model(); |
| 31 } | 28 } |
| 32 protected: | 29 protected: |
| 33 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 34 ExtensionBrowserTest::SetUpCommandLine(command_line); | 31 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 35 | 32 |
| 36 // Do not prelaunch the GPU process for these tests because it will show | 33 // Do not prelaunch the GPU process for these tests because it will show |
| 37 // up in task manager but whether it appears before or after the new tab | 34 // up in task manager but whether it appears before or after the new tab |
| 38 // renderer process is not well defined. | 35 // renderer process is not well defined. |
| 39 command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch); | 36 command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch); |
| 40 } | 37 } |
| 41 }; | 38 }; |
| 42 | 39 |
| 43 // TODO(linux_aura) http://crbug.com/163931 | 40 // TODO(linux_aura) http://crbug.com/163931 |
| 44 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 41 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) |
| 45 #define MAYBE_NoticeNotificationChanges DISABLED_NoticeNotificationChanges | 42 #define MAYBE_NoticeNotificationChanges DISABLED_NoticeNotificationChanges |
| 46 #else | 43 #else |
| 47 #define MAYBE_NoticeNotificationChanges NoticeNotificationChanges | 44 #define MAYBE_NoticeNotificationChanges NoticeNotificationChanges |
| 48 #endif | 45 #endif |
| 49 IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, | 46 IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, |
| 50 MAYBE_NoticeNotificationChanges) { | 47 MAYBE_NoticeNotificationChanges) { |
| 48 // These tests do not apply with Message Center platforms |
| 49 // where notifications do not instantiate a new renderer. |
| 50 if (message_center::IsRichNotificationEnabled()) |
| 51 return; |
| 52 |
| 51 EXPECT_EQ(0, model()->ResourceCount()); | 53 EXPECT_EQ(0, model()->ResourceCount()); |
| 52 | 54 |
| 53 // Show the task manager. | 55 // Show the task manager. |
| 54 chrome::ShowTaskManager(browser(), false); | 56 chrome::ShowTaskManager(browser(), false); |
| 55 // Expect to see the browser and the New Tab Page renderer. | 57 // Expect to see the browser and the New Tab Page renderer. |
| 56 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 58 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); |
| 57 | 59 |
| 58 // Show a notification. | 60 // Show a notification. |
| 59 NotificationUIManager* notifications = | 61 NotificationUIManager* notifications = |
| 60 g_browser_process->notification_ui_manager(); | 62 g_browser_process->notification_ui_manager(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 72 | 74 |
| 73 notifications->Add(n1, browser()->profile()); | 75 notifications->Add(n1, browser()->profile()); |
| 74 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 76 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 75 notifications->Add(n2, browser()->profile()); | 77 notifications->Add(n2, browser()->profile()); |
| 76 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); | 78 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 77 notifications->CancelById(n1.notification_id()); | 79 notifications->CancelById(n1.notification_id()); |
| 78 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 80 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 79 notifications->CancelById(n2.notification_id()); | 81 notifications->CancelById(n2.notification_id()); |
| 80 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 82 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); |
| 81 } | 83 } |
| 82 | |
| 83 #endif // !ENABLE_MESSAGE_CENTER | |
| OLD | NEW |