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

Side by Side Diff: services/preferences/tracked/pref_hash_calculator_unittest.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 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
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | tools/gn/desc_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "services/preferences/tracked/pref_hash_calculator.h" 5 #include "services/preferences/tracked/pref_hash_calculator.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ASSERT_FALSE(calc1.Calculate("pref_path", NULL).empty()); 69 ASSERT_FALSE(calc1.Calculate("pref_path", NULL).empty());
70 } 70 }
71 71
72 // Tests the output against a known value to catch unexpected algorithm changes. 72 // Tests the output against a known value to catch unexpected algorithm changes.
73 // The test hashes below must NEVER be updated, the serialization algorithm used 73 // The test hashes below must NEVER be updated, the serialization algorithm used
74 // must always be able to generate data that will produce these exact hashes. 74 // must always be able to generate data that will produce these exact hashes.
75 TEST(PrefHashCalculatorTest, CatchHashChanges) { 75 TEST(PrefHashCalculatorTest, CatchHashChanges) {
76 static const char kSeed[] = "0123456789ABCDEF0123456789ABCDEF"; 76 static const char kSeed[] = "0123456789ABCDEF0123456789ABCDEF";
77 static const char kDeviceId[] = "test_device_id1"; 77 static const char kDeviceId[] = "test_device_id1";
78 78
79 std::unique_ptr<base::Value> null_value = base::Value::CreateNullValue(); 79 auto null_value = base::MakeUnique<base::Value>();
80 std::unique_ptr<base::Value> bool_value(new base::Value(false)); 80 std::unique_ptr<base::Value> bool_value(new base::Value(false));
81 std::unique_ptr<base::Value> int_value(new base::Value(1234567890)); 81 std::unique_ptr<base::Value> int_value(new base::Value(1234567890));
82 std::unique_ptr<base::Value> double_value(new base::Value(123.0987654321)); 82 std::unique_ptr<base::Value> double_value(new base::Value(123.0987654321));
83 std::unique_ptr<base::Value> string_value( 83 std::unique_ptr<base::Value> string_value(
84 new base::Value("testing with special chars:\n<>{}:^^@#$\\/")); 84 new base::Value("testing with special chars:\n<>{}:^^@#$\\/"));
85 85
86 // For legacy reasons, we have to support pruning of empty lists/dictionaries 86 // For legacy reasons, we have to support pruning of empty lists/dictionaries
87 // and nested empty ists/dicts in the hash generation algorithm. 87 // and nested empty ists/dicts in the hash generation algorithm.
88 std::unique_ptr<base::DictionaryValue> nested_empty_dict( 88 std::unique_ptr<base::DictionaryValue> nested_empty_dict(
89 new base::DictionaryValue); 89 new base::DictionaryValue);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 // As in PrefHashCalculatorTest.CatchHashChanges. 188 // As in PrefHashCalculatorTest.CatchHashChanges.
189 const base::Value string_value("testing with special chars:\n<>{}:^^@#$\\/"); 189 const base::Value string_value("testing with special chars:\n<>{}:^^@#$\\/");
190 static const char kExpectedValue[] = 190 static const char kExpectedValue[] =
191 "05ACCBD3B05C45C36CD06190F63EC577112311929D8380E26E5F13182EB68318"; 191 "05ACCBD3B05C45C36CD06190F63EC577112311929D8380E26E5F13182EB68318";
192 192
193 EXPECT_EQ(PrefHashCalculator::VALID_SECURE_LEGACY, 193 EXPECT_EQ(PrefHashCalculator::VALID_SECURE_LEGACY,
194 PrefHashCalculator(kSeed, kNewDeviceId, kLegacyDeviceId) 194 PrefHashCalculator(kSeed, kNewDeviceId, kLegacyDeviceId)
195 .Validate("pref.path", &string_value, kExpectedValue)); 195 .Validate("pref.path", &string_value, kExpectedValue));
196 } 196 }
OLDNEW
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | tools/gn/desc_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698