| OLD | NEW |
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 user_prefs::kPreferenceResetTime, | 124 user_prefs::kPreferenceResetTime, |
| 125 PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, | 125 PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
| 126 PrefHashFilter::PrefTrackingStrategy::ATOMIC}; | 126 PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
| 127 configuration_.push_back(pref_reset_time_config); | 127 configuration_.push_back(pref_reset_time_config); |
| 128 | 128 |
| 129 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 129 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
| 130 ReloadConfiguration(); | 130 ReloadConfiguration(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void ReloadConfiguration() { | 133 void ReloadConfiguration() { |
| 134 manager_.reset(new ProfilePrefStoreManager( | 134 manager_.reset( |
| 135 profile_dir_.GetPath(), configuration_, kReportingIdCount, seed_, | 135 new ProfilePrefStoreManager(profile_dir_.GetPath(), configuration_, |
| 136 "device_id", &local_state_)); | 136 kReportingIdCount, seed_, "device_id")); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void TearDown() override { DestroyPrefStore(); } | 139 void TearDown() override { DestroyPrefStore(); } |
| 140 | 140 |
| 141 protected: | 141 protected: |
| 142 // Verifies whether a reset was reported via the RecordReset() hook. Also | 142 // Verifies whether a reset was reported via the RecordReset() hook. Also |
| 143 // verifies that GetResetTime() was set (or not) accordingly. | 143 // verifies that GetResetTime() was set (or not) accordingly. |
| 144 void VerifyResetRecorded(bool reset_expected) { | 144 void VerifyResetRecorded(bool reset_expected) { |
| 145 EXPECT_EQ(reset_expected, reset_recorded_); | 145 EXPECT_EQ(reset_expected, reset_recorded_); |
| 146 | 146 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // No validations are expected for platforms that do not support tracking. | 258 // No validations are expected for platforms that do not support tracking. |
| 259 if (!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking) | 259 if (!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking) |
| 260 return; | 260 return; |
| 261 if (!mock_validation_delegate_record_->GetEventForPath(pref_path)) | 261 if (!mock_validation_delegate_record_->GetEventForPath(pref_path)) |
| 262 ADD_FAILURE() << "No validation observed for preference: " << pref_path; | 262 ADD_FAILURE() << "No validation observed for preference: " << pref_path; |
| 263 } | 263 } |
| 264 | 264 |
| 265 base::MessageLoop main_message_loop_; | 265 base::MessageLoop main_message_loop_; |
| 266 std::vector<PrefHashFilter::TrackedPreferenceMetadata> configuration_; | 266 std::vector<PrefHashFilter::TrackedPreferenceMetadata> configuration_; |
| 267 base::ScopedTempDir profile_dir_; | 267 base::ScopedTempDir profile_dir_; |
| 268 TestingPrefServiceSimple local_state_; | |
| 269 scoped_refptr<user_prefs::PrefRegistrySyncable> profile_pref_registry_; | 268 scoped_refptr<user_prefs::PrefRegistrySyncable> profile_pref_registry_; |
| 270 RegistryVerifier registry_verifier_; | 269 RegistryVerifier registry_verifier_; |
| 271 scoped_refptr<MockValidationDelegateRecord> mock_validation_delegate_record_; | 270 scoped_refptr<MockValidationDelegateRecord> mock_validation_delegate_record_; |
| 272 std::unique_ptr<MockValidationDelegate> mock_validation_delegate_; | 271 std::unique_ptr<MockValidationDelegate> mock_validation_delegate_; |
| 273 std::unique_ptr<ProfilePrefStoreManager> manager_; | 272 std::unique_ptr<ProfilePrefStoreManager> manager_; |
| 274 scoped_refptr<PersistentPrefStore> pref_store_; | 273 scoped_refptr<PersistentPrefStore> pref_store_; |
| 275 | 274 |
| 276 std::string seed_; | 275 std::string seed_; |
| 277 | 276 |
| 278 private: | 277 private: |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 487 |
| 489 // Trigger the logic that migrates it back to the unprotected preferences | 488 // Trigger the logic that migrates it back to the unprotected preferences |
| 490 // file. | 489 // file. |
| 491 pref_store_->SetValue(kProtectedAtomic, | 490 pref_store_->SetValue(kProtectedAtomic, |
| 492 base::WrapUnique(new base::Value(kGoodbyeWorld)), | 491 base::WrapUnique(new base::Value(kGoodbyeWorld)), |
| 493 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 492 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 494 LoadExistingPrefs(); | 493 LoadExistingPrefs(); |
| 495 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 494 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
| 496 VerifyResetRecorded(false); | 495 VerifyResetRecorded(false); |
| 497 } | 496 } |
| OLD | NEW |