Index: chrome/browser/prefs/pref_hash_store_impl_unittest.cc |
diff --git a/chrome/browser/prefs/pref_hash_store_impl_unittest.cc b/chrome/browser/prefs/pref_hash_store_impl_unittest.cc |
index 139e9e05c3e0a89262a4610f6c11c1376f8c2c8e..6a3152d33401b2f5dadc08b0a17b2a2f68d4245b 100644 |
--- a/chrome/browser/prefs/pref_hash_store_impl_unittest.cc |
+++ b/chrome/browser/prefs/pref_hash_store_impl_unittest.cc |
@@ -104,7 +104,7 @@ TEST_F(PrefHashStoreImplTest, AtomicHashStoreAndCheck) { |
{ |
// 32 NULL bytes is the seed that was used to generate the legacy hash. |
PrefHashStoreImpl pref_hash_store( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store.BeginTransaction()); |
@@ -149,11 +149,13 @@ TEST_F(PrefHashStoreImplTest, AtomicHashStoreAndCheck) { |
EXPECT_TRUE(hash_store_data_.GetCommitPerformedAndReset()); |
} |
+ ASSERT_FALSE(CreateHashStoreContents()->GetSuperMac().empty()); |
+ |
{ |
// |pref_hash_store2| should trust its initial hashes dictionary and thus |
// trust new unknown values. |
PrefHashStoreImpl pref_hash_store2( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store2.BeginTransaction()); |
EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE, |
@@ -177,7 +179,7 @@ TEST_F(PrefHashStoreImplTest, AtomicHashStoreAndCheck) { |
// |pref_hash_store3| should no longer trust its initial hashes dictionary |
// and thus shouldn't trust non-NULL unknown values. |
PrefHashStoreImpl pref_hash_store3( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store3.BeginTransaction()); |
EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, |
@@ -195,6 +197,34 @@ TEST_F(PrefHashStoreImplTest, AtomicHashStoreAndCheck) { |
} |
} |
+TEST_F(PrefHashStoreImplTest, SuperMACDisabled) { |
+ base::StringValue string_1("string1"); |
+ base::StringValue string_2("string2"); |
+ |
+ { |
+ // Pass |use_super_mac| => false. |
+ PrefHashStoreImpl pref_hash_store( |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), false); |
+ scoped_ptr<PrefHashStoreTransaction> transaction( |
+ pref_hash_store.BeginTransaction()); |
+ |
+ transaction->StoreHash("path1", &string_2); |
+ EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
+ transaction->CheckValue("path1", &string_2)); |
+ } |
+ |
+ ASSERT_TRUE(CreateHashStoreContents()->GetSuperMac().empty()); |
+ |
+ { |
+ PrefHashStoreImpl pref_hash_store2( |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), false); |
+ scoped_ptr<PrefHashStoreTransaction> transaction( |
+ pref_hash_store2.BeginTransaction()); |
+ EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, |
+ transaction->CheckValue("new_path", &string_1)); |
+ } |
+} |
+ |
TEST_F(PrefHashStoreImplTest, SplitHashStoreAndCheck) { |
base::DictionaryValue dict; |
dict.Set("a", new base::StringValue("to be replaced")); |
@@ -212,7 +242,7 @@ TEST_F(PrefHashStoreImplTest, SplitHashStoreAndCheck) { |
{ |
PrefHashStoreImpl pref_hash_store( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store.BeginTransaction()); |
@@ -288,7 +318,7 @@ TEST_F(PrefHashStoreImplTest, SplitHashStoreAndCheck) { |
// |pref_hash_store2| should trust its initial hashes dictionary and thus |
// trust new unknown values. |
PrefHashStoreImpl pref_hash_store2( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store2.BeginTransaction()); |
EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE, |
@@ -309,7 +339,7 @@ TEST_F(PrefHashStoreImplTest, SplitHashStoreAndCheck) { |
// |pref_hash_store3| should no longer trust its initial hashes dictionary |
// and thus shouldn't trust unknown values. |
PrefHashStoreImpl pref_hash_store3( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store3.BeginTransaction()); |
EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, |
@@ -331,7 +361,7 @@ TEST_F(PrefHashStoreImplTest, EmptyAndNULLSplitDict) { |
{ |
PrefHashStoreImpl pref_hash_store( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store.BeginTransaction()); |
@@ -368,7 +398,7 @@ TEST_F(PrefHashStoreImplTest, EmptyAndNULLSplitDict) { |
// test ensuring that the internal action of clearing some hashes does |
// update the stored hash of hashes). |
PrefHashStoreImpl pref_hash_store2( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store2.BeginTransaction()); |
@@ -399,7 +429,7 @@ TEST_F(PrefHashStoreImplTest, TrustedUnknownSplitValueFromExistingAtomic) { |
{ |
PrefHashStoreImpl pref_hash_store( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store.BeginTransaction()); |
@@ -411,7 +441,7 @@ TEST_F(PrefHashStoreImplTest, TrustedUnknownSplitValueFromExistingAtomic) { |
{ |
// Load a new |pref_hash_store2| in which the hashes dictionary is trusted. |
PrefHashStoreImpl pref_hash_store2( |
- std::string(32, 0), "device_id", CreateHashStoreContents()); |
+ std::string(32, 0), "device_id", CreateHashStoreContents(), true); |
scoped_ptr<PrefHashStoreTransaction> transaction( |
pref_hash_store2.BeginTransaction()); |
std::vector<std::string> invalid_keys; |