diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 06:36:08 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 06:36:08 +0000 |
commit | 83fe23a3ff26c5dea371ce94f6a909c4d081b145 (patch) | |
tree | 5117b7c3928d608f51f31a3279997e2716db6110 /chrome/browser/extensions/extension_apitest.cc | |
parent | 8d34c475c53b27511a912880aebea627ad651625 (diff) | |
download | chromium_src-83fe23a3ff26c5dea371ce94f6a909c4d081b145.zip chromium_src-83fe23a3ff26c5dea371ce94f6a909c4d081b145.tar.gz chromium_src-83fe23a3ff26c5dea371ce94f6a909c4d081b145.tar.bz2 |
Reverting r29095 (removes wrench integration for
browser actions).
TBR=mpcomplete@chromium.org
BUG=24379,24671
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_apitest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_apitest.cc | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc index 65f1058..0a8875d 100644 --- a/chrome/browser/extensions/extension_apitest.cc +++ b/chrome/browser/extensions/extension_apitest.cc @@ -12,14 +12,35 @@ namespace { static const int kTimeoutMs = 60 * 1000; // 1 minute }; -ExtensionApiTest::ResultCatcher::ResultCatcher() { - registrar_.Add(this, NotificationType::EXTENSION_TEST_PASSED, - NotificationService::AllSources()); - registrar_.Add(this, NotificationType::EXTENSION_TEST_FAILED, - NotificationService::AllSources()); +// Load an extension and wait for it to notify of PASSED or FAILED. +bool ExtensionApiTest::RunExtensionTest(const char* extension_name) { + // Note the inner scope here. The |registrar| will fall out of scope and + // remove listeners *before* the call to WaitForPassFail() below. + { + LOG(INFO) << "Running ExtensionApiTest with: " << extension_name; + NotificationRegistrar registrar; + registrar.Add(this, NotificationType::EXTENSION_TEST_PASSED, + NotificationService::AllSources()); + registrar.Add(this, NotificationType::EXTENSION_TEST_FAILED, + NotificationService::AllSources()); + + if (!LoadExtension(test_data_dir_.AppendASCII(extension_name))) { + message_ = "Failed to load extension."; + return false; + } + } + + // TODO(erikkay) perhaps we shouldn't do this implicitly. + return WaitForPassFail(); } -bool ExtensionApiTest::ResultCatcher::GetNextResult() { +bool ExtensionApiTest::WaitForPassFail() { + NotificationRegistrar registrar; + registrar.Add(this, NotificationType::EXTENSION_TEST_PASSED, + NotificationService::AllSources()); + registrar.Add(this, NotificationType::EXTENSION_TEST_FAILED, + NotificationService::AllSources()); + // Depending on the tests, multiple results can come in from a single call // to RunMessageLoop(), so we maintain a queue of results and just pull them // off as the test calls this, going to the run loop only when the queue is @@ -40,9 +61,14 @@ bool ExtensionApiTest::ResultCatcher::GetNextResult() { return false; } -void ExtensionApiTest::ResultCatcher::Observe( - NotificationType type, const NotificationSource& source, - const NotificationDetails& details) { +void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { + ExtensionBrowserTest::SetUpCommandLine(command_line); + test_data_dir_ = test_data_dir_.AppendASCII("api_test"); +} + +void ExtensionApiTest::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { switch (type.value) { case NotificationType::EXTENSION_TEST_PASSED: std::cout << "Got EXTENSION_TEST_PASSED notification.\n"; @@ -59,29 +85,6 @@ void ExtensionApiTest::ResultCatcher::Observe( break; default: - NOTREACHED(); - } -} - -// Load an extension and wait for it to notify of PASSED or FAILED. -bool ExtensionApiTest::RunExtensionTest(const char* extension_name) { - ResultCatcher catcher; - - LOG(INFO) << "Running ExtensionApiTest with: " << extension_name; - if (!LoadExtension(test_data_dir_.AppendASCII(extension_name))) { - message_ = "Failed to load extension."; - return false; - } - - if (!catcher.GetNextResult()) { - message_ = catcher.message(); - return false; - } else { - return true; + ExtensionBrowserTest::Observe(type, source, details); } } - -void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { - ExtensionBrowserTest::SetUpCommandLine(command_line); - test_data_dir_ = test_data_dir_.AppendASCII("api_test"); -} |