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

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

Issue 1853573002: [Extensions] Remove 'use_movable_types' from code generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/arrays.h" 5 #include "tools/json_schema_compiler/test/arrays.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 { 155 {
156 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 156 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
157 scoped_ptr<base::ListValue> ref_array(new base::ListValue()); 157 scoped_ptr<base::ListValue> ref_array(new base::ListValue());
158 ref_array->Append(CreateItemValue(1)); 158 ref_array->Append(CreateItemValue(1));
159 ref_array->Append(CreateItemValue(2)); 159 ref_array->Append(CreateItemValue(2));
160 ref_array->Append(CreateItemValue(3)); 160 ref_array->Append(CreateItemValue(3));
161 value->Set("refs", ref_array.release()); 161 value->Set("refs", ref_array.release());
162 scoped_ptr<RefArrayType> ref_array_type(new RefArrayType()); 162 scoped_ptr<RefArrayType> ref_array_type(new RefArrayType());
163 EXPECT_TRUE(RefArrayType::Populate(*value, ref_array_type.get())); 163 EXPECT_TRUE(RefArrayType::Populate(*value, ref_array_type.get()));
164 ASSERT_EQ(3u, ref_array_type->refs.size()); 164 ASSERT_EQ(3u, ref_array_type->refs.size());
165 EXPECT_EQ(1, ref_array_type->refs[0]->val); 165 EXPECT_EQ(1, ref_array_type->refs[0].val);
166 EXPECT_EQ(2, ref_array_type->refs[1]->val); 166 EXPECT_EQ(2, ref_array_type->refs[1].val);
167 EXPECT_EQ(3, ref_array_type->refs[2]->val); 167 EXPECT_EQ(3, ref_array_type->refs[2].val);
168 } 168 }
169 { 169 {
170 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 170 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
171 scoped_ptr<base::ListValue> not_ref_array(new base::ListValue()); 171 scoped_ptr<base::ListValue> not_ref_array(new base::ListValue());
172 not_ref_array->Append(CreateItemValue(1)); 172 not_ref_array->Append(CreateItemValue(1));
173 not_ref_array->Append(new base::FundamentalValue(3)); 173 not_ref_array->Append(new base::FundamentalValue(3));
174 value->Set("refs", not_ref_array.release()); 174 value->Set("refs", not_ref_array.release());
175 scoped_ptr<RefArrayType> ref_array_type(new RefArrayType()); 175 scoped_ptr<RefArrayType> ref_array_type(new RefArrayType());
176 EXPECT_FALSE(RefArrayType::Populate(*value, ref_array_type.get())); 176 EXPECT_FALSE(RefArrayType::Populate(*value, ref_array_type.get()));
177 } 177 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 TEST(JsonSchemaCompilerArrayTest, ObjectArrayParamsCreate) { 212 TEST(JsonSchemaCompilerArrayTest, ObjectArrayParamsCreate) {
213 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 213 scoped_ptr<base::ListValue> params_value(new base::ListValue());
214 scoped_ptr<base::ListValue> item_array(new base::ListValue()); 214 scoped_ptr<base::ListValue> item_array(new base::ListValue());
215 item_array->Append(CreateItemValue(1)); 215 item_array->Append(CreateItemValue(1));
216 item_array->Append(CreateItemValue(2)); 216 item_array->Append(CreateItemValue(2));
217 params_value->Append(item_array.release()); 217 params_value->Append(item_array.release());
218 scoped_ptr<ObjectArray::Params> params( 218 scoped_ptr<ObjectArray::Params> params(
219 ObjectArray::Params::Create(*params_value)); 219 ObjectArray::Params::Create(*params_value));
220 EXPECT_TRUE(params.get()); 220 EXPECT_TRUE(params.get());
221 ASSERT_EQ(2u, params->objects.size()); 221 ASSERT_EQ(2u, params->objects.size());
222 EXPECT_EQ(1, params->objects[0]->additional_properties["val"]); 222 EXPECT_EQ(1, params->objects[0].additional_properties["val"]);
223 EXPECT_EQ(2, params->objects[1]->additional_properties["val"]); 223 EXPECT_EQ(2, params->objects[1].additional_properties["val"]);
224 } 224 }
225 225
226 TEST(JsonSchemaCompilerArrayTest, RefArrayParamsCreate) { 226 TEST(JsonSchemaCompilerArrayTest, RefArrayParamsCreate) {
227 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 227 scoped_ptr<base::ListValue> params_value(new base::ListValue());
228 scoped_ptr<base::ListValue> item_array(new base::ListValue()); 228 scoped_ptr<base::ListValue> item_array(new base::ListValue());
229 item_array->Append(CreateItemValue(1)); 229 item_array->Append(CreateItemValue(1));
230 item_array->Append(CreateItemValue(2)); 230 item_array->Append(CreateItemValue(2));
231 params_value->Append(item_array.release()); 231 params_value->Append(item_array.release());
232 scoped_ptr<RefArray::Params> params( 232 scoped_ptr<RefArray::Params> params(
233 RefArray::Params::Create(*params_value)); 233 RefArray::Params::Create(*params_value));
234 EXPECT_TRUE(params.get()); 234 EXPECT_TRUE(params.get());
235 ASSERT_EQ(2u, params->refs.size()); 235 ASSERT_EQ(2u, params->refs.size());
236 EXPECT_EQ(1, params->refs[0]->val); 236 EXPECT_EQ(1, params->refs[0].val);
237 EXPECT_EQ(2, params->refs[1]->val); 237 EXPECT_EQ(2, params->refs[1].val);
238 } 238 }
239 239
240 TEST(JsonSchemaCompilerArrayTest, ReturnIntegerArrayResultCreate) { 240 TEST(JsonSchemaCompilerArrayTest, ReturnIntegerArrayResultCreate) {
241 std::vector<int> integers; 241 std::vector<int> integers;
242 integers.push_back(1); 242 integers.push_back(1);
243 integers.push_back(2); 243 integers.push_back(2);
244 scoped_ptr<base::ListValue> results = 244 scoped_ptr<base::ListValue> results =
245 ReturnIntegerArray::Results::Create(integers); 245 ReturnIntegerArray::Results::Create(integers);
246 246
247 base::ListValue expected; 247 base::ListValue expected;
248 base::ListValue* expected_argument = new base::ListValue(); 248 base::ListValue* expected_argument = new base::ListValue();
249 expected_argument->Append(new base::FundamentalValue(1)); 249 expected_argument->Append(new base::FundamentalValue(1));
250 expected_argument->Append(new base::FundamentalValue(2)); 250 expected_argument->Append(new base::FundamentalValue(2));
251 expected.Append(expected_argument); 251 expected.Append(expected_argument);
252 EXPECT_TRUE(results->Equals(&expected)); 252 EXPECT_TRUE(results->Equals(&expected));
253 } 253 }
254 254
255 TEST(JsonSchemaCompilerArrayTest, ReturnRefArrayResultCreate) { 255 TEST(JsonSchemaCompilerArrayTest, ReturnRefArrayResultCreate) {
256 std::vector<linked_ptr<Item> > items; 256 std::vector<Item> items;
257 items.push_back(linked_ptr<Item>(new Item())); 257 items.push_back(Item());
258 items.push_back(linked_ptr<Item>(new Item())); 258 items.push_back(Item());
259 items[0]->val = 1; 259 items[0].val = 1;
260 items[1]->val = 2; 260 items[1].val = 2;
261 scoped_ptr<base::ListValue> results = 261 scoped_ptr<base::ListValue> results =
262 ReturnRefArray::Results::Create(items); 262 ReturnRefArray::Results::Create(items);
263 263
264 base::ListValue expected; 264 base::ListValue expected;
265 base::ListValue* expected_argument = new base::ListValue(); 265 base::ListValue* expected_argument = new base::ListValue();
266 base::DictionaryValue* first = new base::DictionaryValue(); 266 base::DictionaryValue* first = new base::DictionaryValue();
267 first->SetInteger("val", 1); 267 first->SetInteger("val", 1);
268 expected_argument->Append(first); 268 expected_argument->Append(first);
269 base::DictionaryValue* second = new base::DictionaryValue(); 269 base::DictionaryValue* second = new base::DictionaryValue();
270 second->SetInteger("val", 2); 270 second->SetInteger("val", 2);
271 expected_argument->Append(second); 271 expected_argument->Append(second);
272 expected.Append(expected_argument); 272 expected.Append(expected_argument);
273 EXPECT_TRUE(results->Equals(&expected)); 273 EXPECT_TRUE(results->Equals(&expected));
274 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698