| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Verify a successful initialization. | 340 // Verify a successful initialization. |
| 341 TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) { | 341 TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) { |
| 342 profile()->GetTestingPrefService()->SetManagedPref( | 342 profile()->GetTestingPrefService()->SetManagedPref( |
| 343 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(false)); | 343 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(false)); |
| 344 IssueTestTokens(); | 344 IssueTestTokens(); |
| 345 CreateService(browser_sync::AUTO_START); | 345 CreateService(browser_sync::AUTO_START); |
| 346 ExpectDataTypeManagerCreation(1); | 346 ExpectDataTypeManagerCreation(1); |
| 347 ExpectSyncBackendHostCreation(1); | 347 ExpectSyncBackendHostCreation(1); |
| 348 InitializeForNthSync(); | 348 InitializeForNthSync(); |
| 349 EXPECT_FALSE(service()->IsManaged()); | 349 EXPECT_FALSE(service()->IsManaged()); |
| 350 EXPECT_TRUE(service()->SyncActive()); | 350 EXPECT_TRUE(service()->IsSyncActive()); |
| 351 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); | 351 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); |
| 352 } | 352 } |
| 353 | 353 |
| 354 | 354 |
| 355 // Verify that the SetSetupInProgress function call updates state | 355 // Verify that the SetSetupInProgress function call updates state |
| 356 // and notifies observers. | 356 // and notifies observers. |
| 357 TEST_F(ProfileSyncServiceTest, SetupInProgress) { | 357 TEST_F(ProfileSyncServiceTest, SetupInProgress) { |
| 358 CreateService(browser_sync::AUTO_START); | 358 CreateService(browser_sync::AUTO_START); |
| 359 InitializeForNthSync(); | 359 InitializeForNthSync(); |
| 360 | 360 |
| 361 TestSyncServiceObserver observer(service()); | 361 TestSyncServiceObserver observer(service()); |
| 362 service()->AddObserver(&observer); | 362 service()->AddObserver(&observer); |
| 363 | 363 |
| 364 service()->SetSetupInProgress(true); | 364 service()->SetSetupInProgress(true); |
| 365 EXPECT_TRUE(observer.first_setup_in_progress()); | 365 EXPECT_TRUE(observer.first_setup_in_progress()); |
| 366 service()->SetSetupInProgress(false); | 366 service()->SetSetupInProgress(false); |
| 367 EXPECT_FALSE(observer.first_setup_in_progress()); | 367 EXPECT_FALSE(observer.first_setup_in_progress()); |
| 368 | 368 |
| 369 service()->RemoveObserver(&observer); | 369 service()->RemoveObserver(&observer); |
| 370 } | 370 } |
| 371 | 371 |
| 372 // Verify that disable by enterprise policy works. | 372 // Verify that disable by enterprise policy works. |
| 373 TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) { | 373 TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) { |
| 374 profile()->GetTestingPrefService()->SetManagedPref( | 374 profile()->GetTestingPrefService()->SetManagedPref( |
| 375 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); | 375 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); |
| 376 IssueTestTokens(); | 376 IssueTestTokens(); |
| 377 CreateService(browser_sync::AUTO_START); | 377 CreateService(browser_sync::AUTO_START); |
| 378 InitializeForNthSync(); | 378 InitializeForNthSync(); |
| 379 EXPECT_TRUE(service()->IsManaged()); | 379 EXPECT_TRUE(service()->IsManaged()); |
| 380 EXPECT_FALSE(service()->SyncActive()); | 380 EXPECT_FALSE(service()->IsSyncActive()); |
| 381 } | 381 } |
| 382 | 382 |
| 383 // Verify that disable by enterprise policy works even after the backend has | 383 // Verify that disable by enterprise policy works even after the backend has |
| 384 // been initialized. | 384 // been initialized. |
| 385 TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) { | 385 TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) { |
| 386 IssueTestTokens(); | 386 IssueTestTokens(); |
| 387 CreateService(browser_sync::AUTO_START); | 387 CreateService(browser_sync::AUTO_START); |
| 388 ExpectDataTypeManagerCreation(1); | 388 ExpectDataTypeManagerCreation(1); |
| 389 ExpectSyncBackendHostCreation(1); | 389 ExpectSyncBackendHostCreation(1); |
| 390 InitializeForNthSync(); | 390 InitializeForNthSync(); |
| 391 | 391 |
| 392 EXPECT_FALSE(service()->IsManaged()); | 392 EXPECT_FALSE(service()->IsManaged()); |
| 393 EXPECT_TRUE(service()->SyncActive()); | 393 EXPECT_TRUE(service()->IsSyncActive()); |
| 394 | 394 |
| 395 profile()->GetTestingPrefService()->SetManagedPref( | 395 profile()->GetTestingPrefService()->SetManagedPref( |
| 396 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); | 396 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); |
| 397 | 397 |
| 398 EXPECT_TRUE(service()->IsManaged()); | 398 EXPECT_TRUE(service()->IsManaged()); |
| 399 EXPECT_FALSE(service()->SyncActive()); | 399 EXPECT_FALSE(service()->IsSyncActive()); |
| 400 } | 400 } |
| 401 | 401 |
| 402 // Exercies the ProfileSyncService's code paths related to getting shut down | 402 // Exercies the ProfileSyncService's code paths related to getting shut down |
| 403 // before the backend initialize call returns. | 403 // before the backend initialize call returns. |
| 404 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { | 404 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { |
| 405 CreateService(browser_sync::AUTO_START); | 405 CreateService(browser_sync::AUTO_START); |
| 406 PrepareDelayedInitSyncBackendHost(); | 406 PrepareDelayedInitSyncBackendHost(); |
| 407 | 407 |
| 408 IssueTestTokens(); | 408 IssueTestTokens(); |
| 409 InitializeForNthSync(); | 409 InitializeForNthSync(); |
| 410 EXPECT_FALSE(service()->SyncActive()); | 410 EXPECT_FALSE(service()->IsSyncActive()); |
| 411 | 411 |
| 412 ShutdownAndDeleteService(); | 412 ShutdownAndDeleteService(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 // Test StopAndSuppress() before we've initialized the backend. | 415 // Test StopAndSuppress() before we've initialized the backend. |
| 416 TEST_F(ProfileSyncServiceTest, EarlyStopAndSuppress) { | 416 TEST_F(ProfileSyncServiceTest, EarlyStopAndSuppress) { |
| 417 CreateService(browser_sync::AUTO_START); | 417 CreateService(browser_sync::AUTO_START); |
| 418 IssueTestTokens(); | 418 IssueTestTokens(); |
| 419 | 419 |
| 420 service()->StopAndSuppress(); | 420 service()->StopAndSuppress(); |
| 421 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( | 421 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( |
| 422 sync_driver::prefs::kSyncSuppressStart)); | 422 sync_driver::prefs::kSyncSuppressStart)); |
| 423 | 423 |
| 424 // Because of supression, this should fail. | 424 // Because of supression, this should fail. |
| 425 InitializeForNthSync(); | 425 InitializeForNthSync(); |
| 426 EXPECT_FALSE(service()->SyncActive()); | 426 EXPECT_FALSE(service()->IsSyncActive()); |
| 427 | 427 |
| 428 // Remove suppression. This should be enough to allow init to happen. | 428 // Remove suppression. This should be enough to allow init to happen. |
| 429 ExpectDataTypeManagerCreation(1); | 429 ExpectDataTypeManagerCreation(1); |
| 430 ExpectSyncBackendHostCreation(1); | 430 ExpectSyncBackendHostCreation(1); |
| 431 service()->UnsuppressAndStart(); | 431 service()->UnsuppressAndStart(); |
| 432 EXPECT_TRUE(service()->SyncActive()); | 432 EXPECT_TRUE(service()->IsSyncActive()); |
| 433 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( | 433 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 434 sync_driver::prefs::kSyncSuppressStart)); | 434 sync_driver::prefs::kSyncSuppressStart)); |
| 435 } | 435 } |
| 436 | 436 |
| 437 // Test StopAndSuppress() after we've initialized the backend. | 437 // Test StopAndSuppress() after we've initialized the backend. |
| 438 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { | 438 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { |
| 439 CreateService(browser_sync::AUTO_START); | 439 CreateService(browser_sync::AUTO_START); |
| 440 IssueTestTokens(); | 440 IssueTestTokens(); |
| 441 ExpectDataTypeManagerCreation(1); | 441 ExpectDataTypeManagerCreation(1); |
| 442 ExpectSyncBackendHostCreation(1); | 442 ExpectSyncBackendHostCreation(1); |
| 443 InitializeForNthSync(); | 443 InitializeForNthSync(); |
| 444 | 444 |
| 445 EXPECT_TRUE(service()->SyncActive()); | 445 EXPECT_TRUE(service()->IsSyncActive()); |
| 446 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( | 446 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 447 sync_driver::prefs::kSyncSuppressStart)); | 447 sync_driver::prefs::kSyncSuppressStart)); |
| 448 | 448 |
| 449 testing::Mock::VerifyAndClearExpectations(components_factory()); | 449 testing::Mock::VerifyAndClearExpectations(components_factory()); |
| 450 | 450 |
| 451 service()->StopAndSuppress(); | 451 service()->StopAndSuppress(); |
| 452 EXPECT_FALSE(service()->SyncActive()); | 452 EXPECT_FALSE(service()->IsSyncActive()); |
| 453 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( | 453 EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( |
| 454 sync_driver::prefs::kSyncSuppressStart)); | 454 sync_driver::prefs::kSyncSuppressStart)); |
| 455 | 455 |
| 456 ExpectDataTypeManagerCreation(1); | 456 ExpectDataTypeManagerCreation(1); |
| 457 ExpectSyncBackendHostCreation(1); | 457 ExpectSyncBackendHostCreation(1); |
| 458 | 458 |
| 459 service()->UnsuppressAndStart(); | 459 service()->UnsuppressAndStart(); |
| 460 EXPECT_TRUE(service()->SyncActive()); | 460 EXPECT_TRUE(service()->IsSyncActive()); |
| 461 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( | 461 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 462 sync_driver::prefs::kSyncSuppressStart)); | 462 sync_driver::prefs::kSyncSuppressStart)); |
| 463 } | 463 } |
| 464 | 464 |
| 465 // Certain ProfileSyncService tests don't apply to Chrome OS, for example | 465 // Certain ProfileSyncService tests don't apply to Chrome OS, for example |
| 466 // things that deal with concepts like "signing out" and policy. | 466 // things that deal with concepts like "signing out" and policy. |
| 467 #if !defined (OS_CHROMEOS) | 467 #if !defined (OS_CHROMEOS) |
| 468 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { | 468 TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { |
| 469 CreateService(browser_sync::AUTO_START); | 469 CreateService(browser_sync::AUTO_START); |
| 470 ExpectDataTypeManagerCreation(1); | 470 ExpectDataTypeManagerCreation(1); |
| 471 ExpectSyncBackendHostCreation(1); | 471 ExpectSyncBackendHostCreation(1); |
| 472 IssueTestTokens(); | 472 IssueTestTokens(); |
| 473 InitializeForNthSync(); | 473 InitializeForNthSync(); |
| 474 | 474 |
| 475 EXPECT_TRUE(service()->SyncActive()); | 475 EXPECT_TRUE(service()->IsSyncActive()); |
| 476 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( | 476 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 477 sync_driver::prefs::kSyncSuppressStart)); | 477 sync_driver::prefs::kSyncSuppressStart)); |
| 478 | 478 |
| 479 SigninManagerFactory::GetForProfile(profile())->SignOut( | 479 SigninManagerFactory::GetForProfile(profile())->SignOut( |
| 480 signin_metrics::SIGNOUT_TEST); | 480 signin_metrics::SIGNOUT_TEST); |
| 481 EXPECT_FALSE(service()->SyncActive()); | 481 EXPECT_FALSE(service()->IsSyncActive()); |
| 482 } | 482 } |
| 483 #endif // !defined(OS_CHROMEOS) | 483 #endif // !defined(OS_CHROMEOS) |
| 484 | 484 |
| 485 TEST_F(ProfileSyncServiceTest, GetSyncTokenStatus) { | 485 TEST_F(ProfileSyncServiceTest, GetSyncTokenStatus) { |
| 486 CreateService(browser_sync::AUTO_START); | 486 CreateService(browser_sync::AUTO_START); |
| 487 IssueTestTokens(); | 487 IssueTestTokens(); |
| 488 ExpectDataTypeManagerCreation(1); | 488 ExpectDataTypeManagerCreation(1); |
| 489 ExpectSyncBackendHostCreation(1); | 489 ExpectSyncBackendHostCreation(1); |
| 490 InitializeForNthSync(); | 490 InitializeForNthSync(); |
| 491 | 491 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param); | 534 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param); |
| 535 InitializeForFirstSync(); | 535 InitializeForFirstSync(); |
| 536 | 536 |
| 537 SigninManagerFactory::GetForProfile(profile()) | 537 SigninManagerFactory::GetForProfile(profile()) |
| 538 ->SetAuthenticatedAccountInfo(kGaiaId, kEmail); | 538 ->SetAuthenticatedAccountInfo(kGaiaId, kEmail); |
| 539 IssueTestTokens(); | 539 IssueTestTokens(); |
| 540 PumpLoop(); | 540 PumpLoop(); |
| 541 | 541 |
| 542 // At this time, backup is finished. Task is posted to start sync again. | 542 // At this time, backup is finished. Task is posted to start sync again. |
| 543 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode()); | 543 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode()); |
| 544 EXPECT_FALSE(service()->SyncActive()); | 544 EXPECT_FALSE(service()->IsSyncActive()); |
| 545 EXPECT_EQ(1u, delete_dir_param.size()); | 545 EXPECT_EQ(1u, delete_dir_param.size()); |
| 546 EXPECT_TRUE(delete_dir_param[0]); | 546 EXPECT_TRUE(delete_dir_param[0]); |
| 547 | 547 |
| 548 // Pump loop to start sync. | 548 // Pump loop to start sync. |
| 549 PumpLoop(); | 549 PumpLoop(); |
| 550 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); | 550 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); |
| 551 EXPECT_TRUE(service()->SyncActive()); | 551 EXPECT_TRUE(service()->IsSyncActive()); |
| 552 EXPECT_EQ(2u, delete_dir_param.size()); | 552 EXPECT_EQ(2u, delete_dir_param.size()); |
| 553 EXPECT_TRUE(delete_dir_param[0]); | 553 EXPECT_TRUE(delete_dir_param[0]); |
| 554 } | 554 } |
| 555 | 555 |
| 556 // Test backup is done again on browser start if user signed in last session | 556 // Test backup is done again on browser start if user signed in last session |
| 557 // but backup didn't finish when last session was closed. | 557 // but backup didn't finish when last session was closed. |
| 558 TEST_F(ProfileSyncServiceTest, ResumeBackupIfAborted) { | 558 TEST_F(ProfileSyncServiceTest, ResumeBackupIfAborted) { |
| 559 IssueTestTokens(); | 559 IssueTestTokens(); |
| 560 CreateService(AUTO_START); | 560 CreateService(AUTO_START); |
| 561 ExpectDataTypeManagerCreation(2); | 561 ExpectDataTypeManagerCreation(2); |
| 562 std::vector<bool> delete_dir_param; | 562 std::vector<bool> delete_dir_param; |
| 563 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param); | 563 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param); |
| 564 InitializeForFirstSync(); | 564 InitializeForFirstSync(); |
| 565 PumpLoop(); | 565 PumpLoop(); |
| 566 | 566 |
| 567 // At this time, backup is finished. Task is posted to start sync again. | 567 // At this time, backup is finished. Task is posted to start sync again. |
| 568 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode()); | 568 EXPECT_EQ(ProfileSyncService::BACKUP, service()->backend_mode()); |
| 569 EXPECT_FALSE(service()->SyncActive()); | 569 EXPECT_FALSE(service()->IsSyncActive()); |
| 570 EXPECT_EQ(1u, delete_dir_param.size()); | 570 EXPECT_EQ(1u, delete_dir_param.size()); |
| 571 EXPECT_TRUE(delete_dir_param[0]); | 571 EXPECT_TRUE(delete_dir_param[0]); |
| 572 | 572 |
| 573 // Pump loop to start sync. | 573 // Pump loop to start sync. |
| 574 PumpLoop(); | 574 PumpLoop(); |
| 575 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); | 575 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); |
| 576 EXPECT_TRUE(service()->SyncActive()); | 576 EXPECT_TRUE(service()->IsSyncActive()); |
| 577 EXPECT_EQ(2u, delete_dir_param.size()); | 577 EXPECT_EQ(2u, delete_dir_param.size()); |
| 578 EXPECT_TRUE(delete_dir_param[0]); | 578 EXPECT_TRUE(delete_dir_param[0]); |
| 579 } | 579 } |
| 580 | 580 |
| 581 TEST_F(ProfileSyncServiceTest, Rollback) { | 581 TEST_F(ProfileSyncServiceTest, Rollback) { |
| 582 CreateService(browser_sync::MANUAL_START); | 582 CreateService(browser_sync::MANUAL_START); |
| 583 service()->SetSyncSetupCompleted(); | 583 service()->SetSyncSetupCompleted(); |
| 584 ExpectDataTypeManagerCreation(2); | 584 ExpectDataTypeManagerCreation(2); |
| 585 std::vector<bool> delete_dir_param; | 585 std::vector<bool> delete_dir_param; |
| 586 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param); | 586 ExpectSyncBackendHostCreationCollectDeleteDir(2, &delete_dir_param); |
| 587 IssueTestTokens(); | 587 IssueTestTokens(); |
| 588 InitializeForNthSync(); | 588 InitializeForNthSync(); |
| 589 EXPECT_TRUE(service()->SyncActive()); | 589 EXPECT_TRUE(service()->IsSyncActive()); |
| 590 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); | 590 EXPECT_EQ(ProfileSyncService::SYNC, service()->backend_mode()); |
| 591 | 591 |
| 592 // First sync time should be recorded. | 592 // First sync time should be recorded. |
| 593 sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs()); | 593 sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs()); |
| 594 base::Time first_sync_time = sync_prefs.GetFirstSyncTime(); | 594 base::Time first_sync_time = sync_prefs.GetFirstSyncTime(); |
| 595 EXPECT_FALSE(first_sync_time.is_null()); | 595 EXPECT_FALSE(first_sync_time.is_null()); |
| 596 | 596 |
| 597 syncer::SyncProtocolError client_cmd; | 597 syncer::SyncProtocolError client_cmd; |
| 598 client_cmd.action = syncer::DISABLE_SYNC_AND_ROLLBACK; | 598 client_cmd.action = syncer::DISABLE_SYNC_AND_ROLLBACK; |
| 599 service()->OnActionableError(client_cmd); | 599 service()->OnActionableError(client_cmd); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 629 ProfileSyncService::GetSyncServiceURL(command_line).spec()); | 629 ProfileSyncService::GetSyncServiceURL(command_line).spec()); |
| 630 } | 630 } |
| 631 | 631 |
| 632 // Verify that LastSyncedTime is cleared when the user signs out. | 632 // Verify that LastSyncedTime is cleared when the user signs out. |
| 633 TEST_F(ProfileSyncServiceTest, ClearLastSyncedTimeOnSignOut) { | 633 TEST_F(ProfileSyncServiceTest, ClearLastSyncedTimeOnSignOut) { |
| 634 IssueTestTokens(); | 634 IssueTestTokens(); |
| 635 CreateService(AUTO_START); | 635 CreateService(AUTO_START); |
| 636 ExpectDataTypeManagerCreation(1); | 636 ExpectDataTypeManagerCreation(1); |
| 637 ExpectSyncBackendHostCreation(1); | 637 ExpectSyncBackendHostCreation(1); |
| 638 InitializeForNthSync(); | 638 InitializeForNthSync(); |
| 639 EXPECT_TRUE(service()->SyncActive()); | 639 EXPECT_TRUE(service()->IsSyncActive()); |
| 640 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW), | 640 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW), |
| 641 service()->GetLastSyncedTimeString()); | 641 service()->GetLastSyncedTimeString()); |
| 642 | 642 |
| 643 // Sign out. | 643 // Sign out. |
| 644 service()->DisableForUser(); | 644 service()->DisableForUser(); |
| 645 PumpLoop(); | 645 PumpLoop(); |
| 646 | 646 |
| 647 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER), | 647 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER), |
| 648 service()->GetLastSyncedTimeString()); | 648 service()->GetLastSyncedTimeString()); |
| 649 } | 649 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 660 } | 660 } |
| 661 | 661 |
| 662 // Test Sync will stop after receive memory pressure | 662 // Test Sync will stop after receive memory pressure |
| 663 TEST_F(ProfileSyncServiceTest, MemoryPressureRecording) { | 663 TEST_F(ProfileSyncServiceTest, MemoryPressureRecording) { |
| 664 CreateService(browser_sync::AUTO_START); | 664 CreateService(browser_sync::AUTO_START); |
| 665 IssueTestTokens(); | 665 IssueTestTokens(); |
| 666 ExpectDataTypeManagerCreation(1); | 666 ExpectDataTypeManagerCreation(1); |
| 667 ExpectSyncBackendHostCreation(1); | 667 ExpectSyncBackendHostCreation(1); |
| 668 InitializeForNthSync(); | 668 InitializeForNthSync(); |
| 669 | 669 |
| 670 EXPECT_TRUE(service()->SyncActive()); | 670 EXPECT_TRUE(service()->IsSyncActive()); |
| 671 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( | 671 EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 672 sync_driver::prefs::kSyncSuppressStart)); | 672 sync_driver::prefs::kSyncSuppressStart)); |
| 673 | 673 |
| 674 testing::Mock::VerifyAndClearExpectations(components_factory()); | 674 testing::Mock::VerifyAndClearExpectations(components_factory()); |
| 675 | 675 |
| 676 sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs()); | 676 sync_driver::SyncPrefs sync_prefs(service()->profile()->GetPrefs()); |
| 677 | 677 |
| 678 EXPECT_EQ(profile()->GetPrefs()->GetInteger( | 678 EXPECT_EQ(profile()->GetPrefs()->GetInteger( |
| 679 sync_driver::prefs::kSyncMemoryPressureWarningCount), | 679 sync_driver::prefs::kSyncMemoryPressureWarningCount), |
| 680 0); | 680 0); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 699 | 699 |
| 700 // Verify memory pressure and shutdown recorded. | 700 // Verify memory pressure and shutdown recorded. |
| 701 EXPECT_EQ(profile()->GetPrefs()->GetInteger( | 701 EXPECT_EQ(profile()->GetPrefs()->GetInteger( |
| 702 sync_driver::prefs::kSyncMemoryPressureWarningCount), | 702 sync_driver::prefs::kSyncMemoryPressureWarningCount), |
| 703 2); | 703 2); |
| 704 EXPECT_TRUE(sync_prefs.DidSyncShutdownCleanly()); | 704 EXPECT_TRUE(sync_prefs.DidSyncShutdownCleanly()); |
| 705 } | 705 } |
| 706 | 706 |
| 707 } // namespace | 707 } // namespace |
| 708 } // namespace browser_sync | 708 } // namespace browser_sync |
| OLD | NEW |