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

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

Issue 9309044: Supporting more APIs with json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rework, add a couple of tests Created 8 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "tools/json_schema_compiler/test/simple_api.h"
6 #include "tools/json_schema_compiler/test/crossref.h"
7
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 using namespace test::api::crossref;
11
12 namespace {
13
14 static scoped_ptr<DictionaryValue> CreateTestTypeDictionary() {
15 DictionaryValue* value(new DictionaryValue());
16 value->SetWithoutPathExpansion("number", Value::CreateDoubleValue(1.1));
17 value->SetWithoutPathExpansion("integer", Value::CreateIntegerValue(4));
18 value->SetWithoutPathExpansion("string", Value::CreateStringValue("bling"));
19 value->SetWithoutPathExpansion("boolean", Value::CreateBooleanValue(true));
20 return scoped_ptr<DictionaryValue>(value);
21 }
22
23 } // namespace
24
25 TEST(JsonSchemaCompilerCrossrefTest, TestTypeOptionalParamCreate) {
26 scoped_ptr<ListValue> params_value(new ListValue());
27 scoped_ptr<DictionaryValue> test_type_value = CreateTestTypeDictionary();
28 params_value->Append(test_type_value.release());
29 scoped_ptr<TestTypeOptionalParam::Params> params(
30 TestTypeOptionalParam::Params::Create(*params_value));
31 EXPECT_TRUE(params.get());
32 EXPECT_TRUE(params->test_type.get());
33 EXPECT_TRUE(
34 CreateTestTypeDictionary()->Equals(params->test_type->ToValue().get()));
35 }
36
37 TEST(JsonSchemaCompilerCrossrefTest, TestTypeOptionalParamFail) {
38 scoped_ptr<ListValue> params_value(new ListValue());
39 scoped_ptr<DictionaryValue> test_type_value = CreateTestTypeDictionary();
40 test_type_value->RemoveWithoutPathExpansion("number", NULL);
41 params_value->Append(test_type_value.release());
42 scoped_ptr<TestTypeOptionalParam::Params> params(
43 TestTypeOptionalParam::Params::Create(*params_value));
44 EXPECT_FALSE(params.get());
45 }
46
47 TEST(JsonSchemaCompilerCrossrefTest, GetTestType) {
48 scoped_ptr<DictionaryValue> value = CreateTestTypeDictionary();
49 scoped_ptr<test::api::simple_api::TestType> test_type(
50 new test::api::simple_api::TestType());
51 EXPECT_TRUE(
52 test::api::simple_api::TestType::Populate(*value, test_type.get()));
53 scoped_ptr<Value> result(GetTestType::Result::Create(*test_type));
54 EXPECT_TRUE(value->Equals(result.get()));
55 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/crossref.json ('k') | tools/json_schema_compiler/test/json_schema_compiler_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698