| 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_contents_service.h" | 9 #include "chrome/browser/background_contents_service.h" |
| 10 #include "chrome/browser/background_contents_service_factory.h" |
| 10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/notifications/desktop_notification_service.h" | 14 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 14 #include "chrome/browser/notifications/notification.h" | 15 #include "chrome/browser/notifications/notification.h" |
| 15 #include "chrome/browser/notifications/notification_test_util.h" | 16 #include "chrome/browser/notifications/notification_test_util.h" |
| 16 #include "chrome/browser/notifications/notification_ui_manager.h" | 17 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 19 #include "chrome/browser/tabs/tab_strip_model.h" | 20 #include "chrome/browser/tabs/tab_strip_model.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 browser()->window()->ShowTaskManager(); | 153 browser()->window()->ShowTaskManager(); |
| 153 | 154 |
| 154 // Browser and the New Tab Page. | 155 // Browser and the New Tab Page. |
| 155 WaitForResourceChange(2); | 156 WaitForResourceChange(2); |
| 156 | 157 |
| 157 // Open a new background contents and make sure we notice that. | 158 // Open a new background contents and make sure we notice that. |
| 158 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 159 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 159 FilePath(kTitle1File))); | 160 FilePath(kTitle1File))); |
| 160 | 161 |
| 161 BackgroundContentsService* service = | 162 BackgroundContentsService* service = |
| 162 browser()->profile()->GetBackgroundContentsService(); | 163 BackgroundContentsServiceFactory::GetForProfile(browser()->profile()); |
| 163 string16 application_id(ASCIIToUTF16("test_app_id")); | 164 string16 application_id(ASCIIToUTF16("test_app_id")); |
| 164 service->LoadBackgroundContents(browser()->profile(), | 165 service->LoadBackgroundContents(browser()->profile(), |
| 165 url, | 166 url, |
| 166 ASCIIToUTF16("background_page"), | 167 ASCIIToUTF16("background_page"), |
| 167 application_id); | 168 application_id); |
| 168 WaitForResourceChange(3); | 169 WaitForResourceChange(3); |
| 169 | 170 |
| 170 // Close the background contents and verify that we notice. | 171 // Close the background contents and verify that we notice. |
| 171 service->ShutdownAssociatedBackgroundContents(application_id); | 172 service->ShutdownAssociatedBackgroundContents(application_id); |
| 172 WaitForResourceChange(2); | 173 WaitForResourceChange(2); |
| 173 } | 174 } |
| 174 | 175 |
| 175 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillBGContents) { | 176 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillBGContents) { |
| 176 EXPECT_EQ(0, model()->ResourceCount()); | 177 EXPECT_EQ(0, model()->ResourceCount()); |
| 177 | 178 |
| 178 // Show the task manager. This populates the model, and helps with debugging | 179 // Show the task manager. This populates the model, and helps with debugging |
| 179 // (you see the task manager). | 180 // (you see the task manager). |
| 180 browser()->window()->ShowTaskManager(); | 181 browser()->window()->ShowTaskManager(); |
| 181 | 182 |
| 182 // Browser and the New Tab Page. | 183 // Browser and the New Tab Page. |
| 183 WaitForResourceChange(2); | 184 WaitForResourceChange(2); |
| 184 | 185 |
| 185 // Open a new background contents and make sure we notice that. | 186 // Open a new background contents and make sure we notice that. |
| 186 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 187 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 187 FilePath(kTitle1File))); | 188 FilePath(kTitle1File))); |
| 188 | 189 |
| 189 BackgroundContentsService* service = | 190 BackgroundContentsService* service = |
| 190 browser()->profile()->GetBackgroundContentsService(); | 191 BackgroundContentsServiceFactory::GetForProfile(browser()->profile()); |
| 191 string16 application_id(ASCIIToUTF16("test_app_id")); | 192 string16 application_id(ASCIIToUTF16("test_app_id")); |
| 192 service->LoadBackgroundContents(browser()->profile(), | 193 service->LoadBackgroundContents(browser()->profile(), |
| 193 url, | 194 url, |
| 194 ASCIIToUTF16("background_page"), | 195 ASCIIToUTF16("background_page"), |
| 195 application_id); | 196 application_id); |
| 196 // Wait for the background contents process to finish loading. | 197 // Wait for the background contents process to finish loading. |
| 197 WaitForBackgroundContents(); | 198 WaitForBackgroundContents(); |
| 198 EXPECT_EQ(3, model()->ResourceCount()); | 199 EXPECT_EQ(3, model()->ResourceCount()); |
| 199 | 200 |
| 200 // Kill the background contents process and verify that it disappears from the | 201 // Kill the background contents process and verify that it disappears from the |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 WaitForResourceChange(3); | 455 WaitForResourceChange(3); |
| 455 | 456 |
| 456 // Check that we get some value for the cache columns. | 457 // Check that we get some value for the cache columns. |
| 457 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), | 458 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), |
| 458 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 459 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 459 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), | 460 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), |
| 460 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 461 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 461 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), | 462 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), |
| 462 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 463 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
| 463 } | 464 } |
| OLD | NEW |