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/memory/ptr_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Test the FooType type. | 177 // Test the FooType type. |
178 FooType f1; | 178 FooType f1; |
179 f1.x = 3; | 179 f1.x = 3; |
180 std::unique_ptr<base::DictionaryValue> serialized_foo = f1.ToValue(); | 180 std::unique_ptr<base::DictionaryValue> serialized_foo = f1.ToValue(); |
181 FooType f2; | 181 FooType f2; |
182 EXPECT_TRUE(FooType::Populate(*serialized_foo.get(), &f2)); | 182 EXPECT_TRUE(FooType::Populate(*serialized_foo.get(), &f2)); |
183 EXPECT_EQ(f1.x, f2.x); | 183 EXPECT_EQ(f1.x, f2.x); |
184 | 184 |
185 // Test the BarType type. | 185 // Test the BarType type. |
186 BarType b1; | 186 BarType b1; |
187 b1.x.reset(new base::FundamentalValue(7)); | 187 b1.x.reset(new base::Value(7)); |
188 std::unique_ptr<base::DictionaryValue> serialized_bar = b1.ToValue(); | 188 std::unique_ptr<base::DictionaryValue> serialized_bar = b1.ToValue(); |
189 BarType b2; | 189 BarType b2; |
190 EXPECT_TRUE(BarType::Populate(*serialized_bar.get(), &b2)); | 190 EXPECT_TRUE(BarType::Populate(*serialized_bar.get(), &b2)); |
191 int tmp_int = 0; | 191 int tmp_int = 0; |
192 EXPECT_TRUE(b2.x->GetAsInteger(&tmp_int)); | 192 EXPECT_TRUE(b2.x->GetAsInteger(&tmp_int)); |
193 EXPECT_EQ(7, tmp_int); | 193 EXPECT_EQ(7, tmp_int); |
194 | 194 |
195 // Test the params to the ObjectFunction1 function. | 195 // Test the params to the ObjectFunction1 function. |
196 std::unique_ptr<base::DictionaryValue> icon_props( | 196 std::unique_ptr<base::DictionaryValue> icon_props( |
197 new base::DictionaryValue()); | 197 new base::DictionaryValue()); |
198 icon_props->SetString("hello", "world"); | 198 icon_props->SetString("hello", "world"); |
199 ObjectFunction1::Params::Icon icon; | 199 ObjectFunction1::Params::Icon icon; |
200 EXPECT_TRUE(ObjectFunction1::Params::Icon::Populate(*(icon_props.get()), | 200 EXPECT_TRUE(ObjectFunction1::Params::Icon::Populate(*(icon_props.get()), |
201 &icon)); | 201 &icon)); |
202 base::ListValue list; | 202 base::ListValue list; |
203 list.Append(std::move(icon_props)); | 203 list.Append(std::move(icon_props)); |
204 std::unique_ptr<ObjectFunction1::Params> params = | 204 std::unique_ptr<ObjectFunction1::Params> params = |
205 ObjectFunction1::Params::Create(list); | 205 ObjectFunction1::Params::Create(list); |
206 ASSERT_TRUE(params.get() != NULL); | 206 ASSERT_TRUE(params.get() != NULL); |
207 std::string tmp; | 207 std::string tmp; |
208 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); | 208 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); |
209 EXPECT_EQ("world", tmp); | 209 EXPECT_EQ("world", tmp); |
210 } | 210 } |
OLD | NEW |