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/additional_properties.h" | 5 #include "tools/json_schema_compiler/test/additional_properties.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 TEST(JsonSchemaCompilerAdditionalPropertiesTest, | 40 TEST(JsonSchemaCompilerAdditionalPropertiesTest, |
41 AdditionalPropertiesParamsCreate) { | 41 AdditionalPropertiesParamsCreate) { |
42 std::unique_ptr<base::DictionaryValue> param_object_value( | 42 std::unique_ptr<base::DictionaryValue> param_object_value( |
43 new base::DictionaryValue()); | 43 new base::DictionaryValue()); |
44 param_object_value->SetString("str", "a"); | 44 param_object_value->SetString("str", "a"); |
45 param_object_value->SetInteger("num", 1); | 45 param_object_value->SetInteger("num", 1); |
46 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); | 46 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); |
47 params_value->Append(param_object_value->DeepCopy()); | 47 params_value->Append(param_object_value->CreateDeepCopy()); |
48 std::unique_ptr<AdditionalProperties::Params> params( | 48 std::unique_ptr<AdditionalProperties::Params> params( |
49 AdditionalProperties::Params::Create(*params_value)); | 49 AdditionalProperties::Params::Create(*params_value)); |
50 EXPECT_TRUE(params.get()); | 50 EXPECT_TRUE(params.get()); |
51 EXPECT_TRUE(params->param_object.additional_properties.Equals( | 51 EXPECT_TRUE(params->param_object.additional_properties.Equals( |
52 param_object_value.get())); | 52 param_object_value.get())); |
53 } | 53 } |
54 | 54 |
55 TEST(JsonSchemaCompilerAdditionalPropertiesTest, | 55 TEST(JsonSchemaCompilerAdditionalPropertiesTest, |
56 ReturnAdditionalPropertiesResultCreate) { | 56 ReturnAdditionalPropertiesResultCreate) { |
57 ReturnAdditionalProperties::Results::ResultObject result_object; | 57 ReturnAdditionalProperties::Results::ResultObject result_object; |
58 result_object.integer = 5; | 58 result_object.integer = 5; |
59 result_object.additional_properties["key"] = "value"; | 59 result_object.additional_properties["key"] = "value"; |
60 | 60 |
61 base::ListValue expected; | 61 base::ListValue expected; |
62 { | 62 { |
63 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 63 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
64 dict->SetInteger("integer", 5); | 64 dict->SetInteger("integer", 5); |
65 dict->SetString("key", "value"); | 65 dict->SetString("key", "value"); |
66 expected.Append(std::move(dict)); | 66 expected.Append(std::move(dict)); |
67 } | 67 } |
68 | 68 |
69 EXPECT_TRUE(base::Value::Equals( | 69 EXPECT_TRUE(base::Value::Equals( |
70 ReturnAdditionalProperties::Results::Create(result_object).get(), | 70 ReturnAdditionalProperties::Results::Create(result_object).get(), |
71 &expected)); | 71 &expected)); |
72 } | 72 } |
OLD | NEW |