Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tools/json_schema_compiler/test/idl_schemas_unittest.cc

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/any.h"
7 #include "tools/json_schema_compiler/test/idl_basics.h" 6 #include "tools/json_schema_compiler/test/idl_basics.h"
8 #include "tools/json_schema_compiler/test/idl_object_types.h" 7 #include "tools/json_schema_compiler/test/idl_object_types.h"
9 8
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 using test::api::idl_basics::MyType1; 11 using test::api::idl_basics::MyType1;
13 using test::api::idl_object_types::BarType; 12 using test::api::idl_object_types::BarType;
14 using test::api::idl_object_types::FooType; 13 using test::api::idl_object_types::FooType;
15 14
16 namespace Function2 = test::api::idl_basics::Function2; 15 namespace Function2 = test::api::idl_basics::Function2;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Test the FooType type. 159 // Test the FooType type.
161 FooType f1; 160 FooType f1;
162 f1.x = 3; 161 f1.x = 3;
163 scoped_ptr<DictionaryValue> serialized_foo = f1.ToValue(); 162 scoped_ptr<DictionaryValue> serialized_foo = f1.ToValue();
164 FooType f2; 163 FooType f2;
165 EXPECT_TRUE(FooType::Populate(*serialized_foo.get(), &f2)); 164 EXPECT_TRUE(FooType::Populate(*serialized_foo.get(), &f2));
166 EXPECT_EQ(f1.x, f2.x); 165 EXPECT_EQ(f1.x, f2.x);
167 166
168 // Test the BarType type. 167 // Test the BarType type.
169 BarType b1; 168 BarType b1;
170 base::FundamentalValue seven(7); 169 b1.x.reset(new base::FundamentalValue(7));
171 b1.x.Init(seven);
172 scoped_ptr<DictionaryValue> serialized_bar = b1.ToValue(); 170 scoped_ptr<DictionaryValue> serialized_bar = b1.ToValue();
173 BarType b2; 171 BarType b2;
174 EXPECT_TRUE(BarType::Populate(*serialized_bar.get(), &b2)); 172 EXPECT_TRUE(BarType::Populate(*serialized_bar.get(), &b2));
175 int tmp_int = 0; 173 int tmp_int = 0;
176 EXPECT_TRUE(b2.x.value().GetAsInteger(&tmp_int)); 174 EXPECT_TRUE(b2.x->GetAsInteger(&tmp_int));
177 EXPECT_EQ(7, tmp_int); 175 EXPECT_EQ(7, tmp_int);
178 176
179 // Test the params to the ObjectFunction1 function. 177 // Test the params to the ObjectFunction1 function.
180 scoped_ptr<DictionaryValue> icon_props(new DictionaryValue()); 178 scoped_ptr<DictionaryValue> icon_props(new DictionaryValue());
181 icon_props->SetString("hello", "world"); 179 icon_props->SetString("hello", "world");
182 ObjectFunction1::Params::Icon icon; 180 ObjectFunction1::Params::Icon icon;
183 EXPECT_TRUE(ObjectFunction1::Params::Icon::Populate(*(icon_props.get()), 181 EXPECT_TRUE(ObjectFunction1::Params::Icon::Populate(*(icon_props.get()),
184 &icon)); 182 &icon));
185 ListValue list; 183 ListValue list;
186 list.Append(icon_props.release()); 184 list.Append(icon_props.release());
187 scoped_ptr<ObjectFunction1::Params> params = 185 scoped_ptr<ObjectFunction1::Params> params =
188 ObjectFunction1::Params::Create(list); 186 ObjectFunction1::Params::Create(list);
189 ASSERT_TRUE(params.get() != NULL); 187 ASSERT_TRUE(params.get() != NULL);
190 std::string tmp; 188 std::string tmp;
191 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); 189 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp));
192 EXPECT_EQ("world", tmp); 190 EXPECT_EQ("world", tmp);
193 } 191 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/functions_on_types_unittest.cc ('k') | tools/json_schema_compiler/test/objects_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698