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

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

Issue 10701012: JSON Schema Compiler: Added event compilation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced. Created 8 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
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" 6 #include "tools/json_schema_compiler/any.h"
7 #include "tools/json_schema_compiler/test/idl_basics.h" 7 #include "tools/json_schema_compiler/test/idl_basics.h"
8 #include "tools/json_schema_compiler/test/idl_object_types.h" 8 #include "tools/json_schema_compiler/test/idl_object_types.h"
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 DictionaryValue* tmp = new DictionaryValue(); 47 DictionaryValue* tmp = new DictionaryValue();
48 tmp->SetInteger("x", 17); 48 tmp->SetInteger("x", 17);
49 tmp->SetString("y", "hello"); 49 tmp->SetString("y", "hello");
50 list.Append(tmp); 50 list.Append(tmp);
51 scoped_ptr<Function3::Params> f3_params = Function3::Params::Create(list); 51 scoped_ptr<Function3::Params> f3_params = Function3::Params::Create(list);
52 EXPECT_EQ(17, f3_params->arg.x); 52 EXPECT_EQ(17, f3_params->arg.x);
53 EXPECT_EQ("hello", f3_params->arg.y); 53 EXPECT_EQ("hello", f3_params->arg.y);
54 54
55 // Test functions that take a callback function as a parameter, with varying 55 // Test functions that take a callback function as a parameter, with varying
56 // callback signatures. 56 // callback signatures.
57 scoped_ptr<Value> f4_result(Function4::Result::Create()); 57 scoped_ptr<ListValue> f4_results = Function4::Results::Create();
58 EXPECT_TRUE(f4_result->IsType(Value::TYPE_NULL)); 58 ListValue expected;
59 EXPECT_TRUE(f4_results->Equals(&expected));
59 60
60 scoped_ptr<Value> f5_result(Function5::Result::Create(13)); 61 scoped_ptr<ListValue> f5_results(Function5::Results::Create(13));
61 EXPECT_TRUE(f5_result->IsType(Value::TYPE_INTEGER)); 62 Value* f5_result_int = NULL;
63 ASSERT_TRUE(f5_results->Get(0, &f5_result_int));
64 EXPECT_TRUE(f5_result_int->IsType(Value::TYPE_INTEGER));
62 65
63 scoped_ptr<Value> f6_result(Function6::Result::Create(a)); 66 scoped_ptr<ListValue> f6_results(Function6::Results::Create(a));
67 Value* f6_result_dict = NULL;
68 ASSERT_TRUE(f6_results->Get(0, &f6_result_dict));
64 MyType1 c; 69 MyType1 c;
65 EXPECT_TRUE(MyType1::Populate(*f6_result, &c)); 70 EXPECT_TRUE(MyType1::Populate(*f6_result_dict, &c));
66 EXPECT_EQ(a.x, c.x); 71 EXPECT_EQ(a.x, c.x);
67 EXPECT_EQ(a.y, c.y); 72 EXPECT_EQ(a.y, c.y);
68 } 73 }
69 74
70 TEST(IdlCompiler, OptionalArguments) { 75 TEST(IdlCompiler, OptionalArguments) {
71 // Test a function that takes one optional argument, both without and with 76 // Test a function that takes one optional argument, both without and with
72 // that argument. 77 // that argument.
73 ListValue list; 78 ListValue list;
74 scoped_ptr<Function7::Params> f7_params = Function7::Params::Create(list); 79 scoped_ptr<Function7::Params> f7_params = Function7::Params::Create(list);
75 EXPECT_EQ(NULL, f7_params->arg.get()); 80 EXPECT_EQ(NULL, f7_params->arg.get());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 &icon)); 184 &icon));
180 ListValue list; 185 ListValue list;
181 list.Append(icon_props.release()); 186 list.Append(icon_props.release());
182 scoped_ptr<ObjectFunction1::Params> params = 187 scoped_ptr<ObjectFunction1::Params> params =
183 ObjectFunction1::Params::Create(list); 188 ObjectFunction1::Params::Create(list);
184 ASSERT_TRUE(params.get() != NULL); 189 ASSERT_TRUE(params.get() != NULL);
185 std::string tmp; 190 std::string tmp;
186 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp)); 191 EXPECT_TRUE(params->icon.additional_properties.GetString("hello", &tmp));
187 EXPECT_EQ("world", tmp); 192 EXPECT_EQ("world", tmp);
188 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698