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

Unified Diff: components/policy/core/common/registry_dict_win_unittest.cc

Issue 1752233002: Convert Pass()→std::move() on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/registry_dict_win.cc ('k') | content/browser/gpu/gpu_internals_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/registry_dict_win_unittest.cc
diff --git a/components/policy/core/common/registry_dict_win_unittest.cc b/components/policy/core/common/registry_dict_win_unittest.cc
index f5a393ae7e50d968eac011a99193eaae24591c26..8f343b656eded0f8185cb15f3a380ee3bc797a4e 100644
--- a/components/policy/core/common/registry_dict_win_unittest.cc
+++ b/components/policy/core/common/registry_dict_win_unittest.cc
@@ -5,6 +5,7 @@
#include "components/policy/core/common/registry_dict_win.h"
#include <string>
+#include <utility>
#include "base/values.h"
#include "components/policy/core/common/schema.h"
@@ -19,12 +20,12 @@ TEST(RegistryDictTest, SetAndGetValue) {
base::FundamentalValue int_value(42);
base::StringValue string_value("fortytwo");
- test_dict.SetValue("one", scoped_ptr<base::Value>(int_value.DeepCopy()));
+ test_dict.SetValue("one", int_value.CreateDeepCopy());
EXPECT_EQ(1u, test_dict.values().size());
EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one")));
EXPECT_FALSE(test_dict.GetValue("two"));
- test_dict.SetValue("two", scoped_ptr<base::Value>(string_value.DeepCopy()));
+ test_dict.SetValue("two", string_value.CreateDeepCopy());
EXPECT_EQ(2u, test_dict.values().size());
EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one")));
EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("two")));
@@ -47,7 +48,7 @@ TEST(RegistryDictTest, CaseInsensitiveButPreservingValueNames) {
base::FundamentalValue int_value(42);
base::StringValue string_value("fortytwo");
- test_dict.SetValue("One", scoped_ptr<base::Value>(int_value.DeepCopy()));
+ test_dict.SetValue("One", int_value.CreateDeepCopy());
EXPECT_EQ(1u, test_dict.values().size());
EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("oNe")));
@@ -55,7 +56,7 @@ TEST(RegistryDictTest, CaseInsensitiveButPreservingValueNames) {
ASSERT_NE(entry, test_dict.values().end());
EXPECT_EQ("One", entry->first);
- test_dict.SetValue("ONE", scoped_ptr<base::Value>(string_value.DeepCopy()));
+ test_dict.SetValue("ONE", string_value.CreateDeepCopy());
EXPECT_EQ(1u, test_dict.values().size());
EXPECT_TRUE(base::Value::Equals(&string_value, test_dict.GetValue("one")));
@@ -71,16 +72,16 @@ TEST(RegistryDictTest, SetAndGetKeys) {
base::StringValue string_value("fortytwo");
scoped_ptr<RegistryDict> subdict(new RegistryDict());
- subdict->SetValue("one", scoped_ptr<base::Value>(int_value.DeepCopy()));
- test_dict.SetKey("two", subdict.Pass());
+ subdict->SetValue("one", int_value.CreateDeepCopy());
+ test_dict.SetKey("two", std::move(subdict));
EXPECT_EQ(1u, test_dict.keys().size());
RegistryDict* actual_subdict = test_dict.GetKey("two");
ASSERT_TRUE(actual_subdict);
EXPECT_TRUE(base::Value::Equals(&int_value, actual_subdict->GetValue("one")));
subdict.reset(new RegistryDict());
- subdict->SetValue("three", scoped_ptr<base::Value>(string_value.DeepCopy()));
- test_dict.SetKey("four", subdict.Pass());
+ subdict->SetValue("three", string_value.CreateDeepCopy());
+ test_dict.SetKey("four", std::move(subdict));
EXPECT_EQ(2u, test_dict.keys().size());
actual_subdict = test_dict.GetKey("two");
ASSERT_TRUE(actual_subdict);
@@ -101,7 +102,7 @@ TEST(RegistryDictTest, CaseInsensitiveButPreservingKeyNames) {
base::FundamentalValue int_value(42);
- test_dict.SetKey("One", make_scoped_ptr(new RegistryDict()).Pass());
+ test_dict.SetKey("One", make_scoped_ptr(new RegistryDict()));
EXPECT_EQ(1u, test_dict.keys().size());
RegistryDict* actual_subdict = test_dict.GetKey("One");
ASSERT_TRUE(actual_subdict);
@@ -112,8 +113,8 @@ TEST(RegistryDictTest, CaseInsensitiveButPreservingKeyNames) {
EXPECT_EQ("One", entry->first);
scoped_ptr<RegistryDict> subdict(new RegistryDict());
- subdict->SetValue("two", scoped_ptr<base::Value>(int_value.DeepCopy()));
- test_dict.SetKey("ONE", subdict.Pass());
+ subdict->SetValue("two", int_value.CreateDeepCopy());
+ test_dict.SetKey("ONE", std::move(subdict));
EXPECT_EQ(1u, test_dict.keys().size());
actual_subdict = test_dict.GetKey("One");
ASSERT_TRUE(actual_subdict);
@@ -134,18 +135,18 @@ TEST(RegistryDictTest, Merge) {
base::FundamentalValue int_value(42);
base::StringValue string_value("fortytwo");
- dict_a.SetValue("one", scoped_ptr<base::Value>(int_value.DeepCopy()));
+ dict_a.SetValue("one", int_value.CreateDeepCopy());
scoped_ptr<RegistryDict> subdict(new RegistryDict());
- subdict->SetValue("two", scoped_ptr<base::Value>(string_value.DeepCopy()));
- dict_a.SetKey("three", subdict.Pass());
+ subdict->SetValue("two", string_value.CreateDeepCopy());
+ dict_a.SetKey("three", std::move(subdict));
- dict_b.SetValue("four", scoped_ptr<base::Value>(string_value.DeepCopy()));
+ dict_b.SetValue("four", string_value.CreateDeepCopy());
subdict.reset(new RegistryDict());
- subdict->SetValue("two", scoped_ptr<base::Value>(int_value.DeepCopy()));
- dict_b.SetKey("three", subdict.Pass());
+ subdict->SetValue("two", int_value.CreateDeepCopy());
+ dict_b.SetKey("three", std::move(subdict));
subdict.reset(new RegistryDict());
- subdict->SetValue("five", scoped_ptr<base::Value>(int_value.DeepCopy()));
- dict_b.SetKey("six", subdict.Pass());
+ subdict->SetValue("five", int_value.CreateDeepCopy());
+ dict_b.SetKey("six", std::move(subdict));
dict_a.Merge(dict_b);
@@ -167,9 +168,9 @@ TEST(RegistryDictTest, Swap) {
base::FundamentalValue int_value(42);
base::StringValue string_value("fortytwo");
- dict_a.SetValue("one", scoped_ptr<base::Value>(int_value.DeepCopy()));
- dict_a.SetKey("two", make_scoped_ptr(new RegistryDict()).Pass());
- dict_b.SetValue("three", scoped_ptr<base::Value>(string_value.DeepCopy()));
+ dict_a.SetValue("one", int_value.CreateDeepCopy());
+ dict_a.SetKey("two", make_scoped_ptr(new RegistryDict()));
+ dict_b.SetValue("three", string_value.CreateDeepCopy());
dict_a.Swap(&dict_b);
@@ -190,25 +191,19 @@ TEST(RegistryDictTest, ConvertToJSON) {
base::StringValue string_zero("0");
base::StringValue string_dict("{ \"key\": [ \"value\" ] }");
- test_dict.SetValue("one", scoped_ptr<base::Value>(int_value.DeepCopy()));
+ test_dict.SetValue("one", int_value.CreateDeepCopy());
scoped_ptr<RegistryDict> subdict(new RegistryDict());
- subdict->SetValue("two", scoped_ptr<base::Value>(string_value.DeepCopy()));
- test_dict.SetKey("three", subdict.Pass());
+ subdict->SetValue("two", string_value.CreateDeepCopy());
+ test_dict.SetKey("three", std::move(subdict));
scoped_ptr<RegistryDict> list(new RegistryDict());
- list->SetValue("1", scoped_ptr<base::Value>(string_value.DeepCopy()));
- test_dict.SetKey("dict-to-list", list.Pass());
- test_dict.SetValue("int-to-bool",
- scoped_ptr<base::Value>(int_value.DeepCopy()));
- test_dict.SetValue("int-to-double",
- scoped_ptr<base::Value>(int_value.DeepCopy()));
- test_dict.SetValue("string-to-bool",
- scoped_ptr<base::Value>(string_zero.DeepCopy()));
- test_dict.SetValue("string-to-double",
- scoped_ptr<base::Value>(string_zero.DeepCopy()));
- test_dict.SetValue("string-to-int",
- scoped_ptr<base::Value>(string_zero.DeepCopy()));
- test_dict.SetValue("string-to-dict",
- scoped_ptr<base::Value>(string_dict.DeepCopy()));
+ list->SetValue("1", string_value.CreateDeepCopy());
+ test_dict.SetKey("dict-to-list", std::move(list));
+ test_dict.SetValue("int-to-bool", int_value.CreateDeepCopy());
+ test_dict.SetValue("int-to-double", int_value.CreateDeepCopy());
+ test_dict.SetValue("string-to-bool", string_zero.CreateDeepCopy());
+ test_dict.SetValue("string-to-double", string_zero.CreateDeepCopy());
+ test_dict.SetValue("string-to-int", string_zero.CreateDeepCopy());
+ test_dict.SetValue("string-to-dict", string_dict.CreateDeepCopy());
std::string error;
Schema schema = Schema::Parse(
@@ -232,14 +227,14 @@ TEST(RegistryDictTest, ConvertToJSON) {
scoped_ptr<base::Value> actual(test_dict.ConvertToJSON(schema));
base::DictionaryValue expected;
- expected.Set("one", int_value.DeepCopy());
+ expected.Set("one", int_value.CreateDeepCopy());
scoped_ptr<base::DictionaryValue> expected_subdict(
new base::DictionaryValue());
- expected_subdict->Set("two", string_value.DeepCopy());
- expected.Set("three", expected_subdict.release());
+ expected_subdict->Set("two", string_value.CreateDeepCopy());
+ expected.Set("three", std::move(expected_subdict));
scoped_ptr<base::ListValue> expected_list(new base::ListValue());
- expected_list->Append(string_value.DeepCopy());
- expected.Set("dict-to-list", expected_list.release());
+ expected_list->Append(string_value.CreateDeepCopy());
+ expected.Set("dict-to-list", std::move(expected_list));
expected.Set("int-to-bool", new base::FundamentalValue(true));
expected.Set("int-to-double", new base::FundamentalValue(42.0));
expected.Set("string-to-bool", new base::FundamentalValue(false));
@@ -249,8 +244,8 @@ TEST(RegistryDictTest, ConvertToJSON) {
expected_list.reset(new base::ListValue());
expected_list->Append(new base::StringValue("value"));
expected_subdict.reset(new base::DictionaryValue());
- expected_subdict->Set("key", expected_list.release());
- expected.Set("string-to-dict", expected_subdict.release());
+ expected_subdict->Set("key", std::move(expected_list));
+ expected.Set("string-to-dict", std::move(expected_subdict));
EXPECT_TRUE(base::Value::Equals(actual.get(), &expected));
}
@@ -261,10 +256,10 @@ TEST(RegistryDictTest, KeyValueNameClashes) {
base::FundamentalValue int_value(42);
base::StringValue string_value("fortytwo");
- test_dict.SetValue("one", scoped_ptr<base::Value>(int_value.DeepCopy()));
+ test_dict.SetValue("one", int_value.CreateDeepCopy());
scoped_ptr<RegistryDict> subdict(new RegistryDict());
- subdict->SetValue("two", scoped_ptr<base::Value>(string_value.DeepCopy()));
- test_dict.SetKey("one", subdict.Pass());
+ subdict->SetValue("two", string_value.CreateDeepCopy());
+ test_dict.SetKey("one", std::move(subdict));
EXPECT_TRUE(base::Value::Equals(&int_value, test_dict.GetValue("one")));
RegistryDict* actual_subdict = test_dict.GetKey("one");
« no previous file with comments | « components/policy/core/common/registry_dict_win.cc ('k') | content/browser/gpu/gpu_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698