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

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

Issue 385263004: Get rid of some uses of CreateIntegerValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
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/pref_hash_calculator.h" 5 #include "chrome/browser/prefs/pref_hash_calculator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // Tests the output against a known value to catch unexpected algorithm changes. 76 // Tests the output against a known value to catch unexpected algorithm changes.
77 // The test hashes below must NEVER be updated, the serialization algorithm used 77 // The test hashes below must NEVER be updated, the serialization algorithm used
78 // must always be able to generate data that will produce these exact hashes. 78 // must always be able to generate data that will produce these exact hashes.
79 TEST(PrefHashCalculatorTest, CatchHashChanges) { 79 TEST(PrefHashCalculatorTest, CatchHashChanges) {
80 static const char kSeed[] = "0123456789ABCDEF0123456789ABCDEF"; 80 static const char kSeed[] = "0123456789ABCDEF0123456789ABCDEF";
81 static const char kDeviceId[] = "test_device_id1"; 81 static const char kDeviceId[] = "test_device_id1";
82 82
83 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); 83 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue());
84 scoped_ptr<base::Value> bool_value(new base::FundamentalValue(false)); 84 scoped_ptr<base::Value> bool_value(new base::FundamentalValue(false));
85 scoped_ptr<base::Value> int_value( 85 scoped_ptr<base::Value> int_value(new base::FundamentalValue(1234567890));
86 base::Value::CreateIntegerValue(1234567890));
87 scoped_ptr<base::Value> double_value( 86 scoped_ptr<base::Value> double_value(
88 new base::FundamentalValue(123.0987654321)); 87 new base::FundamentalValue(123.0987654321));
89 scoped_ptr<base::Value> string_value( 88 scoped_ptr<base::Value> string_value(
90 new base::StringValue("testing with special chars:\n<>{}:^^@#$\\/")); 89 new base::StringValue("testing with special chars:\n<>{}:^^@#$\\/"));
91 90
92 // For legacy reasons, we have to support pruning of empty lists/dictionaries 91 // For legacy reasons, we have to support pruning of empty lists/dictionaries
93 // and nested empty ists/dicts in the hash generation algorithm. 92 // and nested empty ists/dicts in the hash generation algorithm.
94 scoped_ptr<base::DictionaryValue> nested_empty_dict( 93 scoped_ptr<base::DictionaryValue> nested_empty_dict(
95 new base::DictionaryValue); 94 new base::DictionaryValue);
96 nested_empty_dict->Set("a", new base::DictionaryValue); 95 nested_empty_dict->Set("a", new base::DictionaryValue);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // kSeed. 262 // kSeed.
264 static const char kTestedHash[] = 263 static const char kTestedHash[] =
265 "842C71283B9C3D86AA934CD639FDB0428BF0E2B6EC8537A21575CC4C4FA0A615"; 264 "842C71283B9C3D86AA934CD639FDB0428BF0E2B6EC8537A21575CC4C4FA0A615";
266 265
267 const base::StringValue string_value(kPrefValue); 266 const base::StringValue string_value(kPrefValue);
268 EXPECT_EQ(PrefHashCalculator::VALID, 267 EXPECT_EQ(PrefHashCalculator::VALID,
269 PrefHashCalculator(kSeed, kEmptyDeviceId, 268 PrefHashCalculator(kSeed, kEmptyDeviceId,
270 base::Bind(&MockGetLegacyDeviceId)).Validate( 269 base::Bind(&MockGetLegacyDeviceId)).Validate(
271 kPrefPath, &string_value, kTestedHash)); 270 kPrefPath, &string_value, kTestedHash));
272 } 271 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/incognito_mode_prefs_unittest.cc ('k') | chrome/browser/prefs/pref_hash_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698