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