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 #include "tools/json_schema_compiler/test/crossref.h" | 6 #include "tools/json_schema_compiler/test/crossref.h" |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using namespace test::api::crossref; | 10 using namespace test::api::crossref; |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 static scoped_ptr<base::DictionaryValue> CreateTestTypeDictionary() { | 14 static scoped_ptr<base::DictionaryValue> CreateTestTypeDictionary() { |
15 base::DictionaryValue* value(new base::DictionaryValue()); | 15 base::DictionaryValue* value(new base::DictionaryValue()); |
16 value->SetWithoutPathExpansion("number", base::Value::CreateDoubleValue(1.1)); | 16 value->SetWithoutPathExpansion("number", base::Value::CreateDoubleValue(1.1)); |
17 value->SetWithoutPathExpansion("integer", new base::FundamentalValue(4)); | 17 value->SetWithoutPathExpansion("integer", new base::FundamentalValue(4)); |
18 value->SetWithoutPathExpansion("string", | 18 value->SetWithoutPathExpansion("string", new base::StringValue("bling")); |
19 base::Value::CreateStringValue("bling")); | |
20 value->SetWithoutPathExpansion("boolean", new base::FundamentalValue(true)); | 19 value->SetWithoutPathExpansion("boolean", new base::FundamentalValue(true)); |
21 return scoped_ptr<base::DictionaryValue>(value); | 20 return scoped_ptr<base::DictionaryValue>(value); |
22 } | 21 } |
23 | 22 |
24 } // namespace | 23 } // namespace |
25 | 24 |
26 TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) { | 25 TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) { |
27 scoped_ptr<CrossrefType> crossref_type(new CrossrefType()); | 26 scoped_ptr<CrossrefType> crossref_type(new CrossrefType()); |
28 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 27 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
29 value->Set("testType", CreateTestTypeDictionary().release()); | 28 value->Set("testType", CreateTestTypeDictionary().release()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 scoped_ptr<TestTypeInObject::Params> params( | 94 scoped_ptr<TestTypeInObject::Params> params( |
96 TestTypeInObject::Params::Create(*params_value)); | 95 TestTypeInObject::Params::Create(*params_value)); |
97 EXPECT_TRUE(params.get()); | 96 EXPECT_TRUE(params.get()); |
98 EXPECT_FALSE(params->param_object.test_type.get()); | 97 EXPECT_FALSE(params->param_object.test_type.get()); |
99 EXPECT_TRUE(params->param_object.boolean); | 98 EXPECT_TRUE(params->param_object.boolean); |
100 } | 99 } |
101 { | 100 { |
102 scoped_ptr<base::ListValue> params_value(new base::ListValue()); | 101 scoped_ptr<base::ListValue> params_value(new base::ListValue()); |
103 scoped_ptr<base::DictionaryValue> param_object_value( | 102 scoped_ptr<base::DictionaryValue> param_object_value( |
104 new base::DictionaryValue()); | 103 new base::DictionaryValue()); |
105 param_object_value->Set("testType", | 104 param_object_value->Set("testType", new base::StringValue("invalid")); |
106 base::Value::CreateStringValue("invalid")); | |
107 param_object_value->Set("boolean", new base::FundamentalValue(true)); | 105 param_object_value->Set("boolean", new base::FundamentalValue(true)); |
108 params_value->Append(param_object_value.release()); | 106 params_value->Append(param_object_value.release()); |
109 scoped_ptr<TestTypeInObject::Params> params( | 107 scoped_ptr<TestTypeInObject::Params> params( |
110 TestTypeInObject::Params::Create(*params_value)); | 108 TestTypeInObject::Params::Create(*params_value)); |
111 EXPECT_FALSE(params.get()); | 109 EXPECT_FALSE(params.get()); |
112 } | 110 } |
113 { | 111 { |
114 scoped_ptr<base::ListValue> params_value(new base::ListValue()); | 112 scoped_ptr<base::ListValue> params_value(new base::ListValue()); |
115 scoped_ptr<base::DictionaryValue> param_object_value( | 113 scoped_ptr<base::DictionaryValue> param_object_value( |
116 new base::DictionaryValue()); | 114 new base::DictionaryValue()); |
117 param_object_value->Set("testType", CreateTestTypeDictionary().release()); | 115 param_object_value->Set("testType", CreateTestTypeDictionary().release()); |
118 params_value->Append(param_object_value.release()); | 116 params_value->Append(param_object_value.release()); |
119 scoped_ptr<TestTypeInObject::Params> params( | 117 scoped_ptr<TestTypeInObject::Params> params( |
120 TestTypeInObject::Params::Create(*params_value)); | 118 TestTypeInObject::Params::Create(*params_value)); |
121 EXPECT_FALSE(params.get()); | 119 EXPECT_FALSE(params.get()); |
122 } | 120 } |
123 } | 121 } |
OLD | NEW |