MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / chrome / browser / sync / profile_sync_service_unittest.cc
blob0b0c3cf011d37d6ed88b0d44b2d81ff2b3fd25a8
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
3 // found in the LICENSE file.
5 #include "base/basictypes.h"
6 #include "base/command_line.h"
7 #include "base/compiler_specific.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h"
13 #include "chrome/browser/invalidation/fake_invalidation_service.h"
14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
15 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
16 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/browser/sync/glue/sync_backend_host_mock.h"
20 #include "chrome/browser/sync/profile_sync_components_factory_mock.h"
21 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/testing_browser_process.h"
25 #include "chrome/test/base/testing_pref_service_syncable.h"
26 #include "chrome/test/base/testing_profile.h"
27 #include "chrome/test/base/testing_profile_manager.h"
28 #include "components/invalidation/invalidation_service.h"
29 #include "components/invalidation/profile_invalidation_provider.h"
30 #include "components/signin/core/browser/signin_manager.h"
31 #include "components/sync_driver/data_type_manager.h"
32 #include "components/sync_driver/pref_names.h"
33 #include "components/sync_driver/sync_prefs.h"
34 #include "content/public/test/test_browser_thread_bundle.h"
35 #include "google_apis/gaia/gaia_constants.h"
36 #include "testing/gmock/include/gmock/gmock.h"
37 #include "testing/gtest/include/gtest/gtest.h"
39 namespace content {
40 class BrowserContext;
43 namespace browser_sync {
45 namespace {
47 class FakeDataTypeManager : public sync_driver::DataTypeManager {
48 public:
49 explicit FakeDataTypeManager(sync_driver::DataTypeManagerObserver* observer)
50 : observer_(observer) {}
51 ~FakeDataTypeManager() override{};
53 void Configure(syncer::ModelTypeSet desired_types,
54 syncer::ConfigureReason reason) override {
55 sync_driver::DataTypeManager::ConfigureResult result;
56 result.status = sync_driver::DataTypeManager::OK;
57 observer_->OnConfigureDone(result);
60 void ReenableType(syncer::ModelType type) override {}
61 void ResetDataTypeErrors() override {}
62 void PurgeForMigration(syncer::ModelTypeSet undesired_types,
63 syncer::ConfigureReason reason) override {}
64 void Stop() override{};
65 State state() const override {
66 return sync_driver::DataTypeManager::CONFIGURED;
69 private:
70 sync_driver::DataTypeManagerObserver* observer_;
73 ACTION(ReturnNewDataTypeManager) {
74 return new FakeDataTypeManager(arg4);
77 using testing::Return;
78 using testing::StrictMock;
79 using testing::_;
81 class TestProfileSyncServiceObserver : public ProfileSyncServiceObserver {
82 public:
83 explicit TestProfileSyncServiceObserver(ProfileSyncService* service)
84 : service_(service), first_setup_in_progress_(false) {}
85 void OnStateChanged() override {
86 first_setup_in_progress_ = service_->FirstSetupInProgress();
88 bool first_setup_in_progress() const { return first_setup_in_progress_; }
89 private:
90 ProfileSyncService* service_;
91 bool first_setup_in_progress_;
94 // A variant of the SyncBackendHostMock that won't automatically
95 // call back when asked to initialized. Allows us to test things
96 // that could happen while backend init is in progress.
97 class SyncBackendHostNoReturn : public SyncBackendHostMock {
98 void Initialize(
99 sync_driver::SyncFrontend* frontend,
100 scoped_ptr<base::Thread> sync_thread,
101 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
102 const GURL& service_url,
103 const syncer::SyncCredentials& credentials,
104 bool delete_sync_data_folder,
105 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
106 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler,
107 syncer::ReportUnrecoverableErrorFunction
108 report_unrecoverable_error_function,
109 syncer::NetworkResources* network_resources) override {}
112 class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock {
113 public:
114 explicit SyncBackendHostMockCollectDeleteDirParam(
115 std::vector<bool>* delete_dir_param)
116 : delete_dir_param_(delete_dir_param) {}
118 void Initialize(
119 sync_driver::SyncFrontend* frontend,
120 scoped_ptr<base::Thread> sync_thread,
121 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
122 const GURL& service_url,
123 const syncer::SyncCredentials& credentials,
124 bool delete_sync_data_folder,
125 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory,
126 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler,
127 syncer::ReportUnrecoverableErrorFunction
128 report_unrecoverable_error_function,
129 syncer::NetworkResources* network_resources) override {
130 delete_dir_param_->push_back(delete_sync_data_folder);
131 SyncBackendHostMock::Initialize(frontend, sync_thread.Pass(),
132 event_handler, service_url, credentials,
133 delete_sync_data_folder,
134 sync_manager_factory.Pass(),
135 unrecoverable_error_handler.Pass(),
136 report_unrecoverable_error_function,
137 network_resources);
140 private:
141 std::vector<bool>* delete_dir_param_;
144 ACTION(ReturnNewSyncBackendHostMock) {
145 return new browser_sync::SyncBackendHostMock();
148 ACTION(ReturnNewSyncBackendHostNoReturn) {
149 return new browser_sync::SyncBackendHostNoReturn();
152 ACTION_P(ReturnNewMockHostCollectDeleteDirParam, delete_dir_param) {
153 return new browser_sync::SyncBackendHostMockCollectDeleteDirParam(
154 delete_dir_param);
157 KeyedService* BuildFakeProfileInvalidationProvider(
158 content::BrowserContext* context) {
159 return new invalidation::ProfileInvalidationProvider(
160 scoped_ptr<invalidation::InvalidationService>(
161 new invalidation::FakeInvalidationService));
164 // A test harness that uses a real ProfileSyncService and in most cases a
165 // MockSyncBackendHost.
167 // This is useful if we want to test the ProfileSyncService and don't care about
168 // testing the SyncBackendHost.
169 class ProfileSyncServiceTest : public ::testing::Test {
170 protected:
171 ProfileSyncServiceTest()
172 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
173 profile_manager_(TestingBrowserProcess::GetGlobal()) {}
174 virtual ~ProfileSyncServiceTest() {}
176 virtual void SetUp() override {
177 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
178 switches::kSyncDeferredStartupTimeoutSeconds, "0");
180 CHECK(profile_manager_.SetUp());
182 TestingProfile::TestingFactories testing_facotries;
183 testing_facotries.push_back(
184 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(),
185 BuildAutoIssuingFakeProfileOAuth2TokenService));
186 testing_facotries.push_back(
187 std::make_pair(
188 invalidation::ProfileInvalidationProviderFactory::GetInstance(),
189 BuildFakeProfileInvalidationProvider));
191 profile_ = profile_manager_.CreateTestingProfile(
192 "sync-service-test", scoped_ptr<PrefServiceSyncable>(),
193 base::UTF8ToUTF16("sync-service-test"), 0, std::string(),
194 testing_facotries);
197 virtual void TearDown() override {
198 // Kill the service before the profile.
199 if (service_)
200 service_->Shutdown();
202 service_.reset();
205 void IssueTestTokens() {
206 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
207 ->UpdateCredentials("test", "oauth2_login_token");
210 void CreateService(ProfileSyncServiceStartBehavior behavior) {
211 SigninManagerBase* signin =
212 SigninManagerFactory::GetForProfile(profile_);
213 signin->SetAuthenticatedUsername("test");
214 ProfileOAuth2TokenService* oauth2_token_service =
215 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
216 components_factory_ = new ProfileSyncComponentsFactoryMock();
217 service_.reset(new ProfileSyncService(
218 scoped_ptr<ProfileSyncComponentsFactory>(components_factory_),
219 profile_,
220 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile_,
221 signin)),
222 oauth2_token_service,
223 behavior));
224 service_->SetClearingBrowseringDataForTesting(
225 base::Bind(&ProfileSyncServiceTest::ClearBrowsingDataCallback,
226 base::Unretained(this)));
229 #if defined(OS_WIN) || defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
230 void CreateServiceWithoutSignIn() {
231 CreateService(browser_sync::AUTO_START);
232 SigninManagerFactory::GetForProfile(profile())->SignOut(
233 signin_metrics::SIGNOUT_TEST);
235 #endif
237 void ShutdownAndDeleteService() {
238 if (service_)
239 service_->Shutdown();
240 service_.reset();
243 void InitializeForNthSync() {
244 // Set first sync time before initialize to disable backup.
245 sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs());
246 sync_prefs.SetFirstSyncTime(base::Time::Now());
247 service_->Initialize();
250 void InitializeForFirstSync() {
251 service_->Initialize();
254 void ExpectDataTypeManagerCreation(int times) {
255 EXPECT_CALL(*components_factory_, CreateDataTypeManager(_, _, _, _, _))
256 .Times(times)
257 .WillRepeatedly(ReturnNewDataTypeManager());
260 void ExpectSyncBackendHostCreation(int times) {
261 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _))
262 .Times(times)
263 .WillRepeatedly(ReturnNewSyncBackendHostMock());
266 void ExpectSyncBackendHostCreationCollectDeleteDir(
267 int times, std::vector<bool> *delete_dir_param) {
268 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _))
269 .Times(times)
270 .WillRepeatedly(ReturnNewMockHostCollectDeleteDirParam(
271 delete_dir_param));
274 void PrepareDelayedInitSyncBackendHost() {
275 EXPECT_CALL(*components_factory_, CreateSyncBackendHost(_, _, _, _, _)).
276 WillOnce(ReturnNewSyncBackendHostNoReturn());
279 TestingProfile* profile() {
280 return profile_;
283 ProfileSyncService* service() {
284 return service_.get();
287 ProfileSyncComponentsFactoryMock* components_factory() {
288 return components_factory_;
291 void ClearBrowsingDataCallback(BrowsingDataRemover::Observer* observer,
292 Profile* profile,
293 base::Time start,
294 base::Time end) {
295 EXPECT_EQ(profile_, profile);
296 clear_browsing_date_start_ = start;
299 protected:
300 void PumpLoop() {
301 base::RunLoop run_loop;
302 base::MessageLoop::current()->PostTask(
303 FROM_HERE, run_loop.QuitClosure());
304 run_loop.Run();
307 // The requested start time when ClearBrowsingDataCallback is called.
308 base::Time clear_browsing_date_start_;
310 private:
311 content::TestBrowserThreadBundle thread_bundle_;
312 TestingProfileManager profile_manager_;
313 TestingProfile* profile_;
314 scoped_ptr<ProfileSyncService> service_;
316 // Pointer to the components factory. Not owned. May be null.
317 ProfileSyncComponentsFactoryMock* components_factory_;
320 // Verify that the server URLs are sane.
321 TEST_F(ProfileSyncServiceTest, InitialState) {
322 CreateService(browser_sync::AUTO_START);
323 InitializeForNthSync();
324 const std::string& url = service()->sync_service_url().spec();
325 EXPECT_TRUE(url == ProfileSyncService::kSyncServerUrl ||
326 url == ProfileSyncService::kDevServerUrl);
329 // Verify a successful initialization.
330 TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) {
331 profile()->GetTestingPrefService()->SetManagedPref(
332 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(false));
333 IssueTestTokens();
334 CreateService(browser_sync::AUTO_START);
335 ExpectDataTypeManagerCreation(1);
336 ExpectSyncBackendHostCreation(1);
337 InitializeForNthSync();
338 EXPECT_FALSE(service()->IsManaged());
339 EXPECT_TRUE(service()->SyncActive());
340 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
344 // Verify that the SetSetupInProgress function call updates state
345 // and notifies observers.
346 TEST_F(ProfileSyncServiceTest, SetupInProgress) {
347 CreateService(browser_sync::AUTO_START);
348 InitializeForNthSync();
350 TestProfileSyncServiceObserver observer(service());
351 service()->AddObserver(&observer);
353 service()->SetSetupInProgress(true);
354 EXPECT_TRUE(observer.first_setup_in_progress());
355 service()->SetSetupInProgress(false);
356 EXPECT_FALSE(observer.first_setup_in_progress());
358 service()->RemoveObserver(&observer);
361 // Verify that disable by enterprise policy works.
362 TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) {
363 profile()->GetTestingPrefService()->SetManagedPref(
364 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true));
365 IssueTestTokens();
366 CreateService(browser_sync::AUTO_START);
367 InitializeForNthSync();
368 EXPECT_TRUE(service()->IsManaged());
369 EXPECT_FALSE(service()->SyncActive());
372 // Verify that disable by enterprise policy works even after the backend has
373 // been initialized.
374 TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) {
375 IssueTestTokens();
376 CreateService(browser_sync::AUTO_START);
377 ExpectDataTypeManagerCreation(1);
378 ExpectSyncBackendHostCreation(1);
379 InitializeForNthSync();
381 EXPECT_FALSE(service()->IsManaged());
382 EXPECT_TRUE(service()->SyncActive());
384 profile()->GetTestingPrefService()->SetManagedPref(
385 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true));
387 EXPECT_TRUE(service()->IsManaged());
388 EXPECT_FALSE(service()->SyncActive());
391 // Exercies the ProfileSyncService's code paths related to getting shut down
392 // before the backend initialize call returns.
393 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
394 CreateService(browser_sync::AUTO_START);
395 PrepareDelayedInitSyncBackendHost();
397 IssueTestTokens();
398 InitializeForNthSync();
399 EXPECT_FALSE(service()->SyncActive());
401 ShutdownAndDeleteService();
404 // Test StopAndSuppress() before we've initialized the backend.
405 TEST_F(ProfileSyncServiceTest, EarlyStopAndSuppress) {
406 CreateService(browser_sync::AUTO_START);
407 IssueTestTokens();
409 service()->StopAndSuppress();
410 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
411 sync_driver::prefs::kSyncSuppressStart));
413 // Because of supression, this should fail.
414 InitializeForNthSync();
415 EXPECT_FALSE(service()->SyncActive());
417 // Remove suppression. This should be enough to allow init to happen.
418 ExpectDataTypeManagerCreation(1);
419 ExpectSyncBackendHostCreation(1);
420 service()->UnsuppressAndStart();
421 EXPECT_TRUE(service()->SyncActive());
422 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
423 sync_driver::prefs::kSyncSuppressStart));
426 // Test StopAndSuppress() after we've initialized the backend.
427 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) {
428 CreateService(browser_sync::AUTO_START);
429 IssueTestTokens();
430 ExpectDataTypeManagerCreation(1);
431 ExpectSyncBackendHostCreation(1);
432 InitializeForNthSync();
434 EXPECT_TRUE(service()->SyncActive());
435 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
436 sync_driver::prefs::kSyncSuppressStart));
438 testing::Mock::VerifyAndClearExpectations(components_factory());
440 service()->StopAndSuppress();
441 EXPECT_FALSE(service()->SyncActive());
442 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(
443 sync_driver::prefs::kSyncSuppressStart));
445 ExpectDataTypeManagerCreation(1);
446 ExpectSyncBackendHostCreation(1);
448 service()->UnsuppressAndStart();
449 EXPECT_TRUE(service()->SyncActive());
450 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
451 sync_driver::prefs::kSyncSuppressStart));
454 // Certain ProfileSyncService tests don't apply to Chrome OS, for example
455 // things that deal with concepts like "signing out" and policy.
456 #if !defined (OS_CHROMEOS)
457 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) {
458 CreateService(browser_sync::AUTO_START);
459 ExpectDataTypeManagerCreation(1);
460 ExpectSyncBackendHostCreation(1);
461 IssueTestTokens();
462 InitializeForNthSync();
464 EXPECT_TRUE(service()->SyncActive());
465 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(
466 sync_driver::prefs::kSyncSuppressStart));
468 SigninManagerFactory::GetForProfile(profile())->SignOut(
469 signin_metrics::SIGNOUT_TEST);
470 EXPECT_FALSE(service()->SyncActive());
472 #endif // !defined(OS_CHROMEOS)
474 TEST_F(ProfileSyncServiceTest, GetSyncTokenStatus) {
475 CreateService(browser_sync::AUTO_START);
476 IssueTestTokens();
477 ExpectDataTypeManagerCreation(1);
478 ExpectSyncBackendHostCreation(1);
479 InitializeForNthSync();
481 // Initial status.
482 ProfileSyncService::SyncTokenStatus token_status =
483 service()->GetSyncTokenStatus();
484 EXPECT_EQ(syncer::CONNECTION_NOT_ATTEMPTED, token_status.connection_status);
485 EXPECT_TRUE(token_status.connection_status_update_time.is_null());
486 EXPECT_TRUE(token_status.token_request_time.is_null());
487 EXPECT_TRUE(token_status.token_receive_time.is_null());
489 // Simulate an auth error.
490 service()->OnConnectionStatusChange(syncer::CONNECTION_AUTH_ERROR);
492 // The token request will take the form of a posted task. Run it.
493 base::RunLoop loop;
494 loop.RunUntilIdle();
496 token_status = service()->GetSyncTokenStatus();
497 EXPECT_EQ(syncer::CONNECTION_AUTH_ERROR, token_status.connection_status);
498 EXPECT_FALSE(token_status.connection_status_update_time.is_null());
499 EXPECT_FALSE(token_status.token_request_time.is_null());
500 EXPECT_FALSE(token_status.token_receive_time.is_null());
501 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(),
502 token_status.last_get_token_error);
503 EXPECT_TRUE(token_status.next_token_request_time.is_null());
505 // Simulate successful connection.
506 service()->OnConnectionStatusChange(syncer::CONNECTION_OK);
507 token_status = service()->GetSyncTokenStatus();
508 EXPECT_EQ(syncer::CONNECTION_OK, token_status.connection_status);
511 #if defined(ENABLE_PRE_SYNC_BACKUP)
512 TEST_F(ProfileSyncServiceTest, DontStartBackupOnBrowserStart) {
513 CreateServiceWithoutSignIn();
514 InitializeForFirstSync();
515 PumpLoop();
516 EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode());
519 TEST_F(ProfileSyncServiceTest, BackupBeforeFirstSync) {
520 CreateServiceWithoutSignIn();
521 ExpectDataTypeManagerCreation(2);
522 std::vector<bool> delete_dir_param;
523 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param);
524 InitializeForFirstSync();
526 SigninManagerFactory::GetForProfile(profile())
527 ->SetAuthenticatedUsername("test");
528 IssueTestTokens();
529 PumpLoop();
531 // At this time, backup is finished. Task is posted to start sync again.
532 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode());
533 EXPECT_FALSE(service()->SyncActive());
534 EXPECT_EQ(1u, delete_dir_param.size());
535 EXPECT_TRUE(delete_dir_param[0]);
537 // Pump loop to start sync.
538 PumpLoop();
539 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
540 EXPECT_TRUE(service()->SyncActive());
541 EXPECT_EQ(2u, delete_dir_param.size());
542 EXPECT_TRUE(delete_dir_param[0]);
545 // Test backup is done again on browser start if user signed in last session
546 // but backup didn't finish when last session was closed.
547 TEST_F(ProfileSyncServiceTest, ResumeBackupIfAborted) {
548 IssueTestTokens();
549 CreateService(AUTO_START);
550 ExpectDataTypeManagerCreation(2);
551 std::vector<bool> delete_dir_param;
552 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param);
553 InitializeForFirstSync();
554 PumpLoop();
556 // At this time, backup is finished. Task is posted to start sync again.
557 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode());
558 EXPECT_FALSE(service()->SyncActive());
559 EXPECT_EQ(1u, delete_dir_param.size());
560 EXPECT_TRUE(delete_dir_param[0]);
562 // Pump loop to start sync.
563 PumpLoop();
564 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
565 EXPECT_TRUE(service()->SyncActive());
566 EXPECT_EQ(2u, delete_dir_param.size());
567 EXPECT_TRUE(delete_dir_param[0]);
570 TEST_F(ProfileSyncServiceTest, Rollback) {
571 CreateService(browser_sync::MANUAL_START);
572 service()->SetSyncSetupCompleted();
573 ExpectDataTypeManagerCreation(2);
574 std::vector<bool> delete_dir_param;
575 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param);
576 IssueTestTokens();
577 InitializeForNthSync();
578 EXPECT_TRUE(service()->SyncActive());
579 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode());
581 // First sync time should be recorded.
582 sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs());
583 base::Time first_sync_time = sync_prefs.GetFirstSyncTime();
584 EXPECT_FALSE(first_sync_time.is_null());
586 syncer::SyncProtocolError client_cmd;
587 client_cmd.action = syncer::DISABLE_SYNC_AND_ROLLBACK;
588 service()->OnActionableError(client_cmd);
589 EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode());
591 // Pump loop to run rollback.
592 PumpLoop();
593 EXPECT_EQ(ProfileSyncService::ROLLBACK, service()->backend_mode());
595 // Browser data should be cleared during rollback.
596 EXPECT_EQ(first_sync_time, clear_browsing_date_start_);
598 client_cmd.action = syncer::ROLLBACK_DONE;
599 service()->OnActionableError(client_cmd);
600 EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode());
602 // First sync time is erased after rollback is done.
603 EXPECT_TRUE(sync_prefs.GetFirstSyncTime().is_null());
605 EXPECT_EQ(2u, delete_dir_param.size());
606 EXPECT_FALSE(delete_dir_param[0]);
607 EXPECT_FALSE(delete_dir_param[1]);
610 #endif
612 TEST_F(ProfileSyncServiceTest, GetSyncServiceURL) {
613 // See that we can override the URL with a flag.
614 CommandLine command_line(
615 base::FilePath(base::FilePath(FILE_PATH_LITERAL("chrome.exe"))));
616 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar");
617 EXPECT_EQ("https://foo/bar",
618 ProfileSyncService::GetSyncServiceURL(command_line).spec());
621 } // namespace
622 } // namespace browser_sync