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

Side by Side Diff: components/browser_sync/browser/profile_sync_service_unittest.cc

Issue 2126923002: [Sync] Stop purging sync data on restart for users who haven't finished setup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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
« no previous file with comments | « components/browser_sync/browser/profile_sync_service.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 (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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 new base::FundamentalValue(false)); 407 new base::FundamentalValue(false));
408 IssueTestTokens(); 408 IssueTestTokens();
409 CreateService(ProfileSyncService::AUTO_START); 409 CreateService(ProfileSyncService::AUTO_START);
410 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); 410 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
411 ExpectSyncBackendHostCreation(1); 411 ExpectSyncBackendHostCreation(1);
412 InitializeForNthSync(); 412 InitializeForNthSync();
413 EXPECT_FALSE(service()->IsManaged()); 413 EXPECT_FALSE(service()->IsManaged());
414 EXPECT_TRUE(service()->IsSyncActive()); 414 EXPECT_TRUE(service()->IsSyncActive());
415 } 415 }
416 416
417 // Verify that an initialization where first setup is not complete does not
418 // purge preferences and/or the directory.
419 TEST_F(ProfileSyncServiceTest, NeedsConfirmation) {
420 prefs()->SetManagedPref(sync_driver::prefs::kSyncManaged,
421 new base::FundamentalValue(false));
422 IssueTestTokens();
423 CreateService(ProfileSyncService::MANUAL_START);
424 ExpectSyncBackendHostCreation(1);
425 sync_driver::SyncPrefs sync_prefs(prefs());
426 base::Time now = base::Time::Now();
427 sync_prefs.SetLastSyncedTime(now);
428 sync_prefs.SetKeepEverythingSynced(true);
429 service()->Initialize();
430 EXPECT_FALSE(service()->IsSyncActive());
431
432 // The last sync time shouldn't be cleared.
433 // TODO(zea): figure out a way to check that the directory itself wasn't
434 // cleared.
435 EXPECT_EQ(now, sync_prefs.GetLastSyncedTime());
436 }
437
417 // Verify that the SetSetupInProgress function call updates state 438 // Verify that the SetSetupInProgress function call updates state
418 // and notifies observers. 439 // and notifies observers.
419 TEST_F(ProfileSyncServiceTest, SetupInProgress) { 440 TEST_F(ProfileSyncServiceTest, SetupInProgress) {
420 CreateService(ProfileSyncService::AUTO_START); 441 CreateService(ProfileSyncService::AUTO_START);
421 InitializeForFirstSync(); 442 InitializeForFirstSync();
422 443
423 TestSyncServiceObserver observer(service()); 444 TestSyncServiceObserver observer(service());
424 service()->AddObserver(&observer); 445 service()->AddObserver(&observer);
425 446
426 service()->SetSetupInProgress(true); 447 service()->SetSetupInProgress(true);
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if 930 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if
910 // entry for sessions exists in map. 931 // entry for sessions exists in map.
911 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { 932 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) {
912 CreateService(ProfileSyncService::AUTO_START); 933 CreateService(ProfileSyncService::AUTO_START);
913 service()->OnSessionRestoreComplete(); 934 service()->OnSessionRestoreComplete();
914 service()->OnSyncCycleCompleted(); 935 service()->OnSyncCycleCompleted();
915 } 936 }
916 937
917 } // namespace 938 } // namespace
918 } // namespace browser_sync 939 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/browser_sync/browser/profile_sync_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698