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

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

Issue 397793002: Eliminate CreateBooleanValue from test files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad merge 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 "tools/json_schema_compiler/test/simple_api.h" 5 #include "tools/json_schema_compiler/test/simple_api.h"
6 #include "tools/json_schema_compiler/test/crossref.h" 6 #include "tools/json_schema_compiler/test/crossref.h"
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using namespace test::api::crossref; 10 using namespace test::api::crossref;
11 11
12 namespace { 12 namespace {
13 13
14 static scoped_ptr<base::DictionaryValue> CreateTestTypeDictionary() { 14 static scoped_ptr<base::DictionaryValue> CreateTestTypeDictionary() {
15 base::DictionaryValue* value(new base::DictionaryValue()); 15 base::DictionaryValue* value(new base::DictionaryValue());
16 value->SetWithoutPathExpansion("number", base::Value::CreateDoubleValue(1.1)); 16 value->SetWithoutPathExpansion("number", base::Value::CreateDoubleValue(1.1));
17 value->SetWithoutPathExpansion("integer", new base::FundamentalValue(4)); 17 value->SetWithoutPathExpansion("integer", new base::FundamentalValue(4));
18 value->SetWithoutPathExpansion("string", 18 value->SetWithoutPathExpansion("string",
19 base::Value::CreateStringValue("bling")); 19 base::Value::CreateStringValue("bling"));
20 value->SetWithoutPathExpansion("boolean", 20 value->SetWithoutPathExpansion("boolean", new base::FundamentalValue(true));
21 base::Value::CreateBooleanValue(true));
22 return scoped_ptr<base::DictionaryValue>(value); 21 return scoped_ptr<base::DictionaryValue>(value);
23 } 22 }
24 23
25 } // namespace 24 } // namespace
26 25
27 TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) { 26 TEST(JsonSchemaCompilerCrossrefTest, CrossrefTypePopulate) {
28 scoped_ptr<CrossrefType> crossref_type(new CrossrefType()); 27 scoped_ptr<CrossrefType> crossref_type(new CrossrefType());
29 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 28 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
30 value->Set("testType", CreateTestTypeDictionary().release()); 29 value->Set("testType", CreateTestTypeDictionary().release());
31 EXPECT_TRUE(CrossrefType::Populate(*value, crossref_type.get())); 30 EXPECT_TRUE(CrossrefType::Populate(*value, crossref_type.get()));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 results->GetDictionary(0, &result_dict); 69 results->GetDictionary(0, &result_dict);
71 EXPECT_TRUE(value->Equals(result_dict)); 70 EXPECT_TRUE(value->Equals(result_dict));
72 } 71 }
73 72
74 TEST(JsonSchemaCompilerCrossrefTest, TestTypeInObjectParamsCreate) { 73 TEST(JsonSchemaCompilerCrossrefTest, TestTypeInObjectParamsCreate) {
75 { 74 {
76 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 75 scoped_ptr<base::ListValue> params_value(new base::ListValue());
77 scoped_ptr<base::DictionaryValue> param_object_value( 76 scoped_ptr<base::DictionaryValue> param_object_value(
78 new base::DictionaryValue()); 77 new base::DictionaryValue());
79 param_object_value->Set("testType", CreateTestTypeDictionary().release()); 78 param_object_value->Set("testType", CreateTestTypeDictionary().release());
80 param_object_value->Set("boolean", base::Value::CreateBooleanValue(true)); 79 param_object_value->Set("boolean", new base::FundamentalValue(true));
81 params_value->Append(param_object_value.release()); 80 params_value->Append(param_object_value.release());
82 scoped_ptr<TestTypeInObject::Params> params( 81 scoped_ptr<TestTypeInObject::Params> params(
83 TestTypeInObject::Params::Create(*params_value)); 82 TestTypeInObject::Params::Create(*params_value));
84 EXPECT_TRUE(params.get()); 83 EXPECT_TRUE(params.get());
85 EXPECT_TRUE(params->param_object.test_type.get()); 84 EXPECT_TRUE(params->param_object.test_type.get());
86 EXPECT_TRUE(params->param_object.boolean); 85 EXPECT_TRUE(params->param_object.boolean);
87 EXPECT_TRUE(CreateTestTypeDictionary()->Equals( 86 EXPECT_TRUE(CreateTestTypeDictionary()->Equals(
88 params->param_object.test_type->ToValue().get())); 87 params->param_object.test_type->ToValue().get()));
89 } 88 }
90 { 89 {
91 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 90 scoped_ptr<base::ListValue> params_value(new base::ListValue());
92 scoped_ptr<base::DictionaryValue> param_object_value( 91 scoped_ptr<base::DictionaryValue> param_object_value(
93 new base::DictionaryValue()); 92 new base::DictionaryValue());
94 param_object_value->Set("boolean", base::Value::CreateBooleanValue(true)); 93 param_object_value->Set("boolean", new base::FundamentalValue(true));
95 params_value->Append(param_object_value.release()); 94 params_value->Append(param_object_value.release());
96 scoped_ptr<TestTypeInObject::Params> params( 95 scoped_ptr<TestTypeInObject::Params> params(
97 TestTypeInObject::Params::Create(*params_value)); 96 TestTypeInObject::Params::Create(*params_value));
98 EXPECT_TRUE(params.get()); 97 EXPECT_TRUE(params.get());
99 EXPECT_FALSE(params->param_object.test_type.get()); 98 EXPECT_FALSE(params->param_object.test_type.get());
100 EXPECT_TRUE(params->param_object.boolean); 99 EXPECT_TRUE(params->param_object.boolean);
101 } 100 }
102 { 101 {
103 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 102 scoped_ptr<base::ListValue> params_value(new base::ListValue());
104 scoped_ptr<base::DictionaryValue> param_object_value( 103 scoped_ptr<base::DictionaryValue> param_object_value(
105 new base::DictionaryValue()); 104 new base::DictionaryValue());
106 param_object_value->Set("testType", 105 param_object_value->Set("testType",
107 base::Value::CreateStringValue("invalid")); 106 base::Value::CreateStringValue("invalid"));
108 param_object_value->Set("boolean", base::Value::CreateBooleanValue(true)); 107 param_object_value->Set("boolean", new base::FundamentalValue(true));
109 params_value->Append(param_object_value.release()); 108 params_value->Append(param_object_value.release());
110 scoped_ptr<TestTypeInObject::Params> params( 109 scoped_ptr<TestTypeInObject::Params> params(
111 TestTypeInObject::Params::Create(*params_value)); 110 TestTypeInObject::Params::Create(*params_value));
112 EXPECT_FALSE(params.get()); 111 EXPECT_FALSE(params.get());
113 } 112 }
114 { 113 {
115 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 114 scoped_ptr<base::ListValue> params_value(new base::ListValue());
116 scoped_ptr<base::DictionaryValue> param_object_value( 115 scoped_ptr<base::DictionaryValue> param_object_value(
117 new base::DictionaryValue()); 116 new base::DictionaryValue());
118 param_object_value->Set("testType", CreateTestTypeDictionary().release()); 117 param_object_value->Set("testType", CreateTestTypeDictionary().release());
119 params_value->Append(param_object_value.release()); 118 params_value->Append(param_object_value.release());
120 scoped_ptr<TestTypeInObject::Params> params( 119 scoped_ptr<TestTypeInObject::Params> params(
121 TestTypeInObject::Params::Create(*params_value)); 120 TestTypeInObject::Params::Create(*params_value));
122 EXPECT_FALSE(params.get()); 121 EXPECT_FALSE(params.get());
123 } 122 }
124 } 123 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/choices_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