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

Side by Side Diff: chrome/browser/prefs/tracked/pref_hash_calculator_unittest.cc

Issue 1129083003: More base::Values-related bare pointer -> scoped_ptr conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad merge Created 5 years, 7 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 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 "chrome/browser/prefs/tracked/pref_hash_calculator.h" 5 #include "chrome/browser/prefs/tracked/pref_hash_calculator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ASSERT_FALSE(calc1.Calculate("pref_path", NULL).empty()); 71 ASSERT_FALSE(calc1.Calculate("pref_path", NULL).empty());
72 } 72 }
73 73
74 // Tests the output against a known value to catch unexpected algorithm changes. 74 // Tests the output against a known value to catch unexpected algorithm changes.
75 // The test hashes below must NEVER be updated, the serialization algorithm used 75 // The test hashes below must NEVER be updated, the serialization algorithm used
76 // must always be able to generate data that will produce these exact hashes. 76 // must always be able to generate data that will produce these exact hashes.
77 TEST(PrefHashCalculatorTest, CatchHashChanges) { 77 TEST(PrefHashCalculatorTest, CatchHashChanges) {
78 static const char kSeed[] = "0123456789ABCDEF0123456789ABCDEF"; 78 static const char kSeed[] = "0123456789ABCDEF0123456789ABCDEF";
79 static const char kDeviceId[] = "test_device_id1"; 79 static const char kDeviceId[] = "test_device_id1";
80 80
81 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); 81 scoped_ptr<base::Value> null_value = base::Value::CreateNullValue();
82 scoped_ptr<base::Value> bool_value(new base::FundamentalValue(false)); 82 scoped_ptr<base::Value> bool_value(new base::FundamentalValue(false));
83 scoped_ptr<base::Value> int_value(new base::FundamentalValue(1234567890)); 83 scoped_ptr<base::Value> int_value(new base::FundamentalValue(1234567890));
84 scoped_ptr<base::Value> double_value( 84 scoped_ptr<base::Value> double_value(
85 new base::FundamentalValue(123.0987654321)); 85 new base::FundamentalValue(123.0987654321));
86 scoped_ptr<base::Value> string_value( 86 scoped_ptr<base::Value> string_value(
87 new base::StringValue("testing with special chars:\n<>{}:^^@#$\\/")); 87 new base::StringValue("testing with special chars:\n<>{}:^^@#$\\/"));
88 88
89 // For legacy reasons, we have to support pruning of empty lists/dictionaries 89 // For legacy reasons, we have to support pruning of empty lists/dictionaries
90 // and nested empty ists/dicts in the hash generation algorithm. 90 // and nested empty ists/dicts in the hash generation algorithm.
91 scoped_ptr<base::DictionaryValue> nested_empty_dict( 91 scoped_ptr<base::DictionaryValue> nested_empty_dict(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 static const char kExpectedValue[] = 197 static const char kExpectedValue[] =
198 "845EF34663FF8D32BE6707F40258FBA531C2BFC532E3B014AFB3476115C2A9DE"; 198 "845EF34663FF8D32BE6707F40258FBA531C2BFC532E3B014AFB3476115C2A9DE";
199 199
200 base::ListValue startup_urls; 200 base::ListValue startup_urls;
201 startup_urls.Set(0, new base::StringValue("http://www.chromium.org/")); 201 startup_urls.Set(0, new base::StringValue("http://www.chromium.org/"));
202 202
203 EXPECT_EQ(PrefHashCalculator::VALID_SECURE_LEGACY, 203 EXPECT_EQ(PrefHashCalculator::VALID_SECURE_LEGACY,
204 PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId). 204 PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId).
205 Validate("session.startup_urls", &startup_urls, kExpectedValue)); 205 Validate("session.startup_urls", &startup_urls, kExpectedValue));
206 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698