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

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

Issue 2911033002: Remove raw base::DictionaryValue::Set (Closed)
Patch Set: Proper Windows Fix Created 3 years, 6 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/objects.h" 5 #include "tools/json_schema_compiler/test/objects.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/memory/ptr_util.h"
13 #include "base/values.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 #include "tools/json_schema_compiler/test/objects_movable.h" 15 #include "tools/json_schema_compiler/test/objects_movable.h"
14 #include "tools/json_schema_compiler/test/objects_movable_json.h" 16 #include "tools/json_schema_compiler/test/objects_movable_json.h"
15 17
16 using namespace test::api::objects; 18 using namespace test::api::objects;
17 using namespace test::api::objects_movable; 19 using namespace test::api::objects_movable;
18 using namespace test::api::objects_movable_json; 20 using namespace test::api::objects_movable_json;
19 21
20 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { 22 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
21 { 23 {
22 std::unique_ptr<base::ListValue> strings(new base::ListValue()); 24 auto strings = base::MakeUnique<base::ListValue>();
23 strings->AppendString("one"); 25 strings->AppendString("one");
24 strings->AppendString("two"); 26 strings->AppendString("two");
25 std::unique_ptr<base::DictionaryValue> info_value( 27 auto info_value = base::MakeUnique<base::DictionaryValue>();
26 new base::DictionaryValue()); 28 info_value->Set("strings", std::move(strings));
27 info_value->Set("strings", strings.release()); 29 info_value->SetInteger("integer", 5);
28 info_value->Set("integer", new base::Value(5)); 30 info_value->SetBoolean("boolean", true);
29 info_value->Set("boolean", new base::Value(true));
30 31
31 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); 32 auto params_value = base::MakeUnique<base::ListValue>();
32 params_value->Append(std::move(info_value)); 33 params_value->Append(std::move(info_value));
33 std::unique_ptr<ObjectParam::Params> params( 34 std::unique_ptr<ObjectParam::Params> params(
34 ObjectParam::Params::Create(*params_value)); 35 ObjectParam::Params::Create(*params_value));
35 EXPECT_TRUE(params.get()); 36 EXPECT_TRUE(params.get());
36 EXPECT_EQ((size_t) 2, params->info.strings.size()); 37 EXPECT_EQ((size_t) 2, params->info.strings.size());
37 EXPECT_EQ("one", params->info.strings[0]); 38 EXPECT_EQ("one", params->info.strings[0]);
38 EXPECT_EQ("two", params->info.strings[1]); 39 EXPECT_EQ("two", params->info.strings[1]);
39 EXPECT_EQ(5, params->info.integer); 40 EXPECT_EQ(5, params->info.integer);
40 EXPECT_TRUE(params->info.boolean); 41 EXPECT_TRUE(params->info.boolean);
41 } 42 }
42 { 43 {
43 std::unique_ptr<base::ListValue> strings(new base::ListValue()); 44 auto strings = base::MakeUnique<base::ListValue>();
44 strings->AppendString("one"); 45 strings->AppendString("one");
45 strings->AppendString("two"); 46 strings->AppendString("two");
46 std::unique_ptr<base::DictionaryValue> info_value( 47 auto info_value = base::MakeUnique<base::DictionaryValue>();
47 new base::DictionaryValue()); 48 info_value->Set("strings", std::move(strings));
48 info_value->Set("strings", strings.release()); 49 info_value->SetInteger("integer", 5);
49 info_value->Set("integer", new base::Value(5));
50 50
51 std::unique_ptr<base::ListValue> params_value(new base::ListValue()); 51 auto params_value = base::MakeUnique<base::ListValue>();
52 params_value->Append(std::move(info_value)); 52 params_value->Append(std::move(info_value));
53 std::unique_ptr<ObjectParam::Params> params( 53 std::unique_ptr<ObjectParam::Params> params(
54 ObjectParam::Params::Create(*params_value)); 54 ObjectParam::Params::Create(*params_value));
55 EXPECT_FALSE(params.get()); 55 EXPECT_FALSE(params.get());
56 } 56 }
57 } 57 }
58 58
59 TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) { 59 TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) {
60 ReturnsObject::Results::Info info; 60 ReturnsObject::Results::Info info;
61 info.state = FIRST_STATE_FOO; 61 info.state = FIRST_STATE_FOO;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 vals2.push_back("vals2a"); 155 vals2.push_back("vals2a");
156 vals2.push_back("vals2b"); 156 vals2.push_back("vals2b");
157 with_additional.additional_properties["key2"] = vals2; 157 with_additional.additional_properties["key2"] = vals2;
158 158
159 MovableWithAdditional with_additional2(std::move(with_additional)); 159 MovableWithAdditional with_additional2(std::move(with_additional));
160 EXPECT_EQ("str", with_additional2.str); 160 EXPECT_EQ("str", with_additional2.str);
161 EXPECT_EQ(2u, with_additional2.additional_properties.size()); 161 EXPECT_EQ(2u, with_additional2.additional_properties.size());
162 EXPECT_EQ(vals1, with_additional2.additional_properties["key1"]); 162 EXPECT_EQ(vals1, with_additional2.additional_properties["key1"]);
163 EXPECT_EQ(vals2, with_additional2.additional_properties["key2"]); 163 EXPECT_EQ(vals2, with_additional2.additional_properties["key2"]);
164 } 164 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/functions_as_parameters_unittest.cc ('k') | ui/app_list/search/history_data_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698