| 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", base::Value::CreateIntegerValue(4)); | 17 value->SetWithoutPathExpansion("integer", base::Value::CreateIntegerValue(4)); |
| 18 value->SetWithoutPathExpansion("string", | 18 value->SetWithoutPathExpansion("string", new base::StringValue("bling")); |
| 19 base::Value::CreateStringValue("bling")); | |
| 20 value->SetWithoutPathExpansion("boolean", | 19 value->SetWithoutPathExpansion("boolean", |
| 21 base::Value::CreateBooleanValue(true)); | 20 base::Value::CreateBooleanValue(true)); |
| 22 return scoped_ptr<base::DictionaryValue>(value); | 21 return scoped_ptr<base::DictionaryValue>(value); |
| 23 } | 22 } |
| 24 | 23 |
| 25 } // namespace | 24 } // namespace |
| 26 | 25 |
| 27 TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) { | 26 TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) { |
| 28 scoped_ptr<CrossrefType> crossref_type(new CrossrefType()); | 27 scoped_ptr<CrossrefType> crossref_type(new CrossrefType()); |
| 29 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 28 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 scoped_ptr<TestTypeInObject::Params> params( | 95 scoped_ptr<TestTypeInObject::Params> params( |
| 97 TestTypeInObject::Params::Create(*params_value)); | 96 TestTypeInObject::Params::Create(*params_value)); |
| 98 EXPECT_TRUE(params.get()); | 97 EXPECT_TRUE(params.get()); |
| 99 EXPECT_FALSE(params->param_object.test_type.get()); | 98 EXPECT_FALSE(params->param_object.test_type.get()); |
| 100 EXPECT_TRUE(params->param_object.boolean); | 99 EXPECT_TRUE(params->param_object.boolean); |
| 101 } | 100 } |
| 102 { | 101 { |
| 103 scoped_ptr<base::ListValue> params_value(new base::ListValue()); | 102 scoped_ptr<base::ListValue> params_value(new base::ListValue()); |
| 104 scoped_ptr<base::DictionaryValue> param_object_value( | 103 scoped_ptr<base::DictionaryValue> param_object_value( |
| 105 new base::DictionaryValue()); | 104 new base::DictionaryValue()); |
| 106 param_object_value->Set("testType", | 105 param_object_value->Set("testType", new base::StringValue("invalid")); |
| 107 base::Value::CreateStringValue("invalid")); | |
| 108 param_object_value->Set("boolean", base::Value::CreateBooleanValue(true)); | 106 param_object_value->Set("boolean", base::Value::CreateBooleanValue(true)); |
| 109 params_value->Append(param_object_value.release()); | 107 params_value->Append(param_object_value.release()); |
| 110 scoped_ptr<TestTypeInObject::Params> params( | 108 scoped_ptr<TestTypeInObject::Params> params( |
| 111 TestTypeInObject::Params::Create(*params_value)); | 109 TestTypeInObject::Params::Create(*params_value)); |
| 112 EXPECT_FALSE(params.get()); | 110 EXPECT_FALSE(params.get()); |
| 113 } | 111 } |
| 114 { | 112 { |
| 115 scoped_ptr<base::ListValue> params_value(new base::ListValue()); | 113 scoped_ptr<base::ListValue> params_value(new base::ListValue()); |
| 116 scoped_ptr<base::DictionaryValue> param_object_value( | 114 scoped_ptr<base::DictionaryValue> param_object_value( |
| 117 new base::DictionaryValue()); | 115 new base::DictionaryValue()); |
| 118 param_object_value->Set("testType", CreateTestTypeDictionary().release()); | 116 param_object_value->Set("testType", CreateTestTypeDictionary().release()); |
| 119 params_value->Append(param_object_value.release()); | 117 params_value->Append(param_object_value.release()); |
| 120 scoped_ptr<TestTypeInObject::Params> params( | 118 scoped_ptr<TestTypeInObject::Params> params( |
| 121 TestTypeInObject::Params::Create(*params_value)); | 119 TestTypeInObject::Params::Create(*params_value)); |
| 122 EXPECT_FALSE(params.get()); | 120 EXPECT_FALSE(params.get()); |
| 123 } | 121 } |
| 124 } | 122 } |
| OLD | NEW |