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

Side by Side Diff: tools/json_schema_compiler/test/enums_unittest.cc

Issue 2884933002: Remove raw base::DictionaryValue::SetWithoutPathExpansion (Closed)
Patch Set: Include Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/enums.h" 5 #include "tools/json_schema_compiler/test/enums.h"
6 6
7 #include "base/memory/ptr_util.h"
8 #include "base/values.h"
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 #include "tools/json_schema_compiler/test/test_util.h" 10 #include "tools/json_schema_compiler/test/test_util.h"
9 11
10 using namespace test::api::enums; 12 using namespace test::api::enums;
11 using json_schema_compiler::test_util::List; 13 using json_schema_compiler::test_util::List;
12 14
13 TEST(JsonSchemaCompilerEnumsTest, EnumTypePopulate) { 15 TEST(JsonSchemaCompilerEnumsTest, EnumTypePopulate) {
14 { 16 {
15 EnumType enum_type; 17 EnumType enum_type;
16 base::DictionaryValue value; 18 base::DictionaryValue value;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 67
66 value.Set("reference_enum", new base::Value("one")); 68 value.Set("reference_enum", new base::Value("one"));
67 ASSERT_TRUE(ReferenceEnum::Populate(value, &enumeration)); 69 ASSERT_TRUE(ReferenceEnum::Populate(value, &enumeration));
68 EXPECT_TRUE(value.Equals(enumeration.ToValue().get())); 70 EXPECT_TRUE(value.Equals(enumeration.ToValue().get()));
69 } 71 }
70 } 72 }
71 73
72 TEST(JsonSchemaCompilerEnumsTest, EnumsArrayAsType) { 74 TEST(JsonSchemaCompilerEnumsTest, EnumsArrayAsType) {
73 { 75 {
74 base::ListValue params_value; 76 base::ListValue params_value;
75 params_value.Append(List(new base::Value("one"), new base::Value("two"))); 77 params_value.Append(List(base::MakeUnique<base::Value>("one"),
78 base::MakeUnique<base::Value>("two")));
76 std::unique_ptr<TakesEnumArrayAsType::Params> params( 79 std::unique_ptr<TakesEnumArrayAsType::Params> params(
77 TakesEnumArrayAsType::Params::Create(params_value)); 80 TakesEnumArrayAsType::Params::Create(params_value));
78 ASSERT_TRUE(params); 81 ASSERT_TRUE(params);
79 EXPECT_EQ(2U, params->values.size()); 82 EXPECT_EQ(2U, params->values.size());
80 EXPECT_EQ(ENUMERATION_ONE, params->values[0]); 83 EXPECT_EQ(ENUMERATION_ONE, params->values[0]);
81 EXPECT_EQ(ENUMERATION_TWO, params->values[1]); 84 EXPECT_EQ(ENUMERATION_TWO, params->values[1]);
82 } 85 }
83 { 86 {
84 base::ListValue params_value; 87 base::ListValue params_value;
85 params_value.Append(List(new base::Value("invalid"))); 88 params_value.Append(List(base::MakeUnique<base::Value>("invalid")));
86 std::unique_ptr<TakesEnumArrayAsType::Params> params( 89 std::unique_ptr<TakesEnumArrayAsType::Params> params(
87 TakesEnumArrayAsType::Params::Create(params_value)); 90 TakesEnumArrayAsType::Params::Create(params_value));
88 EXPECT_FALSE(params); 91 EXPECT_FALSE(params);
89 } 92 }
90 } 93 }
91 94
92 TEST(JsonSchemaCompilerEnumsTest, ReturnsEnumCreate) { 95 TEST(JsonSchemaCompilerEnumsTest, ReturnsEnumCreate) {
93 { 96 {
94 Enumeration state = ENUMERATION_ONE; 97 Enumeration state = ENUMERATION_ONE;
95 std::unique_ptr<base::Value> result(new base::Value(ToString(state))); 98 std::unique_ptr<base::Value> result(new base::Value(ToString(state)));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 params_value.AppendString("invalid"); 158 params_value.AppendString("invalid");
156 std::unique_ptr<TakesEnum::Params> params( 159 std::unique_ptr<TakesEnum::Params> params(
157 TakesEnum::Params::Create(params_value)); 160 TakesEnum::Params::Create(params_value));
158 EXPECT_FALSE(params.get()); 161 EXPECT_FALSE(params.get());
159 } 162 }
160 } 163 }
161 164
162 TEST(JsonSchemaCompilerEnumsTest, TakesEnumArrayParamsCreate) { 165 TEST(JsonSchemaCompilerEnumsTest, TakesEnumArrayParamsCreate) {
163 { 166 {
164 base::ListValue params_value; 167 base::ListValue params_value;
165 params_value.Append(List(new base::Value("one"), new base::Value("two"))); 168 params_value.Append(List(base::MakeUnique<base::Value>("one"),
169 base::MakeUnique<base::Value>("two")));
166 std::unique_ptr<TakesEnumArray::Params> params( 170 std::unique_ptr<TakesEnumArray::Params> params(
167 TakesEnumArray::Params::Create(params_value)); 171 TakesEnumArray::Params::Create(params_value));
168 ASSERT_TRUE(params); 172 ASSERT_TRUE(params);
169 EXPECT_EQ(2U, params->values.size()); 173 EXPECT_EQ(2U, params->values.size());
170 EXPECT_EQ(ENUMERATION_ONE, params->values[0]); 174 EXPECT_EQ(ENUMERATION_ONE, params->values[0]);
171 EXPECT_EQ(ENUMERATION_TWO, params->values[1]); 175 EXPECT_EQ(ENUMERATION_TWO, params->values[1]);
172 } 176 }
173 { 177 {
174 base::ListValue params_value; 178 base::ListValue params_value;
175 params_value.Append(List(new base::Value("invalid"))); 179 params_value.Append(List(base::MakeUnique<base::Value>("invalid")));
176 std::unique_ptr<TakesEnumArray::Params> params( 180 std::unique_ptr<TakesEnumArray::Params> params(
177 TakesEnumArray::Params::Create(params_value)); 181 TakesEnumArray::Params::Create(params_value));
178 EXPECT_FALSE(params); 182 EXPECT_FALSE(params);
179 } 183 }
180 } 184 }
181 185
182 TEST(JsonSchemaCompilerEnumsTest, TakesOptionalEnumParamsCreate) { 186 TEST(JsonSchemaCompilerEnumsTest, TakesOptionalEnumParamsCreate) {
183 { 187 {
184 base::ListValue params_value; 188 base::ListValue params_value;
185 params_value.AppendString("three"); 189 params_value.AppendString("three");
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 TEST(JsonSchemaCompilerEnumsTest, OnTwoEnumsFiredCreate) { 265 TEST(JsonSchemaCompilerEnumsTest, OnTwoEnumsFiredCreate) {
262 { 266 {
263 std::unique_ptr<base::Value> results( 267 std::unique_ptr<base::Value> results(
264 OnTwoEnumsFired::Create(ENUMERATION_ONE, OTHER_ENUMERATION_HAM)); 268 OnTwoEnumsFired::Create(ENUMERATION_ONE, OTHER_ENUMERATION_HAM));
265 base::ListValue expected; 269 base::ListValue expected;
266 expected.AppendString("one"); 270 expected.AppendString("one");
267 expected.AppendString("ham"); 271 expected.AppendString("ham");
268 EXPECT_TRUE(results->Equals(&expected)); 272 EXPECT_TRUE(results->Equals(&expected));
269 } 273 }
270 } 274 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/choices_unittest.cc ('k') | tools/json_schema_compiler/test/error_generation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698