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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc

Issue 2531863002: Delete all the traces of federation providers in the account chooser. (Closed)
Patch Set: android2 Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <map> 5 #include <map>
6 #include <memory> 6 #include <memory>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 EXPECT_EQ(password_manager::ui::CONFIRMATION_STATE, controller()->GetState()); 512 EXPECT_EQ(password_manager::ui::CONFIRMATION_STATE, controller()->GetState());
513 513
514 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 514 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
515 controller()->OnBubbleHidden(); 515 controller()->OnBubbleHidden();
516 ExpectIconStateIs(password_manager::ui::MANAGE_STATE); 516 ExpectIconStateIs(password_manager::ui::MANAGE_STATE);
517 } 517 }
518 518
519 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialLocal) { 519 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialLocal) {
520 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; 520 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
521 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form())); 521 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form()));
522 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials;
523 GURL origin("http://example.com"); 522 GURL origin("http://example.com");
524 PasswordDialogController* dialog_controller = nullptr; 523 PasswordDialogController* dialog_controller = nullptr;
525 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce( 524 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce(
526 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt()))); 525 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt())));
527 EXPECT_CALL(dialog_prompt(), ShowAccountChooser()); 526 EXPECT_CALL(dialog_prompt(), ShowAccountChooser());
528 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 527 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
529 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true)); 528 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true));
530 EXPECT_TRUE(controller()->OnChooseCredentials( 529 EXPECT_TRUE(controller()->OnChooseCredentials(
531 std::move(local_credentials), std::move(federated_credentials), origin, 530 std::move(local_credentials), origin,
532 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback, 531 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback,
533 base::Unretained(this)))); 532 base::Unretained(this))));
534 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, 533 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE,
535 controller()->GetState()); 534 controller()->GetState());
536 EXPECT_EQ(origin, controller()->GetOrigin()); 535 EXPECT_EQ(origin, controller()->GetOrigin());
537 EXPECT_THAT(controller()->GetCurrentForms(), 536 EXPECT_THAT(controller()->GetCurrentForms(),
538 ElementsAre(Pointee(test_local_form()))); 537 ElementsAre(Pointee(test_local_form())));
539 ASSERT_THAT(dialog_controller->GetLocalForms(), 538 ASSERT_THAT(dialog_controller->GetLocalForms(),
540 ElementsAre(Pointee(test_local_form()))); 539 ElementsAre(Pointee(test_local_form())));
541 EXPECT_THAT(dialog_controller->GetFederationsForms(), testing::IsEmpty());
542 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE); 540 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE);
543 541
544 EXPECT_CALL(dialog_prompt(), ControllerGone()); 542 EXPECT_CALL(dialog_prompt(), ControllerGone());
545 EXPECT_CALL(*this, CredentialCallback(Pointee(test_local_form()))); 543 EXPECT_CALL(*this, CredentialCallback(Pointee(test_local_form())));
546 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 544 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
547 dialog_controller->OnChooseCredentials( 545 dialog_controller->OnChooseCredentials(
548 *dialog_controller->GetLocalForms()[0], 546 *dialog_controller->GetLocalForms()[0],
549 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 547 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
550 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState()); 548 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState());
551 } 549 }
552 550
553 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialLocalButFederated) { 551 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialLocalButFederated) {
554 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; 552 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
555 local_credentials.emplace_back( 553 local_credentials.emplace_back(
556 new autofill::PasswordForm(test_federated_form())); 554 new autofill::PasswordForm(test_federated_form()));
557 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials;
558 GURL origin("http://example.com"); 555 GURL origin("http://example.com");
559 PasswordDialogController* dialog_controller = nullptr; 556 PasswordDialogController* dialog_controller = nullptr;
560 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce( 557 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce(
561 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt()))); 558 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt())));
562 EXPECT_CALL(dialog_prompt(), ShowAccountChooser()); 559 EXPECT_CALL(dialog_prompt(), ShowAccountChooser());
563 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 560 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
564 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true)); 561 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true));
565 EXPECT_TRUE(controller()->OnChooseCredentials( 562 EXPECT_TRUE(controller()->OnChooseCredentials(
566 std::move(local_credentials), std::move(federated_credentials), origin, 563 std::move(local_credentials), origin,
567 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback, 564 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback,
568 base::Unretained(this)))); 565 base::Unretained(this))));
569 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, 566 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE,
570 controller()->GetState()); 567 controller()->GetState());
571 EXPECT_EQ(origin, controller()->GetOrigin()); 568 EXPECT_EQ(origin, controller()->GetOrigin());
572 EXPECT_THAT(controller()->GetCurrentForms(), 569 EXPECT_THAT(controller()->GetCurrentForms(),
573 ElementsAre(Pointee(test_federated_form()))); 570 ElementsAre(Pointee(test_federated_form())));
574 ASSERT_THAT(dialog_controller->GetLocalForms(), 571 ASSERT_THAT(dialog_controller->GetLocalForms(),
575 ElementsAre(Pointee(test_federated_form()))); 572 ElementsAre(Pointee(test_federated_form())));
576 EXPECT_THAT(dialog_controller->GetFederationsForms(), testing::IsEmpty());
577 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE); 573 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE);
578 574
579 EXPECT_CALL(dialog_prompt(), ControllerGone()); 575 EXPECT_CALL(dialog_prompt(), ControllerGone());
580 EXPECT_CALL(*this, CredentialCallback(Pointee(test_federated_form()))); 576 EXPECT_CALL(*this, CredentialCallback(Pointee(test_federated_form())));
581 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 577 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
582 dialog_controller->OnChooseCredentials( 578 dialog_controller->OnChooseCredentials(
583 *dialog_controller->GetLocalForms()[0], 579 *dialog_controller->GetLocalForms()[0],
584 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 580 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
585 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState()); 581 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState());
586 } 582 }
587 583
588 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialCancel) { 584 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialCancel) {
589 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; 585 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
590 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form())); 586 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form()));
591 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials;
592 GURL origin("http://example.com"); 587 GURL origin("http://example.com");
593 PasswordDialogController* dialog_controller = nullptr; 588 PasswordDialogController* dialog_controller = nullptr;
594 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce( 589 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce(
595 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt()))); 590 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt())));
596 EXPECT_CALL(dialog_prompt(), ShowAccountChooser()); 591 EXPECT_CALL(dialog_prompt(), ShowAccountChooser());
597 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 592 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
598 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true)); 593 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true));
599 EXPECT_TRUE(controller()->OnChooseCredentials( 594 EXPECT_TRUE(controller()->OnChooseCredentials(
600 std::move(local_credentials), std::move(federated_credentials), origin, 595 std::move(local_credentials), origin,
601 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback, 596 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback,
602 base::Unretained(this)))); 597 base::Unretained(this))));
603 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, 598 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE,
604 controller()->GetState()); 599 controller()->GetState());
605 EXPECT_EQ(origin, controller()->GetOrigin()); 600 EXPECT_EQ(origin, controller()->GetOrigin());
606 601
607 EXPECT_CALL(dialog_prompt(), ControllerGone()).Times(0); 602 EXPECT_CALL(dialog_prompt(), ControllerGone()).Times(0);
608 EXPECT_CALL(*this, CredentialCallback(nullptr)); 603 EXPECT_CALL(*this, CredentialCallback(nullptr));
609 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 604 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
610 dialog_controller->OnCloseDialog(); 605 dialog_controller->OnCloseDialog();
611 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState()); 606 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState());
612 } 607 }
613 608
614 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialPrefetch) { 609 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialPrefetch) {
615 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; 610 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
616 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form())); 611 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form()));
617 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials;
618 GURL origin("http://example.com"); 612 GURL origin("http://example.com");
619 613
620 // Simulate requesting a credential during prefetch. The tab has no associated 614 // Simulate requesting a credential during prefetch. The tab has no associated
621 // browser. Nothing should happen. 615 // browser. Nothing should happen.
622 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(false)); 616 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(false));
623 EXPECT_FALSE(controller()->OnChooseCredentials( 617 EXPECT_FALSE(controller()->OnChooseCredentials(
624 std::move(local_credentials), std::move(federated_credentials), origin, 618 std::move(local_credentials), origin,
625 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback, 619 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback,
626 base::Unretained(this)))); 620 base::Unretained(this))));
627 EXPECT_EQ(password_manager::ui::INACTIVE_STATE, controller()->GetState()); 621 EXPECT_EQ(password_manager::ui::INACTIVE_STATE, controller()->GetState());
628 } 622 }
629 623
630 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialPSL) { 624 TEST_F(ManagePasswordsUIControllerTest, ChooseCredentialPSL) {
631 test_local_form().is_public_suffix_match = true; 625 test_local_form().is_public_suffix_match = true;
632 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; 626 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
633 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form())); 627 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form()));
634 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials;
635 GURL origin("http://example.com"); 628 GURL origin("http://example.com");
636 PasswordDialogController* dialog_controller = nullptr; 629 PasswordDialogController* dialog_controller = nullptr;
637 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce( 630 EXPECT_CALL(*controller(), CreateAccountChooser(_)).WillOnce(
638 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt()))); 631 DoAll(SaveArg<0>(&dialog_controller), Return(&dialog_prompt())));
639 EXPECT_CALL(dialog_prompt(), ShowAccountChooser()); 632 EXPECT_CALL(dialog_prompt(), ShowAccountChooser());
640 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 633 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
641 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true)); 634 EXPECT_CALL(*controller(), HasBrowserWindow()).WillOnce(Return(true));
642 EXPECT_TRUE(controller()->OnChooseCredentials( 635 EXPECT_TRUE(controller()->OnChooseCredentials(
643 std::move(local_credentials), std::move(federated_credentials), origin, 636 std::move(local_credentials), origin,
644 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback, 637 base::Bind(&ManagePasswordsUIControllerTest::CredentialCallback,
645 base::Unretained(this)))); 638 base::Unretained(this))));
646 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE, 639 EXPECT_EQ(password_manager::ui::CREDENTIAL_REQUEST_STATE,
647 controller()->GetState()); 640 controller()->GetState());
648 EXPECT_EQ(origin, controller()->GetOrigin()); 641 EXPECT_EQ(origin, controller()->GetOrigin());
649 EXPECT_THAT(controller()->GetCurrentForms(), IsEmpty()); 642 EXPECT_THAT(controller()->GetCurrentForms(), IsEmpty());
650 ASSERT_THAT(dialog_controller->GetLocalForms(), 643 ASSERT_THAT(dialog_controller->GetLocalForms(),
651 ElementsAre(Pointee(test_local_form()))); 644 ElementsAre(Pointee(test_local_form())));
652 EXPECT_THAT(dialog_controller->GetFederationsForms(), testing::IsEmpty());
653 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE); 645 ExpectIconStateIs(password_manager::ui::INACTIVE_STATE);
654 646
655 EXPECT_CALL(dialog_prompt(), ControllerGone()); 647 EXPECT_CALL(dialog_prompt(), ControllerGone());
656 EXPECT_CALL(*this, CredentialCallback(Pointee(test_local_form()))); 648 EXPECT_CALL(*this, CredentialCallback(Pointee(test_local_form())));
657 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 649 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
658 dialog_controller->OnChooseCredentials( 650 dialog_controller->OnChooseCredentials(
659 *dialog_controller->GetLocalForms()[0], 651 *dialog_controller->GetLocalForms()[0],
660 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 652 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
661 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState()); 653 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->GetState());
662 EXPECT_THAT(controller()->GetCurrentForms(), IsEmpty()); 654 EXPECT_THAT(controller()->GetCurrentForms(), IsEmpty());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 // Open the bubble again. 801 // Open the bubble again.
810 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form())); 802 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form()));
811 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 803 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
812 controller()->OnAutoSignin(std::move(local_credentials), 804 controller()->OnAutoSignin(std::move(local_credentials),
813 test_local_form().origin); 805 test_local_form().origin);
814 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState()); 806 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState());
815 // Check the delegate is destroyed. Thus, the first bubble has no way to mess 807 // Check the delegate is destroyed. Thus, the first bubble has no way to mess
816 // up with the controller's state. 808 // up with the controller's state.
817 EXPECT_FALSE(proxy_delegate); 809 EXPECT_FALSE(proxy_delegate);
818 } 810 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698