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

Side by Side Diff: chrome/browser/sync/sync_prefs_unittest.cc

Issue 10451058: sync: move invalidation version prefs out of SyncPrefs into InvalidatorStorage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 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/sync/sync_prefs.cc ('k') | chrome/browser/sync/test_profile_sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync/sync_prefs.h" 5 #include "chrome/browser/sync/sync_prefs.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/test/base/testing_pref_service.h" 9 #include "chrome/test/base/testing_pref_service.h"
10 #include "sync/syncable/model_type.h" 10 #include "sync/syncable/model_type.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 if (it.Get() == syncable::EXTENSIONS) { 119 if (it.Get() == syncable::EXTENSIONS) {
120 expected_preferred_types.Put(syncable::EXTENSION_SETTINGS); 120 expected_preferred_types.Put(syncable::EXTENSION_SETTINGS);
121 } 121 }
122 sync_prefs.SetPreferredDataTypes(non_passive_types, preferred_types); 122 sync_prefs.SetPreferredDataTypes(non_passive_types, preferred_types);
123 EXPECT_TRUE(expected_preferred_types.Equals( 123 EXPECT_TRUE(expected_preferred_types.Equals(
124 sync_prefs.GetPreferredDataTypes(non_passive_types))); 124 sync_prefs.GetPreferredDataTypes(non_passive_types)));
125 } 125 }
126 } 126 }
127 127
128 TEST_F(SyncPrefsTest, MaxInvalidationVersions) {
129 SyncPrefs sync_prefs(&pref_service_);
130
131 sync_notifier::InvalidationVersionMap expected_max_versions;
132 EXPECT_EQ(expected_max_versions, sync_prefs.GetAllMaxVersions());
133
134 expected_max_versions[syncable::BOOKMARKS] = 2;
135 sync_prefs.SetMaxVersion(syncable::BOOKMARKS, 2);
136 EXPECT_EQ(expected_max_versions, sync_prefs.GetAllMaxVersions());
137
138 expected_max_versions[syncable::PREFERENCES] = 5;
139 sync_prefs.SetMaxVersion(syncable::PREFERENCES, 5);
140 EXPECT_EQ(expected_max_versions, sync_prefs.GetAllMaxVersions());
141
142 expected_max_versions[syncable::APP_NOTIFICATIONS] = 3;
143 sync_prefs.SetMaxVersion(syncable::APP_NOTIFICATIONS, 3);
144 EXPECT_EQ(expected_max_versions, sync_prefs.GetAllMaxVersions());
145
146 expected_max_versions[syncable::APP_NOTIFICATIONS] = 4;
147 sync_prefs.SetMaxVersion(syncable::APP_NOTIFICATIONS, 4);
148 EXPECT_EQ(expected_max_versions, sync_prefs.GetAllMaxVersions());
149 }
150
151 class MockSyncPrefObserver : public SyncPrefObserver { 128 class MockSyncPrefObserver : public SyncPrefObserver {
152 public: 129 public:
153 MOCK_METHOD1(OnSyncManagedPrefChange, void(bool)); 130 MOCK_METHOD1(OnSyncManagedPrefChange, void(bool));
154 }; 131 };
155 132
156 TEST_F(SyncPrefsTest, ObservedPrefs) { 133 TEST_F(SyncPrefsTest, ObservedPrefs) {
157 SyncPrefs sync_prefs(&pref_service_); 134 SyncPrefs sync_prefs(&pref_service_);
158 135
159 StrictMock<MockSyncPrefObserver> mock_sync_pref_observer; 136 StrictMock<MockSyncPrefObserver> mock_sync_pref_observer;
160 InSequence dummy; 137 InSequence dummy;
(...skipping 27 matching lines...) Expand all
188 sync_prefs.GetAcknowledgeSyncedTypesForTest())); 165 sync_prefs.GetAcknowledgeSyncedTypesForTest()));
189 } 166 }
190 } 167 }
191 168
192 TEST_F(SyncPrefsTest, ClearPreferences) { 169 TEST_F(SyncPrefsTest, ClearPreferences) {
193 SyncPrefs sync_prefs(&pref_service_); 170 SyncPrefs sync_prefs(&pref_service_);
194 171
195 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted()); 172 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted());
196 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime()); 173 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime());
197 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty()); 174 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty());
198 EXPECT_TRUE(sync_prefs.GetAllMaxVersions().empty());
199 175
200 sync_prefs.SetSyncSetupCompleted(); 176 sync_prefs.SetSyncSetupCompleted();
201 sync_prefs.SetLastSyncedTime(base::Time::Now()); 177 sync_prefs.SetLastSyncedTime(base::Time::Now());
202 sync_prefs.SetEncryptionBootstrapToken("token"); 178 sync_prefs.SetEncryptionBootstrapToken("token");
203 179
204 EXPECT_TRUE(sync_prefs.HasSyncSetupCompleted()); 180 EXPECT_TRUE(sync_prefs.HasSyncSetupCompleted());
205 EXPECT_NE(base::Time(), sync_prefs.GetLastSyncedTime()); 181 EXPECT_NE(base::Time(), sync_prefs.GetLastSyncedTime());
206 EXPECT_EQ("token", sync_prefs.GetEncryptionBootstrapToken()); 182 EXPECT_EQ("token", sync_prefs.GetEncryptionBootstrapToken());
207 {
208 sync_notifier::InvalidationVersionMap expected_max_versions;
209 expected_max_versions[syncable::APP_NOTIFICATIONS] = 3;
210 sync_prefs.SetMaxVersion(syncable::APP_NOTIFICATIONS, 3);
211 EXPECT_EQ(expected_max_versions, sync_prefs.GetAllMaxVersions());
212 }
213 183
214 sync_prefs.ClearPreferences(); 184 sync_prefs.ClearPreferences();
215 185
216 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted()); 186 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted());
217 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime()); 187 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime());
218 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty()); 188 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty());
219 EXPECT_TRUE(sync_prefs.GetAllMaxVersions().empty());
220 } 189 }
221 190
222 TEST_F(SyncPrefsTest, NullPrefService) { 191 TEST_F(SyncPrefsTest, NullPrefService) {
223 SyncPrefs sync_prefs(NULL); 192 SyncPrefs sync_prefs(NULL);
224 193
225 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted()); 194 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted());
226 EXPECT_FALSE(sync_prefs.IsStartSuppressed()); 195 EXPECT_FALSE(sync_prefs.IsStartSuppressed());
227 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime()); 196 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime());
228 EXPECT_FALSE(sync_prefs.HasKeepEverythingSynced()); 197 EXPECT_FALSE(sync_prefs.HasKeepEverythingSynced());
229 const syncable::ModelTypeSet non_passive_types = GetNonPassiveTypes(); 198 const syncable::ModelTypeSet non_passive_types = GetNonPassiveTypes();
230 EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(non_passive_types).Empty()); 199 EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(non_passive_types).Empty());
231 EXPECT_FALSE(sync_prefs.IsManaged()); 200 EXPECT_FALSE(sync_prefs.IsManaged());
232 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty()); 201 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty());
233 EXPECT_TRUE(sync_prefs.GetAllMaxVersions().empty());
234 } 202 }
235 203
236 } // namespace 204 } // namespace
237 205
238 } // namespace browser_sync 206 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_prefs.cc ('k') | chrome/browser/sync/test_profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698