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

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

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « tools/json_schema_compiler/test/error_generation_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/ptr_util.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 using namespace test::api::simple_api; 10 using namespace test::api::simple_api;
10 11
11 namespace { 12 namespace {
12 13
13 static std::unique_ptr<base::DictionaryValue> CreateTestTypeDictionary() { 14 static std::unique_ptr<base::DictionaryValue> CreateTestTypeDictionary() {
14 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 15 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
15 value->SetWithoutPathExpansion("number", new base::Value(1.1)); 16 value->SetWithoutPathExpansion("number", new base::Value(1.1));
16 value->SetWithoutPathExpansion("integer", new base::Value(4)); 17 value->SetWithoutPathExpansion("integer", new base::Value(4));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 OptionalString::Params::Create(*params_value)); 71 OptionalString::Params::Create(*params_value));
71 EXPECT_TRUE(params.get()); 72 EXPECT_TRUE(params.get());
72 EXPECT_TRUE(params->str.get()); 73 EXPECT_TRUE(params->str.get());
73 EXPECT_EQ("asdf", *params->str); 74 EXPECT_EQ("asdf", *params->str);
74 } 75 }
75 } 76 }
76 77
77 TEST(JsonSchemaCompilerSimpleTest, OptionalParamsTakingNull) { 78 TEST(JsonSchemaCompilerSimpleTest, OptionalParamsTakingNull) {
78 { 79 {
79 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); 80 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
80 params_value->Append(base::Value::CreateNullValue()); 81 params_value->Append(base::MakeUnique<base::Value>());
81 std::unique_ptr<OptionalString::Params> params( 82 std::unique_ptr<OptionalString::Params> params(
82 OptionalString::Params::Create(*params_value)); 83 OptionalString::Params::Create(*params_value));
83 EXPECT_TRUE(params.get()); 84 EXPECT_TRUE(params.get());
84 EXPECT_FALSE(params->str.get()); 85 EXPECT_FALSE(params->str.get());
85 } 86 }
86 } 87 }
87 88
88 TEST(JsonSchemaCompilerSimpleTest, OptionalStringParamsWrongType) { 89 TEST(JsonSchemaCompilerSimpleTest, OptionalStringParamsWrongType) {
89 { 90 {
90 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); 91 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
91 params_value->AppendInteger(5); 92 params_value->AppendInteger(5);
92 std::unique_ptr<OptionalString::Params> params( 93 std::unique_ptr<OptionalString::Params> params(
93 OptionalString::Params::Create(*params_value)); 94 OptionalString::Params::Create(*params_value));
94 EXPECT_FALSE(params.get()); 95 EXPECT_FALSE(params.get());
95 } 96 }
96 } 97 }
97 98
98 TEST(JsonSchemaCompilerSimpleTest, OptionalBeforeRequired) { 99 TEST(JsonSchemaCompilerSimpleTest, OptionalBeforeRequired) {
99 { 100 {
100 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); 101 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
101 params_value->Append(base::Value::CreateNullValue()); 102 params_value->Append(base::MakeUnique<base::Value>());
102 params_value->AppendString("asdf"); 103 params_value->AppendString("asdf");
103 std::unique_ptr<OptionalBeforeRequired::Params> params( 104 std::unique_ptr<OptionalBeforeRequired::Params> params(
104 OptionalBeforeRequired::Params::Create(*params_value)); 105 OptionalBeforeRequired::Params::Create(*params_value));
105 EXPECT_TRUE(params.get()); 106 EXPECT_TRUE(params.get());
106 EXPECT_FALSE(params->first.get()); 107 EXPECT_FALSE(params->first.get());
107 EXPECT_EQ("asdf", params->second); 108 EXPECT_EQ("asdf", params->second);
108 } 109 }
109 } 110 }
110 111
111 TEST(JsonSchemaCompilerSimpleTest, NoParamsResultCreate) { 112 TEST(JsonSchemaCompilerSimpleTest, NoParamsResultCreate) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 ASSERT_TRUE(expected->GetInteger("integer", &some_test_type.integer)); 176 ASSERT_TRUE(expected->GetInteger("integer", &some_test_type.integer));
176 ASSERT_TRUE(expected->GetBoolean("boolean", &some_test_type.boolean)); 177 ASSERT_TRUE(expected->GetBoolean("boolean", &some_test_type.boolean));
177 178
178 std::unique_ptr<base::ListValue> results( 179 std::unique_ptr<base::ListValue> results(
179 OnTestTypeFired::Create(some_test_type)); 180 OnTestTypeFired::Create(some_test_type));
180 base::DictionaryValue* result = NULL; 181 base::DictionaryValue* result = NULL;
181 results->GetDictionary(0, &result); 182 results->GetDictionary(0, &result);
182 EXPECT_TRUE(result->Equals(expected.get())); 183 EXPECT_TRUE(result->Equals(expected.get()));
183 } 184 }
184 } 185 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/error_generation_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698