| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/values.h" | 9 #include "base/values.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "tools/json_schema_compiler/test/idl_basics.h" | 11 #include "tools/json_schema_compiler/test/idl_basics.h" |
| 11 #include "tools/json_schema_compiler/test/idl_object_types.h" | 12 #include "tools/json_schema_compiler/test/idl_object_types.h" |
| 12 | 13 |
| 13 using test::api::idl_basics::MyType1; | 14 using test::api::idl_basics::MyType1; |
| 14 using test::api::idl_object_types::BarType; | 15 using test::api::idl_object_types::BarType; |
| 15 using test::api::idl_object_types::FooType; | 16 using test::api::idl_object_types::FooType; |
| 16 | 17 |
| 17 namespace Function2 = test::api::idl_basics::Function2; | 18 namespace Function2 = test::api::idl_basics::Function2; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 MyType1* t1 = f9_params->arg.get(); | 123 MyType1* t1 = f9_params->arg.get(); |
| 123 EXPECT_EQ(17, t1->x); | 124 EXPECT_EQ(17, t1->x); |
| 124 EXPECT_EQ("hello", t1->y); | 125 EXPECT_EQ("hello", t1->y); |
| 125 } | 126 } |
| 126 | 127 |
| 127 TEST(IdlCompiler, ArrayTypes) { | 128 TEST(IdlCompiler, ArrayTypes) { |
| 128 // Tests of a function that takes an integer and an array of integers. First | 129 // Tests of a function that takes an integer and an array of integers. First |
| 129 // use an empty array. | 130 // use an empty array. |
| 130 base::ListValue list; | 131 base::ListValue list; |
| 131 list.AppendInteger(33); | 132 list.AppendInteger(33); |
| 132 list.Append(new base::ListValue); | 133 list.Append(base::MakeUnique<base::ListValue>()); |
| 133 std::unique_ptr<Function10::Params> f10_params = | 134 std::unique_ptr<Function10::Params> f10_params = |
| 134 Function10::Params::Create(list); | 135 Function10::Params::Create(list); |
| 135 ASSERT_TRUE(f10_params != NULL); | 136 ASSERT_TRUE(f10_params != NULL); |
| 136 EXPECT_EQ(33, f10_params->x); | 137 EXPECT_EQ(33, f10_params->x); |
| 137 EXPECT_TRUE(f10_params->y.empty()); | 138 EXPECT_TRUE(f10_params->y.empty()); |
| 138 | 139 |
| 139 // Same function, but this time with 2 values in the array. | 140 // Same function, but this time with 2 values in the array. |
| 140 list.Clear(); | 141 list.Clear(); |
| 141 list.AppendInteger(33); | 142 list.AppendInteger(33); |
| 142 std::unique_ptr<base::ListValue> sublist(new base::ListValue); | 143 std::unique_ptr<base::ListValue> sublist(new base::ListValue); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 &icon)); | 201 &icon)); |
| 201 base::ListValue list; | 202 base::ListValue list; |
| 202 list.Append(std::move(icon_props)); | 203 list.Append(std::move(icon_props)); |
| 203 std::unique_ptr<ObjectFunction1::Params> params = | 204 std::unique_ptr<ObjectFunction1::Params> params = |
| 204 ObjectFunction1::Params::Create(list); | 205 ObjectFunction1::Params::Create(list); |
| 205 ASSERT_TRUE(params.get() != NULL); | 206 ASSERT_TRUE(params.get() != NULL); |
| 206 std::string tmp; | 207 std::string tmp; |
| 207 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); | 208 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); |
| 208 EXPECT_EQ("world", tmp); | 209 EXPECT_EQ("world", tmp); |
| 209 } | 210 } |
| OLD | NEW |