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 13 matching lines...) Expand all Loading... |
24 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "components/prefs/json_pref_store.h" | 25 #include "components/prefs/json_pref_store.h" |
26 #include "components/prefs/persistent_pref_store.h" | 26 #include "components/prefs/persistent_pref_store.h" |
27 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
28 #include "components/prefs/pref_service_factory.h" | 28 #include "components/prefs/pref_service_factory.h" |
29 #include "components/prefs/pref_store.h" | 29 #include "components/prefs/pref_store.h" |
30 #include "components/prefs/testing_pref_service.h" | 30 #include "components/prefs/testing_pref_service.h" |
31 #include "components/user_prefs/tracked/mock_validation_delegate.h" | 31 #include "components/user_prefs/tracked/mock_validation_delegate.h" |
32 #include "components/user_prefs/tracked/pref_hash_filter.h" | 32 #include "components/user_prefs/tracked/pref_hash_filter.h" |
33 #include "components/user_prefs/tracked/pref_names.h" | 33 #include "components/user_prefs/tracked/pref_names.h" |
| 34 #include "services/preferences/public/cpp/persistent_pref_store_mojo.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 class FirstEqualsPredicate { | 39 class FirstEqualsPredicate { |
39 public: | 40 public: |
40 explicit FirstEqualsPredicate(const std::string& expected) | 41 explicit FirstEqualsPredicate(const std::string& expected) |
41 : expected_(expected) {} | 42 : expected_(expected) {} |
42 bool operator()(const PrefValueMap::Map::value_type& pair) { | 43 bool operator()(const PrefValueMap::Map::value_type& pair) { |
43 return pair.first == expected_; | 44 return pair.first == expected_; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 const char kUnprotectedPref[] = "unprotected_pref"; | 104 const char kUnprotectedPref[] = "unprotected_pref"; |
104 const char kTrackedAtomic[] = "tracked_atomic"; | 105 const char kTrackedAtomic[] = "tracked_atomic"; |
105 const char kProtectedAtomic[] = "protected_atomic"; | 106 const char kProtectedAtomic[] = "protected_atomic"; |
106 | 107 |
107 const char kFoobar[] = "FOOBAR"; | 108 const char kFoobar[] = "FOOBAR"; |
108 const char kBarfoo[] = "BARFOO"; | 109 const char kBarfoo[] = "BARFOO"; |
109 const char kHelloWorld[] = "HELLOWORLD"; | 110 const char kHelloWorld[] = "HELLOWORLD"; |
110 const char kGoodbyeWorld[] = "GOODBYEWORLD"; | 111 const char kGoodbyeWorld[] = "GOODBYEWORLD"; |
111 | 112 |
112 const PrefHashFilter::TrackedPreferenceMetadata kConfiguration[] = { | 113 const PrefHashFilter::TrackedPreferenceMetadata kConfiguration[] = { |
113 {0u, kTrackedAtomic, PrefHashFilter::NO_ENFORCEMENT, | 114 {0u, kTrackedAtomic, PrefHashFilter::EnforcementLevel::NO_ENFORCEMENT, |
114 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}, | 115 PrefHashFilter::PrefTrackingStrategy::ATOMIC}, |
115 {1u, kProtectedAtomic, PrefHashFilter::ENFORCE_ON_LOAD, | 116 {1u, kProtectedAtomic, PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
116 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}}; | 117 PrefHashFilter::PrefTrackingStrategy::ATOMIC}}; |
117 | 118 |
118 const size_t kExtraReportingId = 2u; | 119 const size_t kExtraReportingId = 2u; |
119 const size_t kReportingIdCount = 3u; | 120 const size_t kReportingIdCount = 3u; |
120 | 121 |
121 } // namespace | 122 } // namespace |
122 | 123 |
123 class ProfilePrefStoreManagerTest : public testing::Test { | 124 class ProfilePrefStoreManagerTest : public testing::Test { |
124 public: | 125 public: |
125 ProfilePrefStoreManagerTest() | 126 ProfilePrefStoreManagerTest() |
126 : configuration_(kConfiguration, | 127 : configuration_(kConfiguration, |
127 kConfiguration + arraysize(kConfiguration)), | 128 kConfiguration + arraysize(kConfiguration)), |
128 profile_pref_registry_(new user_prefs::PrefRegistrySyncable), | 129 profile_pref_registry_(new user_prefs::PrefRegistrySyncable), |
129 registry_verifier_(profile_pref_registry_.get()), | 130 registry_verifier_(profile_pref_registry_.get()), |
130 seed_("seed"), | 131 seed_("seed"), |
131 reset_recorded_(false) {} | 132 reset_recorded_(false) {} |
132 | 133 |
133 void SetUp() override { | 134 void SetUp() override { |
134 mock_validation_delegate_record_ = new MockValidationDelegateRecord; | 135 mock_validation_delegate_record_ = new MockValidationDelegateRecord; |
135 ProfilePrefStoreManager::RegisterProfilePrefs(profile_pref_registry_.get()); | 136 ProfilePrefStoreManager::RegisterProfilePrefs(profile_pref_registry_.get()); |
136 for (const PrefHashFilter::TrackedPreferenceMetadata* it = kConfiguration; | 137 for (const PrefHashFilter::TrackedPreferenceMetadata* it = kConfiguration; |
137 it != kConfiguration + arraysize(kConfiguration); | 138 it != kConfiguration + arraysize(kConfiguration); |
138 ++it) { | 139 ++it) { |
139 if (it->strategy == PrefHashFilter::TRACKING_STRATEGY_ATOMIC) { | 140 if (it->strategy == PrefHashFilter::PrefTrackingStrategy::ATOMIC) { |
140 profile_pref_registry_->RegisterStringPref(it->name, std::string()); | 141 profile_pref_registry_->RegisterStringPref(it->name, std::string()); |
141 } else { | 142 } else { |
142 profile_pref_registry_->RegisterDictionaryPref(it->name); | 143 profile_pref_registry_->RegisterDictionaryPref(it->name); |
143 } | 144 } |
144 } | 145 } |
145 profile_pref_registry_->RegisterStringPref(kUnprotectedPref, std::string()); | 146 profile_pref_registry_->RegisterStringPref(kUnprotectedPref, std::string()); |
146 | 147 |
147 // As in chrome_pref_service_factory.cc, kPreferencesResetTime needs to be | 148 // As in chrome_pref_service_factory.cc, kPreferencesResetTime needs to be |
148 // declared as protected in order to be read from the proper store by the | 149 // declared as protected in order to be read from the proper store by the |
149 // SegregatedPrefStore. Only declare it after configured prefs have been | 150 // SegregatedPrefStore. Only declare it after configured prefs have been |
150 // registered above for this test as kPreferenceResetTime is already | 151 // registered above for this test as kPreferenceResetTime is already |
151 // registered in ProfilePrefStoreManager::RegisterProfilePrefs. | 152 // registered in ProfilePrefStoreManager::RegisterProfilePrefs. |
152 PrefHashFilter::TrackedPreferenceMetadata pref_reset_time_config = | 153 PrefHashFilter::TrackedPreferenceMetadata pref_reset_time_config = { |
153 {configuration_.rbegin()->reporting_id + 1, | 154 configuration_.rbegin()->reporting_id + 1, |
154 user_prefs::kPreferenceResetTime, | 155 user_prefs::kPreferenceResetTime, |
155 PrefHashFilter::ENFORCE_ON_LOAD, | 156 PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
156 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; | 157 PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
157 configuration_.push_back(pref_reset_time_config); | 158 configuration_.push_back(pref_reset_time_config); |
158 | 159 |
159 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); | 160 ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
160 ReloadConfiguration(); | 161 ReloadConfiguration(); |
161 } | 162 } |
162 | 163 |
163 void ReloadConfiguration() { | 164 void ReloadConfiguration() { |
164 manager_.reset(new ProfilePrefStoreManager( | 165 manager_.reset(new ProfilePrefStoreManager( |
165 profile_dir_.GetPath(), configuration_, kReportingIdCount, seed_, | 166 profile_dir_.GetPath(), configuration_, kReportingIdCount, seed_, |
166 "device_id", &local_state_)); | 167 "device_id", &local_state_)); |
(...skipping 29 matching lines...) Expand all Loading... |
196 | 197 |
197 ProfilePrefStoreManager::ClearResetTime(pref_service.get()); | 198 ProfilePrefStoreManager::ClearResetTime(pref_service.get()); |
198 } | 199 } |
199 | 200 |
200 void InitializePrefs() { | 201 void InitializePrefs() { |
201 // According to the implementation of ProfilePrefStoreManager, this is | 202 // According to the implementation of ProfilePrefStoreManager, this is |
202 // actually a SegregatedPrefStore backed by two underlying pref stores. | 203 // actually a SegregatedPrefStore backed by two underlying pref stores. |
203 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> | 204 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> |
204 mock_validation_delegate = base::MakeUnique<MockValidationDelegate>( | 205 mock_validation_delegate = base::MakeUnique<MockValidationDelegate>( |
205 mock_validation_delegate_record_); | 206 mock_validation_delegate_record_); |
| 207 prefs::mojom::PersistentPrefStoreConnectorPtr connector; |
206 scoped_refptr<PersistentPrefStore> pref_store = | 208 scoped_refptr<PersistentPrefStore> pref_store = |
207 manager_->CreateProfilePrefStore( | 209 manager_->CreateProfilePrefStore( |
208 main_message_loop_.task_runner(), main_message_loop_.task_runner(), | 210 main_message_loop_.task_runner(), main_message_loop_.task_runner(), |
209 base::Bind(&ProfilePrefStoreManagerTest::RecordReset, | 211 base::Bind(&ProfilePrefStoreManagerTest::RecordReset, |
210 base::Unretained(this)), | 212 base::Unretained(this)), |
211 &mock_validation_delegate); | 213 &mock_validation_delegate, &connector); |
| 214 if (!pref_store) { |
| 215 ASSERT_TRUE(connector); |
| 216 pref_store = new prefs::PersistentPrefStoreMojo(std::move(connector)); |
| 217 } |
212 InitializePrefStore(pref_store.get()); | 218 InitializePrefStore(pref_store.get()); |
213 pref_store = NULL; | 219 pref_store = NULL; |
214 base::RunLoop().RunUntilIdle(); | 220 base::RunLoop().RunUntilIdle(); |
215 } | 221 } |
216 | 222 |
217 void DestroyPrefStore() { | 223 void DestroyPrefStore() { |
218 if (pref_store_.get()) { | 224 if (pref_store_.get()) { |
219 ClearResetRecorded(); | 225 ClearResetRecorded(); |
220 // Force everything to be written to disk, triggering the PrefHashFilter | 226 // Force everything to be written to disk, triggering the PrefHashFilter |
221 // while our RegistryVerifier is watching. | 227 // while our RegistryVerifier is watching. |
(...skipping 24 matching lines...) Expand all Loading... |
246 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 252 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
247 pref_store->RemoveObserver(®istry_verifier_); | 253 pref_store->RemoveObserver(®istry_verifier_); |
248 pref_store->CommitPendingWrite(); | 254 pref_store->CommitPendingWrite(); |
249 base::RunLoop().RunUntilIdle(); | 255 base::RunLoop().RunUntilIdle(); |
250 } | 256 } |
251 | 257 |
252 void LoadExistingPrefs() { | 258 void LoadExistingPrefs() { |
253 DestroyPrefStore(); | 259 DestroyPrefStore(); |
254 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> | 260 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> |
255 validation_delegate; | 261 validation_delegate; |
| 262 prefs::mojom::PersistentPrefStoreConnectorPtr connector; |
256 pref_store_ = manager_->CreateProfilePrefStore( | 263 pref_store_ = manager_->CreateProfilePrefStore( |
257 main_message_loop_.task_runner(), main_message_loop_.task_runner(), | 264 main_message_loop_.task_runner(), main_message_loop_.task_runner(), |
258 base::Bind(&ProfilePrefStoreManagerTest::RecordReset, | 265 base::Bind(&ProfilePrefStoreManagerTest::RecordReset, |
259 base::Unretained(this)), | 266 base::Unretained(this)), |
260 &validation_delegate); | 267 &validation_delegate, &connector); |
| 268 if (!pref_store_) { |
| 269 ASSERT_TRUE(connector); |
| 270 pref_store_ = new prefs::PersistentPrefStoreMojo(std::move(connector)); |
| 271 } |
261 pref_store_->AddObserver(®istry_verifier_); | 272 pref_store_->AddObserver(®istry_verifier_); |
262 PrefStoreReadObserver read_observer(pref_store_); | 273 PrefStoreReadObserver read_observer(pref_store_); |
263 read_observer.Read(); | 274 read_observer.Read(); |
264 } | 275 } |
265 | 276 |
266 void ReplaceStringInPrefs(const std::string& find, | 277 void ReplaceStringInPrefs(const std::string& find, |
267 const std::string& replace) { | 278 const std::string& replace) { |
268 base::FileEnumerator file_enum(profile_dir_.GetPath(), true, | 279 base::FileEnumerator file_enum(profile_dir_.GetPath(), true, |
269 base::FileEnumerator::FILES); | 280 base::FileEnumerator::FILES); |
270 | 281 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 DestroyPrefStore(); | 399 DestroyPrefStore(); |
389 | 400 |
390 ReplaceStringInPrefs(kFoobar, kBarfoo); | 401 ReplaceStringInPrefs(kFoobar, kBarfoo); |
391 | 402 |
392 // It's unprotected, so we can load the modified value. | 403 // It's unprotected, so we can load the modified value. |
393 LoadExistingPrefs(); | 404 LoadExistingPrefs(); |
394 ExpectStringValueEquals(kUnprotectedPref, kBarfoo); | 405 ExpectStringValueEquals(kUnprotectedPref, kBarfoo); |
395 | 406 |
396 // Now update the configuration to protect it. | 407 // Now update the configuration to protect it. |
397 PrefHashFilter::TrackedPreferenceMetadata new_protected = { | 408 PrefHashFilter::TrackedPreferenceMetadata new_protected = { |
398 kExtraReportingId, kUnprotectedPref, PrefHashFilter::ENFORCE_ON_LOAD, | 409 kExtraReportingId, kUnprotectedPref, |
399 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; | 410 PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
| 411 PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
400 configuration_.push_back(new_protected); | 412 configuration_.push_back(new_protected); |
401 ReloadConfiguration(); | 413 ReloadConfiguration(); |
402 | 414 |
403 // And try loading with the new configuration. | 415 // And try loading with the new configuration. |
404 LoadExistingPrefs(); | 416 LoadExistingPrefs(); |
405 | 417 |
406 // Since there was a valid super MAC we were able to extend the existing trust | 418 // Since there was a valid super MAC we were able to extend the existing trust |
407 // to the newly protected preference. | 419 // to the newly protected preference. |
408 ExpectStringValueEquals(kUnprotectedPref, kBarfoo); | 420 ExpectStringValueEquals(kUnprotectedPref, kBarfoo); |
409 VerifyResetRecorded(false); | 421 VerifyResetRecorded(false); |
(...skipping 11 matching lines...) Expand all Loading... |
421 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); | 433 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); |
422 } | 434 } |
423 | 435 |
424 TEST_F(ProfilePrefStoreManagerTest, NewPrefWhenFirstProtecting) { | 436 TEST_F(ProfilePrefStoreManagerTest, NewPrefWhenFirstProtecting) { |
425 std::vector<PrefHashFilter::TrackedPreferenceMetadata> | 437 std::vector<PrefHashFilter::TrackedPreferenceMetadata> |
426 original_configuration = configuration_; | 438 original_configuration = configuration_; |
427 for (std::vector<PrefHashFilter::TrackedPreferenceMetadata>::iterator it = | 439 for (std::vector<PrefHashFilter::TrackedPreferenceMetadata>::iterator it = |
428 configuration_.begin(); | 440 configuration_.begin(); |
429 it != configuration_.end(); | 441 it != configuration_.end(); |
430 ++it) { | 442 ++it) { |
431 it->enforcement_level = PrefHashFilter::NO_ENFORCEMENT; | 443 it->enforcement_level = PrefHashFilter::EnforcementLevel::NO_ENFORCEMENT; |
432 } | 444 } |
433 ReloadConfiguration(); | 445 ReloadConfiguration(); |
434 | 446 |
435 InitializePrefs(); | 447 InitializePrefs(); |
436 | 448 |
437 ExpectValidationObserved(kTrackedAtomic); | 449 ExpectValidationObserved(kTrackedAtomic); |
438 ExpectValidationObserved(kProtectedAtomic); | 450 ExpectValidationObserved(kProtectedAtomic); |
439 | 451 |
440 LoadExistingPrefs(); | 452 LoadExistingPrefs(); |
441 ExpectStringValueEquals(kUnprotectedPref, kFoobar); | 453 ExpectStringValueEquals(kUnprotectedPref, kFoobar); |
442 | 454 |
443 // Ensure everything is written out to disk. | 455 // Ensure everything is written out to disk. |
444 DestroyPrefStore(); | 456 DestroyPrefStore(); |
445 | 457 |
446 // Now introduce protection, including the never-before tracked "new_pref". | 458 // Now introduce protection, including the never-before tracked "new_pref". |
447 configuration_ = original_configuration; | 459 configuration_ = original_configuration; |
448 PrefHashFilter::TrackedPreferenceMetadata new_protected = { | 460 PrefHashFilter::TrackedPreferenceMetadata new_protected = { |
449 kExtraReportingId, kUnprotectedPref, PrefHashFilter::ENFORCE_ON_LOAD, | 461 kExtraReportingId, kUnprotectedPref, |
450 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; | 462 PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
| 463 PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
451 configuration_.push_back(new_protected); | 464 configuration_.push_back(new_protected); |
452 ReloadConfiguration(); | 465 ReloadConfiguration(); |
453 | 466 |
454 // And try loading with the new configuration. | 467 // And try loading with the new configuration. |
455 LoadExistingPrefs(); | 468 LoadExistingPrefs(); |
456 | 469 |
457 // Since there was a valid super MAC we were able to extend the existing trust | 470 // Since there was a valid super MAC we were able to extend the existing trust |
458 // to the newly tracked & protected preference. | 471 // to the newly tracked & protected preference. |
459 ExpectStringValueEquals(kUnprotectedPref, kFoobar); | 472 ExpectStringValueEquals(kUnprotectedPref, kFoobar); |
460 VerifyResetRecorded(false); | 473 VerifyResetRecorded(false); |
461 } | 474 } |
462 | 475 |
463 TEST_F(ProfilePrefStoreManagerTest, UnprotectedToProtectedWithoutTrust) { | 476 TEST_F(ProfilePrefStoreManagerTest, UnprotectedToProtectedWithoutTrust) { |
464 InitializePrefs(); | 477 InitializePrefs(); |
465 | 478 |
466 ExpectValidationObserved(kTrackedAtomic); | 479 ExpectValidationObserved(kTrackedAtomic); |
467 ExpectValidationObserved(kProtectedAtomic); | 480 ExpectValidationObserved(kProtectedAtomic); |
468 | 481 |
469 // Now update the configuration to protect it. | 482 // Now update the configuration to protect it. |
470 PrefHashFilter::TrackedPreferenceMetadata new_protected = { | 483 PrefHashFilter::TrackedPreferenceMetadata new_protected = { |
471 kExtraReportingId, kUnprotectedPref, PrefHashFilter::ENFORCE_ON_LOAD, | 484 kExtraReportingId, kUnprotectedPref, |
472 PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; | 485 PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
| 486 PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
473 configuration_.push_back(new_protected); | 487 configuration_.push_back(new_protected); |
474 seed_ = "new-seed-to-break-trust"; | 488 seed_ = "new-seed-to-break-trust"; |
475 ReloadConfiguration(); | 489 ReloadConfiguration(); |
476 | 490 |
477 // And try loading with the new configuration. | 491 // And try loading with the new configuration. |
478 LoadExistingPrefs(); | 492 LoadExistingPrefs(); |
479 | 493 |
480 // If preference tracking is supported, kUnprotectedPref will have been | 494 // If preference tracking is supported, kUnprotectedPref will have been |
481 // discarded because new values are not accepted without a valid super MAC. | 495 // discarded because new values are not accepted without a valid super MAC. |
482 EXPECT_NE(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, | 496 EXPECT_NE(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, |
(...skipping 11 matching lines...) Expand all Loading... |
494 ExpectValidationObserved(kProtectedAtomic); | 508 ExpectValidationObserved(kProtectedAtomic); |
495 | 509 |
496 DestroyPrefStore(); | 510 DestroyPrefStore(); |
497 | 511 |
498 // Unconfigure protection for kProtectedAtomic | 512 // Unconfigure protection for kProtectedAtomic |
499 for (std::vector<PrefHashFilter::TrackedPreferenceMetadata>::iterator it = | 513 for (std::vector<PrefHashFilter::TrackedPreferenceMetadata>::iterator it = |
500 configuration_.begin(); | 514 configuration_.begin(); |
501 it != configuration_.end(); | 515 it != configuration_.end(); |
502 ++it) { | 516 ++it) { |
503 if (it->name == kProtectedAtomic) { | 517 if (it->name == kProtectedAtomic) { |
504 it->enforcement_level = PrefHashFilter::NO_ENFORCEMENT; | 518 it->enforcement_level = PrefHashFilter::EnforcementLevel::NO_ENFORCEMENT; |
505 break; | 519 break; |
506 } | 520 } |
507 } | 521 } |
508 | 522 |
509 seed_ = "new-seed-to-break-trust"; | 523 seed_ = "new-seed-to-break-trust"; |
510 ReloadConfiguration(); | 524 ReloadConfiguration(); |
511 LoadExistingPrefs(); | 525 LoadExistingPrefs(); |
512 | 526 |
513 // Verify that the value was not reset. | 527 // Verify that the value was not reset. |
514 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 528 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
515 VerifyResetRecorded(false); | 529 VerifyResetRecorded(false); |
516 | 530 |
517 // Accessing the value of the previously protected pref didn't trigger its | 531 // Accessing the value of the previously protected pref didn't trigger its |
518 // move to the unprotected preferences file, though the loading of the pref | 532 // move to the unprotected preferences file, though the loading of the pref |
519 // store should still have caused the MAC store to be recalculated. | 533 // store should still have caused the MAC store to be recalculated. |
520 LoadExistingPrefs(); | 534 LoadExistingPrefs(); |
521 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 535 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
522 | 536 |
523 // Trigger the logic that migrates it back to the unprotected preferences | 537 // Trigger the logic that migrates it back to the unprotected preferences |
524 // file. | 538 // file. |
525 pref_store_->SetValue(kProtectedAtomic, | 539 pref_store_->SetValue(kProtectedAtomic, |
526 base::WrapUnique(new base::StringValue(kGoodbyeWorld)), | 540 base::WrapUnique(new base::StringValue(kGoodbyeWorld)), |
527 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 541 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
528 LoadExistingPrefs(); | 542 LoadExistingPrefs(); |
529 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 543 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
530 VerifyResetRecorded(false); | 544 VerifyResetRecorded(false); |
531 } | 545 } |
OLD | NEW |