diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 06:41:43 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 06:41:43 +0000 |
commit | 93b86a850b7b1b3f46a7c4fc4521fefa8ca56e8d (patch) | |
tree | 379ae4e770b1a30e925852ee51e58250a4c7d3fd /chrome/browser/extensions/extension_browsertest.cc | |
parent | f039cd1a367ad89d07a2344b6a8e3f39cd5b0758 (diff) | |
download | chromium_src-93b86a850b7b1b3f46a7c4fc4521fefa8ca56e8d.zip chromium_src-93b86a850b7b1b3f46a7c4fc4521fefa8ca56e8d.tar.gz chromium_src-93b86a850b7b1b3f46a7c4fc4521fefa8ca56e8d.tar.bz2 |
[GTTF] Clean up browser tests:
- use more ui_test_utils functions to simplify the code
- expose more consistent and powerful utilities in ui_test_utils
- minor style improvements
- move some tests from DISABLED to FLAKY so we don't lose coverage
- remove redundant timeouts
- check more return values
TEST=browser_tests
BUG=none
Review URL: http://codereview.chromium.org/1571002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43931 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_browsertest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_browsertest.cc | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index 90cca84..a6280a2 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -157,8 +157,9 @@ bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, void ExtensionBrowserTest::ReloadExtension(const std::string& extension_id) { ExtensionsService* service = browser()->profile()->GetExtensionsService(); service->ReloadExtension(extension_id); - ui_test_utils::RegisterAndWait(NotificationType::EXTENSION_PROCESS_CREATED, - this); + ui_test_utils::RegisterAndWait(this, + NotificationType::EXTENSION_PROCESS_CREATED, + NotificationService::AllSources()); } void ExtensionBrowserTest::UnloadExtension(const std::string& extension_id) { @@ -182,30 +183,26 @@ void ExtensionBrowserTest::EnableExtension(const std::string& extension_id) { } bool ExtensionBrowserTest::WaitForPageActionCountChangeTo(int count) { - NotificationRegistrar registrar; - registrar.Add(this, - NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, - NotificationService::AllSources()); - - target_page_action_count_ = count; LocationBarTesting* location_bar = browser()->window()->GetLocationBar()->GetLocationBarForTesting(); - if (location_bar->PageActionCount() != count) - ui_test_utils::RunMessageLoop(); + if (location_bar->PageActionCount() != count) { + target_page_action_count_ = count; + ui_test_utils::RegisterAndWait(this, + NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, + NotificationService::AllSources()); + } return location_bar->PageActionCount() == count; } bool ExtensionBrowserTest::WaitForPageActionVisibilityChangeTo(int count) { - NotificationRegistrar registrar; - registrar.Add(this, - NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, - NotificationService::AllSources()); - - target_visible_page_action_count_ = count; LocationBarTesting* location_bar = browser()->window()->GetLocationBar()->GetLocationBarForTesting(); - if (location_bar->PageActionVisibleCount() != count) - ui_test_utils::RunMessageLoop(); + if (location_bar->PageActionVisibleCount() != count) { + target_visible_page_action_count_ = count; + ui_test_utils::RegisterAndWait(this, + NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, + NotificationService::AllSources()); + } return location_bar->PageActionVisibleCount() == count; } @@ -237,19 +234,22 @@ bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { bool ExtensionBrowserTest::WaitForExtensionInstall() { int before = extension_installs_observed_; - ui_test_utils::RegisterAndWait(NotificationType::EXTENSION_INSTALLED, this); + ui_test_utils::RegisterAndWait(this, NotificationType::EXTENSION_INSTALLED, + NotificationService::AllSources()); return extension_installs_observed_ == (before + 1); } bool ExtensionBrowserTest::WaitForExtensionInstallError() { int before = extension_installs_observed_; - ui_test_utils::RegisterAndWait(NotificationType::EXTENSION_INSTALL_ERROR, - this); + ui_test_utils::RegisterAndWait(this, + NotificationType::EXTENSION_INSTALL_ERROR, + NotificationService::AllSources()); return extension_installs_observed_ == before; } void ExtensionBrowserTest::WaitForExtensionLoad() { - ui_test_utils::RegisterAndWait(NotificationType::EXTENSION_LOADED, this); + ui_test_utils::RegisterAndWait(this, NotificationType::EXTENSION_LOADED, + NotificationService::AllSources()); WaitForExtensionHostsToLoad(); } @@ -261,8 +261,9 @@ bool ExtensionBrowserTest::WaitForExtensionCrash( // The extension is already unloaded, presumably due to a crash. return true; } - ui_test_utils::RegisterAndWait(NotificationType::EXTENSION_PROCESS_TERMINATED, - this); + ui_test_utils::RegisterAndWait(this, + NotificationType::EXTENSION_PROCESS_TERMINATED, + NotificationService::AllSources()); return (service->GetExtensionById(extension_id, true) == NULL); } |