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:07:38 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 06:07:38 +0000
commit15294d803ac17bb5355076c90ddbecca983985a8 (patch)
tree4d8a0f1a95daf85c51420bfa41984becad28e12c /chrome/browser/extensions/extension_apitest.cc
parent66ff7356a381d6c8c6c3272b095938408c4f3188 (diff)
downloadchromium_src-15294d803ac17bb5355076c90ddbecca983985a8.zip
chromium_src-15294d803ac17bb5355076c90ddbecca983985a8.tar.gz
chromium_src-15294d803ac17bb5355076c90ddbecca983985a8.tar.bz2
Remove the implicit wrench menu items for browser actions.
Also, allow browser actions with no initial icons, and add some better tests. BUG=24379,24671 Review URL: http://codereview.chromium.org/276010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29095 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");
+}