| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 147 base::PrefServiceFactory pref_service_factory; | 147 PrefServiceFactory pref_service_factory; |
| 148 pref_service_factory.set_user_prefs(pref_store_); | 148 pref_service_factory.set_user_prefs(pref_store_); |
| 149 | 149 |
| 150 scoped_ptr<PrefService> pref_service( | 150 scoped_ptr<PrefService> pref_service( |
| 151 pref_service_factory.Create(profile_pref_registry_.get())); | 151 pref_service_factory.Create(profile_pref_registry_.get())); |
| 152 | 152 |
| 153 EXPECT_EQ( | 153 EXPECT_EQ( |
| 154 reset_expected, | 154 reset_expected, |
| 155 !ProfilePrefStoreManager::GetResetTime(pref_service.get()).is_null()); | 155 !ProfilePrefStoreManager::GetResetTime(pref_service.get()).is_null()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void ClearResetRecorded() { | 158 void ClearResetRecorded() { |
| 159 reset_recorded_ = false; | 159 reset_recorded_ = false; |
| 160 | 160 |
| 161 base::PrefServiceFactory pref_service_factory; | 161 PrefServiceFactory pref_service_factory; |
| 162 pref_service_factory.set_user_prefs(pref_store_); | 162 pref_service_factory.set_user_prefs(pref_store_); |
| 163 | 163 |
| 164 scoped_ptr<PrefService> pref_service( | 164 scoped_ptr<PrefService> pref_service( |
| 165 pref_service_factory.Create(profile_pref_registry_.get())); | 165 pref_service_factory.Create(profile_pref_registry_.get())); |
| 166 | 166 |
| 167 ProfilePrefStoreManager::ClearResetTime(pref_service.get()); | 167 ProfilePrefStoreManager::ClearResetTime(pref_service.get()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void InitializePrefs() { | 170 void InitializePrefs() { |
| 171 // According to the implementation of ProfilePrefStoreManager, this is | 171 // According to the implementation of ProfilePrefStoreManager, this is |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 570 |
| 571 // Trigger the logic that migrates it back to the unprotected preferences | 571 // Trigger the logic that migrates it back to the unprotected preferences |
| 572 // file. | 572 // file. |
| 573 pref_store_->SetValue(kProtectedAtomic, | 573 pref_store_->SetValue(kProtectedAtomic, |
| 574 make_scoped_ptr(new base::StringValue(kGoodbyeWorld)), | 574 make_scoped_ptr(new base::StringValue(kGoodbyeWorld)), |
| 575 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 575 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 576 LoadExistingPrefs(); | 576 LoadExistingPrefs(); |
| 577 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 577 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
| 578 VerifyResetRecorded(false); | 578 VerifyResetRecorded(false); |
| 579 } | 579 } |
| OLD | NEW |