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

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

Issue 422453006: Merge 284507 "Invoke the StartSyncFlare for prefs when performin..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 5 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
« no previous file with comments | « chrome/browser/prefs/pref_hash_filter.cc ('k') | chrome/browser/prefs/profile_pref_store_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_hash_filter_unittest.cc
===================================================================
--- chrome/browser/prefs/pref_hash_filter_unittest.cc (revision 285907)
+++ chrome/browser/prefs/pref_hash_filter_unittest.cc (working copy)
@@ -348,7 +348,8 @@
public:
PrefHashFilterTest() : mock_pref_hash_store_(NULL),
pref_store_contents_(new base::DictionaryValue),
- last_filter_on_load_modified_prefs_(false) {}
+ last_filter_on_load_modified_prefs_(false),
+ reset_recorded_(false) {}
virtual void SetUp() OVERRIDE {
// Construct a PrefHashFilter and MockPrefHashStore for the test.
@@ -364,16 +365,21 @@
scoped_ptr<MockPrefHashStore> temp_mock_pref_hash_store(
new MockPrefHashStore);
mock_pref_hash_store_ = temp_mock_pref_hash_store.get();
- pref_hash_filter_.reset(
- new PrefHashFilter(temp_mock_pref_hash_store.PassAs<PrefHashStore>(),
- configuration,
- &mock_validation_delegate_,
- arraysize(kTestTrackedPrefs),
- true));
+ pref_hash_filter_.reset(new PrefHashFilter(
+ temp_mock_pref_hash_store.PassAs<PrefHashStore>(),
+ configuration,
+ base::Bind(&PrefHashFilterTest::RecordReset, base::Unretained(this)),
+ &mock_validation_delegate_,
+ arraysize(kTestTrackedPrefs),
+ true));
}
- bool RecordedReset() {
- return pref_store_contents_->Get(prefs::kPreferenceResetTime, NULL);
+ // Verifies whether a reset was reported by the PrefHashFiler. Also verifies
+ // that kPreferenceResetTime was set (or not) accordingly.
+ void VerifyRecordedReset(bool reset_expected) {
+ EXPECT_EQ(reset_expected, reset_recorded_);
+ EXPECT_EQ(reset_expected,
+ pref_store_contents_->Get(prefs::kPreferenceResetTime, NULL));
}
// Calls FilterOnLoad() on |pref_hash_Filter_|. |pref_store_contents_| is
@@ -404,6 +410,15 @@
EXPECT_EQ(expected_schedule_write, schedule_write);
}
+ void RecordReset() {
+ // As-is |reset_recorded_| is only designed to remember a single reset, make
+ // sure none was previously recorded.
+ EXPECT_FALSE(reset_recorded_);
+ reset_recorded_ = true;
+ }
+
+ bool reset_recorded_;
+
DISALLOW_COPY_AND_ASSIGN(PrefHashFilterTest);
};
@@ -421,7 +436,7 @@
kTestTrackedPrefs[i].name).first);
}
ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
// Delegate saw all paths, and all unchanged.
ASSERT_EQ(arraysize(kTestTrackedPrefs),
@@ -450,7 +465,7 @@
ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_ATOMIC, stored_value.second);
ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
}
TEST_P(PrefHashFilterTest, FilterSplitPrefUpdate) {
@@ -474,7 +489,7 @@
ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_value.second);
ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
}
TEST_P(PrefHashFilterTest, FilterUntrackedPrefUpdate) {
@@ -644,7 +659,7 @@
ASSERT_FALSE(pref_store_contents_->Get(kSplitPref, NULL));
ASSERT_EQ(NULL, stored_split_value.first);
- ASSERT_TRUE(RecordedReset());
+ VerifyRecordedReset(true);
} else {
// Otherwise the values should have remained intact and the hashes should
// have been updated to match them.
@@ -658,7 +673,7 @@
ASSERT_EQ(dict_value, split_value_in_store);
ASSERT_EQ(dict_value, stored_split_value.first);
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
}
}
@@ -771,7 +786,7 @@
ASSERT_TRUE(dict_value->HasKey("d"));
ASSERT_EQ(dict_value, stored_split_value.first);
- ASSERT_TRUE(RecordedReset());
+ VerifyRecordedReset(true);
} else {
// Otherwise the value should have remained intact and the hash should have
// been updated to match it.
@@ -790,7 +805,7 @@
ASSERT_TRUE(dict_value->HasKey("d"));
ASSERT_EQ(dict_value, stored_split_value.first);
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
}
}
@@ -873,7 +888,7 @@
ASSERT_FALSE(pref_store_contents_->Get(kAtomicPref, NULL));
ASSERT_EQ(NULL, stored_atomic_value.first);
- ASSERT_TRUE(RecordedReset());
+ VerifyRecordedReset(true);
} else {
// Otherwise the value should have remained intact and the hash should have
// been updated to match it.
@@ -882,7 +897,7 @@
ASSERT_EQ(list_value, atomic_value_in_store);
ASSERT_EQ(list_value, stored_atomic_value.first);
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
}
}
@@ -942,7 +957,7 @@
ASSERT_EQ(dict_value, split_value_in_store);
ASSERT_EQ(dict_value, stored_split_value.first);
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
}
TEST_P(PrefHashFilterTest, DontResetReportOnly) {
@@ -1005,7 +1020,7 @@
ASSERT_EQ(NULL, mock_pref_hash_store_->stored_value(kAtomicPref).first);
ASSERT_EQ(NULL, mock_pref_hash_store_->stored_value(kAtomicPref2).first);
- ASSERT_TRUE(RecordedReset());
+ VerifyRecordedReset(true);
} else {
const base::Value* value_in_store;
const base::Value* value_in_store2;
@@ -1018,7 +1033,7 @@
ASSERT_EQ(int_value2,
mock_pref_hash_store_->stored_value(kAtomicPref2).first);
- ASSERT_FALSE(RecordedReset());
+ VerifyRecordedReset(false);
}
}
« no previous file with comments | « chrome/browser/prefs/pref_hash_filter.cc ('k') | chrome/browser/prefs/profile_pref_store_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698