| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/devtools/devtools_window_testing.h" | 16 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 17 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
| 20 #include "chrome/browser/notifications/notification.h" | 20 #include "chrome/browser/notifications/notification.h" |
| 21 #include "chrome/browser/notifications/notification_test_util.h" | 21 #include "chrome/browser/notifications/notification_test_util.h" |
| 22 #include "chrome/browser/notifications/notification_ui_manager.h" | 22 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/task_manager/resource_provider.h" | 24 #include "chrome/browser/task_management/task_manager_tester.h" |
| 25 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 25 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
| 28 #include "chrome/browser/ui/browser_dialogs.h" | 28 #include "chrome/browser/ui/browser_dialogs.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/panels/panel.h" | 30 #include "chrome/browser/ui/panels/panel.h" |
| 31 #include "chrome/browser/ui/panels/panel_manager.h" | 31 #include "chrome/browser/ui/panels/panel_manager.h" |
| 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 33 #include "chrome/browser/web_applications/web_app.h" | 33 #include "chrome/browser/web_applications/web_app.h" |
| 34 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 56 using task_manager::browsertest_util::MatchAnyApp; | 56 using task_manager::browsertest_util::MatchAnyApp; |
| 57 using task_manager::browsertest_util::MatchAnyExtension; | 57 using task_manager::browsertest_util::MatchAnyExtension; |
| 58 using task_manager::browsertest_util::MatchAnySubframe; | 58 using task_manager::browsertest_util::MatchAnySubframe; |
| 59 using task_manager::browsertest_util::MatchAnyTab; | 59 using task_manager::browsertest_util::MatchAnyTab; |
| 60 using task_manager::browsertest_util::MatchAnyUtility; | 60 using task_manager::browsertest_util::MatchAnyUtility; |
| 61 using task_manager::browsertest_util::MatchApp; | 61 using task_manager::browsertest_util::MatchApp; |
| 62 using task_manager::browsertest_util::MatchExtension; | 62 using task_manager::browsertest_util::MatchExtension; |
| 63 using task_manager::browsertest_util::MatchSubframe; | 63 using task_manager::browsertest_util::MatchSubframe; |
| 64 using task_manager::browsertest_util::MatchTab; | 64 using task_manager::browsertest_util::MatchTab; |
| 65 using task_manager::browsertest_util::MatchUtility; | 65 using task_manager::browsertest_util::MatchUtility; |
| 66 using task_manager::browsertest_util::TaskManagerTester; | |
| 67 using task_manager::browsertest_util::WaitForTaskManagerRows; | 66 using task_manager::browsertest_util::WaitForTaskManagerRows; |
| 68 using task_manager::browsertest_util::WaitForTaskManagerStatToExceed; | 67 using task_manager::browsertest_util::WaitForTaskManagerStatToExceed; |
| 69 | 68 |
| 70 namespace { | 69 namespace { |
| 71 | 70 |
| 72 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); | 71 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); |
| 73 | 72 |
| 74 } // namespace | 73 } // namespace |
| 75 | 74 |
| 76 // TODO(nick): Move this file into task_management. https://crbug.com/606963 | 75 // TODO(nick): Move this file into task_management. https://crbug.com/606963 |
| 77 class TaskManagerBrowserTest : public ExtensionBrowserTest { | 76 class TaskManagerBrowserTest : public ExtensionBrowserTest { |
| 78 public: | 77 public: |
| 79 TaskManagerBrowserTest() {} | 78 TaskManagerBrowserTest() {} |
| 80 ~TaskManagerBrowserTest() override {} | 79 ~TaskManagerBrowserTest() override {} |
| 81 | 80 |
| 82 TaskManagerTester* model() { return model_.get(); } | 81 task_management::TaskManagerTester* model() { return model_.get(); } |
| 83 | 82 |
| 84 void ShowTaskManager() { | 83 void ShowTaskManager() { |
| 85 // Show the task manager. This populates the model, and helps with debugging | 84 // Show the task manager. This populates the model, and helps with debugging |
| 86 // (you see the task manager). | 85 // (you see the task manager). |
| 87 chrome::ShowTaskManager(browser()); | 86 chrome::ShowTaskManager(browser()); |
| 88 model_ = task_manager::browsertest_util::GetTaskManagerTester(); | 87 model_ = task_management::TaskManagerTester::Create(base::Closure()); |
| 89 } | 88 } |
| 90 | 89 |
| 91 void HideTaskManager() { | 90 void HideTaskManager() { |
| 92 model_.reset(); | 91 model_.reset(); |
| 93 | 92 |
| 94 // Hide the task manager, and wait for it to go. | 93 // Hide the task manager, and wait for it to go. |
| 95 chrome::HideTaskManager(); | 94 chrome::HideTaskManager(); |
| 96 base::RunLoop().RunUntilIdle(); // OnWindowClosed happens asynchronously. | 95 base::RunLoop().RunUntilIdle(); // OnWindowClosed happens asynchronously. |
| 97 } | 96 } |
| 98 | 97 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 127 void SetUpCommandLine(base::CommandLine* command_line) override { | 126 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 128 ExtensionBrowserTest::SetUpCommandLine(command_line); | 127 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 129 | 128 |
| 130 // Do not launch device discovery process. | 129 // Do not launch device discovery process. |
| 131 command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); | 130 command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void TearDownOnMainThread() override { model_.reset(); } | 133 void TearDownOnMainThread() override { model_.reset(); } |
| 135 | 134 |
| 136 private: | 135 private: |
| 137 std::unique_ptr<TaskManagerTester> model_; | 136 std::unique_ptr<task_management::TaskManagerTester> model_; |
| 138 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest); | 137 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest); |
| 139 }; | 138 }; |
| 140 | 139 |
| 141 class TaskManagerUtilityProcessBrowserTest : public TaskManagerBrowserTest { | 140 class TaskManagerUtilityProcessBrowserTest : public TaskManagerBrowserTest { |
| 142 public: | 141 public: |
| 143 TaskManagerUtilityProcessBrowserTest() {} | 142 TaskManagerUtilityProcessBrowserTest() {} |
| 144 | 143 |
| 145 protected: | 144 protected: |
| 146 void SetUpCommandLine(base::CommandLine* command_line) override { | 145 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 147 TaskManagerBrowserTest::SetUpCommandLine(command_line); | 146 TaskManagerBrowserTest::SetUpCommandLine(command_line); |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); | 1232 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); |
| 1234 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 1233 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1235 | 1234 |
| 1236 HideTaskManager(); | 1235 HideTaskManager(); |
| 1237 ShowTaskManager(); | 1236 ShowTaskManager(); |
| 1238 | 1237 |
| 1239 ASSERT_NO_FATAL_FAILURE( | 1238 ASSERT_NO_FATAL_FAILURE( |
| 1240 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); | 1239 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); |
| 1241 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 1240 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1242 } | 1241 } |
| OLD | NEW |