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

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

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per review comment. Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (allowed_buckets == ALLOW_NONE || 78 if (allowed_buckets == ALLOW_NONE ||
79 (allowed_buckets != ALLOW_ANY && i != allowed_buckets)) { 79 (allowed_buckets != ALLOW_ANY && i != allowed_buckets)) {
80 EXPECT_EQ(0, count_for_id) << "Unexpected reporting_id: " << i; 80 EXPECT_EQ(0, count_for_id) << "Unexpected reporting_id: " << i;
81 } 81 }
82 } 82 }
83 return sum; 83 return sum;
84 } 84 }
85 85
86 scoped_ptr<base::DictionaryValue> ReadPrefsDictionary( 86 scoped_ptr<base::DictionaryValue> ReadPrefsDictionary(
87 const base::FilePath& pref_file) { 87 const base::FilePath& pref_file) {
88 JSONFileValueSerializer serializer(pref_file); 88 JSONFileValueDeserializer serializer(pref_file);
89 int error_code = JSONFileValueSerializer::JSON_NO_ERROR; 89 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR;
90 std::string error_str; 90 std::string error_str;
91 scoped_ptr<base::Value> prefs( 91 scoped_ptr<base::Value> prefs(
92 serializer.Deserialize(&error_code, &error_str)); 92 serializer.Deserialize(&error_code, &error_str));
93 if (!prefs || error_code != JSONFileValueSerializer::JSON_NO_ERROR) { 93 if (!prefs || error_code != JSONFileValueDeserializer::JSON_NO_ERROR) {
94 ADD_FAILURE() << "Error #" << error_code << ": " << error_str; 94 ADD_FAILURE() << "Error #" << error_code << ": " << error_str;
95 return scoped_ptr<base::DictionaryValue>(); 95 return scoped_ptr<base::DictionaryValue>();
96 } 96 }
97 if (!prefs->IsType(base::Value::TYPE_DICTIONARY)) { 97 if (!prefs->IsType(base::Value::TYPE_DICTIONARY)) {
98 ADD_FAILURE(); 98 ADD_FAILURE();
99 return scoped_ptr<base::DictionaryValue>(); 99 return scoped_ptr<base::DictionaryValue>();
100 } 100 }
101 return scoped_ptr<base::DictionaryValue>( 101 return scoped_ptr<base::DictionaryValue>(
102 static_cast<base::DictionaryValue*>(prefs.release())); 102 static_cast<base::DictionaryValue*>(prefs.release()));
103 } 103 }
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 "Settings.TrackedPreferenceNullInitialized", ALLOW_NONE)); 910 "Settings.TrackedPreferenceNullInitialized", ALLOW_NONE));
911 EXPECT_EQ( 911 EXPECT_EQ(
912 0, 912 0,
913 GetTrackedPrefHistogramCount( 913 GetTrackedPrefHistogramCount(
914 "Settings.TrackedPreferenceMigratedLegacyDeviceId", ALLOW_NONE)); 914 "Settings.TrackedPreferenceMigratedLegacyDeviceId", ALLOW_NONE));
915 } 915 }
916 }; 916 };
917 917
918 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe, 918 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe,
919 UntrustedAdditionToPrefsAfterWipe); 919 UntrustedAdditionToPrefsAfterWipe);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698