| Index: trunk/src/chrome/browser/sync/startup_controller_unittest.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/sync/startup_controller_unittest.cc (revision 254811)
|
| +++ trunk/src/chrome/browser/sync/startup_controller_unittest.cc (working copy)
|
| @@ -86,6 +86,15 @@
|
| started_ = true;
|
| }
|
|
|
| + void ForceDeferredStartup() {
|
| + if (!CommandLine::ForCurrentProcess()->
|
| + HasSwitch(switches::kSyncEnableDeferredStartup)) {
|
| + CommandLine::ForCurrentProcess()->
|
| + AppendSwitch(switches::kSyncEnableDeferredStartup);
|
| + controller_->Reset(syncer::UserTypes());
|
| + }
|
| + }
|
| +
|
| bool started() const { return started_; }
|
| void clear_started() { started_ = false; }
|
| StartupController* controller() { return controller_.get(); }
|
| @@ -118,8 +127,8 @@
|
| controller()->TryStart();
|
| EXPECT_FALSE(started());
|
| token_service()->IssueRefreshTokenForUser(kTestUser, kTestToken);
|
| - const bool deferred_start = !CommandLine::ForCurrentProcess()->
|
| - HasSwitch(switches::kSyncDisableDeferredStartup);
|
| + const bool deferred_start = CommandLine::ForCurrentProcess()->
|
| + HasSwitch(switches::kSyncEnableDeferredStartup);
|
| controller()->TryStart();
|
| EXPECT_EQ(!deferred_start, started());
|
| std::string state(controller()->GetBackendInitializationStateString());
|
| @@ -154,6 +163,7 @@
|
| // Test that sync doesn't start until all conditions are met and a
|
| // data type triggers sync startup.
|
| TEST_F(StartupControllerTest, DataTypeTriggered) {
|
| + ForceDeferredStartup();
|
| sync_prefs()->SetSyncSetupCompleted();
|
| signin()->set_account(kTestUser);
|
| token_service()->IssueRefreshTokenForUser(kTestUser, kTestToken);
|
| @@ -176,6 +186,7 @@
|
| // Test that the fallback timer starts sync in the event all
|
| // conditions are met and no data type requests sync.
|
| TEST_F(StartupControllerTest, FallbackTimer) {
|
| + ForceDeferredStartup();
|
| sync_prefs()->SetSyncSetupCompleted();
|
| signin()->set_account(kTestUser);
|
| token_service()->IssueRefreshTokenForUser(kTestUser, kTestToken);
|
| @@ -195,6 +206,8 @@
|
| types.Remove(syncer::MANAGED_USER_SETTINGS);
|
| sync_prefs()->SetKeepEverythingSynced(false);
|
| sync_prefs()->SetPreferredDataTypes(syncer::UserTypes(), types);
|
| + CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + switches::kSyncEnableDeferredStartup);
|
| controller()->Reset(syncer::UserTypes());
|
| sync_prefs()->SetSyncSetupCompleted();
|
| signin()->set_account(kTestUser);
|
| @@ -206,6 +219,7 @@
|
| // Sanity check that the fallback timer doesn't fire before startup
|
| // conditions are met.
|
| TEST_F(StartupControllerTest, FallbackTimerWaits) {
|
| + ForceDeferredStartup();
|
| controller()->TryStart();
|
| EXPECT_FALSE(started());
|
| base::RunLoop().RunUntilIdle();
|
| @@ -240,8 +254,8 @@
|
| controller()->Reset(syncer::UserTypes());
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_FALSE(started());
|
| - const bool deferred_start = !CommandLine::ForCurrentProcess()->
|
| - HasSwitch(switches::kSyncDisableDeferredStartup);
|
| + const bool deferred_start = CommandLine::ForCurrentProcess()->
|
| + HasSwitch(switches::kSyncEnableDeferredStartup);
|
| controller()->TryStart();
|
| EXPECT_EQ(!deferred_start, started());
|
| controller()->OnDataTypeRequestsSyncStartup(syncer::SESSIONS);
|
|
|