| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/pref_hash_store_impl.h" | 5 #include "chrome/browser/prefs/pref_hash_store_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 pref_hash_store.StoreHash("path1", &string_1); | 30 pref_hash_store.StoreHash("path1", &string_1); |
| 31 ASSERT_EQ(PrefHashStore::UNCHANGED, | 31 ASSERT_EQ(PrefHashStore::UNCHANGED, |
| 32 pref_hash_store.CheckValue("path1", &string_1)); | 32 pref_hash_store.CheckValue("path1", &string_1)); |
| 33 ASSERT_EQ(PrefHashStore::CLEARED, pref_hash_store.CheckValue("path1", NULL)); | 33 ASSERT_EQ(PrefHashStore::CLEARED, pref_hash_store.CheckValue("path1", NULL)); |
| 34 pref_hash_store.StoreHash("path1", NULL); | 34 pref_hash_store.StoreHash("path1", NULL); |
| 35 ASSERT_EQ(PrefHashStore::UNCHANGED, | 35 ASSERT_EQ(PrefHashStore::UNCHANGED, |
| 36 pref_hash_store.CheckValue("path1", NULL)); | 36 pref_hash_store.CheckValue("path1", NULL)); |
| 37 ASSERT_EQ(PrefHashStore::CHANGED, | 37 ASSERT_EQ(PrefHashStore::CHANGED, |
| 38 pref_hash_store.CheckValue("path1", &string_2)); | 38 pref_hash_store.CheckValue("path1", &string_2)); |
| 39 | 39 |
| 40 DictionaryValue dict; | 40 base::DictionaryValue dict; |
| 41 dict.Set("a", new StringValue("foo")); | 41 dict.Set("a", new base::StringValue("foo")); |
| 42 dict.Set("d", new StringValue("bad")); | 42 dict.Set("d", new base::StringValue("bad")); |
| 43 dict.Set("b", new StringValue("bar")); | 43 dict.Set("b", new base::StringValue("bar")); |
| 44 dict.Set("c", new StringValue("baz")); | 44 dict.Set("c", new base::StringValue("baz")); |
| 45 | 45 |
| 46 // Manually shove in a legacy hash. | 46 // Manually shove in a legacy hash. |
| 47 DictionaryPrefUpdate update(&local_state, prefs::kProfilePreferenceHashes); | 47 DictionaryPrefUpdate update(&local_state, prefs::kProfilePreferenceHashes); |
| 48 DictionaryValue* child_dictionary = NULL; | 48 base::DictionaryValue* child_dictionary = NULL; |
| 49 ASSERT_TRUE(update->GetDictionary("store_id", &child_dictionary)); | 49 ASSERT_TRUE(update->GetDictionary("store_id", &child_dictionary)); |
| 50 child_dictionary->SetString( | 50 child_dictionary->SetString( |
| 51 "path1", | 51 "path1", |
| 52 "C503FB7C65EEFD5C07185F616A0AA67923C069909933F362022B1F187E73E9A2"); | 52 "C503FB7C65EEFD5C07185F616A0AA67923C069909933F362022B1F187E73E9A2"); |
| 53 | 53 |
| 54 ASSERT_EQ(PrefHashStore::MIGRATED, | 54 ASSERT_EQ(PrefHashStore::MIGRATED, |
| 55 pref_hash_store.CheckValue("path1", &dict)); | 55 pref_hash_store.CheckValue("path1", &dict)); |
| 56 pref_hash_store.StoreHash("path1", &dict); | 56 pref_hash_store.StoreHash("path1", &dict); |
| 57 ASSERT_EQ(PrefHashStore::UNCHANGED, | 57 ASSERT_EQ(PrefHashStore::UNCHANGED, |
| 58 pref_hash_store.CheckValue("path1", &dict)); | 58 pref_hash_store.CheckValue("path1", &dict)); |
| 59 } | 59 } |
| OLD | NEW |