Index: services/preferences/tracked/pref_hash_calculator_unittest.cc |
diff --git a/services/preferences/tracked/pref_hash_calculator_unittest.cc b/services/preferences/tracked/pref_hash_calculator_unittest.cc |
index df3746a09e0da5014d9b556332b06413a6794903..0dc9765102d0aedb59bde4bfd77e13cec6dee709 100644 |
--- a/services/preferences/tracked/pref_hash_calculator_unittest.cc |
+++ b/services/preferences/tracked/pref_hash_calculator_unittest.cc |
@@ -6,6 +6,7 @@ |
#include <memory> |
#include <string> |
+#include <utility> |
#include "base/macros.h" |
#include "base/memory/ptr_util.h" |
@@ -18,7 +19,8 @@ TEST(PrefHashCalculatorTest, TestCurrentAlgorithm) { |
base::Value string_value_2("string value 2"); |
base::DictionaryValue dictionary_value_1; |
dictionary_value_1.SetInteger("int value", 1); |
- dictionary_value_1.Set("nested empty map", new base::DictionaryValue); |
+ dictionary_value_1.Set("nested empty map", |
+ base::MakeUnique<base::DictionaryValue>()); |
base::DictionaryValue dictionary_value_1_equivalent; |
dictionary_value_1_equivalent.SetInteger("int value", 1); |
base::DictionaryValue dictionary_value_2; |
@@ -77,34 +79,33 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) { |
static const char kDeviceId[] = "test_device_id1"; |
auto null_value = base::MakeUnique<base::Value>(); |
- std::unique_ptr<base::Value> bool_value(new base::Value(false)); |
- std::unique_ptr<base::Value> int_value(new base::Value(1234567890)); |
- std::unique_ptr<base::Value> double_value(new base::Value(123.0987654321)); |
- std::unique_ptr<base::Value> string_value( |
- new base::Value("testing with special chars:\n<>{}:^^@#$\\/")); |
+ auto bool_value = base::MakeUnique<base::Value>(false); |
+ auto int_value = base::MakeUnique<base::Value>(1234567890); |
+ auto double_value = base::MakeUnique<base::Value>(123.0987654321); |
+ auto string_value = base::MakeUnique<base::Value>( |
+ "testing with special chars:\n<>{}:^^@#$\\/"); |
// For legacy reasons, we have to support pruning of empty lists/dictionaries |
// and nested empty ists/dicts in the hash generation algorithm. |
- std::unique_ptr<base::DictionaryValue> nested_empty_dict( |
- new base::DictionaryValue); |
- nested_empty_dict->Set("a", new base::DictionaryValue); |
- nested_empty_dict->Set("b", new base::ListValue); |
- std::unique_ptr<base::ListValue> nested_empty_list(new base::ListValue); |
+ auto nested_empty_dict = base::MakeUnique<base::DictionaryValue>(); |
+ nested_empty_dict->Set("a", base::MakeUnique<base::DictionaryValue>()); |
+ nested_empty_dict->Set("b", base::MakeUnique<base::ListValue>()); |
+ auto nested_empty_list = base::MakeUnique<base::ListValue>(); |
nested_empty_list->Append(base::MakeUnique<base::DictionaryValue>()); |
nested_empty_list->Append(base::MakeUnique<base::ListValue>()); |
- nested_empty_list->Append(nested_empty_dict->CreateDeepCopy()); |
+ nested_empty_list->Append(base::MakeUnique<base::Value>(*nested_empty_dict)); |
// A dictionary with an empty dictionary, an empty list, and nested empty |
// dictionaries/lists in it. |
- std::unique_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue); |
- dict_value->Set("a", new base::Value("foo")); |
- dict_value->Set("d", new base::ListValue); |
- dict_value->Set("b", new base::DictionaryValue); |
- dict_value->Set("c", new base::Value("baz")); |
- dict_value->Set("e", nested_empty_dict.release()); |
- dict_value->Set("f", nested_empty_list.release()); |
- |
- std::unique_ptr<base::ListValue> list_value(new base::ListValue); |
+ auto dict_value = base::MakeUnique<base::DictionaryValue>(); |
+ dict_value->SetString("a", "foo"); |
+ dict_value->Set("d", base::MakeUnique<base::ListValue>()); |
+ dict_value->Set("b", base::MakeUnique<base::DictionaryValue>()); |
+ dict_value->SetString("c", "baz"); |
+ dict_value->Set("e", std::move(nested_empty_dict)); |
+ dict_value->Set("f", std::move(nested_empty_list)); |
+ |
+ auto list_value = base::MakeUnique<base::ListValue>(); |
list_value->AppendBoolean(true); |
list_value->AppendInteger(100); |
list_value->AppendDouble(1.0); |
@@ -166,13 +167,13 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) { |
// Also test every value type together in the same dictionary. |
base::DictionaryValue everything; |
- everything.Set("null", null_value.release()); |
- everything.Set("bool", bool_value.release()); |
- everything.Set("int", int_value.release()); |
- everything.Set("double", double_value.release()); |
- everything.Set("string", string_value.release()); |
- everything.Set("list", list_value.release()); |
- everything.Set("dict", dict_value.release()); |
+ everything.Set("null", std::move(null_value)); |
+ everything.Set("bool", std::move(bool_value)); |
+ everything.Set("int", std::move(int_value)); |
+ everything.Set("double", std::move(double_value)); |
+ everything.Set("string", std::move(string_value)); |
+ everything.Set("list", std::move(list_value)); |
+ everything.Set("dict", std::move(dict_value)); |
static const char kExpectedEverythingValue[] = |
"B97D09BE7005693574DCBDD03D8D9E44FB51F4008B73FB56A49A9FA671A1999B"; |
EXPECT_EQ(PrefHashCalculator::VALID, |