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

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: Better comment + tests. Created 4 years, 10 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..5c6dda3fe59234050a6b804dfe5c2f2bf0439554 100644
--- a/components/browser_sync/browser/profile_sync_service_unittest.cc
+++ b/components/browser_sync/browser/profile_sync_service_unittest.cc
@@ -92,14 +92,14 @@ 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 +265,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 +422,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 +476,20 @@ 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()->IsSyncActive());
Nicolas Zea 2016/02/29 21:21:55 Verify IsSyncRequested?
maxbogue 2016/03/09 02:00:59 Done.
- // 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.

Powered by Google App Engine
This is Rietveld 408576698