| 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 "base/values.h" | 5 #include "base/values.h" |
| 6 #include "tools/json_schema_compiler/test/idl_basics.h" | 6 #include "tools/json_schema_compiler/test/idl_basics.h" |
| 7 #include "tools/json_schema_compiler/test/idl_object_types.h" | 7 #include "tools/json_schema_compiler/test/idl_object_types.h" |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 b.x = 6; | 150 b.x = 6; |
| 151 a.y = std::string("foo"); | 151 a.y = std::string("foo"); |
| 152 b.y = std::string("bar"); | 152 b.y = std::string("bar"); |
| 153 base::ListValue* sublist2 = new base::ListValue; | 153 base::ListValue* sublist2 = new base::ListValue; |
| 154 sublist2->Append(a.ToValue().release()); | 154 sublist2->Append(a.ToValue().release()); |
| 155 sublist2->Append(b.ToValue().release()); | 155 sublist2->Append(b.ToValue().release()); |
| 156 list.Append(sublist2); | 156 list.Append(sublist2); |
| 157 scoped_ptr<Function11::Params> f11_params = Function11::Params::Create(list); | 157 scoped_ptr<Function11::Params> f11_params = Function11::Params::Create(list); |
| 158 ASSERT_TRUE(f11_params != NULL); | 158 ASSERT_TRUE(f11_params != NULL); |
| 159 ASSERT_EQ(2u, f11_params->arg.size()); | 159 ASSERT_EQ(2u, f11_params->arg.size()); |
| 160 EXPECT_EQ(5, f11_params->arg[0]->x); | 160 EXPECT_EQ(5, f11_params->arg[0].x); |
| 161 EXPECT_EQ("foo", f11_params->arg[0]->y); | 161 EXPECT_EQ("foo", f11_params->arg[0].y); |
| 162 EXPECT_EQ(6, f11_params->arg[1]->x); | 162 EXPECT_EQ(6, f11_params->arg[1].x); |
| 163 EXPECT_EQ("bar", f11_params->arg[1]->y); | 163 EXPECT_EQ("bar", f11_params->arg[1].y); |
| 164 } | 164 } |
| 165 | 165 |
| 166 TEST(IdlCompiler, ObjectTypes) { | 166 TEST(IdlCompiler, ObjectTypes) { |
| 167 // Test the FooType type. | 167 // Test the FooType type. |
| 168 FooType f1; | 168 FooType f1; |
| 169 f1.x = 3; | 169 f1.x = 3; |
| 170 scoped_ptr<base::DictionaryValue> serialized_foo = f1.ToValue(); | 170 scoped_ptr<base::DictionaryValue> serialized_foo = f1.ToValue(); |
| 171 FooType f2; | 171 FooType f2; |
| 172 EXPECT_TRUE(FooType::Populate(*serialized_foo.get(), &f2)); | 172 EXPECT_TRUE(FooType::Populate(*serialized_foo.get(), &f2)); |
| 173 EXPECT_EQ(f1.x, f2.x); | 173 EXPECT_EQ(f1.x, f2.x); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 190 &icon)); | 190 &icon)); |
| 191 base::ListValue list; | 191 base::ListValue list; |
| 192 list.Append(icon_props.release()); | 192 list.Append(icon_props.release()); |
| 193 scoped_ptr<ObjectFunction1::Params> params = | 193 scoped_ptr<ObjectFunction1::Params> params = |
| 194 ObjectFunction1::Params::Create(list); | 194 ObjectFunction1::Params::Create(list); |
| 195 ASSERT_TRUE(params.get() != NULL); | 195 ASSERT_TRUE(params.get() != NULL); |
| 196 std::string tmp; | 196 std::string tmp; |
| 197 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); | 197 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); |
| 198 EXPECT_EQ("world", tmp); | 198 EXPECT_EQ("world", tmp); |
| 199 } | 199 } |
| OLD | NEW |