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

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

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Just rebased Created 3 years, 8 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 pref_store_->GetValue(kProtectedAtomic, NULL)); 458 pref_store_->GetValue(kProtectedAtomic, NULL));
459 VerifyResetRecorded( 459 VerifyResetRecorded(
460 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); 460 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking);
461 461
462 ExpectValidationObserved(kTrackedAtomic); 462 ExpectValidationObserved(kTrackedAtomic);
463 ExpectValidationObserved(kProtectedAtomic); 463 ExpectValidationObserved(kProtectedAtomic);
464 } 464 }
465 465
466 TEST_P(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { 466 TEST_P(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) {
467 auto master_prefs = base::MakeUnique<base::DictionaryValue>(); 467 auto master_prefs = base::MakeUnique<base::DictionaryValue>();
468 master_prefs->Set(kTrackedAtomic, new base::Value(kFoobar)); 468 master_prefs->Set(kTrackedAtomic, base::MakeUnique<base::Value>(kFoobar));
469 master_prefs->Set(kProtectedAtomic, new base::Value(kHelloWorld)); 469 master_prefs->Set(kProtectedAtomic,
470 base::MakeUnique<base::Value>(kHelloWorld));
470 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs( 471 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs(
471 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount, 472 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount,
472 std::move(master_prefs))); 473 std::move(master_prefs)));
473 474
474 LoadExistingPrefs(); 475 LoadExistingPrefs();
475 476
476 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs 477 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs
477 // necessary to authenticate these values. 478 // necessary to authenticate these values.
478 ExpectStringValueEquals(kTrackedAtomic, kFoobar); 479 ExpectStringValueEquals(kTrackedAtomic, kFoobar);
479 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); 480 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 616
616 // Accessing the value of the previously protected pref didn't trigger its 617 // Accessing the value of the previously protected pref didn't trigger its
617 // move to the unprotected preferences file, though the loading of the pref 618 // move to the unprotected preferences file, though the loading of the pref
618 // store should still have caused the MAC store to be recalculated. 619 // store should still have caused the MAC store to be recalculated.
619 LoadExistingPrefs(); 620 LoadExistingPrefs();
620 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); 621 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld);
621 622
622 // Trigger the logic that migrates it back to the unprotected preferences 623 // Trigger the logic that migrates it back to the unprotected preferences
623 // file. 624 // file.
624 pref_store_->SetValue(kProtectedAtomic, 625 pref_store_->SetValue(kProtectedAtomic,
625 base::WrapUnique(new base::Value(kGoodbyeWorld)), 626 base::MakeUnique<base::Value>(kGoodbyeWorld),
626 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); 627 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
627 LoadExistingPrefs(); 628 LoadExistingPrefs();
628 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); 629 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld);
629 VerifyResetRecorded(false); 630 VerifyResetRecorded(false);
630 } 631 }
631 632
632 // The parameter controls whether the user pref store is created within a 633 // The parameter controls whether the user pref store is created within a
633 // service. 634 // service.
634 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest, 635 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest,
635 ProfilePrefStoreManagerTest, 636 ProfilePrefStoreManagerTest,
636 testing::Bool()); 637 testing::Bool());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698