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

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

Issue 1869503004: Convert //tools to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, change iwyu fixes for converted directories to include <memory> Created 4 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/json_schema_compiler/test/objects.h" 9 #include "tools/json_schema_compiler/test/objects.h"
10 #include "tools/json_schema_compiler/test/objects_movable.h" 10 #include "tools/json_schema_compiler/test/objects_movable.h"
11 #include "tools/json_schema_compiler/test/objects_movable_json.h" 11 #include "tools/json_schema_compiler/test/objects_movable_json.h"
12 12
13 using namespace test::api::objects; 13 using namespace test::api::objects;
14 using namespace test::api::objects_movable; 14 using namespace test::api::objects_movable;
15 using namespace test::api::objects_movable_json; 15 using namespace test::api::objects_movable_json;
16 16
17 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { 17 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
18 { 18 {
19 scoped_ptr<base::ListValue> strings(new base::ListValue()); 19 std::unique_ptr<base::ListValue> strings(new base::ListValue());
20 strings->Append(new base::StringValue("one")); 20 strings->Append(new base::StringValue("one"));
21 strings->Append(new base::StringValue("two")); 21 strings->Append(new base::StringValue("two"));
22 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue()); 22 std::unique_ptr<base::DictionaryValue> info_value(
23 new base::DictionaryValue());
23 info_value->Set("strings", strings.release()); 24 info_value->Set("strings", strings.release());
24 info_value->Set("integer", new base::FundamentalValue(5)); 25 info_value->Set("integer", new base::FundamentalValue(5));
25 info_value->Set("boolean", new base::FundamentalValue(true)); 26 info_value->Set("boolean", new base::FundamentalValue(true));
26 27
27 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 28 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
28 params_value->Append(info_value.release()); 29 params_value->Append(info_value.release());
29 scoped_ptr<ObjectParam::Params> params( 30 std::unique_ptr<ObjectParam::Params> params(
30 ObjectParam::Params::Create(*params_value)); 31 ObjectParam::Params::Create(*params_value));
31 EXPECT_TRUE(params.get()); 32 EXPECT_TRUE(params.get());
32 EXPECT_EQ((size_t) 2, params->info.strings.size()); 33 EXPECT_EQ((size_t) 2, params->info.strings.size());
33 EXPECT_EQ("one", params->info.strings[0]); 34 EXPECT_EQ("one", params->info.strings[0]);
34 EXPECT_EQ("two", params->info.strings[1]); 35 EXPECT_EQ("two", params->info.strings[1]);
35 EXPECT_EQ(5, params->info.integer); 36 EXPECT_EQ(5, params->info.integer);
36 EXPECT_TRUE(params->info.boolean); 37 EXPECT_TRUE(params->info.boolean);
37 } 38 }
38 { 39 {
39 scoped_ptr<base::ListValue> strings(new base::ListValue()); 40 std::unique_ptr<base::ListValue> strings(new base::ListValue());
40 strings->Append(new base::StringValue("one")); 41 strings->Append(new base::StringValue("one"));
41 strings->Append(new base::StringValue("two")); 42 strings->Append(new base::StringValue("two"));
42 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue()); 43 std::unique_ptr<base::DictionaryValue> info_value(
44 new base::DictionaryValue());
43 info_value->Set("strings", strings.release()); 45 info_value->Set("strings", strings.release());
44 info_value->Set("integer", new base::FundamentalValue(5)); 46 info_value->Set("integer", new base::FundamentalValue(5));
45 47
46 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 48 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
47 params_value->Append(info_value.release()); 49 params_value->Append(info_value.release());
48 scoped_ptr<ObjectParam::Params> params( 50 std::unique_ptr<ObjectParam::Params> params(
49 ObjectParam::Params::Create(*params_value)); 51 ObjectParam::Params::Create(*params_value));
50 EXPECT_FALSE(params.get()); 52 EXPECT_FALSE(params.get());
51 } 53 }
52 } 54 }
53 55
54 TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) { 56 TEST(JsonSchemaCompilerObjectsTest, ReturnsObjectResultCreate) {
55 ReturnsObject::Results::Info info; 57 ReturnsObject::Results::Info info;
56 info.state = FIRST_STATE_FOO; 58 info.state = FIRST_STATE_FOO;
57 scoped_ptr<base::ListValue> results = ReturnsObject::Results::Create(info); 59 std::unique_ptr<base::ListValue> results =
60 ReturnsObject::Results::Create(info);
58 61
59 base::DictionaryValue expected; 62 base::DictionaryValue expected;
60 expected.SetString("state", "foo"); 63 expected.SetString("state", "foo");
61 base::DictionaryValue* result = NULL; 64 base::DictionaryValue* result = NULL;
62 ASSERT_TRUE(results->GetDictionary(0, &result)); 65 ASSERT_TRUE(results->GetDictionary(0, &result));
63 ASSERT_TRUE(result->Equals(&expected)); 66 ASSERT_TRUE(result->Equals(&expected));
64 } 67 }
65 68
66 TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) { 69 TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) {
67 OnObjectFired::SomeObject object; 70 OnObjectFired::SomeObject object;
68 object.state = FIRST_STATE_BAR; 71 object.state = FIRST_STATE_BAR;
69 scoped_ptr<base::ListValue> results(OnObjectFired::Create(object)); 72 std::unique_ptr<base::ListValue> results(OnObjectFired::Create(object));
70 73
71 base::DictionaryValue expected; 74 base::DictionaryValue expected;
72 expected.SetString("state", "bar"); 75 expected.SetString("state", "bar");
73 base::DictionaryValue* result = NULL; 76 base::DictionaryValue* result = NULL;
74 ASSERT_TRUE(results->GetDictionary(0, &result)); 77 ASSERT_TRUE(results->GetDictionary(0, &result));
75 ASSERT_TRUE(result->Equals(&expected)); 78 ASSERT_TRUE(result->Equals(&expected));
76 } 79 }
77 TEST(JsonSchemaCompilerMovableObjectsTest, MovableObjectsTest) { 80 TEST(JsonSchemaCompilerMovableObjectsTest, MovableObjectsTest) {
78 std::vector<MovablePod> pods; 81 std::vector<MovablePod> pods;
79 { 82 {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 vals2.push_back("vals2a"); 152 vals2.push_back("vals2a");
150 vals2.push_back("vals2b"); 153 vals2.push_back("vals2b");
151 with_additional.additional_properties["key2"] = vals2; 154 with_additional.additional_properties["key2"] = vals2;
152 155
153 MovableWithAdditional with_additional2(std::move(with_additional)); 156 MovableWithAdditional with_additional2(std::move(with_additional));
154 EXPECT_EQ("str", with_additional2.str); 157 EXPECT_EQ("str", with_additional2.str);
155 EXPECT_EQ(2u, with_additional2.additional_properties.size()); 158 EXPECT_EQ(2u, with_additional2.additional_properties.size());
156 EXPECT_EQ(vals1, with_additional2.additional_properties["key1"]); 159 EXPECT_EQ(vals1, with_additional2.additional_properties["key1"]);
157 EXPECT_EQ(vals2, with_additional2.additional_properties["key2"]); 160 EXPECT_EQ(vals2, with_additional2.additional_properties["key2"]);
158 } 161 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/idl_schemas_unittest.cc ('k') | tools/json_schema_compiler/test/simple_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698