| 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 c212cfa5781ac76d452143eb03865e489f1871c1..ef6271cc26fa528cb604ccb604d31afba830e725 100644
|
| --- a/chrome/browser/prefs/pref_hash_filter_unittest.cc
|
| +++ b/chrome/browser/prefs/pref_hash_filter_unittest.cc
|
| @@ -17,6 +17,7 @@
|
| #include "base/logging.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/prefs/testing_pref_store.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/prefs/pref_hash_store.h"
|
| #include "chrome/browser/prefs/pref_hash_store_transaction.h"
|
| @@ -844,6 +845,63 @@ TEST_P(PrefHashFilterTest, DontResetReportOnly) {
|
| }
|
| }
|
|
|
| +TEST_P(PrefHashFilterTest, MigrateValuesTest) {
|
| + scoped_refptr<TestingPrefStore> source(new TestingPrefStore);
|
| + scoped_refptr<TestingPrefStore> destination(new TestingPrefStore);
|
| +
|
| + source->SetString(kAtomicPref, "foobar");
|
| + source->SetString(kAtomicPref2, "foobar2");
|
| + source->SetString(kAtomicPref2, "foobar2 preexisting");
|
| + destination->SetString(kAtomicPref3, "foobar3");
|
| + source->SetString(kReportOnlyPref, "helloworld");
|
| +
|
| + mock_pref_hash_store_->SetCheckResult(kAtomicPref,
|
| + PrefHashStoreTransaction::UNCHANGED);
|
| + mock_pref_hash_store_->SetCheckResult(kAtomicPref2,
|
| + PrefHashStoreTransaction::UNCHANGED);
|
| + mock_pref_hash_store_->SetCheckResult(kAtomicPref3,
|
| + PrefHashStoreTransaction::UNCHANGED);
|
| + mock_pref_hash_store_->SetCheckResult(kReportOnlyPref,
|
| + PrefHashStoreTransaction::UNCHANGED);
|
| +
|
| + pref_hash_filter_->MigrateValues(source, destination);
|
| +
|
| + 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_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));
|
| + } 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_TRUE(source->GetString(kAtomicPref3, &value));
|
| + ASSERT_EQ("foobar3", 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_FALSE(destination->GetValue(kAtomicPref3, NULL));
|
| + ASSERT_FALSE(destination->GetValue(kReportOnlyPref, NULL));
|
| + }
|
| +}
|
| +
|
| INSTANTIATE_TEST_CASE_P(
|
| PrefHashFilterTestInstance, PrefHashFilterTest,
|
| testing::Values(PrefHashFilter::NO_ENFORCEMENT,
|
|
|