Chromium Code Reviews| 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 ea63a88ee718d0b2e9757ad6ab334af7cb305ede..228cc047cffd9f16f5ece30c3e135bfc173d304a 100644 |
| --- a/chrome/browser/prefs/pref_hash_filter_unittest.cc |
| +++ b/chrome/browser/prefs/pref_hash_filter_unittest.cc |
| @@ -22,6 +22,7 @@ |
| #include "chrome/browser/prefs/mock_validation_delegate.h" |
| #include "chrome/browser/prefs/pref_hash_store.h" |
| #include "chrome/browser/prefs/pref_hash_store_transaction.h" |
| +#include "chrome/browser/prefs/tracked/hash_store_contents.h" |
| #include "chrome/common/pref_names.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -75,9 +76,8 @@ class MockPrefHashStore : public PrefHashStore { |
| typedef std::pair<const void*, PrefHashFilter::PrefTrackingStrategy> |
| ValuePtrStrategyPair; |
| - MockPrefHashStore() : transactions_performed_(0), |
| - transaction_active_(false), |
| - commit_performed_(false) {} |
| + MockPrefHashStore() |
| + : transactions_performed_(0), transaction_active_(false) {} |
| virtual ~MockPrefHashStore() { |
| EXPECT_FALSE(transaction_active_); |
| @@ -98,10 +98,6 @@ class MockPrefHashStore : public PrefHashStore { |
| // Returns the number of transactions that were performed. |
| size_t transactions_performed() { return transactions_performed_; } |
| - // Returns true if this MockPrefHashStore's CommitPendingWrite method was |
| - // called. |
| - bool commit_performed() { return commit_performed_; } |
| - |
| // Returns the number of paths checked. |
| size_t checked_paths_count() const { |
| return checked_values_.size(); |
| @@ -139,8 +135,8 @@ class MockPrefHashStore : public PrefHashStore { |
| } |
| // PrefHashStore implementation. |
| - virtual scoped_ptr<PrefHashStoreTransaction> BeginTransaction() OVERRIDE; |
| - virtual void CommitPendingWrite() OVERRIDE; |
| + virtual scoped_ptr<PrefHashStoreTransaction> BeginTransaction( |
| + scoped_ptr<HashStoreContents> storage) OVERRIDE; |
| private: |
| // A MockPrefHashStoreTransaction is handed to the caller on |
| @@ -169,6 +165,12 @@ class MockPrefHashStore : public PrefHashStore { |
| virtual void StoreSplitHash( |
| const std::string& path, |
| const base::DictionaryValue* split_value) OVERRIDE; |
| + virtual bool HasHash(const std::string& path) const OVERRIDE; |
| + virtual void ImportHash(const std::string& path, |
| + const base::Value* hash) OVERRIDE; |
| + virtual void ClearHash(const std::string& path) OVERRIDE; |
| + virtual bool IsSuperMACValid() const OVERRIDE; |
| + virtual bool StampSuperMac() OVERRIDE; |
| private: |
| MockPrefHashStore* outer_; |
| @@ -205,9 +207,6 @@ class MockPrefHashStore : public PrefHashStore { |
| // active at a time). |
| bool transaction_active_; |
| - // Whether CommitPendingWrite() was called. |
| - bool commit_performed_; |
| - |
| DISALLOW_COPY_AND_ASSIGN(MockPrefHashStore); |
| }; |
| @@ -229,17 +228,13 @@ void MockPrefHashStore::SetInvalidKeysResult( |
| invalid_keys_results_.insert(std::make_pair(path, invalid_keys_result)); |
| } |
| -scoped_ptr<PrefHashStoreTransaction> MockPrefHashStore::BeginTransaction() { |
| +scoped_ptr<PrefHashStoreTransaction> MockPrefHashStore::BeginTransaction( |
| + scoped_ptr<HashStoreContents> storage) { |
| EXPECT_FALSE(transaction_active_); |
| return scoped_ptr<PrefHashStoreTransaction>( |
| new MockPrefHashStoreTransaction(this)); |
| } |
| -void MockPrefHashStore::CommitPendingWrite() { |
| - EXPECT_FALSE(commit_performed_); |
| - commit_performed_ = true; |
| -} |
| - |
| PrefHashStoreTransaction::ValueState MockPrefHashStore::RecordCheckValue( |
| const std::string& path, |
| const base::Value* value, |
| @@ -304,6 +299,33 @@ void MockPrefHashStore::MockPrefHashStoreTransaction::StoreSplitHash( |
| PrefHashFilter::TRACKING_STRATEGY_SPLIT); |
| } |
| +bool MockPrefHashStore::MockPrefHashStoreTransaction::HasHash( |
| + const std::string& path) const { |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +void MockPrefHashStore::MockPrefHashStoreTransaction::ImportHash( |
| + const std::string& path, |
| + const base::Value* hash) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void MockPrefHashStore::MockPrefHashStoreTransaction::ClearHash( |
| + const std::string& path) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +bool MockPrefHashStore::MockPrefHashStoreTransaction::IsSuperMACValid() const { |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +bool MockPrefHashStore::MockPrefHashStoreTransaction::StampSuperMac() { |
| + NOTIMPLEMENTED(); |
|
gab
2014/06/17 22:08:21
IMO these NOTIMPLEMENTED()'s should be ADD_FAILURE
erikwright (departed)
2014/06/18 15:10:45
Done.
|
| + return false; |
| +} |
| + |
| std::vector<PrefHashFilter::TrackedPreferenceMetadata> GetConfiguration( |
| PrefHashFilter::EnforcementLevel max_enforcement_level) { |
| std::vector<PrefHashFilter::TrackedPreferenceMetadata> configuration( |
| @@ -343,7 +365,8 @@ class PrefHashFilterTest |
| new PrefHashFilter(temp_mock_pref_hash_store.PassAs<PrefHashStore>(), |
| configuration, |
| &mock_validation_delegate_, |
| - arraysize(kTestTrackedPrefs))); |
| + arraysize(kTestTrackedPrefs), |
| + true)); |
| } |
| bool RecordedReset() { |
| @@ -396,7 +419,6 @@ TEST_P(PrefHashFilterTest, EmptyAndUnchanged) { |
| } |
| ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed()); |
| ASSERT_FALSE(RecordedReset()); |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| // Delegate saw all paths, and all unchanged. |
| ASSERT_EQ(arraysize(kTestTrackedPrefs), |
| @@ -426,7 +448,6 @@ TEST_P(PrefHashFilterTest, FilterTrackedPrefUpdate) { |
| ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed()); |
| ASSERT_FALSE(RecordedReset()); |
| - EXPECT_TRUE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, FilterSplitPrefUpdate) { |
| @@ -451,7 +472,6 @@ TEST_P(PrefHashFilterTest, FilterSplitPrefUpdate) { |
| ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed()); |
| ASSERT_FALSE(RecordedReset()); |
| - EXPECT_TRUE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, FilterUntrackedPrefUpdate) { |
| @@ -518,7 +538,6 @@ TEST_P(PrefHashFilterTest, MultiplePrefsFilterSerializeData) { |
| mock_pref_hash_store_->stored_value(kSplitPref); |
| ASSERT_EQ(dict_value, stored_value_split.first); |
| ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_value_split.second); |
| - EXPECT_TRUE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, EmptyAndUnknown) { |
| @@ -546,7 +565,6 @@ TEST_P(PrefHashFilterTest, EmptyAndUnknown) { |
| ASSERT_EQ(NULL, stored_split_value.first); |
| ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, |
| stored_split_value.second); |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| // Delegate saw all prefs, two of which had the expected value_state. |
| ASSERT_EQ(arraysize(kTestTrackedPrefs), |
| @@ -639,7 +657,6 @@ TEST_P(PrefHashFilterTest, InitialValueUnknown) { |
| ASSERT_FALSE(RecordedReset()); |
| } |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) { |
| @@ -693,7 +710,6 @@ TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) { |
| ASSERT_EQ(dict_value, stored_split_value.first); |
| ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, |
| stored_split_value.second); |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, InitialValueChanged) { |
| @@ -773,7 +789,6 @@ TEST_P(PrefHashFilterTest, InitialValueChanged) { |
| ASSERT_FALSE(RecordedReset()); |
| } |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, EmptyCleared) { |
| @@ -814,7 +829,6 @@ TEST_P(PrefHashFilterTest, EmptyCleared) { |
| ASSERT_EQ(NULL, stored_split_value.first); |
| ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, |
| stored_split_value.second); |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, InitialValueMigrated) { |
| @@ -867,7 +881,6 @@ TEST_P(PrefHashFilterTest, InitialValueMigrated) { |
| ASSERT_FALSE(RecordedReset()); |
| } |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) { |
| @@ -927,7 +940,6 @@ TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) { |
| ASSERT_EQ(dict_value, stored_split_value.first); |
| ASSERT_FALSE(RecordedReset()); |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| } |
| TEST_P(PrefHashFilterTest, DontResetReportOnly) { |
| @@ -1005,7 +1017,6 @@ TEST_P(PrefHashFilterTest, DontResetReportOnly) { |
| ASSERT_FALSE(RecordedReset()); |
| } |
| - EXPECT_FALSE(mock_pref_hash_store_->commit_performed()); |
| } |
| INSTANTIATE_TEST_CASE_P( |