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

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

Issue 1200393002: Add more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string
Patch Set: Android Created 5 years, 6 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 | « chrome/browser/pdf/pdf_extension_util.cc ('k') | chrome/browser/search/iframe_source.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 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 <vector> 7 #include <vector>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void ReplaceStringInPrefs(const std::string& find, 231 void ReplaceStringInPrefs(const std::string& find,
232 const std::string& replace) { 232 const std::string& replace) {
233 base::FileEnumerator file_enum( 233 base::FileEnumerator file_enum(
234 profile_dir_.path(), true, base::FileEnumerator::FILES); 234 profile_dir_.path(), true, base::FileEnumerator::FILES);
235 235
236 for (base::FilePath path = file_enum.Next(); !path.empty(); 236 for (base::FilePath path = file_enum.Next(); !path.empty();
237 path = file_enum.Next()) { 237 path = file_enum.Next()) {
238 // Tamper with the file's contents 238 // Tamper with the file's contents
239 std::string contents; 239 std::string contents;
240 EXPECT_TRUE(base::ReadFileToString(path, &contents)); 240 EXPECT_TRUE(base::ReadFileToString(path, &contents));
241 ReplaceSubstringsAfterOffset(&contents, 0u, find, replace); 241 base::ReplaceSubstringsAfterOffset(&contents, 0u, find, replace);
242 EXPECT_EQ(static_cast<int>(contents.length()), 242 EXPECT_EQ(static_cast<int>(contents.length()),
243 base::WriteFile(path, contents.c_str(), contents.length())); 243 base::WriteFile(path, contents.c_str(), contents.length()));
244 } 244 }
245 } 245 }
246 246
247 void ExpectStringValueEquals(const std::string& name, 247 void ExpectStringValueEquals(const std::string& name,
248 const std::string& expected) { 248 const std::string& expected) {
249 const base::Value* value = NULL; 249 const base::Value* value = NULL;
250 std::string as_string; 250 std::string as_string;
251 if (!pref_store_->GetValue(name, &value)) { 251 if (!pref_store_->GetValue(name, &value)) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); 574 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld);
575 575
576 // Trigger the logic that migrates it back to the unprotected preferences 576 // Trigger the logic that migrates it back to the unprotected preferences
577 // file. 577 // file.
578 pref_store_->SetValue(kProtectedAtomic, new base::StringValue(kGoodbyeWorld), 578 pref_store_->SetValue(kProtectedAtomic, new base::StringValue(kGoodbyeWorld),
579 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 579 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
580 LoadExistingPrefs(); 580 LoadExistingPrefs();
581 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); 581 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld);
582 VerifyResetRecorded(false); 582 VerifyResetRecorded(false);
583 } 583 }
OLDNEW
« no previous file with comments | « chrome/browser/pdf/pdf_extension_util.cc ('k') | chrome/browser/search/iframe_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698