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

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

Issue 324493002: Move preference MACs to the protected preference stores. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment typo. Created 6 years, 6 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/pref_hash_store.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
diff --git a/chrome/browser/prefs/pref_hash_filter_unittest.cc b/chrome/browser/prefs/pref_hash_filter_unittest.cc
index ea63a88ee718d0b2e9757ad6ab334af7cb305ede..3b5e8218f1936d3d7892d8ec9e00e9d076fce572 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,36 @@ void MockPrefHashStore::MockPrefHashStoreTransaction::StoreSplitHash(
PrefHashFilter::TRACKING_STRATEGY_SPLIT);
}
+bool MockPrefHashStore::MockPrefHashStoreTransaction::HasHash(
+ const std::string& path) const {
+ ADD_FAILURE() << "Unexpected call.";
+ return false;
+}
+
+void MockPrefHashStore::MockPrefHashStoreTransaction::ImportHash(
+ const std::string& path,
+ const base::Value* hash) {
+ ADD_FAILURE() << "Unexpected call.";
+}
+
+void MockPrefHashStore::MockPrefHashStoreTransaction::ClearHash(
+ const std::string& path) {
+ ADD_FAILURE() << "Unexpected call.";
+}
+
+bool MockPrefHashStore::MockPrefHashStoreTransaction::IsSuperMACValid() const {
+ // TODO(erikwright): Test that the result of this method is reported to
+ // Settings.HashesDictionaryTrusted.
+ return false;
+}
+
+bool MockPrefHashStore::MockPrefHashStoreTransaction::StampSuperMac() {
+ // TODO(erikwright): Test that, when there are no other changes to the store,
+ // the result of this method determines the value of |prefs_altered| in the
+ // |post_filter_on_load_callback| invocation.
+ return false;
+}
+
std::vector<PrefHashFilter::TrackedPreferenceMetadata> GetConfiguration(
PrefHashFilter::EnforcementLevel max_enforcement_level) {
std::vector<PrefHashFilter::TrackedPreferenceMetadata> configuration(
@@ -343,7 +368,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 +422,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 +451,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 +475,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 +541,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 +568,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 +660,6 @@ TEST_P(PrefHashFilterTest, InitialValueUnknown) {
ASSERT_FALSE(RecordedReset());
}
- EXPECT_FALSE(mock_pref_hash_store_->commit_performed());
}
TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) {
@@ -693,7 +713,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 +792,6 @@ TEST_P(PrefHashFilterTest, InitialValueChanged) {
ASSERT_FALSE(RecordedReset());
}
- EXPECT_FALSE(mock_pref_hash_store_->commit_performed());
}
TEST_P(PrefHashFilterTest, EmptyCleared) {
@@ -814,7 +832,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 +884,6 @@ TEST_P(PrefHashFilterTest, InitialValueMigrated) {
ASSERT_FALSE(RecordedReset());
}
- EXPECT_FALSE(mock_pref_hash_store_->commit_performed());
}
TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) {
@@ -927,7 +943,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 +1020,6 @@ TEST_P(PrefHashFilterTest, DontResetReportOnly) {
ASSERT_FALSE(RecordedReset());
}
- EXPECT_FALSE(mock_pref_hash_store_->commit_performed());
}
INSTANTIATE_TEST_CASE_P(
« no previous file with comments | « chrome/browser/prefs/pref_hash_filter.cc ('k') | chrome/browser/prefs/pref_hash_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698