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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 <utility> 10 #include <utility>
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Nothing should have to happen on the background threads, but just in 191 // Nothing should have to happen on the background threads, but just in
192 // case... 192 // case...
193 base::RunLoop().RunUntilIdle(); 193 base::RunLoop().RunUntilIdle();
194 } 194 }
195 } 195 }
196 196
197 void InitializePrefStore(PersistentPrefStore* pref_store) { 197 void InitializePrefStore(PersistentPrefStore* pref_store) {
198 pref_store->AddObserver(&registry_verifier_); 198 pref_store->AddObserver(&registry_verifier_);
199 PersistentPrefStore::PrefReadError error = pref_store->ReadPrefs(); 199 PersistentPrefStore::PrefReadError error = pref_store->ReadPrefs();
200 EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE, error); 200 EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE, error);
201 pref_store->SetValue(kTrackedAtomic, 201 pref_store->SetValue(kTrackedAtomic, base::MakeUnique<base::Value>(kFoobar),
202 base::MakeUnique<base::StringValue>(kFoobar),
203 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 202 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
204 pref_store->SetValue(kProtectedAtomic, 203 pref_store->SetValue(kProtectedAtomic,
205 base::MakeUnique<base::StringValue>(kHelloWorld), 204 base::MakeUnique<base::Value>(kHelloWorld),
206 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 205 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
207 pref_store->SetValue(kUnprotectedPref, 206 pref_store->SetValue(kUnprotectedPref,
208 base::MakeUnique<base::StringValue>(kFoobar), 207 base::MakeUnique<base::Value>(kFoobar),
209 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 208 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
210 pref_store->RemoveObserver(&registry_verifier_); 209 pref_store->RemoveObserver(&registry_verifier_);
211 pref_store->CommitPendingWrite(); 210 pref_store->CommitPendingWrite();
212 base::RunLoop().RunUntilIdle(); 211 base::RunLoop().RunUntilIdle();
213 } 212 }
214 213
215 void LoadExistingPrefs() { 214 void LoadExistingPrefs() {
216 DestroyPrefStore(); 215 DestroyPrefStore();
217 pref_store_ = manager_->CreateProfilePrefStore( 216 pref_store_ = manager_->CreateProfilePrefStore(
218 main_message_loop_.task_runner(), 217 main_message_loop_.task_runner(),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 pref_store_->GetValue(kProtectedAtomic, NULL)); 313 pref_store_->GetValue(kProtectedAtomic, NULL));
315 VerifyResetRecorded( 314 VerifyResetRecorded(
316 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); 315 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking);
317 316
318 ExpectValidationObserved(kTrackedAtomic); 317 ExpectValidationObserved(kTrackedAtomic);
319 ExpectValidationObserved(kProtectedAtomic); 318 ExpectValidationObserved(kProtectedAtomic);
320 } 319 }
321 320
322 TEST_F(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { 321 TEST_F(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) {
323 auto master_prefs = base::MakeUnique<base::DictionaryValue>(); 322 auto master_prefs = base::MakeUnique<base::DictionaryValue>();
324 master_prefs->Set(kTrackedAtomic, new base::StringValue(kFoobar)); 323 master_prefs->Set(kTrackedAtomic, new base::Value(kFoobar));
325 master_prefs->Set(kProtectedAtomic, new base::StringValue(kHelloWorld)); 324 master_prefs->Set(kProtectedAtomic, new base::Value(kHelloWorld));
326 EXPECT_TRUE( 325 EXPECT_TRUE(
327 manager_->InitializePrefsFromMasterPrefs(std::move(master_prefs))); 326 manager_->InitializePrefsFromMasterPrefs(std::move(master_prefs)));
328 327
329 LoadExistingPrefs(); 328 LoadExistingPrefs();
330 329
331 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs 330 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs
332 // necessary to authenticate these values. 331 // necessary to authenticate these values.
333 ExpectStringValueEquals(kTrackedAtomic, kFoobar); 332 ExpectStringValueEquals(kTrackedAtomic, kFoobar);
334 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); 333 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld);
335 VerifyResetRecorded(false); 334 VerifyResetRecorded(false);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 475
477 // Accessing the value of the previously protected pref didn't trigger its 476 // Accessing the value of the previously protected pref didn't trigger its
478 // move to the unprotected preferences file, though the loading of the pref 477 // move to the unprotected preferences file, though the loading of the pref
479 // store should still have caused the MAC store to be recalculated. 478 // store should still have caused the MAC store to be recalculated.
480 LoadExistingPrefs(); 479 LoadExistingPrefs();
481 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); 480 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld);
482 481
483 // Trigger the logic that migrates it back to the unprotected preferences 482 // Trigger the logic that migrates it back to the unprotected preferences
484 // file. 483 // file.
485 pref_store_->SetValue(kProtectedAtomic, 484 pref_store_->SetValue(kProtectedAtomic,
486 base::WrapUnique(new base::StringValue(kGoodbyeWorld)), 485 base::WrapUnique(new base::Value(kGoodbyeWorld)),
487 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 486 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
488 LoadExistingPrefs(); 487 LoadExistingPrefs();
489 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); 488 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld);
490 VerifyResetRecorded(false); 489 VerifyResetRecorded(false);
491 } 490 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/chrome_pref_service_unittest.cc ('k') | chrome/browser/prefs/proxy_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698