OLD | NEW |
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 "components/sync_driver/sync_prefs.h" | 5 #include "components/sync_driver/sync_prefs.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_notifier_impl.h" | 9 #include "base/prefs/pref_notifier_impl.h" |
10 #include "base/prefs/pref_value_store.h" | 10 #include "base/prefs/pref_value_store.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 sync_prefs.AddSyncPrefObserver(&mock_sync_pref_observer); | 194 sync_prefs.AddSyncPrefObserver(&mock_sync_pref_observer); |
195 | 195 |
196 sync_prefs.SetManagedForTest(true); | 196 sync_prefs.SetManagedForTest(true); |
197 EXPECT_TRUE(sync_prefs.IsManaged()); | 197 EXPECT_TRUE(sync_prefs.IsManaged()); |
198 sync_prefs.SetManagedForTest(false); | 198 sync_prefs.SetManagedForTest(false); |
199 EXPECT_FALSE(sync_prefs.IsManaged()); | 199 EXPECT_FALSE(sync_prefs.IsManaged()); |
200 | 200 |
201 sync_prefs.RemoveSyncPrefObserver(&mock_sync_pref_observer); | 201 sync_prefs.RemoveSyncPrefObserver(&mock_sync_pref_observer); |
202 } | 202 } |
203 | 203 |
204 TEST_F(SyncPrefsTest, AcknowledgeSyncedTypes) { | |
205 SyncPrefs sync_prefs(&pref_service_); | |
206 | |
207 syncer::ModelTypeSet expected_acknowledge_synced_types = | |
208 sync_prefs.GetAcknowledgeSyncedTypesForTest(); | |
209 for (int i = syncer::EXTENSION_SETTINGS; i < syncer::MODEL_TYPE_COUNT; ++i) { | |
210 const syncer::ModelType type = syncer::ModelTypeFromInt(i); | |
211 syncer::ModelTypeSet acknowledge_synced_types(type); | |
212 expected_acknowledge_synced_types.Put(type); | |
213 sync_prefs.AcknowledgeSyncedTypes(acknowledge_synced_types); | |
214 EXPECT_TRUE(expected_acknowledge_synced_types.Equals( | |
215 sync_prefs.GetAcknowledgeSyncedTypesForTest())); | |
216 } | |
217 } | |
218 | |
219 TEST_F(SyncPrefsTest, ClearPreferences) { | 204 TEST_F(SyncPrefsTest, ClearPreferences) { |
220 SyncPrefs sync_prefs(&pref_service_); | 205 SyncPrefs sync_prefs(&pref_service_); |
221 | 206 |
222 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted()); | 207 EXPECT_FALSE(sync_prefs.HasSyncSetupCompleted()); |
223 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime()); | 208 EXPECT_EQ(base::Time(), sync_prefs.GetLastSyncedTime()); |
224 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty()); | 209 EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty()); |
225 | 210 |
226 sync_prefs.SetSyncSetupCompleted(); | 211 sync_prefs.SetSyncSetupCompleted(); |
227 sync_prefs.SetLastSyncedTime(base::Time::Now()); | 212 sync_prefs.SetLastSyncedTime(base::Time::Now()); |
228 sync_prefs.SetEncryptionBootstrapToken("token"); | 213 sync_prefs.SetEncryptionBootstrapToken("token"); |
(...skipping 18 matching lines...) Expand all Loading... |
247 EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(syncer::UserTypes()) | 232 EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(syncer::UserTypes()) |
248 .Has(syncer::DEVICE_INFO)); | 233 .Has(syncer::DEVICE_INFO)); |
249 sync_prefs.SetKeepEverythingSynced(false); | 234 sync_prefs.SetKeepEverythingSynced(false); |
250 EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(syncer::UserTypes()) | 235 EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(syncer::UserTypes()) |
251 .Has(syncer::DEVICE_INFO)); | 236 .Has(syncer::DEVICE_INFO)); |
252 } | 237 } |
253 | 238 |
254 } // namespace | 239 } // namespace |
255 | 240 |
256 } // namespace sync_driver | 241 } // namespace sync_driver |
OLD | NEW |