| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "content/public/test/browser_test_utils.h" | 42 #include "content/public/test/browser_test_utils.h" |
| 43 #include "content/public/test/content_browser_test_utils.h" | 43 #include "content/public/test/content_browser_test_utils.h" |
| 44 #include "extensions/browser/extension_system.h" | 44 #include "extensions/browser/extension_system.h" |
| 45 #include "extensions/common/extension.h" | 45 #include "extensions/common/extension.h" |
| 46 #include "net/dns/mock_host_resolver.h" | 46 #include "net/dns/mock_host_resolver.h" |
| 47 #include "net/test/embedded_test_server/embedded_test_server.h" | 47 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
| 50 #include "ui/base/page_transition_types.h" | 50 #include "ui/base/page_transition_types.h" |
| 51 | 51 |
| 52 #if defined(OS_MACOSX) | |
| 53 #include "chrome/browser/task_manager/task_manager.h" | |
| 54 #endif // defined(OS_MACOSX) | |
| 55 | |
| 56 using content::WebContents; | 52 using content::WebContents; |
| 57 using task_management::browsertest_util::ColumnSpecifier; | 53 using task_management::browsertest_util::ColumnSpecifier; |
| 58 using task_management::browsertest_util::MatchAboutBlankTab; | 54 using task_management::browsertest_util::MatchAboutBlankTab; |
| 59 using task_management::browsertest_util::MatchAnyApp; | 55 using task_management::browsertest_util::MatchAnyApp; |
| 60 using task_management::browsertest_util::MatchAnyExtension; | 56 using task_management::browsertest_util::MatchAnyExtension; |
| 61 using task_management::browsertest_util::MatchAnySubframe; | 57 using task_management::browsertest_util::MatchAnySubframe; |
| 62 using task_management::browsertest_util::MatchAnyTab; | 58 using task_management::browsertest_util::MatchAnyTab; |
| 63 using task_management::browsertest_util::MatchAnyUtility; | 59 using task_management::browsertest_util::MatchAnyUtility; |
| 64 using task_management::browsertest_util::MatchApp; | 60 using task_management::browsertest_util::MatchApp; |
| 65 using task_management::browsertest_util::MatchExtension; | 61 using task_management::browsertest_util::MatchExtension; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 92 | 88 |
| 93 void HideTaskManager() { | 89 void HideTaskManager() { |
| 94 model_.reset(); | 90 model_.reset(); |
| 95 | 91 |
| 96 // Hide the task manager, and wait for it to go. | 92 // Hide the task manager, and wait for it to go. |
| 97 chrome::HideTaskManager(); | 93 chrome::HideTaskManager(); |
| 98 base::RunLoop().RunUntilIdle(); // OnWindowClosed happens asynchronously. | 94 base::RunLoop().RunUntilIdle(); // OnWindowClosed happens asynchronously. |
| 99 } | 95 } |
| 100 | 96 |
| 101 void Refresh() { | 97 void Refresh() { |
| 102 #if defined(OS_MACOSX) | 98 task_management::TaskManagerTester::MaybeRefreshLegacyInstance(); |
| 103 // On Mac, the old task manager might still be used if we are not using mac | |
| 104 // views. Refresh() isn't ever needed on the new task manager. | |
| 105 if (!task_management::TaskManagerInterface::IsNewTaskManagerEnabled()) | |
| 106 TaskManager::GetInstance()->model()->Refresh(); | |
| 107 #endif // defined(OS_MACOSX) | |
| 108 } | 99 } |
| 109 | 100 |
| 110 GURL GetTestURL() { | 101 GURL GetTestURL() { |
| 111 return ui_test_utils::GetTestUrl( | 102 return ui_test_utils::GetTestUrl( |
| 112 base::FilePath(base::FilePath::kCurrentDirectory), | 103 base::FilePath(base::FilePath::kCurrentDirectory), |
| 113 base::FilePath(kTitle1File)); | 104 base::FilePath(kTitle1File)); |
| 114 } | 105 } |
| 115 | 106 |
| 116 int FindResourceIndex(const base::string16& title) { | 107 int FindResourceIndex(const base::string16& title) { |
| 117 for (int i = 0; i < model_->GetRowCount(); ++i) { | 108 for (int i = 0; i < model_->GetRowCount(); ++i) { |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); | 1181 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); |
| 1191 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 1182 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1192 | 1183 |
| 1193 HideTaskManager(); | 1184 HideTaskManager(); |
| 1194 ShowTaskManager(); | 1185 ShowTaskManager(); |
| 1195 | 1186 |
| 1196 ASSERT_NO_FATAL_FAILURE( | 1187 ASSERT_NO_FATAL_FAILURE( |
| 1197 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); | 1188 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); |
| 1198 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 1189 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1199 } | 1190 } |
| OLD | NEW |