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

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

Issue 2317123002: c/browser, c/common, components O-P: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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 "chrome/browser/prefs/profile_pref_store_manager.h" 5 #include "chrome/browser/prefs/profile_pref_store_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 user_prefs::kPreferenceResetTime, 120 user_prefs::kPreferenceResetTime,
121 PrefHashFilter::ENFORCE_ON_LOAD, 121 PrefHashFilter::ENFORCE_ON_LOAD,
122 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; 122 PrefHashFilter::TRACKING_STRATEGY_ATOMIC};
123 configuration_.push_back(pref_reset_time_config); 123 configuration_.push_back(pref_reset_time_config);
124 124
125 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); 125 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir());
126 ReloadConfiguration(); 126 ReloadConfiguration();
127 } 127 }
128 128
129 void ReloadConfiguration() { 129 void ReloadConfiguration() {
130 manager_.reset(new ProfilePrefStoreManager(profile_dir_.path(), 130 manager_.reset(new ProfilePrefStoreManager(
131 configuration_, 131 profile_dir_.GetPath(), configuration_, kReportingIdCount, seed_,
132 kReportingIdCount, 132 "device_id", &local_state_));
133 seed_,
134 "device_id",
135 &local_state_));
136 } 133 }
137 134
138 void TearDown() override { DestroyPrefStore(); } 135 void TearDown() override { DestroyPrefStore(); }
139 136
140 protected: 137 protected:
141 // Verifies whether a reset was reported via the RecordReset() hook. Also 138 // Verifies whether a reset was reported via the RecordReset() hook. Also
142 // verifies that GetResetTime() was set (or not) accordingly. 139 // verifies that GetResetTime() was set (or not) accordingly.
143 void VerifyResetRecorded(bool reset_expected) { 140 void VerifyResetRecorded(bool reset_expected) {
144 EXPECT_EQ(reset_expected, reset_recorded_); 141 EXPECT_EQ(reset_expected, reset_recorded_);
145 142
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 main_message_loop_.task_runner(), 217 main_message_loop_.task_runner(),
221 base::Bind(&ProfilePrefStoreManagerTest::RecordReset, 218 base::Bind(&ProfilePrefStoreManagerTest::RecordReset,
222 base::Unretained(this)), 219 base::Unretained(this)),
223 NULL); 220 NULL);
224 pref_store_->AddObserver(&registry_verifier_); 221 pref_store_->AddObserver(&registry_verifier_);
225 pref_store_->ReadPrefs(); 222 pref_store_->ReadPrefs();
226 } 223 }
227 224
228 void ReplaceStringInPrefs(const std::string& find, 225 void ReplaceStringInPrefs(const std::string& find,
229 const std::string& replace) { 226 const std::string& replace) {
230 base::FileEnumerator file_enum( 227 base::FileEnumerator file_enum(profile_dir_.GetPath(), true,
231 profile_dir_.path(), true, base::FileEnumerator::FILES); 228 base::FileEnumerator::FILES);
232 229
233 for (base::FilePath path = file_enum.Next(); !path.empty(); 230 for (base::FilePath path = file_enum.Next(); !path.empty();
234 path = file_enum.Next()) { 231 path = file_enum.Next()) {
235 // Tamper with the file's contents 232 // Tamper with the file's contents
236 std::string contents; 233 std::string contents;
237 EXPECT_TRUE(base::ReadFileToString(path, &contents)); 234 EXPECT_TRUE(base::ReadFileToString(path, &contents));
238 base::ReplaceSubstringsAfterOffset(&contents, 0u, find, replace); 235 base::ReplaceSubstringsAfterOffset(&contents, 0u, find, replace);
239 EXPECT_EQ(static_cast<int>(contents.length()), 236 EXPECT_EQ(static_cast<int>(contents.length()),
240 base::WriteFile(path, contents.c_str(), contents.length())); 237 base::WriteFile(path, contents.c_str(), contents.length()));
241 } 238 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 480
484 // Trigger the logic that migrates it back to the unprotected preferences 481 // Trigger the logic that migrates it back to the unprotected preferences
485 // file. 482 // file.
486 pref_store_->SetValue(kProtectedAtomic, 483 pref_store_->SetValue(kProtectedAtomic,
487 base::WrapUnique(new base::StringValue(kGoodbyeWorld)), 484 base::WrapUnique(new base::StringValue(kGoodbyeWorld)),
488 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 485 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
489 LoadExistingPrefs(); 486 LoadExistingPrefs();
490 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); 487 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld);
491 VerifyResetRecorded(false); 488 VerifyResetRecorded(false);
492 } 489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698