diff options
Diffstat (limited to 'chrome/browser/extensions/extension_test_api.cc')
-rw-r--r-- | chrome/browser/extensions/extension_test_api.cc | 46 |
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; +} |