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/browser_sync/browser/profile_sync_service.h" | 5 #include "components/browser_sync/browser/profile_sync_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 new base::FundamentalValue(false)); | 408 new base::FundamentalValue(false)); |
409 IssueTestTokens(); | 409 IssueTestTokens(); |
410 CreateService(ProfileSyncService::AUTO_START); | 410 CreateService(ProfileSyncService::AUTO_START); |
411 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); | 411 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); |
412 ExpectSyncBackendHostCreation(1); | 412 ExpectSyncBackendHostCreation(1); |
413 InitializeForNthSync(); | 413 InitializeForNthSync(); |
414 EXPECT_FALSE(service()->IsManaged()); | 414 EXPECT_FALSE(service()->IsManaged()); |
415 EXPECT_TRUE(service()->IsSyncActive()); | 415 EXPECT_TRUE(service()->IsSyncActive()); |
416 } | 416 } |
417 | 417 |
| 418 // Verify that an initialization where first setup is not complete does not |
| 419 // purge preferences and/or the directory. |
| 420 TEST_F(ProfileSyncServiceTest, NeedsConfirmation) { |
| 421 prefs()->SetManagedPref(sync_driver::prefs::kSyncManaged, |
| 422 new base::FundamentalValue(false)); |
| 423 IssueTestTokens(); |
| 424 CreateService(ProfileSyncService::MANUAL_START); |
| 425 ExpectSyncBackendHostCreation(1); |
| 426 sync_driver::SyncPrefs sync_prefs(prefs()); |
| 427 base::Time now = base::Time::Now(); |
| 428 sync_prefs.SetLastSyncedTime(now); |
| 429 sync_prefs.SetKeepEverythingSynced(true); |
| 430 service()->Initialize(); |
| 431 EXPECT_FALSE(service()->IsSyncActive()); |
| 432 |
| 433 // The last sync time shouldn't be cleared. |
| 434 // TODO(zea): figure out a way to check that the directory itself wasn't |
| 435 // cleared. |
| 436 EXPECT_EQ(now, sync_prefs.GetLastSyncedTime()); |
| 437 } |
| 438 |
418 // Verify that the SetSetupInProgress function call updates state | 439 // Verify that the SetSetupInProgress function call updates state |
419 // and notifies observers. | 440 // and notifies observers. |
420 TEST_F(ProfileSyncServiceTest, SetupInProgress) { | 441 TEST_F(ProfileSyncServiceTest, SetupInProgress) { |
421 CreateService(ProfileSyncService::AUTO_START); | 442 CreateService(ProfileSyncService::AUTO_START); |
422 InitializeForFirstSync(); | 443 InitializeForFirstSync(); |
423 | 444 |
424 TestSyncServiceObserver observer(service()); | 445 TestSyncServiceObserver observer(service()); |
425 service()->AddObserver(&observer); | 446 service()->AddObserver(&observer); |
426 | 447 |
427 auto sync_blocker = service()->GetSetupInProgressHandle(); | 448 auto sync_blocker = service()->GetSetupInProgressHandle(); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if | 965 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if |
945 // entry for sessions exists in map. | 966 // entry for sessions exists in map. |
946 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { | 967 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { |
947 CreateService(ProfileSyncService::AUTO_START); | 968 CreateService(ProfileSyncService::AUTO_START); |
948 service()->OnSessionRestoreComplete(); | 969 service()->OnSessionRestoreComplete(); |
949 service()->OnSyncCycleCompleted(); | 970 service()->OnSyncCycleCompleted(); |
950 } | 971 } |
951 | 972 |
952 } // namespace | 973 } // namespace |
953 } // namespace browser_sync | 974 } // namespace browser_sync |
OLD | NEW |