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

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

Issue 383263005: Remove more CreateIntegerValue calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/SetBoolean/SetInteger Created 6 years, 5 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/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 19 matching lines...) Expand all
30 a.x = 5; 30 a.x = 5;
31 a.y = std::string("foo"); 31 a.y = std::string("foo");
32 scoped_ptr<base::DictionaryValue> serialized = a.ToValue(); 32 scoped_ptr<base::DictionaryValue> serialized = a.ToValue();
33 MyType1 b; 33 MyType1 b;
34 EXPECT_TRUE(MyType1::Populate(*serialized.get(), &b)); 34 EXPECT_TRUE(MyType1::Populate(*serialized.get(), &b));
35 EXPECT_EQ(a.x, b.x); 35 EXPECT_EQ(a.x, b.x);
36 EXPECT_EQ(a.y, b.y); 36 EXPECT_EQ(a.y, b.y);
37 37
38 // Test Function2, which takes an integer parameter. 38 // Test Function2, which takes an integer parameter.
39 base::ListValue list; 39 base::ListValue list;
40 list.Append(base::Value::CreateIntegerValue(5)); 40 list.Append(new base::FundamentalValue(5));
41 scoped_ptr<Function2::Params> f2_params = Function2::Params::Create(list); 41 scoped_ptr<Function2::Params> f2_params = Function2::Params::Create(list);
42 EXPECT_EQ(5, f2_params->x); 42 EXPECT_EQ(5, f2_params->x);
43 43
44 // Test Function3, which takes a MyType1 parameter. 44 // Test Function3, which takes a MyType1 parameter.
45 list.Clear(); 45 list.Clear();
46 base::DictionaryValue* tmp = new base::DictionaryValue(); 46 base::DictionaryValue* tmp = new base::DictionaryValue();
47 tmp->SetInteger("x", 17); 47 tmp->SetInteger("x", 17);
48 tmp->SetString("y", "hello"); 48 tmp->SetString("y", "hello");
49 tmp->SetString("z", "zstring"); 49 tmp->SetString("z", "zstring");
50 tmp->SetString("a", "astring"); 50 tmp->SetString("a", "astring");
(...skipping 23 matching lines...) Expand all
74 EXPECT_EQ(a.x, c.x); 74 EXPECT_EQ(a.x, c.x);
75 EXPECT_EQ(a.y, c.y); 75 EXPECT_EQ(a.y, c.y);
76 } 76 }
77 77
78 TEST(IdlCompiler, OptionalArguments) { 78 TEST(IdlCompiler, OptionalArguments) {
79 // Test a function that takes one optional argument, both without and with 79 // Test a function that takes one optional argument, both without and with
80 // that argument. 80 // that argument.
81 base::ListValue list; 81 base::ListValue list;
82 scoped_ptr<Function7::Params> f7_params = Function7::Params::Create(list); 82 scoped_ptr<Function7::Params> f7_params = Function7::Params::Create(list);
83 EXPECT_EQ(NULL, f7_params->arg.get()); 83 EXPECT_EQ(NULL, f7_params->arg.get());
84 list.Append(base::Value::CreateIntegerValue(7)); 84 list.Append(new base::FundamentalValue(7));
85 f7_params = Function7::Params::Create(list); 85 f7_params = Function7::Params::Create(list);
86 EXPECT_EQ(7, *(f7_params->arg)); 86 EXPECT_EQ(7, *(f7_params->arg));
87 87
88 // Similar to above, but a function with one required and one optional 88 // Similar to above, but a function with one required and one optional
89 // argument. 89 // argument.
90 list.Clear(); 90 list.Clear();
91 list.Append(base::Value::CreateIntegerValue(8)); 91 list.Append(new base::FundamentalValue(8));
92 scoped_ptr<Function8::Params> f8_params = Function8::Params::Create(list); 92 scoped_ptr<Function8::Params> f8_params = Function8::Params::Create(list);
93 EXPECT_EQ(8, f8_params->arg1); 93 EXPECT_EQ(8, f8_params->arg1);
94 EXPECT_EQ(NULL, f8_params->arg2.get()); 94 EXPECT_EQ(NULL, f8_params->arg2.get());
95 list.Append(base::Value::CreateStringValue("foo")); 95 list.Append(base::Value::CreateStringValue("foo"));
96 f8_params = Function8::Params::Create(list); 96 f8_params = Function8::Params::Create(list);
97 EXPECT_EQ(8, f8_params->arg1); 97 EXPECT_EQ(8, f8_params->arg1);
98 EXPECT_EQ("foo", *(f8_params->arg2)); 98 EXPECT_EQ("foo", *(f8_params->arg2));
99 99
100 // Test a function with an optional argument of custom type. 100 // Test a function with an optional argument of custom type.
101 list.Clear(); 101 list.Clear();
(...skipping 12 matching lines...) Expand all
114 ASSERT_TRUE(f9_params->arg.get() != NULL); 114 ASSERT_TRUE(f9_params->arg.get() != NULL);
115 MyType1* t1 = f9_params->arg.get(); 115 MyType1* t1 = f9_params->arg.get();
116 EXPECT_EQ(17, t1->x); 116 EXPECT_EQ(17, t1->x);
117 EXPECT_EQ("hello", t1->y); 117 EXPECT_EQ("hello", t1->y);
118 } 118 }
119 119
120 TEST(IdlCompiler, ArrayTypes) { 120 TEST(IdlCompiler, ArrayTypes) {
121 // Tests of a function that takes an integer and an array of integers. First 121 // Tests of a function that takes an integer and an array of integers. First
122 // use an empty array. 122 // use an empty array.
123 base::ListValue list; 123 base::ListValue list;
124 list.Append(base::Value::CreateIntegerValue(33)); 124 list.Append(new base::FundamentalValue(33));
125 list.Append(new base::ListValue); 125 list.Append(new base::ListValue);
126 scoped_ptr<Function10::Params> f10_params = Function10::Params::Create(list); 126 scoped_ptr<Function10::Params> f10_params = Function10::Params::Create(list);
127 ASSERT_TRUE(f10_params != NULL); 127 ASSERT_TRUE(f10_params != NULL);
128 EXPECT_EQ(33, f10_params->x); 128 EXPECT_EQ(33, f10_params->x);
129 EXPECT_TRUE(f10_params->y.empty()); 129 EXPECT_TRUE(f10_params->y.empty());
130 130
131 // Same function, but this time with 2 values in the array. 131 // Same function, but this time with 2 values in the array.
132 list.Clear(); 132 list.Clear();
133 list.Append(base::Value::CreateIntegerValue(33)); 133 list.Append(new base::FundamentalValue(33));
134 base::ListValue* sublist = new base::ListValue; 134 base::ListValue* sublist = new base::ListValue;
135 sublist->Append(base::Value::CreateIntegerValue(34)); 135 sublist->Append(new base::FundamentalValue(34));
136 sublist->Append(base::Value::CreateIntegerValue(35)); 136 sublist->Append(new base::FundamentalValue(35));
137 list.Append(sublist); 137 list.Append(sublist);
138 f10_params = Function10::Params::Create(list); 138 f10_params = Function10::Params::Create(list);
139 ASSERT_TRUE(f10_params != NULL); 139 ASSERT_TRUE(f10_params != NULL);
140 EXPECT_EQ(33, f10_params->x); 140 EXPECT_EQ(33, f10_params->x);
141 ASSERT_EQ(2u, f10_params->y.size()); 141 ASSERT_EQ(2u, f10_params->y.size());
142 EXPECT_EQ(34, f10_params->y[0]); 142 EXPECT_EQ(34, f10_params->y[0]);
143 EXPECT_EQ(35, f10_params->y[1]); 143 EXPECT_EQ(35, f10_params->y[1]);
144 144
145 // Now test a function which takes an array of a defined type. 145 // Now test a function which takes an array of a defined type.
146 list.Clear(); 146 list.Clear();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
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