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/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
27 #include "chrome/browser/ui/omnibox/location_bar.h" | 27 #include "chrome/browser/ui/omnibox/location_bar.h" |
28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
32 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/web_contents.h" |
34 | 35 |
35 ExtensionBrowserTest::ExtensionBrowserTest() | 36 ExtensionBrowserTest::ExtensionBrowserTest() |
36 : loaded_(false), | 37 : loaded_(false), |
37 installed_(false), | 38 installed_(false), |
38 extension_installs_observed_(0), | 39 extension_installs_observed_(0), |
39 extension_load_errors_observed_(0), | 40 extension_load_errors_observed_(0), |
40 target_page_action_count_(-1), | 41 target_page_action_count_(-1), |
41 target_visible_page_action_count_(-1) { | 42 target_visible_page_action_count_(-1) { |
42 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 43 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
43 AppShortcutManager::SetShortcutCreationDisabledForTesting(true); | 44 AppShortcutManager::SetShortcutCreationDisabledForTesting(true); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 } | 389 } |
389 | 390 |
390 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { | 391 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { |
391 // Wait for all the extension hosts that exist to finish loading. | 392 // Wait for all the extension hosts that exist to finish loading. |
392 content::NotificationRegistrar registrar; | 393 content::NotificationRegistrar registrar; |
393 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 394 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
394 content::NotificationService::AllSources()); | 395 content::NotificationService::AllSources()); |
395 | 396 |
396 ExtensionProcessManager* manager = | 397 ExtensionProcessManager* manager = |
397 browser()->profile()->GetExtensionProcessManager(); | 398 browser()->profile()->GetExtensionProcessManager(); |
398 for (ExtensionProcessManager::const_iterator iter = manager->begin(); | 399 ExtensionProcessManager::ContentsSet all_contents = manager->GetAllContents(); |
399 iter != manager->end();) { | 400 for (ExtensionProcessManager::ContentsSet::const_iterator iter = |
400 if ((*iter)->did_stop_loading()) { | 401 all_contents.begin(); |
| 402 iter != all_contents.end();) { |
| 403 if (!(*iter)->IsLoading()) { |
401 ++iter; | 404 ++iter; |
402 } else { | 405 } else { |
403 ui_test_utils::RunMessageLoop(); | 406 ui_test_utils::RunMessageLoop(); |
404 | 407 |
405 // Test activity may have modified the set of extension processes during | 408 // Test activity may have modified the set of extension processes during |
406 // message processing, so re-start the iteration to catch added/removed | 409 // message processing, so re-start the iteration to catch added/removed |
407 // processes. | 410 // processes. |
408 iter = manager->begin(); | 411 iter = all_contents.begin(); |
409 } | 412 } |
410 } | 413 } |
411 return true; | 414 return true; |
412 } | 415 } |
413 | 416 |
414 bool ExtensionBrowserTest::WaitForExtensionInstall() { | 417 bool ExtensionBrowserTest::WaitForExtensionInstall() { |
415 int before = extension_installs_observed_; | 418 int before = extension_installs_observed_; |
416 ui_test_utils::RegisterAndWait(this, | 419 ui_test_utils::RegisterAndWait(this, |
417 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 420 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
418 content::NotificationService::AllSources()); | 421 content::NotificationService::AllSources()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 MessageLoopForUI::current()->Quit(); | 535 MessageLoopForUI::current()->Quit(); |
533 } | 536 } |
534 break; | 537 break; |
535 } | 538 } |
536 | 539 |
537 default: | 540 default: |
538 NOTREACHED(); | 541 NOTREACHED(); |
539 break; | 542 break; |
540 } | 543 } |
541 } | 544 } |
OLD | NEW |