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 "chrome/browser/ui/webui/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 TestingSyncSetupHandler(content::WebUI* web_ui, Profile* profile) | 324 TestingSyncSetupHandler(content::WebUI* web_ui, Profile* profile) |
325 : SyncSetupHandler(NULL), | 325 : SyncSetupHandler(NULL), |
326 profile_(profile) { | 326 profile_(profile) { |
327 set_web_ui(web_ui); | 327 set_web_ui(web_ui); |
328 } | 328 } |
329 ~TestingSyncSetupHandler() { | 329 ~TestingSyncSetupHandler() { |
330 set_web_ui(NULL); | 330 set_web_ui(NULL); |
331 } | 331 } |
332 | 332 |
333 virtual void ShowSetupUI() OVERRIDE {} | 333 virtual void ShowSetupUI() OVERRIDE {} |
| 334 virtual void FocusUI() OVERRIDE {} |
334 | 335 |
335 virtual Profile* GetProfile() const OVERRIDE { return profile_; } | 336 virtual Profile* GetProfile() const OVERRIDE { return profile_; } |
336 | 337 |
| 338 using SyncSetupHandler::is_configuring_sync; |
| 339 using SyncSetupHandler::have_signin_tracker; |
| 340 |
337 private: | 341 private: |
| 342 void DisplayGaiaLoginInNewTab() OVERRIDE {} |
| 343 |
338 // Weak pointer to parent profile. | 344 // Weak pointer to parent profile. |
339 Profile* profile_; | 345 Profile* profile_; |
340 DISALLOW_COPY_AND_ASSIGN(TestingSyncSetupHandler); | 346 DISALLOW_COPY_AND_ASSIGN(TestingSyncSetupHandler); |
341 }; | 347 }; |
342 | 348 |
343 class SigninManagerMock : public FakeSigninManager { | 349 class SigninManagerMock : public FakeSigninManager { |
344 public: | 350 public: |
345 explicit SigninManagerMock(Profile* profile) : FakeSigninManager(profile) {} | 351 explicit SigninManagerMock(Profile* profile) : FakeSigninManager(profile) {} |
346 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); | 352 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); |
347 }; | 353 }; |
348 | 354 |
349 static ProfileKeyedService* BuildSigninManagerMock(Profile* profile) { | 355 static ProfileKeyedService* BuildSigninManagerMock(Profile* profile) { |
350 return new SigninManagerMock(profile); | 356 return new SigninManagerMock(profile); |
351 } | 357 } |
352 | 358 |
353 // The boolean parameter indicates whether the test is run with ClientOAuth | 359 // The boolean parameter indicates whether the test is run with ClientOAuth |
354 // or not. | 360 // or not. The test parameter is a bool: whether or not to test with/ |
355 class SyncSetupHandlerTest : public testing::Test { | 361 // /ClientLogin enabled or not. |
| 362 class SyncSetupHandlerTest : public testing::TestWithParam<bool> { |
356 public: | 363 public: |
357 SyncSetupHandlerTest() : error_(GoogleServiceAuthError::NONE) {} | 364 SyncSetupHandlerTest() : error_(GoogleServiceAuthError::NONE) {} |
358 virtual void SetUp() OVERRIDE { | 365 virtual void SetUp() OVERRIDE { |
| 366 bool use_client_login_flow = GetParam(); |
| 367 if (use_client_login_flow) { |
| 368 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 369 switches::kUseClientLoginSigninFlow)) { |
| 370 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 371 switches::kUseClientLoginSigninFlow); |
| 372 } |
| 373 } else { |
| 374 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch( |
| 375 switches::kUseClientLoginSigninFlow)); |
| 376 } |
| 377 |
359 error_ = GoogleServiceAuthError::None(); | 378 error_ = GoogleServiceAuthError::None(); |
360 profile_.reset(ProfileSyncServiceMock::MakeSignedInTestingProfile()); | 379 profile_.reset(ProfileSyncServiceMock::MakeSignedInTestingProfile()); |
361 mock_pss_ = static_cast<ProfileSyncServiceMock*>( | 380 mock_pss_ = static_cast<ProfileSyncServiceMock*>( |
362 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 381 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
363 profile_.get(), | 382 profile_.get(), |
364 ProfileSyncServiceMock::BuildMockProfileSyncService)); | 383 ProfileSyncServiceMock::BuildMockProfileSyncService)); |
365 mock_pss_->Initialize(); | 384 mock_pss_->Initialize(); |
366 | 385 |
367 ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault( | 386 ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault( |
368 Return(syncer::IMPLICIT_PASSPHRASE)); | 387 Return(syncer::IMPLICIT_PASSPHRASE)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 scoped_ptr<Profile> profile_; | 437 scoped_ptr<Profile> profile_; |
419 ProfileSyncServiceMock* mock_pss_; | 438 ProfileSyncServiceMock* mock_pss_; |
420 GoogleServiceAuthError error_; | 439 GoogleServiceAuthError error_; |
421 // MessageLoop instance is required to work with OneShotTimer. | 440 // MessageLoop instance is required to work with OneShotTimer. |
422 MessageLoop message_loop_; | 441 MessageLoop message_loop_; |
423 SigninManagerMock* mock_signin_; | 442 SigninManagerMock* mock_signin_; |
424 TestWebUI web_ui_; | 443 TestWebUI web_ui_; |
425 scoped_ptr<TestingSyncSetupHandler> handler_; | 444 scoped_ptr<TestingSyncSetupHandler> handler_; |
426 }; | 445 }; |
427 | 446 |
428 TEST_F(SyncSetupHandlerTest, Basic) { | 447 TEST_P(SyncSetupHandlerTest, Basic) { |
429 } | 448 } |
430 | 449 |
431 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { | 450 TEST_P(SyncSetupHandlerTest, DisplayBasicLogin) { |
432 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 451 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
433 .WillRepeatedly(Return(false)); | 452 .WillRepeatedly(Return(false)); |
434 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 453 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
435 .WillRepeatedly(Return(false)); | 454 .WillRepeatedly(Return(false)); |
436 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 455 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
437 .WillRepeatedly(Return(false)); | 456 .WillRepeatedly(Return(false)); |
438 handler_->OpenSyncSetup(false); | 457 handler_->OpenSyncSetup(false); |
439 EXPECT_EQ(handler_.get(), | 458 EXPECT_EQ(handler_.get(), |
440 LoginUIServiceFactory::GetForProfile( | 459 LoginUIServiceFactory::GetForProfile( |
441 profile_.get())->current_login_ui()); | 460 profile_.get())->current_login_ui()); |
442 ASSERT_EQ(1U, web_ui_.call_data().size()); | 461 |
443 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 462 if (!SyncPromoUI::UseWebBasedSigninFlow()) { |
444 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 463 ASSERT_EQ(1U, web_ui_.call_data().size()); |
445 std::string page; | 464 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
446 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 465 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
447 EXPECT_EQ(page, "login"); | 466 std::string page; |
448 // Now make sure that the appropriate params are being passed. | 467 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
449 DictionaryValue* dictionary; | 468 EXPECT_EQ(page, "login"); |
450 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 469 // Now make sure that the appropriate params are being passed. |
451 CheckShowSyncSetupArgs( | 470 DictionaryValue* dictionary; |
452 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); | 471 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 472 CheckShowSyncSetupArgs( |
| 473 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); |
| 474 } else { |
| 475 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 476 ASSERT_TRUE(handler_->have_signin_tracker()); |
| 477 } |
| 478 |
453 handler_->CloseSyncSetup(); | 479 handler_->CloseSyncSetup(); |
454 EXPECT_EQ(NULL, | 480 EXPECT_EQ(NULL, |
455 LoginUIServiceFactory::GetForProfile( | 481 LoginUIServiceFactory::GetForProfile( |
456 profile_.get())->current_login_ui()); | 482 profile_.get())->current_login_ui()); |
457 } | 483 } |
458 | 484 |
459 TEST_F(SyncSetupHandlerTest, DisplayForceLogin) { | 485 TEST_P(SyncSetupHandlerTest, DisplayForceLogin) { |
460 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 486 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
461 .WillRepeatedly(Return(false)); | 487 .WillRepeatedly(Return(false)); |
462 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 488 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
463 .WillRepeatedly(Return(false)); | 489 .WillRepeatedly(Return(false)); |
464 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 490 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
465 .WillRepeatedly(Return(true)); | 491 .WillRepeatedly(Return(true)); |
466 // This should display the login UI even though sync setup has already | 492 // This should display the login UI even though sync setup has already |
467 // completed. | 493 // completed. |
468 handler_->OpenSyncSetup(true); | 494 handler_->OpenSyncSetup(true); |
469 EXPECT_EQ(handler_.get(), | 495 EXPECT_EQ(handler_.get(), |
470 LoginUIServiceFactory::GetForProfile( | 496 LoginUIServiceFactory::GetForProfile( |
471 profile_.get())->current_login_ui()); | 497 profile_.get())->current_login_ui()); |
472 ASSERT_EQ(1U, web_ui_.call_data().size()); | 498 |
473 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 499 if (!SyncPromoUI::UseWebBasedSigninFlow()) { |
474 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 500 ASSERT_EQ(1U, web_ui_.call_data().size()); |
475 std::string page; | 501 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
476 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 502 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
477 EXPECT_EQ(page, "login"); | 503 std::string page; |
478 // Now make sure that the appropriate params are being passed. | 504 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
479 DictionaryValue* dictionary; | 505 EXPECT_EQ(page, "login"); |
480 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 506 // Now make sure that the appropriate params are being passed. |
481 CheckShowSyncSetupArgs( | 507 DictionaryValue* dictionary; |
482 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); | 508 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 509 CheckShowSyncSetupArgs( |
| 510 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); |
| 511 } else { |
| 512 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 513 ASSERT_TRUE(handler_->have_signin_tracker()); |
| 514 } |
| 515 |
483 handler_->CloseSyncSetup(); | 516 handler_->CloseSyncSetup(); |
484 EXPECT_EQ(NULL, | 517 EXPECT_EQ(NULL, |
485 LoginUIServiceFactory::GetForProfile( | 518 LoginUIServiceFactory::GetForProfile( |
486 profile_.get())->current_login_ui()); | 519 profile_.get())->current_login_ui()); |
487 } | 520 } |
488 | 521 |
489 // Verifies that the handler correctly handles a cancellation when | 522 // Verifies that the handler correctly handles a cancellation when |
490 // it is displaying the spinner to the user. | 523 // it is displaying the spinner to the user. |
491 TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { | 524 TEST_P(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { |
492 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 525 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
493 .WillRepeatedly(Return(true)); | 526 .WillRepeatedly(Return(true)); |
494 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 527 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
495 .WillRepeatedly(Return(true)); | 528 .WillRepeatedly(Return(true)); |
496 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 529 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
497 .WillRepeatedly(Return(false)); | 530 .WillRepeatedly(Return(false)); |
498 error_ = GoogleServiceAuthError::None(); | 531 error_ = GoogleServiceAuthError::None(); |
499 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 532 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
500 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 533 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); |
501 | 534 |
(...skipping 14 matching lines...) Expand all Loading... |
516 EXPECT_EQ(page, "spinner"); | 549 EXPECT_EQ(page, "spinner"); |
517 // Cancelling the spinner dialog will cause CloseSyncSetup(). | 550 // Cancelling the spinner dialog will cause CloseSyncSetup(). |
518 handler_->CloseSyncSetup(); | 551 handler_->CloseSyncSetup(); |
519 EXPECT_EQ(NULL, | 552 EXPECT_EQ(NULL, |
520 LoginUIServiceFactory::GetForProfile( | 553 LoginUIServiceFactory::GetForProfile( |
521 profile_.get())->current_login_ui()); | 554 profile_.get())->current_login_ui()); |
522 } | 555 } |
523 | 556 |
524 // Verifies that the handler correctly transitions from showing the spinner | 557 // Verifies that the handler correctly transitions from showing the spinner |
525 // to showing a configuration page when signin completes successfully. | 558 // to showing a configuration page when signin completes successfully. |
526 TEST_F(SyncSetupHandlerTest, | 559 TEST_P(SyncSetupHandlerTest, |
527 DisplayConfigureWithBackendDisabledAndSigninSuccess) { | 560 DisplayConfigureWithBackendDisabledAndSigninSuccess) { |
528 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 561 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
529 .WillRepeatedly(Return(true)); | 562 .WillRepeatedly(Return(true)); |
530 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 563 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
531 .WillRepeatedly(Return(true)); | 564 .WillRepeatedly(Return(true)); |
532 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 565 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
533 .WillRepeatedly(Return(false)); | 566 .WillRepeatedly(Return(false)); |
534 error_ = GoogleServiceAuthError::None(); | 567 error_ = GoogleServiceAuthError::None(); |
535 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 568 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
536 // Sync backend is stopped initially, and will start up. | 569 // Sync backend is stopped initially, and will start up. |
(...skipping 27 matching lines...) Expand all Loading... |
564 CheckBool(dictionary, "syncAllDataTypes", true); | 597 CheckBool(dictionary, "syncAllDataTypes", true); |
565 CheckBool(dictionary, "encryptAllData", false); | 598 CheckBool(dictionary, "encryptAllData", false); |
566 CheckBool(dictionary, "usePassphrase", false); | 599 CheckBool(dictionary, "usePassphrase", false); |
567 } | 600 } |
568 | 601 |
569 // Verifies the case where the user cancels after the sync backend has | 602 // Verifies the case where the user cancels after the sync backend has |
570 // initialized (meaning it already transitioned from the spinner to a proper | 603 // initialized (meaning it already transitioned from the spinner to a proper |
571 // configuration page, tested by | 604 // configuration page, tested by |
572 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user | 605 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user |
573 // before the user has continued on. | 606 // before the user has continued on. |
574 TEST_F(SyncSetupHandlerTest, | 607 TEST_P(SyncSetupHandlerTest, |
575 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { | 608 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { |
576 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 609 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
577 .WillRepeatedly(Return(true)); | 610 .WillRepeatedly(Return(true)); |
578 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 611 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
579 .WillRepeatedly(Return(true)); | 612 .WillRepeatedly(Return(true)); |
580 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 613 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
581 .WillRepeatedly(Return(false)); | 614 .WillRepeatedly(Return(false)); |
582 error_ = GoogleServiceAuthError::None(); | 615 error_ = GoogleServiceAuthError::None(); |
583 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 616 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
584 EXPECT_CALL(*mock_pss_, sync_initialized()) | 617 EXPECT_CALL(*mock_pss_, sync_initialized()) |
585 .WillOnce(Return(false)) | 618 .WillOnce(Return(false)) |
586 .WillRepeatedly(Return(true)); | 619 .WillRepeatedly(Return(true)); |
587 SetDefaultExpectationsForConfigPage(); | 620 SetDefaultExpectationsForConfigPage(); |
588 handler_->OpenSyncSetup(false); | 621 handler_->OpenSyncSetup(false); |
589 handler_->SigninSuccess(); | 622 handler_->SigninSuccess(); |
590 | 623 |
591 // It's important to tell sync the user cancelled the setup flow before we | 624 // It's important to tell sync the user cancelled the setup flow before we |
592 // tell it we're through with the setup progress. | 625 // tell it we're through with the setup progress. |
593 testing::InSequence seq; | 626 testing::InSequence seq; |
594 EXPECT_CALL(*mock_pss_, DisableForUser()); | 627 EXPECT_CALL(*mock_pss_, DisableForUser()); |
595 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); | 628 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); |
596 | 629 |
597 handler_->CloseSyncSetup(); | 630 handler_->CloseSyncSetup(); |
598 EXPECT_EQ(NULL, | 631 EXPECT_EQ(NULL, |
599 LoginUIServiceFactory::GetForProfile( | 632 LoginUIServiceFactory::GetForProfile( |
600 profile_.get())->current_login_ui()); | 633 profile_.get())->current_login_ui()); |
601 } | 634 } |
602 | 635 |
603 TEST_F(SyncSetupHandlerTest, | 636 TEST_P(SyncSetupHandlerTest, |
604 DisplayConfigureWithBackendDisabledAndSigninFalied) { | 637 DisplayConfigureWithBackendDisabledAndSigninFalied) { |
605 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 638 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
606 .WillRepeatedly(Return(true)); | 639 .WillRepeatedly(Return(true)); |
607 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 640 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
608 .WillRepeatedly(Return(true)); | 641 .WillRepeatedly(Return(true)); |
609 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 642 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
610 .WillRepeatedly(Return(false)); | 643 .WillRepeatedly(Return(false)); |
611 error_ = GoogleServiceAuthError::None(); | 644 error_ = GoogleServiceAuthError::None(); |
612 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 645 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
613 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 646 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); |
614 | 647 |
615 handler_->OpenSyncSetup(false); | 648 handler_->OpenSyncSetup(false); |
616 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 649 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
617 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 650 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
618 std::string page; | 651 std::string page; |
619 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 652 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
620 EXPECT_EQ(page, "spinner"); | 653 EXPECT_EQ(page, "spinner"); |
621 GoogleServiceAuthError error( | 654 GoogleServiceAuthError error( |
622 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 655 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
623 handler_->SigninFailed(error); | 656 handler_->SigninFailed(error); |
624 // On failure, the dialog will be closed. | 657 // On failure, the dialog will be closed. |
625 EXPECT_EQ(NULL, | 658 EXPECT_EQ(NULL, |
626 LoginUIServiceFactory::GetForProfile( | 659 LoginUIServiceFactory::GetForProfile( |
627 profile_.get())->current_login_ui()); | 660 profile_.get())->current_login_ui()); |
628 } | 661 } |
629 | 662 |
630 TEST_F(SyncSetupHandlerTest, HandleGaiaAuthFailure) { | 663 TEST_P(SyncSetupHandlerTest, HandleGaiaAuthFailure) { |
631 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 664 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
632 .WillRepeatedly(Return(false)); | 665 .WillRepeatedly(Return(false)); |
633 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 666 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
634 .WillRepeatedly(Return(false)); | 667 .WillRepeatedly(Return(false)); |
635 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 668 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
636 .WillRepeatedly(Return(false)); | 669 .WillRepeatedly(Return(false)); |
637 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 670 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
638 .WillRepeatedly(Return(false)); | 671 .WillRepeatedly(Return(false)); |
639 // Open the web UI. | 672 // Open the web UI. |
640 handler_->OpenSyncSetup(false); | 673 handler_->OpenSyncSetup(false); |
641 // Fake a failed signin attempt. | 674 |
642 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 675 if (!SyncPromoUI::UseWebBasedSigninFlow()) { |
643 GoogleServiceAuthError error( | 676 // Fake a failed signin attempt. |
644 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 677 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
645 handler_->SigninFailed(error); | 678 GoogleServiceAuthError error( |
646 ASSERT_EQ(2U, web_ui_.call_data().size()); | 679 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
647 // Validate the second JS call (the first call was already tested by | 680 handler_->SigninFailed(error); |
648 // the DisplayBasicLogin test). | 681 |
649 const TestWebUI::CallData& data = web_ui_.call_data()[1]; | 682 ASSERT_EQ(2U, web_ui_.call_data().size()); |
650 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 683 // Validate the second JS call (the first call was already tested by |
651 std::string page; | 684 // the DisplayBasicLogin test). |
652 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 685 const TestWebUI::CallData& data = web_ui_.call_data()[1]; |
653 EXPECT_EQ(page, "login"); | 686 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
654 // Now make sure that the appropriate params are being passed. | 687 std::string page; |
655 DictionaryValue* dictionary; | 688 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
656 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 689 EXPECT_EQ(page, "login"); |
657 CheckShowSyncSetupArgs( | 690 // Now make sure that the appropriate params are being passed. |
658 dictionary, "", false, GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, | 691 DictionaryValue* dictionary; |
659 kTestUser, true, ""); | 692 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 693 CheckShowSyncSetupArgs( |
| 694 dictionary, "", false, GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, |
| 695 kTestUser, true, ""); |
| 696 } else { |
| 697 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 698 ASSERT_TRUE(handler_->have_signin_tracker()); |
| 699 } |
660 } | 700 } |
661 | 701 |
662 TEST_F(SyncSetupHandlerTest, HandleCaptcha) { | 702 TEST_P(SyncSetupHandlerTest, HandleCaptcha) { |
663 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 703 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
664 .WillRepeatedly(Return(false)); | 704 .WillRepeatedly(Return(false)); |
665 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 705 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
666 .WillRepeatedly(Return(false)); | 706 .WillRepeatedly(Return(false)); |
667 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 707 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
668 .WillRepeatedly(Return(false)); | 708 .WillRepeatedly(Return(false)); |
669 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 709 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
670 .WillRepeatedly(Return(false)); | 710 .WillRepeatedly(Return(false)); |
671 // Open the web UI. | 711 // Open the web UI. |
672 handler_->OpenSyncSetup(false); | 712 handler_->OpenSyncSetup(false); |
673 // Fake a failed signin attempt that requires a captcha. | 713 |
674 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 714 if (!SyncPromoUI::UseWebBasedSigninFlow()) { |
675 GoogleServiceAuthError error = | 715 // Fake a failed signin attempt that requires a captcha. |
676 GoogleServiceAuthError::FromClientLoginCaptchaChallenge( | 716 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
677 "token", GURL(kTestCaptchaImageUrl), GURL(kTestCaptchaUnlockUrl)); | 717 GoogleServiceAuthError error = |
678 handler_->SigninFailed(error); | 718 GoogleServiceAuthError::FromClientLoginCaptchaChallenge( |
679 ASSERT_EQ(2U, web_ui_.call_data().size()); | 719 "token", GURL(kTestCaptchaImageUrl), GURL(kTestCaptchaUnlockUrl)); |
680 // Validate the second JS call (the first call was already tested by | 720 handler_->SigninFailed(error); |
681 // the DisplayBasicLogin test). | 721 ASSERT_EQ(2U, web_ui_.call_data().size()); |
682 const TestWebUI::CallData& data = web_ui_.call_data()[1]; | 722 // Validate the second JS call (the first call was already tested by |
683 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 723 // the DisplayBasicLogin test). |
684 std::string page; | 724 const TestWebUI::CallData& data = web_ui_.call_data()[1]; |
685 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 725 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
686 EXPECT_EQ(page, "login"); | 726 std::string page; |
687 // Now make sure that the appropriate params are being passed. | 727 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
688 DictionaryValue* dictionary; | 728 EXPECT_EQ(page, "login"); |
689 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 729 // Now make sure that the appropriate params are being passed. |
690 CheckShowSyncSetupArgs( | 730 DictionaryValue* dictionary; |
691 dictionary, "", false, GoogleServiceAuthError::CAPTCHA_REQUIRED, | 731 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
692 kTestUser, true, kTestCaptchaImageUrl); | 732 CheckShowSyncSetupArgs( |
| 733 dictionary, "", false, GoogleServiceAuthError::CAPTCHA_REQUIRED, |
| 734 kTestUser, true, kTestCaptchaImageUrl); |
| 735 } else { |
| 736 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 737 ASSERT_TRUE(handler_->have_signin_tracker()); |
| 738 } |
693 } | 739 } |
694 | 740 |
695 // TODO(kochi): We need equivalent tests for ChromeOS. | 741 // TODO(kochi): We need equivalent tests for ChromeOS. |
696 TEST_F(SyncSetupHandlerTest, UnrecoverableErrorInitializingSync) { | 742 TEST_P(SyncSetupHandlerTest, UnrecoverableErrorInitializingSync) { |
697 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 743 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
698 .WillRepeatedly(Return(false)); | 744 .WillRepeatedly(Return(false)); |
699 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 745 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
700 .WillRepeatedly(Return(false)); | 746 .WillRepeatedly(Return(false)); |
701 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 747 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
702 .WillRepeatedly(Return(false)); | 748 .WillRepeatedly(Return(false)); |
703 // Open the web UI. | 749 // Open the web UI. |
704 handler_->OpenSyncSetup(false); | 750 handler_->OpenSyncSetup(false); |
705 ASSERT_EQ(1U, web_ui_.call_data().size()); | 751 |
706 // Fake a successful GAIA request (gaia credentials valid, but signin not | 752 if (!SyncPromoUI::UseWebBasedSigninFlow()) { |
707 // complete yet). | 753 ASSERT_EQ(1U, web_ui_.call_data().size()); |
708 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 754 // Fake a successful GAIA request (gaia credentials valid, but signin not |
709 handler_->GaiaCredentialsValid(); | 755 // complete yet). |
710 ASSERT_EQ(2U, web_ui_.call_data().size()); | 756 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
711 EXPECT_EQ("SyncSetupOverlay.showSuccessAndSettingUp", | 757 handler_->GaiaCredentialsValid(); |
712 web_ui_.call_data()[1].function_name); | 758 ASSERT_EQ(2U, web_ui_.call_data().size()); |
713 // Now fake a sync error. | 759 EXPECT_EQ("SyncSetupOverlay.showSuccessAndSettingUp", |
714 GoogleServiceAuthError none(GoogleServiceAuthError::NONE); | 760 web_ui_.call_data()[1].function_name); |
715 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 761 // Now fake a sync error. |
716 .WillRepeatedly(Return(true)); | 762 GoogleServiceAuthError none(GoogleServiceAuthError::NONE); |
717 mock_signin_->SignOut(); | 763 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
718 handler_->SigninFailed(none); | 764 .WillRepeatedly(Return(true)); |
719 ASSERT_EQ(3U, web_ui_.call_data().size()); | 765 mock_signin_->SignOut(); |
720 // Validate the second JS call (the first call was already tested by | 766 handler_->SigninFailed(none); |
721 // the DisplayBasicLogin test). | 767 ASSERT_EQ(3U, web_ui_.call_data().size()); |
722 const TestWebUI::CallData& data = web_ui_.call_data()[2]; | 768 // Validate the second JS call (the first call was already tested by |
723 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 769 // the DisplayBasicLogin test). |
724 std::string page; | 770 const TestWebUI::CallData& data = web_ui_.call_data()[2]; |
725 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 771 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
726 EXPECT_EQ(page, "login"); | 772 std::string page; |
727 // Now make sure that the appropriate params are being passed. | 773 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
728 DictionaryValue* dictionary; | 774 EXPECT_EQ(page, "login"); |
729 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 775 // Now make sure that the appropriate params are being passed. |
730 CheckShowSyncSetupArgs( | 776 DictionaryValue* dictionary; |
731 dictionary, "", true, GoogleServiceAuthError::NONE, | 777 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
732 kTestUser, true, ""); | 778 CheckShowSyncSetupArgs( |
| 779 dictionary, "", true, GoogleServiceAuthError::NONE, |
| 780 kTestUser, true, ""); |
| 781 } else { |
| 782 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 783 ASSERT_TRUE(handler_->have_signin_tracker()); |
| 784 } |
733 } | 785 } |
734 | 786 |
735 TEST_F(SyncSetupHandlerTest, GaiaErrorInitializingSync) { | 787 TEST_P(SyncSetupHandlerTest, GaiaErrorInitializingSync) { |
736 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 788 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
737 .WillRepeatedly(Return(false)); | 789 .WillRepeatedly(Return(false)); |
738 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 790 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
739 .WillRepeatedly(Return(false)); | 791 .WillRepeatedly(Return(false)); |
740 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 792 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
741 .WillRepeatedly(Return(false)); | 793 .WillRepeatedly(Return(false)); |
742 // Open the web UI. | 794 // Open the web UI. |
743 handler_->OpenSyncSetup(false); | 795 handler_->OpenSyncSetup(false); |
744 ASSERT_EQ(1U, web_ui_.call_data().size()); | 796 |
745 // Fake a successful GAIA request (gaia credentials valid, but signin not | 797 if (!SyncPromoUI::UseWebBasedSigninFlow()) { |
746 // complete yet). | 798 ASSERT_EQ(1U, web_ui_.call_data().size()); |
747 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 799 // Fake a successful GAIA request (gaia credentials valid, but signin not |
748 handler_->GaiaCredentialsValid(); | 800 // complete yet). |
749 ASSERT_EQ(2U, web_ui_.call_data().size()); | 801 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
750 EXPECT_EQ("SyncSetupOverlay.showSuccessAndSettingUp", | 802 handler_->GaiaCredentialsValid(); |
751 web_ui_.call_data()[1].function_name); | 803 ASSERT_EQ(2U, web_ui_.call_data().size()); |
752 // Now fake a sync gaia error. | 804 EXPECT_EQ("SyncSetupOverlay.showSuccessAndSettingUp", |
753 GoogleServiceAuthError unavailable( | 805 web_ui_.call_data()[1].function_name); |
754 GoogleServiceAuthError::SERVICE_UNAVAILABLE); | 806 // Now fake a sync gaia error. |
755 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 807 GoogleServiceAuthError unavailable( |
756 .WillRepeatedly(Return(false)); | 808 GoogleServiceAuthError::SERVICE_UNAVAILABLE); |
757 mock_signin_->SignOut(); | 809 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
758 handler_->SigninFailed(unavailable); | 810 .WillRepeatedly(Return(false)); |
759 ASSERT_EQ(3U, web_ui_.call_data().size()); | 811 mock_signin_->SignOut(); |
760 // Validate the second JS call (the first call was already tested by | 812 handler_->SigninFailed(unavailable); |
761 // the DisplayBasicLogin test). | 813 ASSERT_EQ(3U, web_ui_.call_data().size()); |
762 const TestWebUI::CallData& data = web_ui_.call_data()[2]; | 814 // Validate the second JS call (the first call was already tested by |
763 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 815 // the DisplayBasicLogin test). |
764 std::string page; | 816 const TestWebUI::CallData& data = web_ui_.call_data()[2]; |
765 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 817 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
766 EXPECT_EQ(page, "login"); | 818 std::string page; |
767 // Now make sure that the appropriate params are being passed. | 819 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
768 DictionaryValue* dictionary; | 820 EXPECT_EQ(page, "login"); |
769 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 821 // Now make sure that the appropriate params are being passed. |
770 CheckShowSyncSetupArgs( | 822 DictionaryValue* dictionary; |
771 dictionary, "", false, GoogleServiceAuthError::SERVICE_UNAVAILABLE, | 823 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
772 kTestUser, true, ""); | 824 CheckShowSyncSetupArgs( |
| 825 dictionary, "", false, GoogleServiceAuthError::SERVICE_UNAVAILABLE, |
| 826 kTestUser, true, ""); |
| 827 } else { |
| 828 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 829 ASSERT_TRUE(handler_->have_signin_tracker()); |
| 830 } |
773 } | 831 } |
774 | 832 |
775 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { | 833 TEST_P(SyncSetupHandlerTest, TestSyncEverything) { |
776 std::string args = GetConfiguration( | 834 std::string args = GetConfiguration( |
777 NULL, SYNC_ALL_DATA, GetAllTypes(), "", ENCRYPT_PASSWORDS); | 835 NULL, SYNC_ALL_DATA, GetAllTypes(), "", ENCRYPT_PASSWORDS); |
778 ListValue list_args; | 836 ListValue list_args; |
779 list_args.Append(new StringValue(args)); | 837 list_args.Append(new StringValue(args)); |
780 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 838 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
781 .WillRepeatedly(Return(false)); | 839 .WillRepeatedly(Return(false)); |
782 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 840 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
783 .WillRepeatedly(Return(false)); | 841 .WillRepeatedly(Return(false)); |
784 SetupInitializedProfileSyncService(); | 842 SetupInitializedProfileSyncService(); |
785 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 843 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
786 handler_->HandleConfigure(&list_args); | 844 handler_->HandleConfigure(&list_args); |
787 | 845 |
788 // Ensure that we navigated to the "done" state since we don't need a | 846 // Ensure that we navigated to the "done" state since we don't need a |
789 // passphrase. | 847 // passphrase. |
790 ExpectDone(); | 848 ExpectDone(); |
791 } | 849 } |
792 | 850 |
793 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { | 851 TEST_P(SyncSetupHandlerTest, TurnOnEncryptAll) { |
794 std::string args = GetConfiguration( | 852 std::string args = GetConfiguration( |
795 NULL, SYNC_ALL_DATA, GetAllTypes(), "", ENCRYPT_ALL_DATA); | 853 NULL, SYNC_ALL_DATA, GetAllTypes(), "", ENCRYPT_ALL_DATA); |
796 ListValue list_args; | 854 ListValue list_args; |
797 list_args.Append(new StringValue(args)); | 855 list_args.Append(new StringValue(args)); |
798 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 856 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
799 .WillRepeatedly(Return(false)); | 857 .WillRepeatedly(Return(false)); |
800 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 858 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
801 .WillRepeatedly(Return(false)); | 859 .WillRepeatedly(Return(false)); |
802 SetupInitializedProfileSyncService(); | 860 SetupInitializedProfileSyncService(); |
803 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); | 861 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); |
804 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 862 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
805 handler_->HandleConfigure(&list_args); | 863 handler_->HandleConfigure(&list_args); |
806 | 864 |
807 // Ensure that we navigated to the "done" state since we don't need a | 865 // Ensure that we navigated to the "done" state since we don't need a |
808 // passphrase. | 866 // passphrase. |
809 ExpectDone(); | 867 ExpectDone(); |
810 } | 868 } |
811 | 869 |
812 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { | 870 TEST_P(SyncSetupHandlerTest, TestPassphraseStillRequired) { |
813 std::string args = GetConfiguration( | 871 std::string args = GetConfiguration( |
814 NULL, SYNC_ALL_DATA, GetAllTypes(), "", ENCRYPT_PASSWORDS); | 872 NULL, SYNC_ALL_DATA, GetAllTypes(), "", ENCRYPT_PASSWORDS); |
815 ListValue list_args; | 873 ListValue list_args; |
816 list_args.Append(new StringValue(args)); | 874 list_args.Append(new StringValue(args)); |
817 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 875 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
818 .WillRepeatedly(Return(true)); | 876 .WillRepeatedly(Return(true)); |
819 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 877 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
820 .WillRepeatedly(Return(true)); | 878 .WillRepeatedly(Return(true)); |
821 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 879 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
822 .WillRepeatedly(Return(false)); | 880 .WillRepeatedly(Return(false)); |
823 SetupInitializedProfileSyncService(); | 881 SetupInitializedProfileSyncService(); |
824 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 882 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
825 SetDefaultExpectationsForConfigPage(); | 883 SetDefaultExpectationsForConfigPage(); |
826 | 884 |
827 // We should navigate back to the configure page since we need a passphrase. | 885 // We should navigate back to the configure page since we need a passphrase. |
828 handler_->HandleConfigure(&list_args); | 886 handler_->HandleConfigure(&list_args); |
829 | 887 |
830 ExpectConfig(); | 888 ExpectConfig(); |
831 } | 889 } |
832 | 890 |
833 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { | 891 TEST_P(SyncSetupHandlerTest, SuccessfullySetPassphrase) { |
834 DictionaryValue dict; | 892 DictionaryValue dict; |
835 dict.SetBoolean("isGooglePassphrase", true); | 893 dict.SetBoolean("isGooglePassphrase", true); |
836 std::string args = GetConfiguration(&dict, | 894 std::string args = GetConfiguration(&dict, |
837 SYNC_ALL_DATA, | 895 SYNC_ALL_DATA, |
838 GetAllTypes(), | 896 GetAllTypes(), |
839 "gaiaPassphrase", | 897 "gaiaPassphrase", |
840 ENCRYPT_PASSWORDS); | 898 ENCRYPT_PASSWORDS); |
841 ListValue list_args; | 899 ListValue list_args; |
842 list_args.Append(new StringValue(args)); | 900 list_args.Append(new StringValue(args)); |
843 // Act as if an encryption passphrase is required the first time, then never | 901 // Act as if an encryption passphrase is required the first time, then never |
844 // again after that. | 902 // again after that. |
845 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); | 903 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); |
846 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 904 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
847 .WillRepeatedly(Return(false)); | 905 .WillRepeatedly(Return(false)); |
848 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 906 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
849 .WillRepeatedly(Return(false)); | 907 .WillRepeatedly(Return(false)); |
850 SetupInitializedProfileSyncService(); | 908 SetupInitializedProfileSyncService(); |
851 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 909 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
852 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). | 910 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). |
853 WillOnce(Return(true)); | 911 WillOnce(Return(true)); |
854 | 912 |
855 handler_->HandleConfigure(&list_args); | 913 handler_->HandleConfigure(&list_args); |
856 // We should navigate to "done" page since we finished configuring. | 914 // We should navigate to "done" page since we finished configuring. |
857 ExpectDone(); | 915 ExpectDone(); |
858 } | 916 } |
859 | 917 |
860 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { | 918 TEST_P(SyncSetupHandlerTest, SelectCustomEncryption) { |
861 DictionaryValue dict; | 919 DictionaryValue dict; |
862 dict.SetBoolean("isGooglePassphrase", false); | 920 dict.SetBoolean("isGooglePassphrase", false); |
863 std::string args = GetConfiguration(&dict, | 921 std::string args = GetConfiguration(&dict, |
864 SYNC_ALL_DATA, | 922 SYNC_ALL_DATA, |
865 GetAllTypes(), | 923 GetAllTypes(), |
866 "custom_passphrase", | 924 "custom_passphrase", |
867 ENCRYPT_PASSWORDS); | 925 ENCRYPT_PASSWORDS); |
868 ListValue list_args; | 926 ListValue list_args; |
869 list_args.Append(new StringValue(args)); | 927 list_args.Append(new StringValue(args)); |
870 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 928 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
871 .WillRepeatedly(Return(false)); | 929 .WillRepeatedly(Return(false)); |
872 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 930 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
873 .WillRepeatedly(Return(false)); | 931 .WillRepeatedly(Return(false)); |
874 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 932 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
875 .WillRepeatedly(Return(false)); | 933 .WillRepeatedly(Return(false)); |
876 SetupInitializedProfileSyncService(); | 934 SetupInitializedProfileSyncService(); |
877 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 935 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
878 EXPECT_CALL(*mock_pss_, | 936 EXPECT_CALL(*mock_pss_, |
879 SetEncryptionPassphrase("custom_passphrase", | 937 SetEncryptionPassphrase("custom_passphrase", |
880 ProfileSyncService::EXPLICIT)); | 938 ProfileSyncService::EXPLICIT)); |
881 | 939 |
882 handler_->HandleConfigure(&list_args); | 940 handler_->HandleConfigure(&list_args); |
883 // We should navigate to "done" page since we finished configuring. | 941 // We should navigate to "done" page since we finished configuring. |
884 ExpectDone(); | 942 ExpectDone(); |
885 } | 943 } |
886 | 944 |
887 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { | 945 TEST_P(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { |
888 DictionaryValue dict; | 946 DictionaryValue dict; |
889 dict.SetBoolean("isGooglePassphrase", true); | 947 dict.SetBoolean("isGooglePassphrase", true); |
890 std::string args = GetConfiguration(&dict, | 948 std::string args = GetConfiguration(&dict, |
891 SYNC_ALL_DATA, | 949 SYNC_ALL_DATA, |
892 GetAllTypes(), | 950 GetAllTypes(), |
893 "invalid_passphrase", | 951 "invalid_passphrase", |
894 ENCRYPT_PASSWORDS); | 952 ENCRYPT_PASSWORDS); |
895 ListValue list_args; | 953 ListValue list_args; |
896 list_args.Append(new StringValue(args)); | 954 list_args.Append(new StringValue(args)); |
897 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 955 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
(...skipping 16 matching lines...) Expand all Loading... |
914 // Make sure we display an error message to the user due to the failed | 972 // Make sure we display an error message to the user due to the failed |
915 // passphrase. | 973 // passphrase. |
916 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 974 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
917 DictionaryValue* dictionary; | 975 DictionaryValue* dictionary; |
918 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 976 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
919 CheckBool(dictionary, "passphraseFailed", true); | 977 CheckBool(dictionary, "passphraseFailed", true); |
920 } | 978 } |
921 | 979 |
922 // Walks through each user selectable type, and tries to sync just that single | 980 // Walks through each user selectable type, and tries to sync just that single |
923 // data type. | 981 // data type. |
924 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { | 982 TEST_P(SyncSetupHandlerTest, TestSyncIndividualTypes) { |
925 for (size_t i = 0; i < arraysize(kUserSelectableTypes); ++i) { | 983 for (size_t i = 0; i < arraysize(kUserSelectableTypes); ++i) { |
926 syncer::ModelTypeSet type_to_set; | 984 syncer::ModelTypeSet type_to_set; |
927 type_to_set.Put(kUserSelectableTypes[i]); | 985 type_to_set.Put(kUserSelectableTypes[i]); |
928 std::string args = GetConfiguration( | 986 std::string args = GetConfiguration( |
929 NULL, CHOOSE_WHAT_TO_SYNC, type_to_set, "", ENCRYPT_PASSWORDS); | 987 NULL, CHOOSE_WHAT_TO_SYNC, type_to_set, "", ENCRYPT_PASSWORDS); |
930 ListValue list_args; | 988 ListValue list_args; |
931 list_args.Append(new StringValue(args)); | 989 list_args.Append(new StringValue(args)); |
932 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 990 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
933 .WillRepeatedly(Return(false)); | 991 .WillRepeatedly(Return(false)); |
934 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 992 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
935 .WillRepeatedly(Return(false)); | 993 .WillRepeatedly(Return(false)); |
936 SetupInitializedProfileSyncService(); | 994 SetupInitializedProfileSyncService(); |
937 EXPECT_CALL(*mock_pss_, | 995 EXPECT_CALL(*mock_pss_, |
938 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); | 996 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); |
939 handler_->HandleConfigure(&list_args); | 997 handler_->HandleConfigure(&list_args); |
940 | 998 |
941 ExpectDone(); | 999 ExpectDone(); |
942 Mock::VerifyAndClearExpectations(mock_pss_); | 1000 Mock::VerifyAndClearExpectations(mock_pss_); |
943 web_ui_.ClearTrackedCalls(); | 1001 web_ui_.ClearTrackedCalls(); |
944 } | 1002 } |
945 } | 1003 } |
946 | 1004 |
947 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) { | 1005 TEST_P(SyncSetupHandlerTest, TestSyncAllManually) { |
948 std::string args = GetConfiguration( | 1006 std::string args = GetConfiguration( |
949 NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(), "", ENCRYPT_PASSWORDS); | 1007 NULL, CHOOSE_WHAT_TO_SYNC, GetAllTypes(), "", ENCRYPT_PASSWORDS); |
950 ListValue list_args; | 1008 ListValue list_args; |
951 list_args.Append(new StringValue(args)); | 1009 list_args.Append(new StringValue(args)); |
952 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 1010 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
953 .WillRepeatedly(Return(false)); | 1011 .WillRepeatedly(Return(false)); |
954 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1012 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
955 .WillRepeatedly(Return(false)); | 1013 .WillRepeatedly(Return(false)); |
956 SetupInitializedProfileSyncService(); | 1014 SetupInitializedProfileSyncService(); |
957 EXPECT_CALL(*mock_pss_, | 1015 EXPECT_CALL(*mock_pss_, |
958 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); | 1016 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); |
959 handler_->HandleConfigure(&list_args); | 1017 handler_->HandleConfigure(&list_args); |
960 | 1018 |
961 ExpectDone(); | 1019 ExpectDone(); |
962 } | 1020 } |
963 | 1021 |
964 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) { | 1022 TEST_P(SyncSetupHandlerTest, ShowSyncSetup) { |
965 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1023 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
966 .WillRepeatedly(Return(false)); | 1024 .WillRepeatedly(Return(false)); |
967 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1025 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
968 .WillRepeatedly(Return(false)); | 1026 .WillRepeatedly(Return(false)); |
969 SetupInitializedProfileSyncService(); | 1027 SetupInitializedProfileSyncService(); |
970 // This should display the sync setup dialog (not login). | 1028 // This should display the sync setup dialog (not login). |
971 SetDefaultExpectationsForConfigPage(); | 1029 SetDefaultExpectationsForConfigPage(); |
972 handler_->OpenSyncSetup(false); | 1030 handler_->OpenSyncSetup(false); |
973 | 1031 |
974 ExpectConfig(); | 1032 ExpectConfig(); |
975 } | 1033 } |
976 | 1034 |
977 TEST_F(SyncSetupHandlerTest, ShowSyncSetupWithAuthError) { | 1035 TEST_P(SyncSetupHandlerTest, ShowSyncSetupWithAuthError) { |
978 // Initialize the system to a signed in state, but with an auth error. | 1036 // Initialize the system to a signed in state, but with an auth error. |
979 error_ = GoogleServiceAuthError( | 1037 error_ = GoogleServiceAuthError( |
980 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 1038 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
981 SetupInitializedProfileSyncService(); | 1039 SetupInitializedProfileSyncService(); |
982 mock_signin_->SetAuthenticatedUsername(kTestUser); | 1040 mock_signin_->SetAuthenticatedUsername(kTestUser); |
983 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 1041 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
984 .WillRepeatedly(Return(true)); | 1042 .WillRepeatedly(Return(true)); |
985 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 1043 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
986 .WillRepeatedly(Return(true)); | 1044 .WillRepeatedly(Return(true)); |
987 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1045 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
988 .WillRepeatedly(Return(false)); | 1046 .WillRepeatedly(Return(false)); |
989 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1047 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
990 .WillRepeatedly(Return(false)); | 1048 .WillRepeatedly(Return(false)); |
991 // This should display the login dialog (not login). | 1049 // This should display the login dialog (not login). |
992 handler_->OpenSyncSetup(false); | 1050 handler_->OpenSyncSetup(false); |
993 | 1051 |
994 EXPECT_EQ(handler_.get(), | 1052 EXPECT_EQ(handler_.get(), |
995 LoginUIServiceFactory::GetForProfile( | 1053 LoginUIServiceFactory::GetForProfile( |
996 profile_.get())->current_login_ui()); | 1054 profile_.get())->current_login_ui()); |
997 ASSERT_EQ(1U, web_ui_.call_data().size()); | 1055 |
998 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1056 if (!SyncPromoUI::UseWebBasedSigninFlow()) { |
999 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 1057 ASSERT_EQ(1U, web_ui_.call_data().size()); |
1000 std::string page; | 1058 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1001 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 1059 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
1002 EXPECT_EQ(page, "login"); | 1060 std::string page; |
1003 DictionaryValue* dictionary; | 1061 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
1004 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1062 EXPECT_EQ(page, "login"); |
1005 // We should display a login screen with a non-editable username filled in. | 1063 DictionaryValue* dictionary; |
1006 CheckShowSyncSetupArgs(dictionary, | 1064 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1007 "", | 1065 // We should display a login screen with a non-editable username filled in. |
1008 false, | 1066 CheckShowSyncSetupArgs(dictionary, |
1009 GoogleServiceAuthError::NONE, | 1067 "", |
1010 kTestUser, | 1068 false, |
1011 false, | 1069 GoogleServiceAuthError::NONE, |
1012 ""); | 1070 kTestUser, |
| 1071 false, |
| 1072 ""); |
| 1073 } else { |
| 1074 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 1075 ASSERT_TRUE(handler_->have_signin_tracker()); |
| 1076 } |
1013 } | 1077 } |
1014 | 1078 |
1015 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { | 1079 TEST_P(SyncSetupHandlerTest, ShowSetupSyncEverything) { |
1016 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1080 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
1017 .WillRepeatedly(Return(false)); | 1081 .WillRepeatedly(Return(false)); |
1018 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1082 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
1019 .WillRepeatedly(Return(false)); | 1083 .WillRepeatedly(Return(false)); |
1020 SetupInitializedProfileSyncService(); | 1084 SetupInitializedProfileSyncService(); |
1021 SetDefaultExpectationsForConfigPage(); | 1085 SetDefaultExpectationsForConfigPage(); |
1022 // This should display the sync setup dialog (not login). | 1086 // This should display the sync setup dialog (not login). |
1023 handler_->OpenSyncSetup(false); | 1087 handler_->OpenSyncSetup(false); |
1024 | 1088 |
1025 ExpectConfig(); | 1089 ExpectConfig(); |
(...skipping 11 matching lines...) Expand all Loading... |
1037 CheckBool(dictionary, "sessionsRegistered", true); | 1101 CheckBool(dictionary, "sessionsRegistered", true); |
1038 CheckBool(dictionary, "themesRegistered", true); | 1102 CheckBool(dictionary, "themesRegistered", true); |
1039 CheckBool(dictionary, "typedUrlsRegistered", true); | 1103 CheckBool(dictionary, "typedUrlsRegistered", true); |
1040 CheckBool(dictionary, "showPassphrase", false); | 1104 CheckBool(dictionary, "showPassphrase", false); |
1041 CheckBool(dictionary, "usePassphrase", false); | 1105 CheckBool(dictionary, "usePassphrase", false); |
1042 CheckBool(dictionary, "passphraseFailed", false); | 1106 CheckBool(dictionary, "passphraseFailed", false); |
1043 CheckBool(dictionary, "encryptAllData", false); | 1107 CheckBool(dictionary, "encryptAllData", false); |
1044 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); | 1108 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); |
1045 } | 1109 } |
1046 | 1110 |
1047 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { | 1111 TEST_P(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { |
1048 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1112 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
1049 .WillRepeatedly(Return(false)); | 1113 .WillRepeatedly(Return(false)); |
1050 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1114 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
1051 .WillRepeatedly(Return(false)); | 1115 .WillRepeatedly(Return(false)); |
1052 SetupInitializedProfileSyncService(); | 1116 SetupInitializedProfileSyncService(); |
1053 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); | 1117 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); |
1054 sync_prefs.SetKeepEverythingSynced(false); | 1118 sync_prefs.SetKeepEverythingSynced(false); |
1055 SetDefaultExpectationsForConfigPage(); | 1119 SetDefaultExpectationsForConfigPage(); |
1056 // This should display the sync setup dialog (not login). | 1120 // This should display the sync setup dialog (not login). |
1057 handler_->OpenSyncSetup(false); | 1121 handler_->OpenSyncSetup(false); |
1058 | 1122 |
1059 ExpectConfig(); | 1123 ExpectConfig(); |
1060 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1124 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1061 DictionaryValue* dictionary; | 1125 DictionaryValue* dictionary; |
1062 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1126 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1063 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); | 1127 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
1064 } | 1128 } |
1065 | 1129 |
1066 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { | 1130 TEST_P(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
1067 for (size_t i = 0; i < arraysize(kUserSelectableTypes); ++i) { | 1131 for (size_t i = 0; i < arraysize(kUserSelectableTypes); ++i) { |
1068 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1132 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
1069 .WillRepeatedly(Return(false)); | 1133 .WillRepeatedly(Return(false)); |
1070 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1134 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
1071 .WillRepeatedly(Return(false)); | 1135 .WillRepeatedly(Return(false)); |
1072 SetupInitializedProfileSyncService(); | 1136 SetupInitializedProfileSyncService(); |
1073 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); | 1137 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); |
1074 sync_prefs.SetKeepEverythingSynced(false); | 1138 sync_prefs.SetKeepEverythingSynced(false); |
1075 SetDefaultExpectationsForConfigPage(); | 1139 SetDefaultExpectationsForConfigPage(); |
1076 syncer::ModelTypeSet types; | 1140 syncer::ModelTypeSet types; |
(...skipping 11 matching lines...) Expand all Loading... |
1088 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1152 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1089 DictionaryValue* dictionary; | 1153 DictionaryValue* dictionary; |
1090 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1154 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1091 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); | 1155 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); |
1092 Mock::VerifyAndClearExpectations(mock_pss_); | 1156 Mock::VerifyAndClearExpectations(mock_pss_); |
1093 // Clean up so we can loop back to display the dialog again. | 1157 // Clean up so we can loop back to display the dialog again. |
1094 web_ui_.ClearTrackedCalls(); | 1158 web_ui_.ClearTrackedCalls(); |
1095 } | 1159 } |
1096 } | 1160 } |
1097 | 1161 |
1098 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { | 1162 TEST_P(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { |
1099 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1163 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
1100 .WillRepeatedly(Return(true)); | 1164 .WillRepeatedly(Return(true)); |
1101 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1165 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
1102 .WillRepeatedly(Return(false)); | 1166 .WillRepeatedly(Return(false)); |
1103 SetupInitializedProfileSyncService(); | 1167 SetupInitializedProfileSyncService(); |
1104 SetDefaultExpectationsForConfigPage(); | 1168 SetDefaultExpectationsForConfigPage(); |
1105 | 1169 |
1106 // This should display the sync setup dialog (not login). | 1170 // This should display the sync setup dialog (not login). |
1107 handler_->OpenSyncSetup(false); | 1171 handler_->OpenSyncSetup(false); |
1108 | 1172 |
1109 ExpectConfig(); | 1173 ExpectConfig(); |
1110 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1174 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1111 DictionaryValue* dictionary; | 1175 DictionaryValue* dictionary; |
1112 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1176 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1113 CheckBool(dictionary, "showPassphrase", true); | 1177 CheckBool(dictionary, "showPassphrase", true); |
1114 CheckBool(dictionary, "usePassphrase", false); | 1178 CheckBool(dictionary, "usePassphrase", false); |
1115 CheckBool(dictionary, "passphraseFailed", false); | 1179 CheckBool(dictionary, "passphraseFailed", false); |
1116 } | 1180 } |
1117 | 1181 |
1118 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { | 1182 TEST_P(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { |
1119 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1183 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
1120 .WillRepeatedly(Return(true)); | 1184 .WillRepeatedly(Return(true)); |
1121 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1185 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
1122 .WillRepeatedly(Return(true)); | 1186 .WillRepeatedly(Return(true)); |
1123 EXPECT_CALL(*mock_pss_, GetPassphraseType()) | 1187 EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
1124 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); | 1188 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); |
1125 SetupInitializedProfileSyncService(); | 1189 SetupInitializedProfileSyncService(); |
1126 SetDefaultExpectationsForConfigPage(); | 1190 SetDefaultExpectationsForConfigPage(); |
1127 | 1191 |
1128 // This should display the sync setup dialog (not login). | 1192 // This should display the sync setup dialog (not login). |
1129 handler_->OpenSyncSetup(false); | 1193 handler_->OpenSyncSetup(false); |
1130 | 1194 |
1131 ExpectConfig(); | 1195 ExpectConfig(); |
1132 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1196 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1133 DictionaryValue* dictionary; | 1197 DictionaryValue* dictionary; |
1134 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1198 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1135 CheckBool(dictionary, "showPassphrase", true); | 1199 CheckBool(dictionary, "showPassphrase", true); |
1136 CheckBool(dictionary, "usePassphrase", true); | 1200 CheckBool(dictionary, "usePassphrase", true); |
1137 CheckBool(dictionary, "passphraseFailed", false); | 1201 CheckBool(dictionary, "passphraseFailed", false); |
1138 } | 1202 } |
1139 | 1203 |
1140 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) { | 1204 TEST_P(SyncSetupHandlerTest, ShowSetupEncryptAll) { |
1141 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 1205 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
1142 .WillRepeatedly(Return(false)); | 1206 .WillRepeatedly(Return(false)); |
1143 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 1207 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
1144 .WillRepeatedly(Return(false)); | 1208 .WillRepeatedly(Return(false)); |
1145 SetupInitializedProfileSyncService(); | 1209 SetupInitializedProfileSyncService(); |
1146 SetDefaultExpectationsForConfigPage(); | 1210 SetDefaultExpectationsForConfigPage(); |
1147 EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()). | 1211 EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()). |
1148 WillRepeatedly(Return(true)); | 1212 WillRepeatedly(Return(true)); |
1149 | 1213 |
1150 // This should display the sync setup dialog (not login). | 1214 // This should display the sync setup dialog (not login). |
1151 handler_->OpenSyncSetup(false); | 1215 handler_->OpenSyncSetup(false); |
1152 | 1216 |
1153 ExpectConfig(); | 1217 ExpectConfig(); |
1154 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1218 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1155 DictionaryValue* dictionary; | 1219 DictionaryValue* dictionary; |
1156 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1220 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1157 CheckBool(dictionary, "encryptAllData", true); | 1221 CheckBool(dictionary, "encryptAllData", true); |
1158 } | 1222 } |
1159 | 1223 |
1160 // Tests that trying to log in with an invalid username results in an error | 1224 // Tests that trying to log in with an invalid username results in an error |
1161 // displayed to the user. | 1225 // displayed to the user. |
1162 TEST_F(SyncSetupHandlerTest, SubmitAuthWithInvalidUsername) { | 1226 TEST_P(SyncSetupHandlerTest, SubmitAuthWithInvalidUsername) { |
1163 EXPECT_CALL(*mock_signin_, IsAllowedUsername(_)). | 1227 EXPECT_CALL(*mock_signin_, IsAllowedUsername(_)). |
1164 WillRepeatedly(Return(false)); | 1228 WillRepeatedly(Return(false)); |
1165 | 1229 |
1166 // Generate a blob of json that matches what would be submitted by the login | 1230 // Generate a blob of json that matches what would be submitted by the login |
1167 // javascript code. | 1231 // javascript code. |
1168 DictionaryValue args; | 1232 DictionaryValue args; |
1169 args.SetString("user", "user@not_allowed.com"); | 1233 args.SetString("user", "user@not_allowed.com"); |
1170 args.SetString("pass", "password"); | 1234 args.SetString("pass", "password"); |
1171 args.SetString("captcha", ""); | 1235 args.SetString("captcha", ""); |
1172 args.SetString("otp", ""); | 1236 args.SetString("otp", ""); |
(...skipping 18 matching lines...) Expand all Loading... |
1191 DictionaryValue* dictionary; | 1255 DictionaryValue* dictionary; |
1192 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1256 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1193 std::string err = l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED); | 1257 std::string err = l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED); |
1194 CheckShowSyncSetupArgs( | 1258 CheckShowSyncSetupArgs( |
1195 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); | 1259 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); |
1196 handler_->CloseSyncSetup(); | 1260 handler_->CloseSyncSetup(); |
1197 EXPECT_EQ(NULL, | 1261 EXPECT_EQ(NULL, |
1198 LoginUIServiceFactory::GetForProfile( | 1262 LoginUIServiceFactory::GetForProfile( |
1199 profile_.get())->current_login_ui()); | 1263 profile_.get())->current_login_ui()); |
1200 } | 1264 } |
| 1265 |
| 1266 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, |
| 1267 SyncSetupHandlerTest, |
| 1268 Values(true, false)); |
OLD | NEW |