| 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/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" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/infobars/infobar_tab_helper.h" | 14 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 15 #include "chrome/browser/notifications/desktop_notification_service.h" | 15 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 16 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
| 17 #include "chrome/browser/notifications/notification_test_util.h" | 17 #include "chrome/browser/notifications/notification_test_util.h" |
| 18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 21 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 21 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_navigator.h" | 23 #include "chrome/browser/ui/browser_navigator.h" |
| 24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
| 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 25 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.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/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
| 33 #include "content/public/common/page_transition_types.h" | 33 #include "content/public/common/page_transition_types.h" |
| 34 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 35 #include "net/base/mock_host_resolver.h" | 35 #include "net/base/mock_host_resolver.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 96 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
| 97 | 97 |
| 98 // Check that the third entry is a tab contents resource whose title starts | 98 // Check that the third entry is a tab contents resource whose title starts |
| 99 // starts with "Tab:". | 99 // starts with "Tab:". |
| 100 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); | 100 ASSERT_TRUE(model()->GetResourceTabContents(2) != NULL); |
| 101 string16 prefix = l10n_util::GetStringFUTF16( | 101 string16 prefix = l10n_util::GetStringFUTF16( |
| 102 IDS_TASK_MANAGER_TAB_PREFIX, string16()); | 102 IDS_TASK_MANAGER_TAB_PREFIX, string16()); |
| 103 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); | 103 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), prefix, true)); |
| 104 | 104 |
| 105 // Close the tab and verify that we notice. | 105 // Close the tab and verify that we notice. |
| 106 WebContents* first_tab = | 106 WebContents* first_tab = browser()->GetTabContentsAt(0)->web_contents(); |
| 107 browser()->GetTabContentsWrapperAt(0)->web_contents(); | |
| 108 ASSERT_TRUE(first_tab); | 107 ASSERT_TRUE(first_tab); |
| 109 browser()->CloseTabContents(first_tab); | 108 browser()->CloseTabContents(first_tab); |
| 110 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 109 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
| 111 } | 110 } |
| 112 | 111 |
| 113 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeBGContentsChanges) { | 112 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeBGContentsChanges) { |
| 114 EXPECT_EQ(0, model()->ResourceCount()); | 113 EXPECT_EQ(0, model()->ResourceCount()); |
| 115 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); | 114 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); |
| 116 | 115 |
| 117 // Show the task manager. This populates the model, and helps with debugging | 116 // Show the task manager. This populates the model, and helps with debugging |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); | 387 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); |
| 389 | 388 |
| 390 // Kill the extension process and make sure we notice it. | 389 // Kill the extension process and make sure we notice it. |
| 391 TaskManager::GetInstance()->KillProcess(2); | 390 TaskManager::GetInstance()->KillProcess(2); |
| 392 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 391 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
| 393 | 392 |
| 394 // Reload the extension using the "crashed extension" infobar while the task | 393 // Reload the extension using the "crashed extension" infobar while the task |
| 395 // manager is still visible. Make sure we don't crash and the extension | 394 // manager is still visible. Make sure we don't crash and the extension |
| 396 // gets reloaded and noticed in the task manager. | 395 // gets reloaded and noticed in the task manager. |
| 397 InfoBarTabHelper* infobar_helper = | 396 InfoBarTabHelper* infobar_helper = |
| 398 browser()->GetSelectedTabContentsWrapper()->infobar_tab_helper(); | 397 browser()->GetActiveTabContents()->infobar_tab_helper(); |
| 399 ASSERT_EQ(1U, infobar_helper->infobar_count()); | 398 ASSERT_EQ(1U, infobar_helper->infobar_count()); |
| 400 ConfirmInfoBarDelegate* delegate = infobar_helper-> | 399 ConfirmInfoBarDelegate* delegate = infobar_helper-> |
| 401 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 400 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 402 ASSERT_TRUE(delegate); | 401 ASSERT_TRUE(delegate); |
| 403 delegate->Accept(); | 402 delegate->Accept(); |
| 404 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 403 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
| 405 } | 404 } |
| 406 | 405 |
| 407 #if defined(OS_WIN) | 406 #if defined(OS_WIN) |
| 408 // http://crbug.com/93158. | 407 // http://crbug.com/93158. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 472 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
| 474 | 473 |
| 475 // Check that we get some value for the cache columns. | 474 // Check that we get some value for the cache columns. |
| 476 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), | 475 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), |
| 477 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 476 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 478 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), | 477 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), |
| 479 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 478 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 480 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), | 479 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), |
| 481 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 480 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 482 } | 481 } |
| OLD | NEW |