Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1929)

Unified Diff: chrome/browser/extensions/extension_apitest.cc

Issue 276010: Remove the implicit wrench menu items for browser actions. (Closed)
Patch Set: Rebase Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_apitest.cc
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc
index 0a8875d4252c57ca6f200737f9503158a8946027..65f1058c663706a6233090e5f7651cd7e7db1b96 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");
+}
« no previous file with comments | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/browser/extensions/extension_browser_actions_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698