| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_UNITTEST_BASE_H_ | |
| 6 #define CHROME_COMMON_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_UNITTEST_BASE_H_ | |
| 7 | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace base { | |
| 11 class DictionaryValue; | |
| 12 class ListValue; | |
| 13 class Value; | |
| 14 } | |
| 15 | |
| 16 // Base class for unit tests for JSONSchemaValidator. There is currently only | |
| 17 // one implementation, JSONSchemaValidatorCPPTest. | |
| 18 // | |
| 19 // TODO(aa): Refactor chrome/test/data/json_schema_test.js into | |
| 20 // JSONSchemaValidatorJSTest that inherits from this. | |
| 21 class JSONSchemaValidatorTestBase : public testing::Test { | |
| 22 public: | |
| 23 enum ValidatorType { | |
| 24 CPP = 1, | |
| 25 JS = 2 | |
| 26 }; | |
| 27 | |
| 28 explicit JSONSchemaValidatorTestBase(ValidatorType type); | |
| 29 | |
| 30 void RunTests(); | |
| 31 | |
| 32 protected: | |
| 33 virtual void ExpectValid(const std::string& test_source, | |
| 34 base::Value* instance, | |
| 35 base::DictionaryValue* schema, | |
| 36 base::ListValue* types) = 0; | |
| 37 | |
| 38 virtual void ExpectNotValid(const std::string& test_source, | |
| 39 base::Value* instance, | |
| 40 base::DictionaryValue* schema, | |
| 41 base::ListValue* types, | |
| 42 const std::string& expected_error_path, | |
| 43 const std::string& expected_error_message) = 0; | |
| 44 | |
| 45 private: | |
| 46 void TestComplex(); | |
| 47 void TestStringPattern(); | |
| 48 void TestEnum(); | |
| 49 void TestChoices(); | |
| 50 void TestExtends(); | |
| 51 void TestObject(); | |
| 52 void TestTypeReference(); | |
| 53 void TestArrayTuple(); | |
| 54 void TestArrayNonTuple(); | |
| 55 void TestString(); | |
| 56 void TestNumber(); | |
| 57 void TestTypeClassifier(); | |
| 58 void TestTypes(); | |
| 59 | |
| 60 ValidatorType type_; | |
| 61 }; | |
| 62 | |
| 63 #endif // CHROME_COMMON_JSON_SCHEMA_JSON_SCHEMA_VALIDATOR_UNITTEST_BASE_H_ | |
| OLD | NEW |