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

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

Issue 329093003: Remove unloaded profile hash store initialization, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Combine three CLs. 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
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 }
69 }
70 78
71 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetVersion) {
72 int version = 0;
73 { 79 {
74 PrefServiceHashStoreContents contents("store_id", &local_state_); 80 PrefServiceHashStoreContents other_contents("other_store_id",
75 ASSERT_FALSE(contents.GetVersion(&version)); 81 &local_state_);
76 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar")); 82 other_contents.Reset();
77 ASSERT_FALSE(contents.GetVersion(&version));
78 }
79 {
80 PrefServiceHashStoreContents contents("store_id", &local_state_);
81 ASSERT_FALSE(contents.GetVersion(&version));
82 contents.SetVersion(1);
83 ASSERT_TRUE(contents.GetVersion(&version));
84 ASSERT_EQ(1, version);
85 } 83 }
86 84
87 version = 0; 85 ASSERT_FALSE(local_state_.GetUserPrefValue(prefs::kProfilePreferenceHashes));
88
89 {
90 PrefServiceHashStoreContents contents("store_id", &local_state_);
91 ASSERT_TRUE(contents.GetVersion(&version));
92 ASSERT_EQ(1, version);
93 PrefServiceHashStoreContents other_contents("other_store_id",
94 &local_state_);
95 ASSERT_FALSE(other_contents.GetVersion(&version));
96 }
97 } 86 }
98 87
99 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetContents) { 88 TEST_F(PrefServiceHashStoreContentsTest, GetAndSetContents) {
100 { 89 {
101 PrefServiceHashStoreContents contents("store_id", &local_state_); 90 PrefServiceHashStoreContents contents("store_id", &local_state_);
102 ASSERT_EQ(NULL, contents.GetContents()); 91 ASSERT_EQ(NULL, contents.GetContents());
103 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar")); 92 (*contents.GetMutableContents())->Set("foo", new base::StringValue("bar"));
104 ASSERT_FALSE(contents.GetContents() == NULL); 93 ASSERT_FALSE(contents.GetContents() == NULL);
105 std::string actual_value; 94 std::string actual_value;
106 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
151 140
152 PrefServiceHashStoreContents::ResetAllPrefHashStores(&local_state_); 141 PrefServiceHashStoreContents::ResetAllPrefHashStores(&local_state_);
153 142
154 { 143 {
155 PrefServiceHashStoreContents contents_1("store_id_1", &local_state_); 144 PrefServiceHashStoreContents contents_1("store_id_1", &local_state_);
156 PrefServiceHashStoreContents contents_2("store_id_2", &local_state_); 145 PrefServiceHashStoreContents contents_2("store_id_2", &local_state_);
157 ASSERT_FALSE(contents_1.IsInitialized()); 146 ASSERT_FALSE(contents_1.IsInitialized());
158 ASSERT_FALSE(contents_2.IsInitialized()); 147 ASSERT_FALSE(contents_2.IsInitialized());
159 } 148 }
160 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698