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 "tools/json_schema_compiler/test/simple_api.h" | 5 #include "tools/json_schema_compiler/test/simple_api.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using namespace test::api::simple_api; | 9 using namespace test::api::simple_api; |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 TEST(JsonSchemaCompilerSimpleTest, IncrementIntegerParamsCreate) { | 31 TEST(JsonSchemaCompilerSimpleTest, IncrementIntegerParamsCreate) { |
32 scoped_ptr<ListValue> params_value(new ListValue()); | 32 scoped_ptr<ListValue> params_value(new ListValue()); |
33 params_value->Append(Value::CreateIntegerValue(6)); | 33 params_value->Append(Value::CreateIntegerValue(6)); |
34 scoped_ptr<IncrementInteger::Params> params( | 34 scoped_ptr<IncrementInteger::Params> params( |
35 IncrementInteger::Params::Create(*params_value)); | 35 IncrementInteger::Params::Create(*params_value)); |
36 EXPECT_TRUE(params.get()); | 36 EXPECT_TRUE(params.get()); |
37 EXPECT_EQ(6, params->num); | 37 EXPECT_EQ(6, params->num); |
38 } | 38 } |
39 | 39 |
| 40 TEST(JsonSchemaCompilerSimpleTest, NumberOfParams) { |
| 41 { |
| 42 scoped_ptr<ListValue> params_value(new ListValue()); |
| 43 params_value->Append(Value::CreateStringValue("text")); |
| 44 params_value->Append(Value::CreateStringValue("text")); |
| 45 scoped_ptr<OptionalString::Params> params( |
| 46 OptionalString::Params::Create(*params_value)); |
| 47 EXPECT_FALSE(params.get()); |
| 48 } |
| 49 { |
| 50 scoped_ptr<ListValue> params_value(new ListValue()); |
| 51 scoped_ptr<IncrementInteger::Params> params( |
| 52 IncrementInteger::Params::Create(*params_value)); |
| 53 EXPECT_FALSE(params.get()); |
| 54 } |
| 55 } |
| 56 |
40 TEST(JsonSchemaCompilerSimpleTest, OptionalStringParamsCreate) { | 57 TEST(JsonSchemaCompilerSimpleTest, OptionalStringParamsCreate) { |
41 { | 58 { |
42 scoped_ptr<ListValue> params_value(new ListValue()); | 59 scoped_ptr<ListValue> params_value(new ListValue()); |
43 scoped_ptr<OptionalString::Params> params( | 60 scoped_ptr<OptionalString::Params> params( |
44 OptionalString::Params::Create(*params_value)); | 61 OptionalString::Params::Create(*params_value)); |
45 EXPECT_TRUE(params.get()); | 62 EXPECT_TRUE(params.get()); |
46 EXPECT_FALSE(params->str.get()); | 63 EXPECT_FALSE(params->str.get()); |
47 } | 64 } |
48 { | 65 { |
49 scoped_ptr<ListValue> params_value(new ListValue()); | 66 scoped_ptr<ListValue> params_value(new ListValue()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 EXPECT_TRUE(TestType::Populate(*value, test_type.get())); | 107 EXPECT_TRUE(TestType::Populate(*value, test_type.get())); |
91 EXPECT_EQ("bling", test_type->string); | 108 EXPECT_EQ("bling", test_type->string); |
92 EXPECT_EQ(1.1, test_type->number); | 109 EXPECT_EQ(1.1, test_type->number); |
93 EXPECT_EQ(4, test_type->integer); | 110 EXPECT_EQ(4, test_type->integer); |
94 EXPECT_EQ(true, test_type->boolean); | 111 EXPECT_EQ(true, test_type->boolean); |
95 EXPECT_TRUE(value->Equals(test_type->ToValue().get())); | 112 EXPECT_TRUE(value->Equals(test_type->ToValue().get())); |
96 } | 113 } |
97 { | 114 { |
98 scoped_ptr<TestType> test_type(new TestType()); | 115 scoped_ptr<TestType> test_type(new TestType()); |
99 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary(); | 116 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary(); |
100 value->RemoveWithoutPathExpansion("number", NULL); | 117 value->Remove("number", NULL); |
101 EXPECT_FALSE(TestType::Populate(*value, test_type.get())); | 118 EXPECT_FALSE(TestType::Populate(*value, test_type.get())); |
102 } | 119 } |
103 } | 120 } |
104 | 121 |
105 TEST(JsonSchemaCompilerSimpleTest, GetTestType) { | 122 TEST(JsonSchemaCompilerSimpleTest, GetTestType) { |
106 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary(); | 123 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary(); |
107 scoped_ptr<TestType> test_type(new TestType()); | 124 scoped_ptr<TestType> test_type(new TestType()); |
108 EXPECT_TRUE(TestType::Populate(*value, test_type.get())); | 125 EXPECT_TRUE(TestType::Populate(*value, test_type.get())); |
109 scoped_ptr<Value> result(GetTestType::Result::Create(*test_type)); | 126 scoped_ptr<Value> result(GetTestType::Result::Create(*test_type)); |
110 EXPECT_TRUE(value->Equals(result.get())); | 127 EXPECT_TRUE(value->Equals(result.get())); |
111 } | 128 } |
112 | 129 |
OLD | NEW |