Chromium Code Reviews| Index: components/user_prefs/tracked/pref_hash_store_impl_unittest.cc |
| diff --git a/components/user_prefs/tracked/pref_hash_store_impl_unittest.cc b/components/user_prefs/tracked/pref_hash_store_impl_unittest.cc |
| index 10867e66d4510dc12500d0b526becc70392073be..97ef0c9e5143a2b557151a54217b12afc6b8f515 100644 |
| --- a/components/user_prefs/tracked/pref_hash_store_impl_unittest.cc |
| +++ b/components/user_prefs/tracked/pref_hash_store_impl_unittest.cc |
| @@ -25,6 +25,44 @@ class PrefHashStoreImplTest : public testing::Test { |
| base::DictionaryValue pref_store_contents_; |
| }; |
| +TEST_F(PrefHashStoreImplTest, ComputeMac) { |
| + base::StringValue string_1("string1"); |
| + base::StringValue string_2("string2"); |
| + PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
| + |
| + std::string computed_mac_1 = pref_hash_store.ComputeMac("path1", &string_1); |
| + std::string computed_mac_2 = pref_hash_store.ComputeMac("path1", &string_2); |
| + std::string computed_mac_3 = pref_hash_store.ComputeMac("path2", &string_1); |
| + |
| + // Quick sanity checks here, see pref_hash_calculator_unittest.cc for more |
| + // complete tests. |
|
gab
2016/09/01 21:21:56
Also
EXPECT_EQ(computed_mac_1, pref_hash_store.Co
proberge
2016/09/06 18:43:39
Done.
|
| + EXPECT_NE(computed_mac_1, computed_mac_2); |
| + EXPECT_NE(computed_mac_1, computed_mac_3); |
| + EXPECT_EQ(64, computed_mac_1.size()); |
| +} |
| + |
| +TEST_F(PrefHashStoreImplTest, ComputeSplitMacs) { |
| + base::DictionaryValue dict; |
| + dict.Set("a", new base::StringValue("string1")); |
| + dict.Set("b", new base::StringValue("string2")); |
| + PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
| + |
| + std::unique_ptr<base::DictionaryValue> computed_macs = |
| + pref_hash_store.ComputeSplitMacs("foo.bar", &dict); |
| + |
| + std::string mac_1; |
| + std::string mac_2; |
| + ASSERT_TRUE(computed_macs->GetString("a", &mac_1)); |
| + ASSERT_TRUE(computed_macs->GetString("b", &mac_2)); |
| + |
| + EXPECT_EQ(2, computed_macs->size()); |
| + |
| + base::StringValue string_1("string1"); |
| + base::StringValue string_2("string2"); |
| + EXPECT_EQ(pref_hash_store.ComputeMac("foo.bar.a", &string_1), mac_1); |
| + EXPECT_EQ(pref_hash_store.ComputeMac("foo.bar.b", &string_2), mac_2); |
| +} |
| + |
| TEST_F(PrefHashStoreImplTest, AtomicHashStoreAndCheck) { |
| base::StringValue string_1("string1"); |
| base::StringValue string_2("string2"); |