Revert of Use ExtensionRegistryObserver instead of deprecated extension notification...
[chromium-blink-merge.git] / tools / json_schema_compiler / test / test_util.cc
blob79d5f7b9711b7094af4aac9031cf6f94bbde70ae
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/json_schema_compiler/test/test_util.h"
7 #include <string>
9 #include "base/json/json_reader.h"
10 #include "base/logging.h"
12 namespace json_schema_compiler {
13 namespace test_util {
15 scoped_ptr<base::Value> ReadJson(const base::StringPiece& json) {
16 int error_code;
17 std::string error_msg;
18 scoped_ptr<base::Value> result(base::JSONReader::ReadAndReturnError(
19 json,
20 base::JSON_ALLOW_TRAILING_COMMAS,
21 &error_code,
22 &error_msg));
23 // CHECK not ASSERT since passing invalid |json| is a test error.
24 CHECK(result) << error_msg;
25 return result.Pass();
28 scoped_ptr<base::ListValue> List(base::Value* a) {
29 scoped_ptr<base::ListValue> list(new base::ListValue());
30 list->Append(a);
31 return list.Pass();
33 scoped_ptr<base::ListValue> List(base::Value* a, base::Value* b) {
34 scoped_ptr<base::ListValue> list = List(a);
35 list->Append(b);
36 return list.Pass();
38 scoped_ptr<base::ListValue> List(base::Value* a,
39 base::Value* b,
40 base::Value* c) {
41 scoped_ptr<base::ListValue> list = List(a, b);
42 list->Append(c);
43 return list.Pass();
46 scoped_ptr<base::DictionaryValue> Dictionary(
47 const std::string& ak, base::Value* av) {
48 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
49 dict->SetWithoutPathExpansion(ak, av);
50 return dict.Pass();
52 scoped_ptr<base::DictionaryValue> Dictionary(
53 const std::string& ak, base::Value* av,
54 const std::string& bk, base::Value* bv) {
55 scoped_ptr<base::DictionaryValue> dict = Dictionary(ak, av);
56 dict->SetWithoutPathExpansion(bk, bv);
57 return dict.Pass();
59 scoped_ptr<base::DictionaryValue> Dictionary(
60 const std::string& ak, base::Value* av,
61 const std::string& bk, base::Value* bv,
62 const std::string& ck, base::Value* cv) {
63 scoped_ptr<base::DictionaryValue> dict = Dictionary(ak, av, bk, bv);
64 dict->SetWithoutPathExpansion(ck, cv);
65 return dict.Pass();
68 } // namespace test_util
69 } // namespace json_schema_compiler