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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
Devlin
2016/04/07 04:15:59
nit: maybe fix IWYU error here and in the other te
dcheng
2016/04/07 04:24:02
Done.
| |
6 #include "tools/json_schema_compiler/test/additional_properties.h" | 6 #include "tools/json_schema_compiler/test/additional_properties.h" |
7 | 7 |
8 using namespace test::api::additional_properties; | 8 using namespace test::api::additional_properties; |
9 | 9 |
10 TEST(JsonSchemaCompilerAdditionalPropertiesTest, | 10 TEST(JsonSchemaCompilerAdditionalPropertiesTest, |
11 AdditionalPropertiesTypePopulate) { | 11 AdditionalPropertiesTypePopulate) { |
12 { | 12 { |
13 scoped_ptr<base::ListValue> list_value(new base::ListValue()); | 13 std::unique_ptr<base::ListValue> list_value(new base::ListValue()); |
14 list_value->Append(new base::StringValue("asdf")); | 14 list_value->Append(new base::StringValue("asdf")); |
15 list_value->Append(new base::FundamentalValue(4)); | 15 list_value->Append(new base::FundamentalValue(4)); |
16 scoped_ptr<base::DictionaryValue> type_value(new base::DictionaryValue()); | 16 std::unique_ptr<base::DictionaryValue> type_value( |
17 new base::DictionaryValue()); | |
17 type_value->SetString("string", "value"); | 18 type_value->SetString("string", "value"); |
18 type_value->SetInteger("other", 9); | 19 type_value->SetInteger("other", 9); |
19 type_value->Set("another", list_value.release()); | 20 type_value->Set("another", list_value.release()); |
20 scoped_ptr<AdditionalPropertiesType> type(new AdditionalPropertiesType()); | 21 std::unique_ptr<AdditionalPropertiesType> type( |
22 new AdditionalPropertiesType()); | |
21 ASSERT_TRUE(AdditionalPropertiesType::Populate(*type_value, type.get())); | 23 ASSERT_TRUE(AdditionalPropertiesType::Populate(*type_value, type.get())); |
22 EXPECT_TRUE(type->additional_properties.Equals(type_value.get())); | 24 EXPECT_TRUE(type->additional_properties.Equals(type_value.get())); |
23 } | 25 } |
24 { | 26 { |
25 scoped_ptr<base::DictionaryValue> type_value(new base::DictionaryValue()); | 27 std::unique_ptr<base::DictionaryValue> type_value( |
28 new base::DictionaryValue()); | |
26 type_value->SetInteger("string", 3); | 29 type_value->SetInteger("string", 3); |
27 scoped_ptr<AdditionalPropertiesType> type(new AdditionalPropertiesType()); | 30 std::unique_ptr<AdditionalPropertiesType> type( |
31 new AdditionalPropertiesType()); | |
28 EXPECT_FALSE(AdditionalPropertiesType::Populate(*type_value, type.get())); | 32 EXPECT_FALSE(AdditionalPropertiesType::Populate(*type_value, type.get())); |
29 } | 33 } |
30 } | 34 } |
31 | 35 |
32 TEST(JsonSchemaCompilerAdditionalPropertiesTest, | 36 TEST(JsonSchemaCompilerAdditionalPropertiesTest, |
33 AdditionalPropertiesParamsCreate) { | 37 AdditionalPropertiesParamsCreate) { |
34 scoped_ptr<base::DictionaryValue> param_object_value( | 38 std::unique_ptr<base::DictionaryValue> param_object_value( |
35 new base::DictionaryValue()); | 39 new base::DictionaryValue()); |
36 param_object_value->SetString("str", "a"); | 40 param_object_value->SetString("str", "a"); |
37 param_object_value->SetInteger("num", 1); | 41 param_object_value->SetInteger("num", 1); |
38 scoped_ptr<base::ListValue> params_value(new base::ListValue()); | 42 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); |
39 params_value->Append(param_object_value->DeepCopy()); | 43 params_value->Append(param_object_value->DeepCopy()); |
40 scoped_ptr<AdditionalProperties::Params> params( | 44 std::unique_ptr<AdditionalProperties::Params> params( |
41 AdditionalProperties::Params::Create(*params_value)); | 45 AdditionalProperties::Params::Create(*params_value)); |
42 EXPECT_TRUE(params.get()); | 46 EXPECT_TRUE(params.get()); |
43 EXPECT_TRUE(params->param_object.additional_properties.Equals( | 47 EXPECT_TRUE(params->param_object.additional_properties.Equals( |
44 param_object_value.get())); | 48 param_object_value.get())); |
45 } | 49 } |
46 | 50 |
47 TEST(JsonSchemaCompilerAdditionalPropertiesTest, | 51 TEST(JsonSchemaCompilerAdditionalPropertiesTest, |
48 ReturnAdditionalPropertiesResultCreate) { | 52 ReturnAdditionalPropertiesResultCreate) { |
49 ReturnAdditionalProperties::Results::ResultObject result_object; | 53 ReturnAdditionalProperties::Results::ResultObject result_object; |
50 result_object.integer = 5; | 54 result_object.integer = 5; |
51 result_object.additional_properties["key"] = "value"; | 55 result_object.additional_properties["key"] = "value"; |
52 | 56 |
53 base::ListValue expected; | 57 base::ListValue expected; |
54 { | 58 { |
55 base::DictionaryValue* dict = new base::DictionaryValue(); | 59 base::DictionaryValue* dict = new base::DictionaryValue(); |
56 dict->SetInteger("integer", 5); | 60 dict->SetInteger("integer", 5); |
57 dict->SetString("key", "value"); | 61 dict->SetString("key", "value"); |
58 expected.Append(dict); | 62 expected.Append(dict); |
59 } | 63 } |
60 | 64 |
61 EXPECT_TRUE(base::Value::Equals( | 65 EXPECT_TRUE(base::Value::Equals( |
62 ReturnAdditionalProperties::Results::Create(result_object).get(), | 66 ReturnAdditionalProperties::Results::Create(result_object).get(), |
63 &expected)); | 67 &expected)); |
64 } | 68 } |
OLD | NEW |