| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/background/background_contents_service.h" | 9 #include "chrome/browser/background/background_contents_service.h" |
| 10 #include "chrome/browser/background/background_contents_service_factory.h" | 10 #include "chrome/browser/background/background_contents_service_factory.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/tabs/tab_strip_model.h" | 21 #include "chrome/browser/tabs/tab_strip_model.h" |
| 22 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 22 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_navigator.h" | 24 #include "chrome/browser/ui/browser_navigator.h" |
| 25 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
| 29 #include "chrome/test/base/in_process_browser_test.h" | 29 #include "chrome/test/base/in_process_browser_test.h" |
| 30 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
| 31 #include "content/common/page_transition_types.h" | 31 #include "content/public/common/page_transition_types.h" |
| 32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 33 #include "net/base/mock_host_resolver.h" | 33 #include "net/base/mock_host_resolver.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 | 36 |
| 37 // On Linux this is crashing intermittently http://crbug/84719 | 37 // On Linux this is crashing intermittently http://crbug/84719 |
| 38 // In some environments this test fails about 1/6 http://crbug/84850 | 38 // In some environments this test fails about 1/6 http://crbug/84850 |
| 39 #if defined(OS_LINUX) | 39 #if defined(OS_LINUX) |
| 40 #define MAYBE_KillExtension DISABLED_KillExtension | 40 #define MAYBE_KillExtension DISABLED_KillExtension |
| 41 #elif defined(TOUCH_UI) | 41 #elif defined(TOUCH_UI) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Show the task manager. This populates the model, and helps with debugging | 76 // Show the task manager. This populates the model, and helps with debugging |
| 77 // (you see the task manager). | 77 // (you see the task manager). |
| 78 browser()->window()->ShowTaskManager(); | 78 browser()->window()->ShowTaskManager(); |
| 79 | 79 |
| 80 // Browser and the New Tab Page. | 80 // Browser and the New Tab Page. |
| 81 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 81 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
| 82 | 82 |
| 83 // Open a new tab and make sure we notice that. | 83 // Open a new tab and make sure we notice that. |
| 84 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 84 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 85 FilePath(kTitle1File))); | 85 FilePath(kTitle1File))); |
| 86 AddTabAtIndex(0, url, PageTransition::TYPED); | 86 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 87 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 87 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
| 88 | 88 |
| 89 // Check that the third entry is a tab contents resource whose title starts | 89 // Check that the third entry is a tab contents resource whose title starts |
| 90 // starts with "Tab:". | 90 // starts with "Tab:". |
| 91 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); | 91 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); |
| 92 string16 prefix = l10n_util::GetStringFUTF16( | 92 string16 prefix = l10n_util::GetStringFUTF16( |
| 93 IDS_TASK_MANAGER_TAB_PREFIX, string16()); | 93 IDS_TASK_MANAGER_TAB_PREFIX, string16()); |
| 94 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); | 94 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); |
| 95 | 95 |
| 96 // Close the tab and verify that we notice. | 96 // Close the tab and verify that we notice. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 ASSERT_TRUE(LoadExtension( | 211 ASSERT_TRUE(LoadExtension( |
| 212 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 212 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 213 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 213 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 214 .AppendASCII("1.0.0.0"))); | 214 .AppendASCII("1.0.0.0"))); |
| 215 | 215 |
| 216 // Browser, Extension background page, and the New Tab Page. | 216 // Browser, Extension background page, and the New Tab Page. |
| 217 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 217 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
| 218 | 218 |
| 219 // Open a new tab to an extension URL and make sure we notice that. | 219 // Open a new tab to an extension URL and make sure we notice that. |
| 220 GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); | 220 GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); |
| 221 AddTabAtIndex(0, url, PageTransition::TYPED); | 221 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 222 TaskManagerBrowserTestUtil::WaitForResourceChange(4); | 222 TaskManagerBrowserTestUtil::WaitForResourceChange(4); |
| 223 | 223 |
| 224 // Check that the third entry (background) is an extension resource whose | 224 // Check that the third entry (background) is an extension resource whose |
| 225 // title starts with "Extension:". | 225 // title starts with "Extension:". |
| 226 ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2)); | 226 ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2)); |
| 227 ASSERT_TRUE(model()->GetResourceTabContents(2) == NULL); | 227 ASSERT_TRUE(model()->GetResourceTabContents(2) == NULL); |
| 228 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); | 228 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); |
| 229 string16 prefix = l10n_util::GetStringFUTF16( | 229 string16 prefix = l10n_util::GetStringFUTF16( |
| 230 IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); | 230 IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); |
| 231 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); | 231 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 251 test_data_dir_.AppendASCII("packaged_app"))); | 251 test_data_dir_.AppendASCII("packaged_app"))); |
| 252 ExtensionService* service = browser()->profile()->GetExtensionService(); | 252 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 253 const Extension* extension = | 253 const Extension* extension = |
| 254 service->GetExtensionById(last_loaded_extension_id_, false); | 254 service->GetExtensionById(last_loaded_extension_id_, false); |
| 255 | 255 |
| 256 // Browser and the New Tab Page. | 256 // Browser and the New Tab Page. |
| 257 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 257 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
| 258 | 258 |
| 259 // Open a new tab to the app's launch URL and make sure we notice that. | 259 // Open a new tab to the app's launch URL and make sure we notice that. |
| 260 GURL url(extension->GetResourceURL("main.html")); | 260 GURL url(extension->GetResourceURL("main.html")); |
| 261 AddTabAtIndex(0, url, PageTransition::TYPED); | 261 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 262 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 262 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
| 263 | 263 |
| 264 // Check that the third entry (main.html) is of type extension and has both | 264 // Check that the third entry (main.html) is of type extension and has both |
| 265 // a tab contents and an extension. The title should start with "App:". | 265 // a tab contents and an extension. The title should start with "App:". |
| 266 ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2)); | 266 ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(2)); |
| 267 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); | 267 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); |
| 268 ASSERT_TRUE(model()->GetResourceExtension(2) == extension); | 268 ASSERT_TRUE(model()->GetResourceExtension(2) == extension); |
| 269 string16 prefix = l10n_util::GetStringFUTF16( | 269 string16 prefix = l10n_util::GetStringFUTF16( |
| 270 IDS_TASK_MANAGER_APP_PREFIX, string16()); | 270 IDS_TASK_MANAGER_APP_PREFIX, string16()); |
| 271 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); | 271 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 289 ASSERT_TRUE(test_server()->Start()); | 289 ASSERT_TRUE(test_server()->Start()); |
| 290 GURL::Replacements replace_host; | 290 GURL::Replacements replace_host; |
| 291 std::string host_str("localhost"); // must stay in scope with replace_host | 291 std::string host_str("localhost"); // must stay in scope with replace_host |
| 292 replace_host.SetHostStr(host_str); | 292 replace_host.SetHostStr(host_str); |
| 293 GURL base_url = test_server()->GetURL( | 293 GURL base_url = test_server()->GetURL( |
| 294 "files/extensions/api_test/app_process/"); | 294 "files/extensions/api_test/app_process/"); |
| 295 base_url = base_url.ReplaceComponents(replace_host); | 295 base_url = base_url.ReplaceComponents(replace_host); |
| 296 | 296 |
| 297 // Open a new tab to an app URL before the app is loaded. | 297 // Open a new tab to an app URL before the app is loaded. |
| 298 GURL url(base_url.Resolve("path1/empty.html")); | 298 GURL url(base_url.Resolve("path1/empty.html")); |
| 299 AddTabAtIndex(0, url, PageTransition::TYPED); | 299 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 300 ui_test_utils::WaitForNavigation( | 300 ui_test_utils::WaitForNavigation( |
| 301 &browser()->GetSelectedTabContents()->controller()); | 301 &browser()->GetSelectedTabContents()->controller()); |
| 302 | 302 |
| 303 // Check that the third entry's title starts with "Tab:". | 303 // Check that the third entry's title starts with "Tab:". |
| 304 string16 tab_prefix = l10n_util::GetStringFUTF16( | 304 string16 tab_prefix = l10n_util::GetStringFUTF16( |
| 305 IDS_TASK_MANAGER_TAB_PREFIX, string16()); | 305 IDS_TASK_MANAGER_TAB_PREFIX, string16()); |
| 306 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), tab_prefix, true)); | 306 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), tab_prefix, true)); |
| 307 | 307 |
| 308 // Load the hosted app and make sure it still starts with "Tab:", | 308 // Load the hosted app and make sure it still starts with "Tab:", |
| 309 // since it hasn't changed to an app process yet. | 309 // since it hasn't changed to an app process yet. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 // Show the task manager. This populates the model, and helps with debugging | 440 // Show the task manager. This populates the model, and helps with debugging |
| 441 // (you see the task manager). | 441 // (you see the task manager). |
| 442 browser()->window()->ShowTaskManager(); | 442 browser()->window()->ShowTaskManager(); |
| 443 | 443 |
| 444 // Browser and the New Tab Page. | 444 // Browser and the New Tab Page. |
| 445 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 445 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
| 446 | 446 |
| 447 // Open a new tab and make sure we notice that. | 447 // Open a new tab and make sure we notice that. |
| 448 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 448 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 449 FilePath(kTitle1File))); | 449 FilePath(kTitle1File))); |
| 450 AddTabAtIndex(0, url, PageTransition::TYPED); | 450 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 451 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 451 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
| 452 | 452 |
| 453 // Check that we get some value for the cache columns. | 453 // Check that we get some value for the cache columns. |
| 454 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), | 454 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), |
| 455 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 455 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 456 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), | 456 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), |
| 457 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 457 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 458 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), | 458 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), |
| 459 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 459 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 460 } | 460 } |
| OLD | NEW |