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

Side by Side Diff: chrome/browser/prefs/tracked/pref_service_hash_store_contents_unittest.cc

Issue 326403003: Remove all traces of pref hash stores after last store reset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/tracked/pref_service_hash_store_contents.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/tracked/pref_service_hash_store_contents.h" 5 #include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.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/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/pref_names.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 class PrefServiceHashStoreContentsTest : public testing::Test { 15 class PrefServiceHashStoreContentsTest : public testing::Test {
15 public: 16 public:
16 virtual void SetUp() OVERRIDE { 17 virtual void SetUp() OVERRIDE {
17 PrefServiceHashStoreContents::RegisterPrefs(local_state_.registry()); 18 PrefServiceHashStoreContents::RegisterPrefs(local_state_.registry());
18 } 19 }
19 20
20 protected: 21 protected:
21 TestingPrefServiceSimple local_state_; 22 TestingPrefServiceSimple local_state_;
(...skipping 14 matching lines...) Expand all
36 { 37 {
37 PrefServiceHashStoreContents contents("store_id", &local_state_); 38 PrefServiceHashStoreContents contents("store_id", &local_state_);
38 ASSERT_TRUE(contents.IsInitialized()); 39 ASSERT_TRUE(contents.IsInitialized());
39 PrefServiceHashStoreContents other_contents("other_store_id", 40 PrefServiceHashStoreContents other_contents("other_store_id",
40 &local_state_); 41 &local_state_);
41 ASSERT_FALSE(other_contents.IsInitialized()); 42 ASSERT_FALSE(other_contents.IsInitialized());
42 } 43 }
43 } 44 }
44 45
45 TEST_F(PrefServiceHashStoreContentsTest, Reset) { 46 TEST_F(PrefServiceHashStoreContentsTest, Reset) {
47 ASSERT_FALSE(local_state_.GetUserPrefValue(prefs::kProfilePreferenceHashes));
48
46 { 49 {
47 PrefServiceHashStoreContents contents("store_id", &local_state_); 50 PrefServiceHashStoreContents contents("store_id", &local_state_);
48 ASSERT_FALSE(contents.IsInitialized()); 51 ASSERT_FALSE(contents.IsInitialized());
49 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar")); 52 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar"));
50 ASSERT_TRUE(contents.IsInitialized()); 53 ASSERT_TRUE(contents.IsInitialized());
51 PrefServiceHashStoreContents other_contents("other_store_id", 54 PrefServiceHashStoreContents other_contents("other_store_id",
52 &local_state_); 55 &local_state_);
53 (*other_contents.GetMutableContents()) 56 (*other_contents.GetMutableContents())
54 ->Set("foo", new base::StringValue("bar")); 57 ->Set("foo", new base::StringValue("bar"));
55 } 58 }
59
60 ASSERT_TRUE(local_state_.GetUserPrefValue(prefs::kProfilePreferenceHashes));
61
56 { 62 {
57 PrefServiceHashStoreContents contents("store_id", &local_state_); 63 PrefServiceHashStoreContents contents("store_id", &local_state_);
58 ASSERT_TRUE(contents.IsInitialized()); 64 ASSERT_TRUE(contents.IsInitialized());
59 contents.Reset(); 65 contents.Reset();
60 ASSERT_FALSE(contents.IsInitialized()); 66 ASSERT_FALSE(contents.IsInitialized());
61 } 67 }
68
69 ASSERT_TRUE(local_state_.GetUserPrefValue(prefs::kProfilePreferenceHashes));
70
62 { 71 {
63 PrefServiceHashStoreContents contents("store_id", &local_state_); 72 PrefServiceHashStoreContents contents("store_id", &local_state_);
64 ASSERT_FALSE(contents.IsInitialized()); 73 ASSERT_FALSE(contents.IsInitialized());
65 PrefServiceHashStoreContents other_contents("other_store_id", 74 PrefServiceHashStoreContents other_contents("other_store_id",
66 &local_state_); 75 &local_state_);
67 ASSERT_TRUE(other_contents.IsInitialized()); 76 ASSERT_TRUE(other_contents.IsInitialized());
68 } 77 }
78
79 {
80 PrefServiceHashStoreContents other_contents("other_store_id",
81 &local_state_);
82 other_contents.Reset();
83 }
84
85 ASSERT_FALSE(local_state_.GetUserPrefValue(prefs::kProfilePreferenceHashes));
69 } 86 }
70 87
71 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetContents) { 88 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetContents) {
72 { 89 {
73 PrefServiceHashStoreContents contents("store_id", &local_state_); 90 PrefServiceHashStoreContents contents("store_id", &local_state_);
74 ASSERT_EQ(NULL, contents.GetContents()); 91 ASSERT_EQ(NULL, contents.GetContents());
75 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar")); 92 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar"));
76 ASSERT_FALSE(contents.GetContents() == NULL); 93 ASSERT_FALSE(contents.GetContents() == NULL);
77 std::string actual_value; 94 std::string actual_value;
78 ASSERT_TRUE(contents.GetContents()->GetString("foo", &actual_value)); 95 ASSERT_TRUE(contents.GetContents()->GetString("foo", &actual_value));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 140
124 PrefServiceHashStoreContents::ResetAllPrefHashStores(&local_state_); 141 PrefServiceHashStoreContents::ResetAllPrefHashStores(&local_state_);
125 142
126 { 143 {
127 PrefServiceHashStoreContents contents_1("store_id_1", &local_state_); 144 PrefServiceHashStoreContents contents_1("store_id_1", &local_state_);
128 PrefServiceHashStoreContents contents_2("store_id_2", &local_state_); 145 PrefServiceHashStoreContents contents_2("store_id_2", &local_state_);
129 ASSERT_FALSE(contents_1.IsInitialized()); 146 ASSERT_FALSE(contents_1.IsInitialized());
130 ASSERT_FALSE(contents_2.IsInitialized()); 147 ASSERT_FALSE(contents_2.IsInitialized());
131 } 148 }
132 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/tracked/pref_service_hash_store_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698