Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2756)

Unified Diff: chrome/browser/prefs/pref_hash_filter_unittest.cc

Issue 257003007: Introduce a new framework for back-and-forth tracked/protected preferences migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some tests -- more to come Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prefs/pref_hash_filter_unittest.cc
diff --git a/chrome/browser/prefs/pref_hash_filter_unittest.cc b/chrome/browser/prefs/pref_hash_filter_unittest.cc
index 1c7dfc6615262e18be525d9d8d15ba5c326be05c..245dc18558f82b392e8f37c583ae192d01362362 100644
--- a/chrome/browser/prefs/pref_hash_filter_unittest.cc
+++ b/chrome/browser/prefs/pref_hash_filter_unittest.cc
@@ -894,103 +894,6 @@ TEST_P(PrefHashFilterTest, DontResetReportOnly) {
EXPECT_FALSE(mock_pref_hash_store_->commit_performed());
}
-TEST_P(PrefHashFilterTest, MigrateValuesTest) {
- // Migration configuration should only contain the protected preferences.
- std::vector<PrefHashFilter::TrackedPreferenceMetadata> configuration =
- GetConfiguration(GetParam());
- std::vector<PrefHashFilter::TrackedPreferenceMetadata>
- migration_configuration;
-
- for (std::vector<PrefHashFilter::TrackedPreferenceMetadata>::iterator it =
- configuration.begin();
- it != configuration.end();
- ++it) {
- if (it->enforcement_level >= PrefHashFilter::ENFORCE_ON_LOAD)
- migration_configuration.push_back(*it);
- }
-
- // Discards the default created pref_hash_filter_.
- InitializePrefHashFilter(migration_configuration);
-
- scoped_refptr<TestingPrefStore> source(new TestingPrefStore);
- scoped_refptr<TestingPrefStore> destination(new TestingPrefStore);
-
- // If enforcing, should be migrated.
- source->SetString(kAtomicPref, "foobar");
- mock_pref_hash_store_->SetCheckResult(kAtomicPref,
- PrefHashStoreTransaction::UNCHANGED);
-
- // If enforcing, should be discarded due to pre-existing value in
- // |destination|.
- source->SetString(kAtomicPref2, "foobar2");
- mock_pref_hash_store_->SetCheckResult(kAtomicPref2,
- PrefHashStoreTransaction::UNCHANGED);
-
- // If enforcing, should be kept preferentially to value from |source|. If not
- // enforcing, should still be unaffected.
- destination->SetString(kAtomicPref2, "foobar2 preexisting");
- // Should stay in |destination| in both scenarios.
- destination->SetString(kAtomicPref3, "foobar3");
- mock_pref_hash_store_->SetCheckResult(kAtomicPref3,
- PrefHashStoreTransaction::UNCHANGED);
-
- // When enforcing, should be discarded due to MAC mismatch. If not enforcing,
- // stays in |source|.
- source->SetString(kAtomicPref4, "foobar4");
- mock_pref_hash_store_->SetCheckResult(kAtomicPref4,
- PrefHashStoreTransaction::CHANGED);
-
- // Should remain in |source| in both scenarios.
- source->SetString(kReportOnlyPref, "helloworld");
- mock_pref_hash_store_->SetCheckResult(kReportOnlyPref,
- PrefHashStoreTransaction::UNCHANGED);
-
- // Perform the migration.
- pref_hash_filter_->MigrateValues(source, destination);
- ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
-
- if (GetParam() == PrefHashFilter::ENFORCE_ON_LOAD) {
- std::string value;
-
- ASSERT_FALSE(source->GetValue(kAtomicPref, NULL));
- ASSERT_FALSE(source->GetValue(kAtomicPref2, NULL));
- ASSERT_FALSE(source->GetValue(kAtomicPref3, NULL));
- ASSERT_FALSE(source->GetValue(kAtomicPref4, NULL));
- ASSERT_TRUE(source->GetString(kReportOnlyPref, &value));
- ASSERT_EQ("helloworld", value);
-
- ASSERT_TRUE(destination->GetString(kAtomicPref, &value));
- ASSERT_EQ("foobar", value);
- ASSERT_TRUE(destination->GetString(kAtomicPref2, &value));
- ASSERT_EQ("foobar2 preexisting", value);
- ASSERT_TRUE(destination->GetString(kAtomicPref3, &value));
- ASSERT_EQ("foobar3", value);
- ASSERT_FALSE(destination->GetValue(kReportOnlyPref, NULL));
- ASSERT_FALSE(destination->GetValue(kAtomicPref4, NULL));
- } else {
- std::string value;
-
- ASSERT_TRUE(source->GetString(kAtomicPref, &value));
- ASSERT_EQ("foobar", value);
- ASSERT_TRUE(source->GetString(kAtomicPref2, &value));
- ASSERT_EQ("foobar2", value);
- ASSERT_FALSE(source->GetString(kAtomicPref3, &value));
- ASSERT_TRUE(source->GetString(kAtomicPref4, &value));
- ASSERT_EQ("foobar4", value);
- ASSERT_TRUE(source->GetString(kReportOnlyPref, &value));
- ASSERT_EQ("helloworld", value);
-
- ASSERT_FALSE(destination->GetValue(kAtomicPref, NULL));
- ASSERT_TRUE(destination->GetString(kAtomicPref2, &value));
- ASSERT_EQ("foobar2 preexisting", value);
- ASSERT_TRUE(destination->GetString(kAtomicPref3, &value));
- ASSERT_EQ("foobar3", value);
- ASSERT_FALSE(destination->GetValue(kAtomicPref4, NULL));
- ASSERT_FALSE(destination->GetValue(kReportOnlyPref, NULL));
- }
- EXPECT_FALSE(mock_pref_hash_store_->commit_performed());
-}
-
INSTANTIATE_TEST_CASE_P(
PrefHashFilterTestInstance, PrefHashFilterTest,
testing::Values(PrefHashFilter::NO_ENFORCEMENT,

Powered by Google App Engine
This is Rietveld 408576698