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

Side by Side Diff: components/json_schema/json_schema_validator_unittest_base.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 6 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 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 "components/json_schema/json_schema_validator_unittest_base.h" 5 #include "components/json_schema/json_schema_validator_unittest_base.h"
6 6
7 #include <cfloat> 7 #include <cfloat>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 instance->SetInteger("foo", 123); 248 instance->SetInteger("foo", 123);
249 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "foo", 249 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "foo",
250 JSONSchemaValidator::FormatErrorMessage( 250 JSONSchemaValidator::FormatErrorMessage(
251 JSONSchemaValidator::kInvalidType, 251 JSONSchemaValidator::kInvalidType,
252 schema::kString, 252 schema::kString,
253 schema::kInteger)); 253 schema::kInteger));
254 instance->SetString("foo", "foo"); 254 instance->SetString("foo", "foo");
255 schema->Remove(schema::kPatternProperties, NULL); 255 schema->Remove(schema::kPatternProperties, NULL);
256 256
257 // Test additional properties. 257 // Test additional properties.
258 base::DictionaryValue* additional_properties = new base::DictionaryValue(); 258 base::DictionaryValue* additional_properties = schema->SetDictionary(
259 schema::kAdditionalProperties, base::MakeUnique<base::DictionaryValue>());
259 additional_properties->SetString(schema::kType, schema::kAny); 260 additional_properties->SetString(schema::kType, schema::kAny);
260 schema->Set(schema::kAdditionalProperties, additional_properties);
261 261
262 instance->SetBoolean("extra", true); 262 instance->SetBoolean("extra", true);
263 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 263 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
264 264
265 instance->SetString("extra", "foo"); 265 instance->SetString("extra", "foo");
266 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 266 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
267 267
268 additional_properties->SetString(schema::kType, schema::kBoolean); 268 additional_properties->SetString(schema::kType, schema::kBoolean);
269 instance->SetBoolean("extra", true); 269 instance->SetBoolean("extra", true);
270 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 270 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 JSONSchemaValidator::kArrayItemRequired); 399 JSONSchemaValidator::kArrayItemRequired);
400 400
401 instance->Set(0, base::MakeUnique<base::Value>(42)); 401 instance->Set(0, base::MakeUnique<base::Value>(42));
402 instance->AppendInteger(42); 402 instance->AppendInteger(42);
403 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0", 403 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0",
404 JSONSchemaValidator::FormatErrorMessage( 404 JSONSchemaValidator::FormatErrorMessage(
405 JSONSchemaValidator::kInvalidType, 405 JSONSchemaValidator::kInvalidType,
406 schema::kString, 406 schema::kString,
407 schema::kInteger)); 407 schema::kInteger));
408 408
409 base::DictionaryValue* additional_properties = new base::DictionaryValue(); 409 base::DictionaryValue* additional_properties = schema->SetDictionary(
410 schema::kAdditionalProperties, base::MakeUnique<base::DictionaryValue>());
410 additional_properties->SetString(schema::kType, schema::kAny); 411 additional_properties->SetString(schema::kType, schema::kAny);
411 schema->Set(schema::kAdditionalProperties, additional_properties);
412 instance->Set(0, base::MakeUnique<base::Value>("42")); 412 instance->Set(0, base::MakeUnique<base::Value>("42"));
413 instance->AppendString("anything"); 413 instance->AppendString("anything");
414 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 414 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
415 instance->Set(2, base::MakeUnique<base::ListValue>()); 415 instance->Set(2, base::MakeUnique<base::ListValue>());
416 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 416 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
417 417
418 additional_properties->SetString(schema::kType, schema::kBoolean); 418 additional_properties->SetString(schema::kType, schema::kBoolean);
419 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "2", 419 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "2",
420 JSONSchemaValidator::FormatErrorMessage( 420 JSONSchemaValidator::FormatErrorMessage(
421 JSONSchemaValidator::kInvalidType, 421 JSONSchemaValidator::kInvalidType,
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 JSONSchemaValidator::kInvalidType, schema::kBoolean, 724 JSONSchemaValidator::kInvalidType, schema::kBoolean,
725 schema::kInteger)); 725 schema::kInteger));
726 726
727 schema->SetString(schema::kType, schema::kNull); 727 schema->SetString(schema::kType, schema::kNull);
728 ExpectNotValid( 728 ExpectNotValid(
729 TEST_SOURCE, std::unique_ptr<base::Value>(new base::Value(false)).get(), 729 TEST_SOURCE, std::unique_ptr<base::Value>(new base::Value(false)).get(),
730 schema.get(), NULL, std::string(), 730 schema.get(), NULL, std::string(),
731 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, 731 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType,
732 schema::kNull, schema::kBoolean)); 732 schema::kNull, schema::kBoolean));
733 } 733 }
OLDNEW
« no previous file with comments | « components/invalidation/public/invalidation.cc ('k') | components/login/screens/screen_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698