OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/json_schema_compiler/test/test_util.h" | 5 #include "tools/json_schema_compiler/test/test_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
11 | 12 |
12 namespace json_schema_compiler { | 13 namespace json_schema_compiler { |
13 namespace test_util { | 14 namespace test_util { |
14 | 15 |
15 std::unique_ptr<base::Value> ReadJson(const base::StringPiece& json) { | 16 std::unique_ptr<base::Value> ReadJson(const base::StringPiece& json) { |
16 int error_code; | 17 int error_code; |
17 std::string error_msg; | 18 std::string error_msg; |
18 std::unique_ptr<base::Value> result(base::JSONReader::ReadAndReturnError( | 19 std::unique_ptr<base::Value> result(base::JSONReader::ReadAndReturnError( |
19 json, base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error_msg)); | 20 json, base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error_msg)); |
20 // CHECK not ASSERT since passing invalid |json| is a test error. | 21 // CHECK not ASSERT since passing invalid |json| is a test error. |
21 CHECK(result) << error_msg; | 22 CHECK(result) << error_msg; |
22 return result; | 23 return result; |
23 } | 24 } |
24 | 25 |
25 std::unique_ptr<base::ListValue> List(base::Value* a) { | 26 std::unique_ptr<base::ListValue> List(base::Value* a) { |
26 std::unique_ptr<base::ListValue> list(new base::ListValue()); | 27 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
27 list->Append(a); | 28 list->Append(base::WrapUnique(a)); |
28 return list; | 29 return list; |
29 } | 30 } |
30 std::unique_ptr<base::ListValue> List(base::Value* a, base::Value* b) { | 31 std::unique_ptr<base::ListValue> List(base::Value* a, base::Value* b) { |
31 std::unique_ptr<base::ListValue> list = List(a); | 32 std::unique_ptr<base::ListValue> list = List(a); |
32 list->Append(b); | 33 list->Append(base::WrapUnique(b)); |
33 return list; | 34 return list; |
34 } | 35 } |
35 std::unique_ptr<base::ListValue> List(base::Value* a, | 36 std::unique_ptr<base::ListValue> List(base::Value* a, |
36 base::Value* b, | 37 base::Value* b, |
37 base::Value* c) { | 38 base::Value* c) { |
38 std::unique_ptr<base::ListValue> list = List(a, b); | 39 std::unique_ptr<base::ListValue> list = List(a, b); |
39 list->Append(c); | 40 list->Append(base::WrapUnique(c)); |
40 return list; | 41 return list; |
41 } | 42 } |
42 | 43 |
43 std::unique_ptr<base::DictionaryValue> Dictionary(const std::string& ak, | 44 std::unique_ptr<base::DictionaryValue> Dictionary(const std::string& ak, |
44 base::Value* av) { | 45 base::Value* av) { |
45 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 46 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
46 dict->SetWithoutPathExpansion(ak, av); | 47 dict->SetWithoutPathExpansion(ak, av); |
47 return dict; | 48 return dict; |
48 } | 49 } |
49 std::unique_ptr<base::DictionaryValue> Dictionary(const std::string& ak, | 50 std::unique_ptr<base::DictionaryValue> Dictionary(const std::string& ak, |
(...skipping 10 matching lines...) Expand all Loading... |
60 base::Value* bv, | 61 base::Value* bv, |
61 const std::string& ck, | 62 const std::string& ck, |
62 base::Value* cv) { | 63 base::Value* cv) { |
63 std::unique_ptr<base::DictionaryValue> dict = Dictionary(ak, av, bk, bv); | 64 std::unique_ptr<base::DictionaryValue> dict = Dictionary(ak, av, bk, bv); |
64 dict->SetWithoutPathExpansion(ck, cv); | 65 dict->SetWithoutPathExpansion(ck, cv); |
65 return dict; | 66 return dict; |
66 } | 67 } |
67 | 68 |
68 } // namespace test_util | 69 } // namespace test_util |
69 } // namespace json_schema_compiler | 70 } // namespace json_schema_compiler |
OLD | NEW |