summaryrefslogtreecommitdiffstats
path: root/extensions/common/test_util.cc
diff options
context:
space:
mode:
authorJames Cook <jamescook@chromium.org>2014-09-16 16:11:10 -0700
committerJames Cook <jamescook@chromium.org>2014-09-16 23:11:46 +0000
commit2bc038699947d1b05b15d35c5c5b3d4eac934f5d (patch)
tree0581666f67d88e9535f65abe348f63d0989d8b10 /extensions/common/test_util.cc
parent23fdae2acd89612f5198651e51c5aa7557667a2b (diff)
downloadchromium_src-2bc038699947d1b05b15d35c5c5b3d4eac934f5d.zip
chromium_src-2bc038699947d1b05b15d35c5c5b3d4eac934f5d.tar.gz
chromium_src-2bc038699947d1b05b15d35c5c5b3d4eac934f5d.tar.bz2
Revert "Refactor ExtensionManifestTest to allow usage in src/extensions"
This reverts commit bd1cc624f6fd9761409ee8a8ac5cfd3a5896c87a. Original CL: Refactor ExtensionManifestTest to allow usage in src/extensions https://codereview.chromium.org/572813002 Reason: Broke the official Win builders due to differences in how they report their version channel. http://master.chrome.corp.google.com:8011/builders/win%20trunk/builds/26150 BUG=414917 TEST=unit_tests TBR=rockot@chromium.org Review URL: https://codereview.chromium.org/578653005 Cr-Commit-Position: refs/heads/master@{#295172}
Diffstat (limited to 'extensions/common/test_util.cc')
-rw-r--r--extensions/common/test_util.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/extensions/common/test_util.cc b/extensions/common/test_util.cc
index 4eacfa6..03b35b8 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