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

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

Issue 779083002: Move system.display tests to extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Less duplicated code Created 6 years 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
« no previous file with comments | « chrome/browser/extensions/api/system_display/system_display_apitest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_function_test_utils.cc
diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc
index 7cdb98dc37ade0fdd7d97b090ae2519c2478cc80..e872a1c7cfba0bc66032f388c5fdf8e552025c45 100644
--- a/chrome/browser/extensions/extension_function_test_utils.cc
+++ b/chrome/browser/extensions/extension_function_test_utils.cc
@@ -60,32 +60,20 @@ base::ListValue* ParseList(const std::string& data) {
base::DictionaryValue* ParseDictionary(
const std::string& data) {
- base::Value* result = ParseJSON(data);
- base::DictionaryValue* dict = NULL;
- result->GetAsDictionary(&dict);
- return dict;
+ return extensions::api_test_utils::ParseDictionary(data);
}
bool GetBoolean(const base::DictionaryValue* val, const std::string& key) {
- bool result = false;
- if (!val->GetBoolean(key, &result))
- ADD_FAILURE() << key << " does not exist or is not a boolean.";
- return result;
+ return extensions::api_test_utils::GetBoolean(val, key);
}
int GetInteger(const base::DictionaryValue* val, const std::string& key) {
- int result = 0;
- if (!val->GetInteger(key, &result))
- ADD_FAILURE() << key << " does not exist or is not an integer.";
- return result;
+ return extensions::api_test_utils::GetInteger(val, key);
}
std::string GetString(const base::DictionaryValue* val,
const std::string& key) {
- std::string result;
- if (!val->GetString(key, &result))
- ADD_FAILURE() << key << " does not exist or is not a string.";
- return result;
+ return extensions::api_test_utils::GetString(val, key);
}
base::DictionaryValue* ToDictionary(base::Value* val) {
@@ -104,33 +92,22 @@ scoped_refptr<Extension> CreateEmptyExtensionWithLocation(
Manifest::Location location) {
scoped_ptr<base::DictionaryValue> test_extension_value(
ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}"));
- return CreateExtension(location, test_extension_value.get(), std::string());
+ return extensions::api_test_utils::CreateExtension(
+ location, test_extension_value.get(), std::string());
}
scoped_refptr<Extension> CreateExtension(
base::DictionaryValue* test_extension_value) {
- return CreateExtension(Manifest::INTERNAL, test_extension_value,
- std::string());
+ return extensions::api_test_utils::CreateExtension(
+ Manifest::INTERNAL, test_extension_value, std::string());
}
scoped_refptr<Extension> CreateExtension(
Manifest::Location location,
base::DictionaryValue* test_extension_value,
const std::string& id_input) {
- std::string error;
- const base::FilePath test_extension_path;
- std::string id;
- if (!id_input.empty())
- id = crx_file::id_util::GenerateId(id_input);
- scoped_refptr<Extension> extension(Extension::Create(
- test_extension_path,
- location,
- *test_extension_value,
- Extension::NO_FLAGS,
- id,
- &error));
- EXPECT_TRUE(error.empty()) << "Could not parse test extension " << error;
- return extension;
+ return extensions::api_test_utils::CreateExtension(
+ location, test_extension_value, id_input);
}
bool HasPrivacySensitiveFields(base::DictionaryValue* val) {
« no previous file with comments | « chrome/browser/extensions/api/system_display/system_display_apitest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698