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

Side by Side Diff: tools/json_schema_compiler/test/functions_on_types_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 "base/values.h" 5 #include "base/values.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "tools/json_schema_compiler/test/functions_on_types.h" 7 #include "tools/json_schema_compiler/test/functions_on_types.h"
8 8
9 using namespace test::api::functions_on_types; 9 using namespace test::api::functions_on_types;
10 10
11 TEST(JsonSchemaCompilerFunctionsOnTypesTest, StorageAreaGetParamsCreate) { 11 TEST(JsonSchemaCompilerFunctionsOnTypesTest, StorageAreaGetParamsCreate) {
12 { 12 {
13 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 13 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
14 scoped_ptr<StorageArea::Get::Params> params( 14 std::unique_ptr<StorageArea::Get::Params> params(
15 StorageArea::Get::Params::Create(*params_value)); 15 StorageArea::Get::Params::Create(*params_value));
16 ASSERT_TRUE(params); 16 ASSERT_TRUE(params);
17 EXPECT_FALSE(params->keys); 17 EXPECT_FALSE(params->keys);
18 } 18 }
19 { 19 {
20 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 20 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
21 params_value->Append(new base::FundamentalValue(9)); 21 params_value->Append(new base::FundamentalValue(9));
22 scoped_ptr<StorageArea::Get::Params> params( 22 std::unique_ptr<StorageArea::Get::Params> params(
23 StorageArea::Get::Params::Create(*params_value)); 23 StorageArea::Get::Params::Create(*params_value));
24 EXPECT_FALSE(params); 24 EXPECT_FALSE(params);
25 } 25 }
26 { 26 {
27 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 27 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
28 params_value->Append(new base::StringValue("test")); 28 params_value->Append(new base::StringValue("test"));
29 scoped_ptr<StorageArea::Get::Params> params( 29 std::unique_ptr<StorageArea::Get::Params> params(
30 StorageArea::Get::Params::Create(*params_value)); 30 StorageArea::Get::Params::Create(*params_value));
31 ASSERT_TRUE(params); 31 ASSERT_TRUE(params);
32 ASSERT_TRUE(params->keys); 32 ASSERT_TRUE(params->keys);
33 EXPECT_EQ("test", *params->keys->as_string); 33 EXPECT_EQ("test", *params->keys->as_string);
34 } 34 }
35 { 35 {
36 scoped_ptr<base::DictionaryValue> keys_object_value( 36 std::unique_ptr<base::DictionaryValue> keys_object_value(
37 new base::DictionaryValue()); 37 new base::DictionaryValue());
38 keys_object_value->SetInteger("integer", 5); 38 keys_object_value->SetInteger("integer", 5);
39 keys_object_value->SetString("string", "string"); 39 keys_object_value->SetString("string", "string");
40 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 40 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
41 params_value->Append(keys_object_value->DeepCopy()); 41 params_value->Append(keys_object_value->DeepCopy());
42 scoped_ptr<StorageArea::Get::Params> params( 42 std::unique_ptr<StorageArea::Get::Params> params(
43 StorageArea::Get::Params::Create(*params_value)); 43 StorageArea::Get::Params::Create(*params_value));
44 ASSERT_TRUE(params); 44 ASSERT_TRUE(params);
45 ASSERT_TRUE(params->keys); 45 ASSERT_TRUE(params->keys);
46 EXPECT_TRUE(keys_object_value->Equals( 46 EXPECT_TRUE(keys_object_value->Equals(
47 &params->keys->as_object->additional_properties)); 47 &params->keys->as_object->additional_properties));
48 } 48 }
49 } 49 }
50 50
51 TEST(JsonSchemaCompilerFunctionsOnTypesTest, StorageAreaGetResultCreate) { 51 TEST(JsonSchemaCompilerFunctionsOnTypesTest, StorageAreaGetResultCreate) {
52 StorageArea::Get::Results::Items items; 52 StorageArea::Get::Results::Items items;
53 items.additional_properties.SetDouble("asdf", 0.1); 53 items.additional_properties.SetDouble("asdf", 0.1);
54 items.additional_properties.SetString("sdfg", "zxcv"); 54 items.additional_properties.SetString("sdfg", "zxcv");
55 scoped_ptr<base::ListValue> results = 55 std::unique_ptr<base::ListValue> results =
56 StorageArea::Get::Results::Create(items); 56 StorageArea::Get::Results::Create(items);
57 base::DictionaryValue* item_result = NULL; 57 base::DictionaryValue* item_result = NULL;
58 ASSERT_TRUE(results->GetDictionary(0, &item_result)); 58 ASSERT_TRUE(results->GetDictionary(0, &item_result));
59 EXPECT_TRUE(item_result->Equals(&items.additional_properties)); 59 EXPECT_TRUE(item_result->Equals(&items.additional_properties));
60 } 60 }
61 61
62 TEST(JsonSchemaCompilerFunctionsOnTypesTest, ChromeSettingGetParamsCreate) { 62 TEST(JsonSchemaCompilerFunctionsOnTypesTest, ChromeSettingGetParamsCreate) {
63 scoped_ptr<base::DictionaryValue> details_value(new base::DictionaryValue()); 63 std::unique_ptr<base::DictionaryValue> details_value(
64 new base::DictionaryValue());
64 details_value->SetBoolean("incognito", true); 65 details_value->SetBoolean("incognito", true);
65 scoped_ptr<base::ListValue> params_value(new base::ListValue()); 66 std::unique_ptr<base::ListValue> params_value(new base::ListValue());
66 params_value->Append(details_value.release()); 67 params_value->Append(details_value.release());
67 scoped_ptr<ChromeSetting::Get::Params> params( 68 std::unique_ptr<ChromeSetting::Get::Params> params(
68 ChromeSetting::Get::Params::Create(*params_value)); 69 ChromeSetting::Get::Params::Create(*params_value));
69 EXPECT_TRUE(params.get()); 70 EXPECT_TRUE(params.get());
70 EXPECT_TRUE(*params->details.incognito); 71 EXPECT_TRUE(*params->details.incognito);
71 } 72 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/error_generation_unittest.cc ('k') | tools/json_schema_compiler/test/idl_schemas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698