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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 // Unload extension to avoid crash on Windows (see http://crbug.com/31663). | 200 // Unload extension to avoid crash on Windows (see http://crbug.com/31663). |
201 UnloadExtension(last_loaded_extension_id_); | 201 UnloadExtension(last_loaded_extension_id_); |
202 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 202 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
203 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); | 203 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); |
204 } | 204 } |
205 | 205 |
206 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { | 206 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { |
207 // Show the task manager. This populates the model, and helps with debugging | 207 // Show the task manager. This populates the model, and helps with debugging |
208 // (you see the task manager). | 208 // (you see the task manager). |
209 browser()->window()->ShowTaskManager(); | 209 browser()->window()->ShowTaskManager(); |
210 // Wait for loading of task manager. | |
211 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | |
210 | 212 |
211 ASSERT_TRUE(LoadExtension( | 213 ASSERT_TRUE(LoadExtension( |
212 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 214 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
213 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 215 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
214 .AppendASCII("1.0.0.0"))); | 216 .AppendASCII("1.0.0.0"))); |
215 | 217 |
216 // Browser, Extension background page, and the New Tab Page. | 218 // Browser, Extension background page, and the New Tab Page. |
217 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 219 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
218 | 220 |
219 // Open a new tab to an extension URL and make sure we notice that. | 221 // Open a new tab to an extension URL and make sure we notice that. |
(...skipping 19 matching lines...) Expand all Loading... | |
239 | 241 |
240 // Unload extension to avoid crash on Windows. | 242 // Unload extension to avoid crash on Windows. |
241 UnloadExtension(last_loaded_extension_id_); | 243 UnloadExtension(last_loaded_extension_id_); |
242 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 244 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
243 } | 245 } |
244 | 246 |
245 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { | 247 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { |
246 // Show the task manager. This populates the model, and helps with debugging | 248 // Show the task manager. This populates the model, and helps with debugging |
247 // (you see the task manager). | 249 // (you see the task manager). |
248 browser()->window()->ShowTaskManager(); | 250 browser()->window()->ShowTaskManager(); |
251 // Wait for loading of task manager. | |
252 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | |
249 | 253 |
250 ASSERT_TRUE(LoadExtension( | 254 ASSERT_TRUE(LoadExtension( |
251 test_data_dir_.AppendASCII("packaged_app"))); | 255 test_data_dir_.AppendASCII("packaged_app"))); |
252 ExtensionService* service = browser()->profile()->GetExtensionService(); | 256 ExtensionService* service = browser()->profile()->GetExtensionService(); |
253 const Extension* extension = | 257 const Extension* extension = |
254 service->GetExtensionById(last_loaded_extension_id_, false); | 258 service->GetExtensionById(last_loaded_extension_id_, false); |
255 | 259 |
256 // Browser and the New Tab Page. | 260 // Browser and the New Tab Page. |
257 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 261 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
258 | 262 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 | 327 |
324 // The third entry's title should be back to a normal tab. | 328 // The third entry's title should be back to a normal tab. |
325 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), tab_prefix, true)); | 329 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(2), tab_prefix, true)); |
326 } | 330 } |
327 | 331 |
328 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillExtension) { | 332 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillExtension) { |
329 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); | 333 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); |
330 // Show the task manager. This populates the model, and helps with debugging | 334 // Show the task manager. This populates the model, and helps with debugging |
331 // (you see the task manager). | 335 // (you see the task manager). |
332 browser()->window()->ShowTaskManager(); | 336 browser()->window()->ShowTaskManager(); |
337 // Wait for loading of task manager. | |
338 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | |
333 | 339 |
340 LOG(INFO) << "loading extension"; | |
mazda
2011/10/10 23:58:46
Are these LOG(INFO) added intentionally?
If not, p
yoshiki
2011/10/11 00:09:09
Done.
| |
334 ASSERT_TRUE(LoadExtension( | 341 ASSERT_TRUE(LoadExtension( |
335 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); | 342 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); |
336 | 343 |
337 // Wait until we see the loaded extension in the task manager (the three | 344 // Wait until we see the loaded extension in the task manager (the three |
338 // resources are: the browser process, New Tab Page, and the extension). | 345 // resources are: the browser process, New Tab Page, and the extension). |
346 LOG(INFO) << "waiting for resource change"; | |
339 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 347 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
340 EXPECT_EQ(1, TaskManager::GetBackgroundPageCount()); | 348 EXPECT_EQ(1, TaskManager::GetBackgroundPageCount()); |
341 | 349 |
342 EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); | 350 EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); |
343 EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); | 351 EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); |
344 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); | 352 ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); |
345 | 353 |
346 // Kill the extension process and make sure we notice it. | 354 // Kill the extension process and make sure we notice it. |
355 LOG(INFO) << "killing extension"; | |
347 TaskManager::GetInstance()->KillProcess(2); | 356 TaskManager::GetInstance()->KillProcess(2); |
357 LOG(INFO) << "waiting for resource change"; | |
348 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | 358 TaskManagerBrowserTestUtil::WaitForResourceChange(2); |
349 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); | 359 EXPECT_EQ(0, TaskManager::GetBackgroundPageCount()); |
350 } | 360 } |
351 | 361 |
352 // Disabled, http://crbug.com/66957. | 362 // Disabled, http://crbug.com/66957. |
353 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, | 363 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, |
354 DISABLED_KillExtensionAndReload) { | 364 DISABLED_KillExtensionAndReload) { |
355 // Show the task manager. This populates the model, and helps with debugging | 365 // Show the task manager. This populates the model, and helps with debugging |
356 // (you see the task manager). | 366 // (you see the task manager). |
357 browser()->window()->ShowTaskManager(); | 367 browser()->window()->ShowTaskManager(); |
368 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | |
358 | 369 |
359 ASSERT_TRUE(LoadExtension( | 370 ASSERT_TRUE(LoadExtension( |
360 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); | 371 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); |
361 | 372 |
362 // Wait until we see the loaded extension in the task manager (the three | 373 // Wait until we see the loaded extension in the task manager (the three |
363 // resources are: the browser process, New Tab Page, and the extension). | 374 // resources are: the browser process, New Tab Page, and the extension). |
364 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 375 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
365 | 376 |
366 EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); | 377 EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); |
367 EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); | 378 EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); |
(...skipping 21 matching lines...) Expand all Loading... | |
389 #define MAYBE_ReloadExtension FLAKY_ReloadExtension | 400 #define MAYBE_ReloadExtension FLAKY_ReloadExtension |
390 #else | 401 #else |
391 #define MAYBE_ReloadExtension ReloadExtension | 402 #define MAYBE_ReloadExtension ReloadExtension |
392 #endif | 403 #endif |
393 | 404 |
394 // Regression test for http://crbug.com/18693. | 405 // Regression test for http://crbug.com/18693. |
395 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) { | 406 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) { |
396 // Show the task manager. This populates the model, and helps with debugging | 407 // Show the task manager. This populates the model, and helps with debugging |
397 // (you see the task manager). | 408 // (you see the task manager). |
398 browser()->window()->ShowTaskManager(); | 409 browser()->window()->ShowTaskManager(); |
410 // Wait for loading of task manager. | |
411 TaskManagerBrowserTestUtil::WaitForResourceChange(2); | |
399 | 412 |
400 LOG(INFO) << "loading extension"; | 413 LOG(INFO) << "loading extension"; |
401 ASSERT_TRUE(LoadExtension( | 414 ASSERT_TRUE(LoadExtension( |
402 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); | 415 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); |
403 | 416 |
404 // Wait until we see the loaded extension in the task manager (the three | 417 // Wait until we see the loaded extension in the task manager (the three |
405 // resources are: the browser process, New Tab Page, and the extension). | 418 // resources are: the browser process, New Tab Page, and the extension). |
406 LOG(INFO) << "waiting for resource change"; | 419 LOG(INFO) << "waiting for resource change"; |
407 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 420 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
408 | 421 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 TaskManagerBrowserTestUtil::WaitForResourceChange(3); | 464 TaskManagerBrowserTestUtil::WaitForResourceChange(3); |
452 | 465 |
453 // Check that we get some value for the cache columns. | 466 // Check that we get some value for the cache columns. |
454 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), | 467 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(2), |
455 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 468 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
456 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), | 469 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(2), |
457 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 470 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
458 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), | 471 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(2), |
459 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); | 472 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); |
460 } | 473 } |
OLD | NEW |