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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 TEST_F(ProfilePrefStoreManagerTest, ResetPrefHashStore) { | 274 TEST_F(ProfilePrefStoreManagerTest, ResetPrefHashStore) { |
275 InitializePrefs(); | 275 InitializePrefs(); |
276 | 276 |
277 manager_->ResetPrefHashStore(); | 277 manager_->ResetPrefHashStore(); |
278 | 278 |
279 LoadExistingPrefs(); | 279 LoadExistingPrefs(); |
280 | 280 |
281 // kTrackedAtomic is loaded as it appears on disk. | 281 // kTrackedAtomic is loaded as it appears on disk. |
282 ExpectStringValueEquals(kTrackedAtomic, kFoobar); | 282 ExpectStringValueEquals(kTrackedAtomic, kFoobar); |
283 // If preference tracking is supported, the tampered value of kProtectedAtomic | 283 // If preference tracking is supported, kProtectedAtomic will be undefined |
284 // will be discarded at load time, leaving this preference undefined. | 284 // because the value was discarded due to loss of the hash store contents. |
285 EXPECT_NE(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, | 285 EXPECT_NE(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, |
286 pref_store_->GetValue(kProtectedAtomic, NULL)); | 286 pref_store_->GetValue(kProtectedAtomic, NULL)); |
287 EXPECT_EQ(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, | 287 EXPECT_EQ(ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking, |
288 ResetRecorded()); | 288 ResetRecorded()); |
289 } | 289 } |
290 | 290 |
291 TEST_F(ProfilePrefStoreManagerTest, ResetAllPrefHashStores) { | 291 TEST_F(ProfilePrefStoreManagerTest, ResetAllPrefHashStores) { |
292 InitializePrefs(); | 292 InitializePrefs(); |
293 | 293 |
294 ProfilePrefStoreManager::ResetAllPrefHashStores(&local_state_); | 294 ProfilePrefStoreManager::ResetAllPrefHashStores(&local_state_); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // values. | 335 // values. |
336 LoadExistingPrefs(); | 336 LoadExistingPrefs(); |
337 | 337 |
338 // These expectations hold whether or not tracking is supported. | 338 // These expectations hold whether or not tracking is supported. |
339 ExpectStringValueEquals(kTrackedAtomic, kFoobar); | 339 ExpectStringValueEquals(kTrackedAtomic, kFoobar); |
340 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 340 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
341 EXPECT_FALSE(ResetRecorded()); | 341 EXPECT_FALSE(ResetRecorded()); |
342 } | 342 } |
343 | 343 |
344 TEST_F(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { | 344 TEST_F(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { |
345 scoped_ptr<base::DictionaryValue> master_prefs( | 345 base::DictionaryValue master_prefs; |
346 new base::DictionaryValue); | 346 master_prefs.Set(kTrackedAtomic, new base::StringValue(kFoobar)); |
347 master_prefs->Set(kTrackedAtomic, new base::StringValue(kFoobar)); | 347 master_prefs.Set(kProtectedAtomic, new base::StringValue(kHelloWorld)); |
348 master_prefs->Set(kProtectedAtomic, new base::StringValue(kHelloWorld)); | 348 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs(master_prefs)); |
349 EXPECT_TRUE( | |
350 manager_->InitializePrefsFromMasterPrefs(*master_prefs)); | |
351 | 349 |
352 LoadExistingPrefs(); | 350 LoadExistingPrefs(); |
353 | 351 |
354 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs | 352 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs |
355 // necessary to authenticate these values. | 353 // necessary to authenticate these values. |
356 ExpectStringValueEquals(kTrackedAtomic, kFoobar); | 354 ExpectStringValueEquals(kTrackedAtomic, kFoobar); |
357 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 355 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
358 EXPECT_FALSE(ResetRecorded()); | 356 EXPECT_FALSE(ResetRecorded()); |
359 } | 357 } |
360 | 358 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 LoadExistingPrefs(); | 456 LoadExistingPrefs(); |
459 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 457 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
460 | 458 |
461 // Trigger the logic that migrates it back to the unprotected preferences | 459 // Trigger the logic that migrates it back to the unprotected preferences |
462 // file. | 460 // file. |
463 pref_store_->SetValue(kProtectedAtomic, new base::StringValue(kGoodbyeWorld)); | 461 pref_store_->SetValue(kProtectedAtomic, new base::StringValue(kGoodbyeWorld)); |
464 LoadExistingPrefs(); | 462 LoadExistingPrefs(); |
465 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 463 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
466 EXPECT_FALSE(ResetRecorded()); | 464 EXPECT_FALSE(ResetRecorded()); |
467 } | 465 } |
OLD | NEW |