summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_apitest.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 06:59:22 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 06:59:22 +0000
commit80d6a44253e9e28bbb06a384d6249f1623e8b1e4 (patch)
treea581b4528f323ea84b5c8b5b6a92bc767096efa1 /chrome/browser/extensions/extension_apitest.cc
parent83fe23a3ff26c5dea371ce94f6a909c4d081b145 (diff)
downloadchromium_src-80d6a44253e9e28bbb06a384d6249f1623e8b1e4.zip
chromium_src-80d6a44253e9e28bbb06a384d6249f1623e8b1e4.tar.gz
chromium_src-80d6a44253e9e28bbb06a384d6249f1623e8b1e4.tar.bz2
Reland r29095 (removes wrench integration for
browser actions). Test failure was a fluke. I forgot that changing resources always makes the first bot run fail. TBR=mpcomplete@chromium.org BUG=24379,24671 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_apitest.cc')
-rw-r--r--chrome/browser/extensions/extension_apitest.cc69
1 files changed, 33 insertions, 36 deletions
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc
index 0a8875d..65f1058 100644
--- a/chrome/browser/extensions/extension_apitest.cc
+++ b/chrome/browser/extensions/extension_apitest.cc
@@ -12,35 +12,14 @@ namespace {
static const int kTimeoutMs = 60 * 1000; // 1 minute
};
-// 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();
+ExtensionApiTest::ResultCatcher::ResultCatcher() {
+ registrar_.Add(this, NotificationType::EXTENSION_TEST_PASSED,
+ NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::EXTENSION_TEST_FAILED,
+ NotificationService::AllSources());
}
-bool ExtensionApiTest::WaitForPassFail() {
- NotificationRegistrar registrar;
- registrar.Add(this, NotificationType::EXTENSION_TEST_PASSED,
- NotificationService::AllSources());
- registrar.Add(this, NotificationType::EXTENSION_TEST_FAILED,
- NotificationService::AllSources());
-
+bool ExtensionApiTest::ResultCatcher::GetNextResult() {
// 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
@@ -61,14 +40,9 @@ bool ExtensionApiTest::WaitForPassFail() {
return false;
}
-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) {
+void ExtensionApiTest::ResultCatcher::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";
@@ -85,6 +59,29 @@ void ExtensionApiTest::Observe(NotificationType type,
break;
default:
- ExtensionBrowserTest::Observe(type, source, details);
+ 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;
}
}
+
+void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) {
+ ExtensionBrowserTest::SetUpCommandLine(command_line);
+ test_data_dir_ = test_data_dir_.AppendASCII("api_test");
+}