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

Unified Diff: extensions/common/test_util.cc

Issue 578653005: Revert "Refactor ExtensionManifestTest to allow usage in src/extensions" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « extensions/common/test_util.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/test_util.cc
diff --git a/extensions/common/test_util.cc b/extensions/common/test_util.cc
index 4eacfa68f3e91c94e53f6654f3b8b1192efba73d..03b35b84801522cd6f945ee3b99549e9a9efb362 100644
--- a/extensions/common/test_util.cc
+++ b/extensions/common/test_util.cc
@@ -4,9 +4,12 @@
#include "extensions/common/test_util.h"
+#include "base/json/json_reader.h"
+#include "base/values.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/value_builder.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
namespace test_util {
@@ -36,5 +39,21 @@ scoped_refptr<Extension> CreateExtensionWithID(const std::string& id) {
.Build();
}
+scoped_ptr<base::DictionaryValue> ParseJsonDictionaryWithSingleQuotes(
+ std::string json) {
+ std::replace(json.begin(), json.end(), '\'', '"');
+ std::string error_msg;
+ scoped_ptr<base::Value> result(base::JSONReader::ReadAndReturnError(
+ json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error_msg));
+ scoped_ptr<base::DictionaryValue> result_dict;
+ if (result && result->IsType(base::Value::TYPE_DICTIONARY)) {
+ result_dict.reset(static_cast<base::DictionaryValue*>(result.release()));
+ } else {
+ ADD_FAILURE() << "Failed to parse \"" << json << "\": " << error_msg;
+ result_dict.reset(new base::DictionaryValue());
+ }
+ return result_dict.Pass();
+}
+
} // namespace test_util
} // namespace extensions
« no previous file with comments | « extensions/common/test_util.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698