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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 130563003: Change all other AutofillDialogView methods with a const DetailInput& as a param (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 11 months 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 | Annotate | Revision Log
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, 549 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED,
550 metric_logger().dialog_dismissal_action()); 550 metric_logger().dialog_dismissal_action());
551 } 551 }
552 552
553 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { 553 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
554 AutofillProfile full_profile(test::GetFullProfile()); 554 AutofillProfile full_profile(test::GetFullProfile());
555 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 555 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
556 556
557 const DetailInputs& inputs = 557 const DetailInputs& inputs =
558 controller()->RequestedFieldsForSection(SECTION_SHIPPING); 558 controller()->RequestedFieldsForSection(SECTION_SHIPPING);
559 const DetailInput& triggering_input = inputs[0]; 559 const ServerFieldType triggering_type = inputs[0].type;
560 base::string16 value = full_profile.GetRawInfo(triggering_input.type); 560 base::string16 value = full_profile.GetRawInfo(triggering_type);
561 TestableAutofillDialogView* view = controller()->GetTestableView(); 561 TestableAutofillDialogView* view = controller()->GetTestableView();
562 view->SetTextContentsOfInput(triggering_input, 562 view->SetTextContentsOfInput(triggering_type,
563 value.substr(0, value.size() / 2)); 563 value.substr(0, value.size() / 2));
564 view->ActivateInput(triggering_input); 564 view->ActivateInput(triggering_type);
565 565
566 ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); 566 ASSERT_EQ(triggering_type, controller()->popup_input_type());
567 controller()->DidAcceptSuggestion(base::string16(), 0); 567 controller()->DidAcceptSuggestion(base::string16(), 0);
568 568
569 // All inputs should be filled. 569 // All inputs should be filled.
570 AutofillProfileWrapper wrapper(&full_profile); 570 AutofillProfileWrapper wrapper(&full_profile);
571 for (size_t i = 0; i < inputs.size(); ++i) { 571 for (size_t i = 0; i < inputs.size(); ++i) {
572 EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)), 572 EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)),
573 view->GetTextContentsOfInput(inputs[i])); 573 view->GetTextContentsOfInput(inputs[i].type));
574 } 574 }
575 575
576 // Now simulate some user edits and try again. 576 // Now simulate some user edits and try again.
577 std::vector<base::string16> expectations; 577 std::vector<base::string16> expectations;
578 for (size_t i = 0; i < inputs.size(); ++i) { 578 for (size_t i = 0; i < inputs.size(); ++i) {
579 base::string16 users_input = i % 2 == 0 ? base::string16() 579 base::string16 users_input = i % 2 == 0 ? base::string16()
580 : ASCIIToUTF16("dummy"); 580 : ASCIIToUTF16("dummy");
581 view->SetTextContentsOfInput(inputs[i], users_input); 581 view->SetTextContentsOfInput(inputs[i].type, users_input);
582 // Empty inputs should be filled, others should be left alone. 582 // Empty inputs should be filled, others should be left alone.
583 base::string16 expectation = 583 base::string16 expectation =
584 &inputs[i] == &triggering_input || users_input.empty() ? 584 inputs[i].type == triggering_type || users_input.empty() ?
585 wrapper.GetInfo(AutofillType(inputs[i].type)) : 585 wrapper.GetInfo(AutofillType(inputs[i].type)) :
586 users_input; 586 users_input;
587 expectations.push_back(expectation); 587 expectations.push_back(expectation);
588 } 588 }
589 589
590 view->SetTextContentsOfInput(triggering_input, 590 view->SetTextContentsOfInput(triggering_type,
591 value.substr(0, value.size() / 2)); 591 value.substr(0, value.size() / 2));
592 view->ActivateInput(triggering_input); 592 view->ActivateInput(triggering_type);
593 ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); 593 ASSERT_EQ(triggering_type, controller()->popup_input_type());
594 controller()->DidAcceptSuggestion(base::string16(), 0); 594 controller()->DidAcceptSuggestion(base::string16(), 0);
595 595
596 for (size_t i = 0; i < inputs.size(); ++i) { 596 for (size_t i = 0; i < inputs.size(); ++i) {
597 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i])); 597 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type));
598 } 598 }
599 } 599 }
600 600
601 // For now, no matter what, the country must always be US. See 601 // For now, no matter what, the country must always be US. See
602 // http://crbug.com/247518 602 // http://crbug.com/247518
603 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 603 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
604 FillInputFromForeignProfile) { 604 FillInputFromForeignProfile) {
605 AutofillProfile full_profile(test::GetFullProfile()); 605 AutofillProfile full_profile(test::GetFullProfile());
606 full_profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), 606 full_profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY),
607 ASCIIToUTF16("France"), "en-US"); 607 ASCIIToUTF16("France"), "en-US");
608 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 608 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
609 609
610 const DetailInputs& inputs = 610 const DetailInputs& inputs =
611 controller()->RequestedFieldsForSection(SECTION_SHIPPING); 611 controller()->RequestedFieldsForSection(SECTION_SHIPPING);
612 const DetailInput& triggering_input = inputs[0]; 612 const ServerFieldType triggering_type = inputs[0].type;
613 base::string16 value = full_profile.GetRawInfo(triggering_input.type); 613 base::string16 value = full_profile.GetRawInfo(triggering_type);
614 TestableAutofillDialogView* view = controller()->GetTestableView(); 614 TestableAutofillDialogView* view = controller()->GetTestableView();
615 view->SetTextContentsOfInput(triggering_input, 615 view->SetTextContentsOfInput(triggering_type,
616 value.substr(0, value.size() / 2)); 616 value.substr(0, value.size() / 2));
617 view->ActivateInput(triggering_input); 617 view->ActivateInput(triggering_type);
618 618
619 ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); 619 ASSERT_EQ(triggering_type, controller()->popup_input_type());
620 controller()->DidAcceptSuggestion(base::string16(), 0); 620 controller()->DidAcceptSuggestion(base::string16(), 0);
621 621
622 // All inputs should be filled. 622 // All inputs should be filled.
623 AutofillProfileWrapper wrapper(&full_profile); 623 AutofillProfileWrapper wrapper(&full_profile);
624 for (size_t i = 0; i < inputs.size(); ++i) { 624 for (size_t i = 0; i < inputs.size(); ++i) {
625 const ServerFieldType type = inputs[i].type;
625 base::string16 expectation = 626 base::string16 expectation =
626 AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY ? 627 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY ?
627 ASCIIToUTF16("United States") : 628 ASCIIToUTF16("United States") : wrapper.GetInfo(AutofillType(type));
628 wrapper.GetInfo(AutofillType(inputs[i].type)); 629 EXPECT_EQ(expectation, view->GetTextContentsOfInput(type));
629 EXPECT_EQ(expectation, view->GetTextContentsOfInput(inputs[i]));
630 } 630 }
631 631
632 // Now simulate some user edits and try again. 632 // Now simulate some user edits and try again.
633 std::vector<base::string16> expectations; 633 std::vector<base::string16> expectations;
634 for (size_t i = 0; i < inputs.size(); ++i) { 634 for (size_t i = 0; i < inputs.size(); ++i) {
635 base::string16 users_input = i % 2 == 0 ? base::string16() 635 base::string16 users_input = i % 2 == 0 ? base::string16()
636 : ASCIIToUTF16("dummy"); 636 : ASCIIToUTF16("dummy");
637 view->SetTextContentsOfInput(inputs[i], users_input); 637 view->SetTextContentsOfInput(inputs[i].type, users_input);
638 // Empty inputs should be filled, others should be left alone. 638 // Empty inputs should be filled, others should be left alone.
639 base::string16 expectation = 639 base::string16 expectation =
640 &inputs[i] == &triggering_input || users_input.empty() ? 640 inputs[i].type == triggering_type || users_input.empty() ?
641 wrapper.GetInfo(AutofillType(inputs[i].type)) : 641 wrapper.GetInfo(AutofillType(inputs[i].type)) :
642 users_input; 642 users_input;
643 if (AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY) 643 if (AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY)
644 expectation = ASCIIToUTF16("United States"); 644 expectation = ASCIIToUTF16("United States");
645 645
646 expectations.push_back(expectation); 646 expectations.push_back(expectation);
647 } 647 }
648 648
649 view->SetTextContentsOfInput(triggering_input, 649 view->SetTextContentsOfInput(triggering_type,
650 value.substr(0, value.size() / 2)); 650 value.substr(0, value.size() / 2));
651 view->ActivateInput(triggering_input); 651 view->ActivateInput(triggering_type);
652 ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); 652 ASSERT_EQ(triggering_type, controller()->popup_input_type());
653 controller()->DidAcceptSuggestion(base::string16(), 0); 653 controller()->DidAcceptSuggestion(base::string16(), 0);
654 654
655 for (size_t i = 0; i < inputs.size(); ++i) { 655 for (size_t i = 0; i < inputs.size(); ++i) {
656 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i])); 656 EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type));
657 } 657 }
658 } 658 }
659 659
660 // This test makes sure that picking a profile variant in the Autofill 660 // This test makes sure that picking a profile variant in the Autofill
661 // popup works as expected. 661 // popup works as expected.
662 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 662 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
663 FillInputFromAutofillVariant) { 663 FillInputFromAutofillVariant) {
664 AutofillProfile full_profile(test::GetFullProfile()); 664 AutofillProfile full_profile(test::GetFullProfile());
665 665
666 // Set up some variant data. 666 // Set up some variant data.
667 std::vector<base::string16> names; 667 std::vector<base::string16> names;
668 names.push_back(ASCIIToUTF16("John Doe")); 668 names.push_back(ASCIIToUTF16("John Doe"));
669 names.push_back(ASCIIToUTF16("Jane Doe")); 669 names.push_back(ASCIIToUTF16("Jane Doe"));
670 full_profile.SetRawMultiInfo(NAME_FULL, names); 670 full_profile.SetRawMultiInfo(NAME_FULL, names);
671 std::vector<base::string16> emails; 671 std::vector<base::string16> emails;
672 emails.push_back(ASCIIToUTF16("user@example.com")); 672 emails.push_back(ASCIIToUTF16("user@example.com"));
673 emails.push_back(ASCIIToUTF16("admin@example.com")); 673 emails.push_back(ASCIIToUTF16("admin@example.com"));
674 full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails); 674 full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails);
675 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 675 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
676 676
677 const DetailInputs& inputs = 677 const DetailInputs& inputs =
678 controller()->RequestedFieldsForSection(SECTION_BILLING); 678 controller()->RequestedFieldsForSection(SECTION_BILLING);
679 const DetailInput& triggering_input = inputs[0]; 679 const ServerFieldType triggering_type = inputs[0].type;
680 EXPECT_EQ(NAME_BILLING_FULL, triggering_input.type); 680 EXPECT_EQ(NAME_BILLING_FULL, triggering_type);
681 TestableAutofillDialogView* view = controller()->GetTestableView(); 681 TestableAutofillDialogView* view = controller()->GetTestableView();
682 view->ActivateInput(triggering_input); 682 view->ActivateInput(triggering_type);
683 683
684 ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); 684 ASSERT_EQ(triggering_type, controller()->popup_input_type());
685 685
686 // Choose the variant suggestion. 686 // Choose the variant suggestion.
687 controller()->DidAcceptSuggestion(base::string16(), 1); 687 controller()->DidAcceptSuggestion(base::string16(), 1);
688 688
689 // All inputs should be filled. 689 // All inputs should be filled.
690 AutofillProfileWrapper wrapper( 690 AutofillProfileWrapper wrapper(
691 &full_profile, AutofillType(NAME_BILLING_FULL), 1); 691 &full_profile, AutofillType(NAME_BILLING_FULL), 1);
692 for (size_t i = 0; i < inputs.size(); ++i) { 692 for (size_t i = 0; i < inputs.size(); ++i) {
693 EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)), 693 EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)),
694 view->GetTextContentsOfInput(inputs[i])); 694 view->GetTextContentsOfInput(inputs[i].type));
695 } 695 }
696 696
697 // Make sure the wrapper applies the variant index to the right group. 697 // Make sure the wrapper applies the variant index to the right group.
698 EXPECT_EQ(names[1], wrapper.GetInfo(AutofillType(NAME_BILLING_FULL))); 698 EXPECT_EQ(names[1], wrapper.GetInfo(AutofillType(NAME_BILLING_FULL)));
699 // Make sure the wrapper doesn't apply the variant index to the wrong group. 699 // Make sure the wrapper doesn't apply the variant index to the wrong group.
700 EXPECT_EQ(emails[0], wrapper.GetInfo(AutofillType(EMAIL_ADDRESS))); 700 EXPECT_EQ(emails[0], wrapper.GetInfo(AutofillType(EMAIL_ADDRESS)));
701 } 701 }
702 702
703 // Tests that changing the value of a CC expiration date combobox works as 703 // Tests that changing the value of a CC expiration date combobox works as
704 // expected when Autofill is used to fill text inputs. 704 // expected when Autofill is used to fill text inputs.
(...skipping 10 matching lines...) Expand all
715 test::SetCreditCardInfo(&card1, "JJ Smith", "4111111111111111", "12", "2018"); 715 test::SetCreditCardInfo(&card1, "JJ Smith", "4111111111111111", "12", "2018");
716 controller()->GetTestingManager()->AddTestingCreditCard(&card1); 716 controller()->GetTestingManager()->AddTestingCreditCard(&card1);
717 CreditCard card2; 717 CreditCard card2;
718 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); 718 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017");
719 controller()->GetTestingManager()->AddTestingCreditCard(&card2); 719 controller()->GetTestingManager()->AddTestingCreditCard(&card2);
720 AutofillProfile full_profile(test::GetFullProfile()); 720 AutofillProfile full_profile(test::GetFullProfile());
721 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 721 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
722 722
723 const DetailInputs& inputs = 723 const DetailInputs& inputs =
724 controller()->RequestedFieldsForSection(SECTION_CC); 724 controller()->RequestedFieldsForSection(SECTION_CC);
725 const DetailInput& triggering_input = inputs[0]; 725 const ServerFieldType triggering_type = inputs[0].type;
726 base::string16 value = card1.GetRawInfo(triggering_input.type); 726 base::string16 value = card1.GetRawInfo(triggering_type);
727 TestableAutofillDialogView* view = controller()->GetTestableView(); 727 TestableAutofillDialogView* view = controller()->GetTestableView();
728 view->SetTextContentsOfInput(triggering_input, 728 view->SetTextContentsOfInput(triggering_type,
729 value.substr(0, value.size() / 2)); 729 value.substr(0, value.size() / 2));
730 view->ActivateInput(triggering_input); 730 view->ActivateInput(triggering_type);
731 731
732 ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); 732 ASSERT_EQ(triggering_type, controller()->popup_input_type());
733 controller()->DidAcceptSuggestion(base::string16(), 0); 733 controller()->DidAcceptSuggestion(base::string16(), 0);
734 734
735 // All inputs should be filled. 735 // All inputs should be filled.
736 AutofillCreditCardWrapper wrapper1(&card1); 736 AutofillCreditCardWrapper wrapper1(&card1);
737 for (size_t i = 0; i < inputs.size(); ++i) { 737 for (size_t i = 0; i < inputs.size(); ++i) {
738 EXPECT_EQ(wrapper1.GetInfo(AutofillType(inputs[i].type)), 738 EXPECT_EQ(wrapper1.GetInfo(AutofillType(inputs[i].type)),
739 view->GetTextContentsOfInput(inputs[i])); 739 view->GetTextContentsOfInput(inputs[i].type));
740 } 740 }
741 741
742 // Try again with different data. Only expiration date and the triggering 742 // Try again with different data. Only expiration date and the triggering
743 // input should be overwritten. 743 // input should be overwritten.
744 value = card2.GetRawInfo(triggering_input.type); 744 value = card2.GetRawInfo(triggering_type);
745 view->SetTextContentsOfInput(triggering_input, 745 view->SetTextContentsOfInput(triggering_type,
746 value.substr(0, value.size() / 2)); 746 value.substr(0, value.size() / 2));
747 view->ActivateInput(triggering_input); 747 view->ActivateInput(triggering_type);
748 ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); 748 ASSERT_EQ(triggering_type, controller()->popup_input_type());
749 controller()->DidAcceptSuggestion(base::string16(), 0); 749 controller()->DidAcceptSuggestion(base::string16(), 0);
750 750
751 AutofillCreditCardWrapper wrapper2(&card2); 751 AutofillCreditCardWrapper wrapper2(&card2);
752 for (size_t i = 0; i < inputs.size(); ++i) { 752 for (size_t i = 0; i < inputs.size(); ++i) {
753 const DetailInput& input = inputs[i]; 753 const ServerFieldType type = inputs[i].type;
754 if (&input == &triggering_input || 754 if (type == triggering_type ||
755 input.type == CREDIT_CARD_EXP_MONTH || 755 type == CREDIT_CARD_EXP_MONTH ||
756 input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { 756 type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
757 EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)), 757 EXPECT_EQ(wrapper2.GetInfo(AutofillType(type)),
758 view->GetTextContentsOfInput(input)); 758 view->GetTextContentsOfInput(type));
759 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) { 759 } else if (type == CREDIT_CARD_VERIFICATION_CODE) {
760 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); 760 EXPECT_TRUE(view->GetTextContentsOfInput(type).empty());
761 } else { 761 } else {
762 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), 762 EXPECT_EQ(wrapper1.GetInfo(AutofillType(type)),
763 view->GetTextContentsOfInput(input)); 763 view->GetTextContentsOfInput(type));
764 } 764 }
765 } 765 }
766 766
767 // Now fill from a profile. It should not overwrite any CC info. 767 // Now fill from a profile. It should not overwrite any CC info.
768 const DetailInputs& billing_inputs = 768 const DetailInputs& billing_inputs =
769 controller()->RequestedFieldsForSection(SECTION_BILLING); 769 controller()->RequestedFieldsForSection(SECTION_BILLING);
770 const DetailInput& billing_triggering_input = billing_inputs[0]; 770 const ServerFieldType billing_triggering_type = billing_inputs[0].type;
771 value = full_profile.GetRawInfo(triggering_input.type); 771 value = full_profile.GetRawInfo(triggering_type);
772 view->SetTextContentsOfInput(billing_triggering_input, 772 view->SetTextContentsOfInput(billing_triggering_type,
773 value.substr(0, value.size() / 2)); 773 value.substr(0, value.size() / 2));
774 view->ActivateInput(billing_triggering_input); 774 view->ActivateInput(billing_triggering_type);
775 775
776 ASSERT_EQ(billing_triggering_input.type, controller()->popup_input_type()); 776 ASSERT_EQ(billing_triggering_type, controller()->popup_input_type());
777 controller()->DidAcceptSuggestion(base::string16(), 0); 777 controller()->DidAcceptSuggestion(base::string16(), 0);
778 778
779 for (size_t i = 0; i < inputs.size(); ++i) { 779 for (size_t i = 0; i < inputs.size(); ++i) {
780 const DetailInput& input = inputs[i]; 780 const ServerFieldType type = inputs[i].type;
781 if (&input == &triggering_input || 781 if (type == triggering_type ||
782 input.type == CREDIT_CARD_EXP_MONTH || 782 type == CREDIT_CARD_EXP_MONTH ||
783 input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { 783 type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
784 EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)), 784 EXPECT_EQ(wrapper2.GetInfo(AutofillType(type)),
785 view->GetTextContentsOfInput(input)); 785 view->GetTextContentsOfInput(type));
786 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) { 786 } else if (type == CREDIT_CARD_VERIFICATION_CODE) {
787 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); 787 EXPECT_TRUE(view->GetTextContentsOfInput(type).empty());
788 } else { 788 } else {
789 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), 789 EXPECT_EQ(wrapper1.GetInfo(AutofillType(type)),
790 view->GetTextContentsOfInput(input)); 790 view->GetTextContentsOfInput(type));
791 } 791 }
792 } 792 }
793 } 793 }
794 794
795 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) { 795 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) {
796 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); 796 EXPECT_TRUE(controller()->ShouldShowErrorBubble());
797 797
798 CreditCard card(test::GetCreditCard()); 798 CreditCard card(test::GetCreditCard());
799 ASSERT_FALSE(card.IsVerified()); 799 ASSERT_FALSE(card.IsVerified());
800 controller()->GetTestingManager()->AddTestingCreditCard(&card); 800 controller()->GetTestingManager()->AddTestingCreditCard(&card);
801 801
802 const DetailInputs& cc_inputs =
803 controller()->RequestedFieldsForSection(SECTION_CC);
804 const DetailInput& cc_number_input = cc_inputs[0];
805 ASSERT_EQ(CREDIT_CARD_NUMBER, cc_number_input.type);
806
807 TestableAutofillDialogView* view = controller()->GetTestableView(); 802 TestableAutofillDialogView* view = controller()->GetTestableView();
808 view->SetTextContentsOfInput( 803 view->SetTextContentsOfInput(
809 cc_number_input, 804 CREDIT_CARD_NUMBER,
810 card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1)); 805 card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1));
811 806
812 view->ActivateInput(cc_number_input); 807 view->ActivateInput(CREDIT_CARD_NUMBER);
813 EXPECT_FALSE(controller()->ShouldShowErrorBubble()); 808 EXPECT_FALSE(controller()->ShouldShowErrorBubble());
814 809
815 controller()->FocusMoved(); 810 controller()->FocusMoved();
816 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); 811 EXPECT_TRUE(controller()->ShouldShowErrorBubble());
817 } 812 }
818 813
819 // Ensure that expired cards trigger invalid suggestions. 814 // Ensure that expired cards trigger invalid suggestions.
820 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) { 815 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ExpiredCard) {
821 CreditCard verified_card(test::GetCreditCard()); 816 CreditCard verified_card(test::GetCreditCard());
822 verified_card.set_origin("Chrome settings"); 817 verified_card.set_origin("Chrome settings");
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314. 943 // Flaky on Win7, WinXP, and Win Aura. http://crbug.com/270314.
949 #if defined(OS_WIN) 944 #if defined(OS_WIN)
950 #define MAYBE_PreservedSections DISABLED_PreservedSections 945 #define MAYBE_PreservedSections DISABLED_PreservedSections
951 #else 946 #else
952 #define MAYBE_PreservedSections PreservedSections 947 #define MAYBE_PreservedSections PreservedSections
953 #endif 948 #endif
954 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { 949 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) {
955 controller()->set_use_validation(true); 950 controller()->set_use_validation(true);
956 951
957 TestableAutofillDialogView* view = controller()->GetTestableView(); 952 TestableAutofillDialogView* view = controller()->GetTestableView();
958 953 view->SetTextContentsOfInput(CREDIT_CARD_NUMBER,
959 { 954 ASCIIToUTF16("4111111111111111"));
960 // Create some valid inputted billing data.
961 const DetailInput& cc_number =
962 controller()->RequestedFieldsForSection(SECTION_CC)[0];
963 EXPECT_EQ(cc_number.type, CREDIT_CARD_NUMBER);
964 view->SetTextContentsOfInput(cc_number, ASCIIToUTF16("4111111111111111"));
965 }
966 955
967 // Create some invalid, manually inputted shipping data. 956 // Create some invalid, manually inputted shipping data.
968 const DetailInput& shipping_zip = 957 view->SetTextContentsOfInput(ADDRESS_HOME_ZIP, ASCIIToUTF16("shipping zip"));
969 controller()->RequestedFieldsForSection(SECTION_SHIPPING)[5];
970 ASSERT_EQ(ADDRESS_HOME_ZIP, shipping_zip.type);
971 view->SetTextContentsOfInput(shipping_zip, ASCIIToUTF16("shipping zip"));
972 958
973 // Switch to Wallet by simulating a successful server response. 959 // Switch to Wallet by simulating a successful server response.
974 controller()->OnDidFetchWalletCookieValue(std::string()); 960 controller()->OnDidFetchWalletCookieValue(std::string());
975 controller()->OnDidGetWalletItems( 961 controller()->OnDidGetWalletItems(
976 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); 962 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED));
977 ASSERT_TRUE(controller()->IsPayingWithWallet()); 963 ASSERT_TRUE(controller()->IsPayingWithWallet());
978 964
979 { 965 // The valid data should be preserved.
980 // The valid data should be preserved. 966 EXPECT_EQ(ASCIIToUTF16("4111111111111111"),
981 const DetailInput& cc_number = 967 view->GetTextContentsOfInput(CREDIT_CARD_NUMBER));
982 controller()->RequestedFieldsForSection(SECTION_CC_BILLING)[0];
983 EXPECT_EQ(cc_number.type, CREDIT_CARD_NUMBER);
984 EXPECT_EQ(ASCIIToUTF16("4111111111111111"),
985 view->GetTextContentsOfInput(cc_number));
986 }
987 968
988 // The invalid data should be dropped. 969 // The invalid data should be dropped.
989 EXPECT_TRUE(view->GetTextContentsOfInput(shipping_zip).empty()); 970 EXPECT_TRUE(view->GetTextContentsOfInput(ADDRESS_HOME_ZIP).empty());
990 971
991 // Switch back to Autofill. 972 // Switch back to Autofill.
992 ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser(); 973 ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser();
993 account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1); 974 account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1);
994 ASSERT_FALSE(controller()->IsPayingWithWallet()); 975 ASSERT_FALSE(controller()->IsPayingWithWallet());
995 976
996 { 977 // The valid data should still be preserved when switched back.
997 // The valid data should still be preserved when switched back. 978 EXPECT_EQ(ASCIIToUTF16("4111111111111111"),
998 const DetailInput& cc_number = 979 view->GetTextContentsOfInput(CREDIT_CARD_NUMBER));
999 controller()->RequestedFieldsForSection(SECTION_CC)[0];
1000 EXPECT_EQ(cc_number.type, CREDIT_CARD_NUMBER);
1001 EXPECT_EQ(ASCIIToUTF16("4111111111111111"),
1002 view->GetTextContentsOfInput(cc_number));
1003 }
1004 } 980 }
1005 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) 981 #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
1006 982
1007 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, 983 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
1008 GeneratedCardLastFourAfterVerifyCvv) { 984 GeneratedCardLastFourAfterVerifyCvv) {
1009 controller()->OnDidFetchWalletCookieValue(std::string()); 985 controller()->OnDidFetchWalletCookieValue(std::string());
1010 986
1011 scoped_ptr<wallet::WalletItems> wallet_items = 987 scoped_ptr<wallet::WalletItems> wallet_items =
1012 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); 988 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED);
1013 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); 989 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument());
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 ASSERT_TRUE(card.IsVerified()); 1193 ASSERT_TRUE(card.IsVerified());
1218 1194
1219 // Add the card and check that there's a menu for that section. 1195 // Add the card and check that there's a menu for that section.
1220 controller()->GetTestingManager()->AddTestingCreditCard(&card); 1196 controller()->GetTestingManager()->AddTestingCreditCard(&card);
1221 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_CC)); 1197 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_CC));
1222 1198
1223 // Select the invalid, suggested card from the menu. 1199 // Select the invalid, suggested card from the menu.
1224 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(0); 1200 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(0);
1225 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); 1201 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC));
1226 1202
1227 const DetailInputs& inputs =
1228 controller()->RequestedFieldsForSection(SECTION_CC);
1229 const DetailInput& cc_exp_month = inputs[1];
1230 ASSERT_EQ(CREDIT_CARD_EXP_MONTH, cc_exp_month.type);
1231
1232 // Get the contents of the combobox of the credit card's expiration month. 1203 // Get the contents of the combobox of the credit card's expiration month.
1233 TestableAutofillDialogView* view = controller()->GetTestableView(); 1204 TestableAutofillDialogView* view = controller()->GetTestableView();
1234 base::string16 cc_exp_month_text = view->GetTextContentsOfInput(cc_exp_month); 1205 base::string16 cc_exp_month_text =
1206 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH);
1235 1207
1236 // Select "New X..." from the suggestion menu to clear the section's inputs. 1208 // Select "New X..." from the suggestion menu to clear the section's inputs.
1237 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(1); 1209 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(1);
1238 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); 1210 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC));
1239 1211
1240 // Ensure that the credit card expiration month has changed. 1212 // Ensure that the credit card expiration month has changed.
1241 EXPECT_NE(cc_exp_month_text, view->GetTextContentsOfInput(cc_exp_month)); 1213 EXPECT_NE(cc_exp_month_text,
1214 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH));
1242 } 1215 }
1243 1216
1244 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, TabOpensToJustRight) { 1217 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, TabOpensToJustRight) {
1245 ASSERT_TRUE(browser()->is_type_tabbed()); 1218 ASSERT_TRUE(browser()->is_type_tabbed());
1246 1219
1247 // Tabs should currently be: / rAc() \. 1220 // Tabs should currently be: / rAc() \.
1248 content::WebContents* dialog_invoker = controller()->GetWebContents(); 1221 content::WebContents* dialog_invoker = controller()->GetWebContents();
1249 EXPECT_EQ(dialog_invoker, GetActiveWebContents()); 1222 EXPECT_EQ(dialog_invoker, GetActiveWebContents());
1250 1223
1251 TabStripModel* tab_strip = browser()->tab_strip_model(); 1224 TabStripModel* tab_strip = browser()->tab_strip_model();
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 MAYBE_DoesntWorkOnBrokenHttps) { 1390 MAYBE_DoesntWorkOnBrokenHttps) {
1418 net::SpawnedTestServer https_server( 1391 net::SpawnedTestServer https_server(
1419 net::SpawnedTestServer::TYPE_HTTPS, 1392 net::SpawnedTestServer::TYPE_HTTPS,
1420 SSLOptions(SSLOptions::CERT_EXPIRED), 1393 SSLOptions(SSLOptions::CERT_EXPIRED),
1421 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 1394 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
1422 ASSERT_TRUE(https_server.Start()); 1395 ASSERT_TRUE(https_server.Start());
1423 EXPECT_FALSE(RunTestPage(https_server)); 1396 EXPECT_FALSE(RunTestPage(https_server));
1424 } 1397 }
1425 1398
1426 } // namespace autofill 1399 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698