Index: chrome/browser/prefs/profile_pref_store_manager_unittest.cc |
diff --git a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc |
index 29318a92c96dddda6a7e19d06916ebde914a8a75..10ac6f548eb1ec281f6f2ac19c9c94cea3c48c76 100644 |
--- a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc |
+++ b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc |
@@ -31,6 +31,7 @@ |
#include "components/user_prefs/tracked/mock_validation_delegate.h" |
#include "components/user_prefs/tracked/pref_hash_filter.h" |
#include "components/user_prefs/tracked/pref_names.h" |
+#include "services/preferences/public/cpp/persistent_pref_store_mojo.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace { |
@@ -110,10 +111,10 @@ const char kHelloWorld[] = "HELLOWORLD"; |
const char kGoodbyeWorld[] = "GOODBYEWORLD"; |
const PrefHashFilter::TrackedPreferenceMetadata kConfiguration[] = { |
- {0u, kTrackedAtomic, PrefHashFilter::NO_ENFORCEMENT, |
- PrefHashFilter::TRACKING_STRATEGY_ATOMIC}, |
- {1u, kProtectedAtomic, PrefHashFilter::ENFORCE_ON_LOAD, |
- PrefHashFilter::TRACKING_STRATEGY_ATOMIC}}; |
+ {0u, kTrackedAtomic, PrefHashFilter::EnforcementLevel::NO_ENFORCEMENT, |
+ PrefHashFilter::PrefTrackingStrategy::ATOMIC}, |
+ {1u, kProtectedAtomic, PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
+ PrefHashFilter::PrefTrackingStrategy::ATOMIC}}; |
const size_t kExtraReportingId = 2u; |
const size_t kReportingIdCount = 3u; |
@@ -136,7 +137,7 @@ class ProfilePrefStoreManagerTest : public testing::Test { |
for (const PrefHashFilter::TrackedPreferenceMetadata* it = kConfiguration; |
it != kConfiguration + arraysize(kConfiguration); |
++it) { |
- if (it->strategy == PrefHashFilter::TRACKING_STRATEGY_ATOMIC) { |
+ if (it->strategy == PrefHashFilter::PrefTrackingStrategy::ATOMIC) { |
profile_pref_registry_->RegisterStringPref(it->name, std::string()); |
} else { |
profile_pref_registry_->RegisterDictionaryPref(it->name); |
@@ -149,11 +150,11 @@ class ProfilePrefStoreManagerTest : public testing::Test { |
// SegregatedPrefStore. Only declare it after configured prefs have been |
// registered above for this test as kPreferenceResetTime is already |
// registered in ProfilePrefStoreManager::RegisterProfilePrefs. |
- PrefHashFilter::TrackedPreferenceMetadata pref_reset_time_config = |
- {configuration_.rbegin()->reporting_id + 1, |
- user_prefs::kPreferenceResetTime, |
- PrefHashFilter::ENFORCE_ON_LOAD, |
- PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; |
+ PrefHashFilter::TrackedPreferenceMetadata pref_reset_time_config = { |
+ configuration_.rbegin()->reporting_id + 1, |
+ user_prefs::kPreferenceResetTime, |
+ PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
+ PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
configuration_.push_back(pref_reset_time_config); |
ASSERT_TRUE(profile_dir_.CreateUniqueTempDir()); |
@@ -203,12 +204,17 @@ class ProfilePrefStoreManagerTest : public testing::Test { |
std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> |
mock_validation_delegate = base::MakeUnique<MockValidationDelegate>( |
mock_validation_delegate_record_); |
+ prefs::mojom::PersistentPrefStoreConnectorPtr connector; |
scoped_refptr<PersistentPrefStore> pref_store = |
manager_->CreateProfilePrefStore( |
main_message_loop_.task_runner(), main_message_loop_.task_runner(), |
base::Bind(&ProfilePrefStoreManagerTest::RecordReset, |
base::Unretained(this)), |
- &mock_validation_delegate); |
+ &mock_validation_delegate, &connector); |
+ if (!pref_store) { |
+ ASSERT_TRUE(connector); |
+ pref_store = new prefs::PersistentPrefStoreMojo(std::move(connector)); |
+ } |
InitializePrefStore(pref_store.get()); |
pref_store = NULL; |
base::RunLoop().RunUntilIdle(); |
@@ -253,11 +259,16 @@ class ProfilePrefStoreManagerTest : public testing::Test { |
DestroyPrefStore(); |
std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> |
validation_delegate; |
+ prefs::mojom::PersistentPrefStoreConnectorPtr connector; |
pref_store_ = manager_->CreateProfilePrefStore( |
main_message_loop_.task_runner(), main_message_loop_.task_runner(), |
base::Bind(&ProfilePrefStoreManagerTest::RecordReset, |
base::Unretained(this)), |
- &validation_delegate); |
+ &validation_delegate, &connector); |
+ if (!pref_store_) { |
+ ASSERT_TRUE(connector); |
+ pref_store_ = new prefs::PersistentPrefStoreMojo(std::move(connector)); |
+ } |
pref_store_->AddObserver(®istry_verifier_); |
PrefStoreReadObserver read_observer(pref_store_); |
read_observer.Read(); |
@@ -395,8 +406,9 @@ TEST_F(ProfilePrefStoreManagerTest, UnprotectedToProtected) { |
// Now update the configuration to protect it. |
PrefHashFilter::TrackedPreferenceMetadata new_protected = { |
- kExtraReportingId, kUnprotectedPref, PrefHashFilter::ENFORCE_ON_LOAD, |
- PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; |
+ kExtraReportingId, kUnprotectedPref, |
+ PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
+ PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
configuration_.push_back(new_protected); |
ReloadConfiguration(); |
@@ -428,7 +440,7 @@ TEST_F(ProfilePrefStoreManagerTest, NewPrefWhenFirstProtecting) { |
configuration_.begin(); |
it != configuration_.end(); |
++it) { |
- it->enforcement_level = PrefHashFilter::NO_ENFORCEMENT; |
+ it->enforcement_level = PrefHashFilter::EnforcementLevel::NO_ENFORCEMENT; |
} |
ReloadConfiguration(); |
@@ -446,8 +458,9 @@ TEST_F(ProfilePrefStoreManagerTest, NewPrefWhenFirstProtecting) { |
// Now introduce protection, including the never-before tracked "new_pref". |
configuration_ = original_configuration; |
PrefHashFilter::TrackedPreferenceMetadata new_protected = { |
- kExtraReportingId, kUnprotectedPref, PrefHashFilter::ENFORCE_ON_LOAD, |
- PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; |
+ kExtraReportingId, kUnprotectedPref, |
+ PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
+ PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
configuration_.push_back(new_protected); |
ReloadConfiguration(); |
@@ -468,8 +481,9 @@ TEST_F(ProfilePrefStoreManagerTest, UnprotectedToProtectedWithoutTrust) { |
// Now update the configuration to protect it. |
PrefHashFilter::TrackedPreferenceMetadata new_protected = { |
- kExtraReportingId, kUnprotectedPref, PrefHashFilter::ENFORCE_ON_LOAD, |
- PrefHashFilter::TRACKING_STRATEGY_ATOMIC}; |
+ kExtraReportingId, kUnprotectedPref, |
+ PrefHashFilter::EnforcementLevel::ENFORCE_ON_LOAD, |
+ PrefHashFilter::PrefTrackingStrategy::ATOMIC}; |
configuration_.push_back(new_protected); |
seed_ = "new-seed-to-break-trust"; |
ReloadConfiguration(); |
@@ -501,7 +515,7 @@ TEST_F(ProfilePrefStoreManagerTest, ProtectedToUnprotected) { |
it != configuration_.end(); |
++it) { |
if (it->name == kProtectedAtomic) { |
- it->enforcement_level = PrefHashFilter::NO_ENFORCEMENT; |
+ it->enforcement_level = PrefHashFilter::EnforcementLevel::NO_ENFORCEMENT; |
break; |
} |
} |