summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_test_api.cc
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 19:26:39 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 19:26:39 +0000
commit761e7160090e0643dc265067e7f833aeedbf9e21 (patch)
treee5d7a5e59ea246e5d4f84112666dd40efe21fce2 /chrome/browser/extensions/extension_test_api.cc
parent9288808841602769a316568cb6d14ed6b6d988dc (diff)
downloadchromium_src-761e7160090e0643dc265067e7f833aeedbf9e21.zip
chromium_src-761e7160090e0643dc265067e7f833aeedbf9e21.tar.gz
chromium_src-761e7160090e0643dc265067e7f833aeedbf9e21.tar.bz2
Pass test server port to javascript part of extensions API tests.
BUG=56715 TEST=ExtensionApiTests.(I18N|History|Clipboard,TabConnect) Review URL: http://codereview.chromium.org/3728004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_test_api.cc')
-rw-r--r--chrome/browser/extensions/extension_test_api.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_test_api.cc b/chrome/browser/extensions/extension_test_api.cc
index b5f64ba..9fe1749 100644
--- a/chrome/browser/extensions/extension_test_api.cc
+++ b/chrome/browser/extensions/extension_test_api.cc
@@ -12,6 +12,18 @@
#include "chrome/browser/extensions/extensions_quota_service.h"
#include "chrome/common/notification_service.h"
+namespace {
+
+// If you see this error in your test, you need to set the config state
+// to be returned by chrome.test.getConfig(). Do this by calling
+// ExtensionTestGetConfigFunction::set_test_config_state(Value* state)
+// in test set up.
+const char kNoTestConfigDataError[] = "Test configuration was not set.";
+
+} // namespace
+
+ExtensionTestPassFunction::~ExtensionTestPassFunction() {}
+
bool ExtensionTestPassFunction::RunImpl() {
NotificationService::current()->Notify(
NotificationType::EXTENSION_TEST_PASSED,
@@ -20,6 +32,8 @@ bool ExtensionTestPassFunction::RunImpl() {
return true;
}
+ExtensionTestFailFunction::~ExtensionTestFailFunction() {}
+
bool ExtensionTestFailFunction::RunImpl() {
std::string message;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &message));
@@ -30,12 +44,16 @@ bool ExtensionTestFailFunction::RunImpl() {
return true;
}
+ExtensionTestLogFunction::~ExtensionTestLogFunction() {}
+
bool ExtensionTestLogFunction::RunImpl() {
std::string message;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &message));
return true;
}
+ExtensionTestQuotaResetFunction::~ExtensionTestQuotaResetFunction() {}
+
bool ExtensionTestQuotaResetFunction::RunImpl() {
ExtensionsService* service = profile()->GetExtensionsService();
ExtensionsQuotaService* quota = service->quota_service();
@@ -44,6 +62,9 @@ bool ExtensionTestQuotaResetFunction::RunImpl() {
return true;
}
+ExtensionTestCreateIncognitoTabFunction::
+ ~ExtensionTestCreateIncognitoTabFunction() {}
+
bool ExtensionTestCreateIncognitoTabFunction::RunImpl() {
std::string url;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
@@ -61,9 +82,34 @@ bool ExtensionTestSendMessageFunction::RunImpl() {
Details<std::string>(&message));
return true;
}
+ExtensionTestSendMessageFunction::~ExtensionTestSendMessageFunction() {}
void ExtensionTestSendMessageFunction::Reply(const std::string& message) {
result_.reset(Value::CreateStringValue(message));
SendResponse(true);
Release(); // balanced in RunImpl
}
+
+// static
+void ExtensionTestGetConfigFunction::set_test_config_state(
+ DictionaryValue* value) {
+ TestConfigState* test_config_state = Singleton<TestConfigState>::get();
+ test_config_state->set_config_state(value);
+}
+
+ExtensionTestGetConfigFunction::TestConfigState::TestConfigState()
+ : config_state_(NULL) {}
+
+ExtensionTestGetConfigFunction::~ExtensionTestGetConfigFunction() {}
+
+bool ExtensionTestGetConfigFunction::RunImpl() {
+ TestConfigState* test_config_state = Singleton<TestConfigState>::get();
+
+ if (!test_config_state->config_state()) {
+ error_ = kNoTestConfigDataError;
+ return false;
+ }
+
+ result_.reset(test_config_state->config_state()->DeepCopy());
+ return true;
+}