| OLD | NEW | 
|---|
| 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 "chrome/common/json_schema/json_schema_validator_unittest_base.h" | 5 #include "chrome/common/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 | 10 | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 123   schema->SetString(schema::kPattern, "foo+"); | 123   schema->SetString(schema::kPattern, "foo+"); | 
| 124 | 124 | 
| 125   ExpectValid(TEST_SOURCE, | 125   ExpectValid(TEST_SOURCE, | 
| 126               scoped_ptr<base::Value>(new base::StringValue("foo")).get(), | 126               scoped_ptr<base::Value>(new base::StringValue("foo")).get(), | 
| 127               schema.get(), NULL); | 127               schema.get(), NULL); | 
| 128   ExpectValid(TEST_SOURCE, | 128   ExpectValid(TEST_SOURCE, | 
| 129               scoped_ptr<base::Value>(new base::StringValue("foooooo")).get(), | 129               scoped_ptr<base::Value>(new base::StringValue("foooooo")).get(), | 
| 130               schema.get(), NULL); | 130               schema.get(), NULL); | 
| 131   ExpectNotValid(TEST_SOURCE, | 131   ExpectNotValid(TEST_SOURCE, | 
| 132                  scoped_ptr<base::Value>(new base::StringValue("bar")).get(), | 132                  scoped_ptr<base::Value>(new base::StringValue("bar")).get(), | 
| 133                  schema.get(), NULL, "", | 133                  schema.get(), | 
|  | 134                  NULL, | 
|  | 135                  std::string(), | 
| 134                  JSONSchemaValidator::FormatErrorMessage( | 136                  JSONSchemaValidator::FormatErrorMessage( | 
| 135                      JSONSchemaValidator::kStringPattern, "foo+")); | 137                      JSONSchemaValidator::kStringPattern, "foo+")); | 
| 136 } | 138 } | 
| 137 | 139 | 
| 138 void JSONSchemaValidatorTestBase::TestEnum() { | 140 void JSONSchemaValidatorTestBase::TestEnum() { | 
| 139   scoped_ptr<base::DictionaryValue> schema(LoadDictionary("enum_schema.json")); | 141   scoped_ptr<base::DictionaryValue> schema(LoadDictionary("enum_schema.json")); | 
| 140 | 142 | 
| 141   ExpectValid(TEST_SOURCE, | 143   ExpectValid(TEST_SOURCE, | 
| 142               scoped_ptr<base::Value>(new base::StringValue("foo")).get(), | 144               scoped_ptr<base::Value>(new base::StringValue("foo")).get(), | 
| 143               schema.get(), NULL); | 145               schema.get(), NULL); | 
| 144   ExpectValid(TEST_SOURCE, | 146   ExpectValid(TEST_SOURCE, | 
| 145               scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 147               scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 
| 146               schema.get(), NULL); | 148               schema.get(), NULL); | 
| 147   ExpectValid(TEST_SOURCE, | 149   ExpectValid(TEST_SOURCE, | 
| 148               scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), | 150               scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), | 
| 149               schema.get(), NULL); | 151               schema.get(), NULL); | 
| 150 | 152 | 
| 151   ExpectNotValid(TEST_SOURCE, | 153   ExpectNotValid(TEST_SOURCE, | 
| 152                  scoped_ptr<base::Value>(new base::StringValue("42")).get(), | 154                  scoped_ptr<base::Value>(new base::StringValue("42")).get(), | 
| 153                  schema.get(), NULL, "", JSONSchemaValidator::kInvalidEnum); | 155                  schema.get(), | 
|  | 156                  NULL, | 
|  | 157                  std::string(), | 
|  | 158                  JSONSchemaValidator::kInvalidEnum); | 
| 154   ExpectNotValid(TEST_SOURCE, | 159   ExpectNotValid(TEST_SOURCE, | 
| 155                  scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 160                  scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 
| 156                  schema.get(), NULL, "", JSONSchemaValidator::kInvalidEnum); | 161                  schema.get(), | 
|  | 162                  NULL, | 
|  | 163                  std::string(), | 
|  | 164                  JSONSchemaValidator::kInvalidEnum); | 
| 157 } | 165 } | 
| 158 | 166 | 
| 159 void JSONSchemaValidatorTestBase::TestChoices() { | 167 void JSONSchemaValidatorTestBase::TestChoices() { | 
| 160   scoped_ptr<base::DictionaryValue> schema( | 168   scoped_ptr<base::DictionaryValue> schema( | 
| 161       LoadDictionary("choices_schema.json")); | 169       LoadDictionary("choices_schema.json")); | 
| 162 | 170 | 
| 163   ExpectValid(TEST_SOURCE, | 171   ExpectValid(TEST_SOURCE, | 
| 164               scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 172               scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 
| 165               schema.get(), NULL); | 173               schema.get(), NULL); | 
| 166   ExpectValid(TEST_SOURCE, | 174   ExpectValid(TEST_SOURCE, | 
| 167               scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 175               scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 
| 168               schema.get(), NULL); | 176               schema.get(), NULL); | 
| 169 | 177 | 
| 170   scoped_ptr<base::DictionaryValue> instance(new base::DictionaryValue()); | 178   scoped_ptr<base::DictionaryValue> instance(new base::DictionaryValue()); | 
| 171   instance->SetString("foo", "bar"); | 179   instance->SetString("foo", "bar"); | 
| 172   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 180   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 
| 173 | 181 | 
| 174   ExpectNotValid(TEST_SOURCE, | 182   ExpectNotValid(TEST_SOURCE, | 
| 175                  scoped_ptr<base::Value>(new base::StringValue("foo")).get(), | 183                  scoped_ptr<base::Value>(new base::StringValue("foo")).get(), | 
| 176                  schema.get(), NULL, "", JSONSchemaValidator::kInvalidChoice); | 184                  schema.get(), | 
|  | 185                  NULL, | 
|  | 186                  std::string(), | 
|  | 187                  JSONSchemaValidator::kInvalidChoice); | 
| 177   ExpectNotValid(TEST_SOURCE, | 188   ExpectNotValid(TEST_SOURCE, | 
| 178                  scoped_ptr<base::Value>(new base::ListValue()).get(), | 189                  scoped_ptr<base::Value>(new base::ListValue()).get(), | 
| 179                  schema.get(), NULL, "", JSONSchemaValidator::kInvalidChoice); | 190                  schema.get(), | 
|  | 191                  NULL, | 
|  | 192                  std::string(), | 
|  | 193                  JSONSchemaValidator::kInvalidChoice); | 
| 180 | 194 | 
| 181   instance->SetInteger("foo", 42); | 195   instance->SetInteger("foo", 42); | 
| 182   ExpectNotValid(TEST_SOURCE, instance.get(), | 196   ExpectNotValid(TEST_SOURCE, | 
| 183                  schema.get(), NULL, "", JSONSchemaValidator::kInvalidChoice); | 197                  instance.get(), | 
|  | 198                  schema.get(), | 
|  | 199                  NULL, | 
|  | 200                  std::string(), | 
|  | 201                  JSONSchemaValidator::kInvalidChoice); | 
| 184 } | 202 } | 
| 185 | 203 | 
| 186 void JSONSchemaValidatorTestBase::TestExtends() { | 204 void JSONSchemaValidatorTestBase::TestExtends() { | 
| 187   // TODO(aa): JS only | 205   // TODO(aa): JS only | 
| 188 } | 206 } | 
| 189 | 207 | 
| 190 void JSONSchemaValidatorTestBase::TestObject() { | 208 void JSONSchemaValidatorTestBase::TestObject() { | 
| 191   scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); | 209   scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); | 
| 192   schema->SetString(schema::kType, schema::kObject); | 210   schema->SetString(schema::kType, schema::kObject); | 
| 193   schema->SetString("properties.foo.type", schema::kString); | 211   schema->SetString("properties.foo.type", schema::kString); | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 326       LoadDictionary("array_tuple_schema.json")); | 344       LoadDictionary("array_tuple_schema.json")); | 
| 327   ASSERT_TRUE(schema.get()); | 345   ASSERT_TRUE(schema.get()); | 
| 328 | 346 | 
| 329   scoped_ptr<base::ListValue> instance(new base::ListValue()); | 347   scoped_ptr<base::ListValue> instance(new base::ListValue()); | 
| 330   instance->Append(new base::StringValue("42")); | 348   instance->Append(new base::StringValue("42")); | 
| 331   instance->Append(new base::FundamentalValue(42)); | 349   instance->Append(new base::FundamentalValue(42)); | 
| 332 | 350 | 
| 333   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 351   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 
| 334 | 352 | 
| 335   instance->Append(new base::StringValue("anything")); | 353   instance->Append(new base::StringValue("anything")); | 
| 336   ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "", | 354   ExpectNotValid(TEST_SOURCE, | 
|  | 355                  instance.get(), | 
|  | 356                  schema.get(), | 
|  | 357                  NULL, | 
|  | 358                  std::string(), | 
| 337                  JSONSchemaValidator::FormatErrorMessage( | 359                  JSONSchemaValidator::FormatErrorMessage( | 
| 338                      JSONSchemaValidator::kArrayMaxItems, "2")); | 360                      JSONSchemaValidator::kArrayMaxItems, "2")); | 
| 339 | 361 | 
| 340   instance->Remove(1, NULL); | 362   instance->Remove(1, NULL); | 
| 341   instance->Remove(1, NULL); | 363   instance->Remove(1, NULL); | 
| 342   ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1", | 364   ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1", | 
| 343                  JSONSchemaValidator::kArrayItemRequired); | 365                  JSONSchemaValidator::kArrayItemRequired); | 
| 344 | 366 | 
| 345   instance->Set(0, new base::FundamentalValue(42)); | 367   instance->Set(0, new base::FundamentalValue(42)); | 
| 346   instance->Append(new base::FundamentalValue(42)); | 368   instance->Append(new base::FundamentalValue(42)); | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 396 | 418 | 
| 397   scoped_ptr<base::ListValue> instance(new base::ListValue()); | 419   scoped_ptr<base::ListValue> instance(new base::ListValue()); | 
| 398   instance->Append(new base::StringValue("x")); | 420   instance->Append(new base::StringValue("x")); | 
| 399   instance->Append(new base::StringValue("x")); | 421   instance->Append(new base::StringValue("x")); | 
| 400 | 422 | 
| 401   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 423   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 
| 402   instance->Append(new base::StringValue("x")); | 424   instance->Append(new base::StringValue("x")); | 
| 403   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 425   ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 
| 404 | 426 | 
| 405   instance->Append(new base::StringValue("x")); | 427   instance->Append(new base::StringValue("x")); | 
| 406   ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "", | 428   ExpectNotValid(TEST_SOURCE, | 
|  | 429                  instance.get(), | 
|  | 430                  schema.get(), | 
|  | 431                  NULL, | 
|  | 432                  std::string(), | 
| 407                  JSONSchemaValidator::FormatErrorMessage( | 433                  JSONSchemaValidator::FormatErrorMessage( | 
| 408                      JSONSchemaValidator::kArrayMaxItems, "3")); | 434                      JSONSchemaValidator::kArrayMaxItems, "3")); | 
| 409   instance->Remove(1, NULL); | 435   instance->Remove(1, NULL); | 
| 410   instance->Remove(1, NULL); | 436   instance->Remove(1, NULL); | 
| 411   instance->Remove(1, NULL); | 437   instance->Remove(1, NULL); | 
| 412   ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "", | 438   ExpectNotValid(TEST_SOURCE, | 
|  | 439                  instance.get(), | 
|  | 440                  schema.get(), | 
|  | 441                  NULL, | 
|  | 442                  std::string(), | 
| 413                  JSONSchemaValidator::FormatErrorMessage( | 443                  JSONSchemaValidator::FormatErrorMessage( | 
| 414                      JSONSchemaValidator::kArrayMinItems, "2")); | 444                      JSONSchemaValidator::kArrayMinItems, "2")); | 
| 415 | 445 | 
| 416   instance->Remove(1, NULL); | 446   instance->Remove(1, NULL); | 
| 417   instance->Append(new base::FundamentalValue(42)); | 447   instance->Append(new base::FundamentalValue(42)); | 
| 418   ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1", | 448   ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1", | 
| 419                  JSONSchemaValidator::FormatErrorMessage( | 449                  JSONSchemaValidator::FormatErrorMessage( | 
| 420                      JSONSchemaValidator::kInvalidType, | 450                      JSONSchemaValidator::kInvalidType, | 
| 421                      schema::kString, | 451                      schema::kString, | 
| 422                      schema::kInteger)); | 452                      schema::kInteger)); | 
| 423 } | 453 } | 
| 424 | 454 | 
| 425 void JSONSchemaValidatorTestBase::TestString() { | 455 void JSONSchemaValidatorTestBase::TestString() { | 
| 426   scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); | 456   scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); | 
| 427   schema->SetString(schema::kType, schema::kString); | 457   schema->SetString(schema::kType, schema::kString); | 
| 428   schema->SetInteger(schema::kMinLength, 1); | 458   schema->SetInteger(schema::kMinLength, 1); | 
| 429   schema->SetInteger(schema::kMaxLength, 10); | 459   schema->SetInteger(schema::kMaxLength, 10); | 
| 430 | 460 | 
| 431   ExpectValid(TEST_SOURCE, | 461   ExpectValid(TEST_SOURCE, | 
| 432               scoped_ptr<base::Value>(new base::StringValue("x")).get(), | 462               scoped_ptr<base::Value>(new base::StringValue("x")).get(), | 
| 433               schema.get(), NULL); | 463               schema.get(), NULL); | 
| 434   ExpectValid(TEST_SOURCE, | 464   ExpectValid(TEST_SOURCE, | 
| 435               scoped_ptr<base::Value>( | 465               scoped_ptr<base::Value>( | 
| 436                   new base::StringValue("xxxxxxxxxx")).get(), | 466                   new base::StringValue("xxxxxxxxxx")).get(), | 
| 437               schema.get(), NULL); | 467               schema.get(), NULL); | 
| 438 | 468 | 
| 439   ExpectNotValid(TEST_SOURCE, | 469   ExpectNotValid( | 
| 440                  scoped_ptr<base::Value>(new base::StringValue("")).get(), | 470       TEST_SOURCE, | 
| 441                  schema.get(), NULL, "", | 471       scoped_ptr<base::Value>(new base::StringValue(std::string())).get(), | 
| 442                  JSONSchemaValidator::FormatErrorMessage( | 472       schema.get(), | 
| 443                      JSONSchemaValidator::kStringMinLength, "1")); | 473       NULL, | 
|  | 474       std::string(), | 
|  | 475       JSONSchemaValidator::FormatErrorMessage( | 
|  | 476           JSONSchemaValidator::kStringMinLength, "1")); | 
| 444   ExpectNotValid( | 477   ExpectNotValid( | 
| 445       TEST_SOURCE, | 478       TEST_SOURCE, | 
| 446       scoped_ptr<base::Value>(new base::StringValue("xxxxxxxxxxx")).get(), | 479       scoped_ptr<base::Value>(new base::StringValue("xxxxxxxxxxx")).get(), | 
| 447       schema.get(), NULL, "", | 480       schema.get(), | 
|  | 481       NULL, | 
|  | 482       std::string(), | 
| 448       JSONSchemaValidator::FormatErrorMessage( | 483       JSONSchemaValidator::FormatErrorMessage( | 
| 449           JSONSchemaValidator::kStringMaxLength, "10")); | 484           JSONSchemaValidator::kStringMaxLength, "10")); | 
| 450 } | 485 } | 
| 451 | 486 | 
| 452 void JSONSchemaValidatorTestBase::TestNumber() { | 487 void JSONSchemaValidatorTestBase::TestNumber() { | 
| 453   scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); | 488   scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); | 
| 454   schema->SetString(schema::kType, schema::kNumber); | 489   schema->SetString(schema::kType, schema::kNumber); | 
| 455   schema->SetInteger(schema::kMinimum, 1); | 490   schema->SetInteger(schema::kMinimum, 1); | 
| 456   schema->SetInteger(schema::kMaximum, 100); | 491   schema->SetInteger(schema::kMaximum, 100); | 
| 457   schema->SetInteger("maxDecimal", 2); | 492   schema->SetInteger("maxDecimal", 2); | 
| 458 | 493 | 
| 459   ExpectValid(TEST_SOURCE, | 494   ExpectValid(TEST_SOURCE, | 
| 460               scoped_ptr<base::Value>(new base::FundamentalValue(1)).get(), | 495               scoped_ptr<base::Value>(new base::FundamentalValue(1)).get(), | 
| 461               schema.get(), NULL); | 496               schema.get(), NULL); | 
| 462   ExpectValid(TEST_SOURCE, | 497   ExpectValid(TEST_SOURCE, | 
| 463               scoped_ptr<base::Value>(new base::FundamentalValue(50)).get(), | 498               scoped_ptr<base::Value>(new base::FundamentalValue(50)).get(), | 
| 464               schema.get(), NULL); | 499               schema.get(), NULL); | 
| 465   ExpectValid(TEST_SOURCE, | 500   ExpectValid(TEST_SOURCE, | 
| 466               scoped_ptr<base::Value>(new base::FundamentalValue(100)).get(), | 501               scoped_ptr<base::Value>(new base::FundamentalValue(100)).get(), | 
| 467               schema.get(), NULL); | 502               schema.get(), NULL); | 
| 468   ExpectValid(TEST_SOURCE, | 503   ExpectValid(TEST_SOURCE, | 
| 469               scoped_ptr<base::Value>(new base::FundamentalValue(88.88)).get(), | 504               scoped_ptr<base::Value>(new base::FundamentalValue(88.88)).get(), | 
| 470               schema.get(), NULL); | 505               schema.get(), NULL); | 
| 471 | 506 | 
| 472   ExpectNotValid( | 507   ExpectNotValid(TEST_SOURCE, | 
| 473       TEST_SOURCE, | 508                  scoped_ptr<base::Value>(new base::FundamentalValue(0.5)).get(), | 
| 474       scoped_ptr<base::Value>(new base::FundamentalValue(0.5)).get(), | 509                  schema.get(), | 
| 475       schema.get(), NULL, "", | 510                  NULL, | 
| 476       JSONSchemaValidator::FormatErrorMessage( | 511                  std::string(), | 
| 477           JSONSchemaValidator::kNumberMinimum, "1")); | 512                  JSONSchemaValidator::FormatErrorMessage( | 
|  | 513                      JSONSchemaValidator::kNumberMinimum, "1")); | 
| 478   ExpectNotValid( | 514   ExpectNotValid( | 
| 479       TEST_SOURCE, | 515       TEST_SOURCE, | 
| 480       scoped_ptr<base::Value>(new base::FundamentalValue(100.1)).get(), | 516       scoped_ptr<base::Value>(new base::FundamentalValue(100.1)).get(), | 
| 481       schema.get(), NULL, "", | 517       schema.get(), | 
|  | 518       NULL, | 
|  | 519       std::string(), | 
| 482       JSONSchemaValidator::FormatErrorMessage( | 520       JSONSchemaValidator::FormatErrorMessage( | 
| 483           JSONSchemaValidator::kNumberMaximum, "100")); | 521           JSONSchemaValidator::kNumberMaximum, "100")); | 
| 484 } | 522 } | 
| 485 | 523 | 
| 486 void JSONSchemaValidatorTestBase::TestTypeClassifier() { | 524 void JSONSchemaValidatorTestBase::TestTypeClassifier() { | 
| 487   EXPECT_EQ(std::string(schema::kBoolean), | 525   EXPECT_EQ(std::string(schema::kBoolean), | 
| 488             JSONSchemaValidator::GetJSONSchemaType( | 526             JSONSchemaValidator::GetJSONSchemaType( | 
| 489                 scoped_ptr<base::Value>( | 527                 scoped_ptr<base::Value>( | 
| 490                     new base::FundamentalValue(true)).get())); | 528                     new base::FundamentalValue(true)).get())); | 
| 491   EXPECT_EQ(std::string(schema::kBoolean), | 529   EXPECT_EQ(std::string(schema::kBoolean), | 
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 599               scoped_ptr<base::Value>(new base::FundamentalValue(true)).get(), | 637               scoped_ptr<base::Value>(new base::FundamentalValue(true)).get(), | 
| 600               schema.get(), NULL); | 638               schema.get(), NULL); | 
| 601 | 639 | 
| 602   schema->SetString(schema::kType, schema::kNull); | 640   schema->SetString(schema::kType, schema::kNull); | 
| 603   ExpectValid(TEST_SOURCE, | 641   ExpectValid(TEST_SOURCE, | 
| 604               scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 642               scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 
| 605               schema.get(), NULL); | 643               schema.get(), NULL); | 
| 606 | 644 | 
| 607   // not valid | 645   // not valid | 
| 608   schema->SetString(schema::kType, schema::kObject); | 646   schema->SetString(schema::kType, schema::kObject); | 
| 609   ExpectNotValid(TEST_SOURCE, | 647   ExpectNotValid( | 
| 610                  scoped_ptr<base::Value>(new base::ListValue()).get(), | 648       TEST_SOURCE, | 
| 611                  schema.get(), NULL, "", | 649       scoped_ptr<base::Value>(new base::ListValue()).get(), | 
| 612                  JSONSchemaValidator::FormatErrorMessage( | 650       schema.get(), | 
| 613                      JSONSchemaValidator::kInvalidType, | 651       NULL, | 
| 614                      schema::kObject, | 652       std::string(), | 
| 615                      schema::kArray)); | 653       JSONSchemaValidator::FormatErrorMessage( | 
|  | 654           JSONSchemaValidator::kInvalidType, schema::kObject, schema::kArray)); | 
| 616 | 655 | 
| 617   schema->SetString(schema::kType, schema::kObject); | 656   schema->SetString(schema::kType, schema::kObject); | 
| 618   ExpectNotValid(TEST_SOURCE, | 657   ExpectNotValid( | 
| 619                  scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 658       TEST_SOURCE, | 
| 620                  schema.get(), NULL, "", | 659       scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), | 
| 621                  JSONSchemaValidator::FormatErrorMessage( | 660       schema.get(), | 
| 622                      JSONSchemaValidator::kInvalidType, | 661       NULL, | 
| 623                      schema::kObject, | 662       std::string(), | 
| 624                      schema::kNull)); | 663       JSONSchemaValidator::FormatErrorMessage( | 
|  | 664           JSONSchemaValidator::kInvalidType, schema::kObject, schema::kNull)); | 
| 625 | 665 | 
| 626   schema->SetString(schema::kType, schema::kArray); | 666   schema->SetString(schema::kType, schema::kArray); | 
| 627   ExpectNotValid(TEST_SOURCE, | 667   ExpectNotValid( | 
| 628                  scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 668       TEST_SOURCE, | 
| 629                  schema.get(), NULL, "", | 669       scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 
| 630                  JSONSchemaValidator::FormatErrorMessage( | 670       schema.get(), | 
| 631                      JSONSchemaValidator::kInvalidType, | 671       NULL, | 
| 632                      schema::kArray, | 672       std::string(), | 
| 633                      schema::kInteger)); | 673       JSONSchemaValidator::FormatErrorMessage( | 
|  | 674           JSONSchemaValidator::kInvalidType, schema::kArray, schema::kInteger)); | 
| 634 | 675 | 
| 635   schema->SetString(schema::kType, schema::kString); | 676   schema->SetString(schema::kType, schema::kString); | 
| 636   ExpectNotValid(TEST_SOURCE, | 677   ExpectNotValid( | 
| 637                  scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 678       TEST_SOURCE, | 
| 638                  schema.get(), NULL, "", | 679       scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), | 
| 639                  JSONSchemaValidator::FormatErrorMessage( | 680       schema.get(), | 
| 640                      JSONSchemaValidator::kInvalidType, | 681       NULL, | 
| 641                      schema::kString, | 682       std::string(), | 
| 642                      schema::kInteger)); | 683       JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, | 
|  | 684                                               schema::kString, | 
|  | 685                                               schema::kInteger)); | 
| 643 | 686 | 
| 644   schema->SetString(schema::kType, schema::kNumber); | 687   schema->SetString(schema::kType, schema::kNumber); | 
| 645   ExpectNotValid(TEST_SOURCE, | 688   ExpectNotValid( | 
| 646                  scoped_ptr<base::Value>(new base::StringValue("42")).get(), | 689       TEST_SOURCE, | 
| 647                  schema.get(), NULL, "", | 690       scoped_ptr<base::Value>(new base::StringValue("42")).get(), | 
| 648                  JSONSchemaValidator::FormatErrorMessage( | 691       schema.get(), | 
| 649                      JSONSchemaValidator::kInvalidType, | 692       NULL, | 
| 650                      schema::kNumber, | 693       std::string(), | 
| 651                      schema::kString)); | 694       JSONSchemaValidator::FormatErrorMessage( | 
|  | 695           JSONSchemaValidator::kInvalidType, schema::kNumber, schema::kString)); | 
| 652 | 696 | 
| 653   schema->SetString(schema::kType, schema::kInteger); | 697   schema->SetString(schema::kType, schema::kInteger); | 
| 654   ExpectNotValid(TEST_SOURCE, | 698   ExpectNotValid( | 
| 655                  scoped_ptr<base::Value>( | 699       TEST_SOURCE, | 
| 656                      new base::FundamentalValue(88.8)).get(), | 700       scoped_ptr<base::Value>(new base::FundamentalValue(88.8)).get(), | 
| 657                  schema.get(), NULL, "", | 701       schema.get(), | 
| 658                  JSONSchemaValidator::kInvalidTypeIntegerNumber); | 702       NULL, | 
|  | 703       std::string(), | 
|  | 704       JSONSchemaValidator::kInvalidTypeIntegerNumber); | 
| 659 | 705 | 
| 660   schema->SetString(schema::kType, schema::kBoolean); | 706   schema->SetString(schema::kType, schema::kBoolean); | 
| 661   ExpectNotValid(TEST_SOURCE, | 707   ExpectNotValid( | 
| 662                  scoped_ptr<base::Value>(new base::FundamentalValue(1)).get(), | 708       TEST_SOURCE, | 
| 663                  schema.get(), NULL, "", | 709       scoped_ptr<base::Value>(new base::FundamentalValue(1)).get(), | 
| 664                  JSONSchemaValidator::FormatErrorMessage( | 710       schema.get(), | 
| 665                      JSONSchemaValidator::kInvalidType, | 711       NULL, | 
| 666                      schema::kBoolean, | 712       std::string(), | 
| 667                      schema::kInteger)); | 713       JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, | 
|  | 714                                               schema::kBoolean, | 
|  | 715                                               schema::kInteger)); | 
| 668 | 716 | 
| 669   schema->SetString(schema::kType, schema::kNull); | 717   schema->SetString(schema::kType, schema::kNull); | 
| 670   ExpectNotValid(TEST_SOURCE, | 718   ExpectNotValid( | 
| 671                  scoped_ptr<base::Value>( | 719       TEST_SOURCE, | 
| 672                      new base::FundamentalValue(false)).get(), | 720       scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), | 
| 673                  schema.get(), NULL, "", | 721       schema.get(), | 
| 674                  JSONSchemaValidator::FormatErrorMessage( | 722       NULL, | 
| 675                      JSONSchemaValidator::kInvalidType, | 723       std::string(), | 
| 676                      schema::kNull, | 724       JSONSchemaValidator::FormatErrorMessage( | 
| 677                      schema::kBoolean)); | 725           JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean)); | 
| 678 } | 726 } | 
| OLD | NEW | 
|---|