By moving the call to Load() up in SearchProvider::Start(), we are giving a chance...
[chromium-blink-merge.git] / chrome / common / json_schema_validator_unittest.cc
blobca4b38803c177b4a836475d5d04e8ce61c25b50f
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/values.h"
6 #include "chrome/common/json_schema_validator.h"
7 #include "chrome/common/json_schema_validator_unittest_base.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 class JSONSchemaValidatorCPPTest : public JSONSchemaValidatorTestBase {
11 public:
12 JSONSchemaValidatorCPPTest()
13 : JSONSchemaValidatorTestBase(JSONSchemaValidatorTestBase::CPP) {
16 protected:
17 virtual void ExpectValid(const std::string& test_source,
18 Value* instance, DictionaryValue* schema,
19 ListValue* types) {
20 JSONSchemaValidator validator(schema, types);
21 if (validator.Validate(instance))
22 return;
24 for (size_t i = 0; i < validator.errors().size(); ++i) {
25 ADD_FAILURE() << test_source << ": "
26 << validator.errors()[i].path << ": "
27 << validator.errors()[i].message;
31 virtual void ExpectNotValid(const std::string& test_source,
32 Value* instance, DictionaryValue* schema,
33 ListValue* types,
34 const std::string& expected_error_path,
35 const std::string& expected_error_message) {
36 JSONSchemaValidator validator(schema, types);
37 if (validator.Validate(instance)) {
38 ADD_FAILURE() << test_source;
39 return;
42 ASSERT_EQ(1u, validator.errors().size()) << test_source;
43 EXPECT_EQ(expected_error_path, validator.errors()[0].path) << test_source;
44 EXPECT_EQ(expected_error_message, validator.errors()[0].message)
45 << test_source;
49 TEST_F(JSONSchemaValidatorCPPTest, Test) {
50 RunTests();