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

Unified Diff: components/browser_sync/browser/profile_sync_service_unittest.cc

Issue 1575153004: [Sync] Simplify sync startup behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setup
Patch Set: Rebase. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/browser_sync/browser/profile_sync_service_unittest.cc
diff --git a/components/browser_sync/browser/profile_sync_service_unittest.cc b/components/browser_sync/browser/profile_sync_service_unittest.cc
index b348ffaa3caf688121108660b04f7bd87742b438..be52cbeae20f8f9f5519fdbf62bf369a21cccbfb 100644
--- a/components/browser_sync/browser/profile_sync_service_unittest.cc
+++ b/components/browser_sync/browser/profile_sync_service_unittest.cc
@@ -92,14 +92,15 @@ using testing::_;
class TestSyncServiceObserver : public sync_driver::SyncServiceObserver {
public:
explicit TestSyncServiceObserver(ProfileSyncService* service)
- : service_(service), first_setup_in_progress_(false) {}
+ : service_(service), setup_in_progress_(false) {}
void OnStateChanged() override {
- first_setup_in_progress_ = service_->IsFirstSetupInProgress();
+ setup_in_progress_ = service_->IsSetupInProgress();
}
- bool first_setup_in_progress() const { return first_setup_in_progress_; }
+ bool setup_in_progress() const { return setup_in_progress_; }
+
private:
ProfileSyncService* service_;
- bool first_setup_in_progress_;
+ bool setup_in_progress_;
};
// A variant of the SyncBackendHostMock that won't automatically
@@ -265,8 +266,7 @@ class ProfileSyncServiceTest : public ::testing::Test {
void InitializeForNthSync() {
// Set first sync time before initialize to simulate a complete sync setup.
- sync_driver::SyncPrefs sync_prefs(
- service_->GetSyncClient()->GetPrefService());
+ sync_driver::SyncPrefs sync_prefs(prefs());
sync_prefs.SetFirstSyncTime(base::Time::Now());
sync_prefs.SetFirstSetupComplete();
sync_prefs.SetKeepEverythingSynced(true);
@@ -423,9 +423,9 @@ TEST_F(ProfileSyncServiceTest, SetupInProgress) {
service()->AddObserver(&observer);
service()->SetSetupInProgress(true);
- EXPECT_TRUE(observer.first_setup_in_progress());
+ EXPECT_TRUE(observer.setup_in_progress());
service()->SetSetupInProgress(false);
- EXPECT_FALSE(observer.first_setup_in_progress());
+ EXPECT_FALSE(observer.setup_in_progress());
service()->RemoveObserver(&observer);
}
@@ -477,23 +477,21 @@ TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
TEST_F(ProfileSyncServiceTest, EarlyRequestStop) {
CreateService(browser_sync::AUTO_START);
IssueTestTokens();
+ ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
+ ExpectSyncBackendHostCreation(1);
service()->RequestStop(ProfileSyncService::KEEP_DATA);
- EXPECT_TRUE(prefs()->GetBoolean(sync_driver::prefs::kSyncSuppressStart));
+ EXPECT_FALSE(service()->IsSyncRequested());
- // Because of suppression, this should fail.
- sync_driver::SyncPrefs sync_prefs(
- service()->GetSyncClient()->GetPrefService());
- sync_prefs.SetFirstSyncTime(base::Time::Now());
- service()->Initialize();
+ // Because sync is not requested, this should fail.
+ InitializeForNthSync();
+ EXPECT_FALSE(service()->IsSyncRequested());
EXPECT_FALSE(service()->IsSyncActive());
- // Request start. This should be enough to allow init to happen.
- ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
- ExpectSyncBackendHostCreation(1);
+ // Request start. This should be enough to allow init to happen.
service()->RequestStart();
+ EXPECT_TRUE(service()->IsSyncRequested());
EXPECT_TRUE(service()->IsSyncActive());
- EXPECT_FALSE(prefs()->GetBoolean(sync_driver::prefs::kSyncSuppressStart));
}
// Test RequestStop() after we've initialized the backend.
« no previous file with comments | « components/browser_sync/browser/profile_sync_service_startup_unittest.cc ('k') | components/sync_driver/startup_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698