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

Side by Side Diff: tools/json_schema_compiler/test/simple_api_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 "tools/json_schema_compiler/test/simple_api.h" 5 #include "tools/json_schema_compiler/test/simple_api.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 using namespace test::api::simple_api; 9 using namespace test::api::simple_api;
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 { 127 {
128 scoped_ptr<TestType> test_type(new TestType()); 128 scoped_ptr<TestType> test_type(new TestType());
129 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary(); 129 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary();
130 value->Remove("number", NULL); 130 value->Remove("number", NULL);
131 EXPECT_FALSE(TestType::Populate(*value, test_type.get())); 131 EXPECT_FALSE(TestType::Populate(*value, test_type.get()));
132 } 132 }
133 } 133 }
134 134
135 TEST(JsonSchemaCompilerSimpleTest, GetTestType) { 135 TEST(JsonSchemaCompilerSimpleTest, GetTestType) {
136 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary(); 136 {
137 scoped_ptr<TestType> test_type(new TestType()); 137 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary();
138 EXPECT_TRUE(TestType::Populate(*value, test_type.get())); 138 scoped_ptr<TestType> test_type(new TestType());
139 scoped_ptr<Value> result(GetTestType::Result::Create(*test_type)); 139 EXPECT_TRUE(TestType::Populate(*value, test_type.get()));
140 EXPECT_TRUE(value->Equals(result.get())); 140 scoped_ptr<Value> result(GetTestType::Result::Create(*test_type));
141 EXPECT_TRUE(value->Equals(result.get()));
142 }
141 } 143 }
142 144
145 TEST(JsonSchemaCompilerSimpleTest, OnIntegerFiredCreate) {
146 {
147 int some_integer = 5;
148 scoped_ptr<Value> result_value(OnIntegerFired::Create(some_integer));
149
150 int result_integer = 0;
151 EXPECT_TRUE(result_value->GetAsInteger(&result_integer));
152 EXPECT_EQ(some_integer, result_integer);
153 }
154 }
155
156 TEST(JsonSchemaCompilerSimpleTest, OnStringFiredCreate) {
157 {
158 std::string some_string("yo dawg");
159 scoped_ptr<Value> result_value(OnStringFired::Create(some_string));
160
161 std::string result_string;
162 EXPECT_TRUE(result_value->GetAsString(&result_string));
163 EXPECT_EQ(some_string, result_string);
164 }
165 }
166
167 TEST(JsonSchemaCompilerSimpleTest, OnTestTypeFiredCreate) {
168 {
169 TestType some_test_type;
170 some_test_type.number = 1.1;
171 some_test_type.string = "bling";
172 some_test_type.integer = 4;
173 some_test_type.boolean = true;
not at google - send to devlin 2012/07/03 14:21:39 same comment(s)
174 scoped_ptr<Value> result_value(OnTestTypeFired::Create(some_test_type));
175
176 DictionaryValue* result_dict = NULL;
177 ASSERT_TRUE(result_value->GetAsDictionary(&result_dict));
178
179 double result_number = 0.0;
180 EXPECT_TRUE(result_dict->GetDouble("number", &result_number));
181 EXPECT_EQ(some_test_type.number, result_number);
182
183 std::string result_string;
184 EXPECT_TRUE(result_dict->GetString("string", &result_string));
185 EXPECT_EQ(some_test_type.string, result_string);
186
187 int result_integer = 0;
188 EXPECT_TRUE(result_dict->GetInteger("integer", &result_integer));
189 EXPECT_EQ(some_test_type.integer, result_integer);
190
191 bool result_boolean = false;
192 EXPECT_TRUE(result_dict->GetBoolean("boolean", &result_boolean));
193 EXPECT_EQ(some_test_type.boolean, result_boolean);
194 }
195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698