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

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

Issue 127153004: Change AutofillDialogControllerImpl::input_showing_popup_ -> popup_input_type_ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 virtual bool ShouldOfferToSaveInChrome() const OVERRIDE { 159 virtual bool ShouldOfferToSaveInChrome() const OVERRIDE {
160 return false; 160 return false;
161 } 161 }
162 162
163 void ForceFinishSubmit() { 163 void ForceFinishSubmit() {
164 DoFinishSubmit(); 164 DoFinishSubmit();
165 } 165 }
166 166
167 // Increase visibility for testing. 167 // Increase visibility for testing.
168 using AutofillDialogControllerImpl::view; 168 using AutofillDialogControllerImpl::view;
169 using AutofillDialogControllerImpl::input_showing_popup; 169 using AutofillDialogControllerImpl::popup_input_type;
170 170
171 MOCK_METHOD0(LoadRiskFingerprintData, void()); 171 MOCK_METHOD0(LoadRiskFingerprintData, void());
172 172
173 virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE { 173 virtual std::vector<DialogNotification> CurrentNotifications() OVERRIDE {
174 return notifications_; 174 return notifications_;
175 } 175 }
176 176
177 void set_notifications(const std::vector<DialogNotification>& notifications) { 177 void set_notifications(const std::vector<DialogNotification>& notifications) {
178 notifications_ = notifications; 178 notifications_ = notifications;
179 } 179 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DetailInput& triggering_input = inputs[0];
560 base::string16 value = full_profile.GetRawInfo(triggering_input.type); 560 base::string16 value = full_profile.GetRawInfo(triggering_input.type);
561 TestableAutofillDialogView* view = controller()->GetTestableView(); 561 TestableAutofillDialogView* view = controller()->GetTestableView();
562 view->SetTextContentsOfInput(triggering_input, 562 view->SetTextContentsOfInput(triggering_input,
563 value.substr(0, value.size() / 2)); 563 value.substr(0, value.size() / 2));
564 view->ActivateInput(triggering_input); 564 view->ActivateInput(triggering_input);
565 565
566 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 566 ASSERT_EQ(triggering_input.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]));
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], 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] == &triggering_input || 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_input,
591 value.substr(0, value.size() / 2)); 591 value.substr(0, value.size() / 2));
592 view->ActivateInput(triggering_input); 592 view->ActivateInput(triggering_input);
593 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 593 ASSERT_EQ(triggering_input.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]));
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 DetailInput& triggering_input = inputs[0];
613 base::string16 value = full_profile.GetRawInfo(triggering_input.type); 613 base::string16 value = full_profile.GetRawInfo(triggering_input.type);
614 TestableAutofillDialogView* view = controller()->GetTestableView(); 614 TestableAutofillDialogView* view = controller()->GetTestableView();
615 view->SetTextContentsOfInput(triggering_input, 615 view->SetTextContentsOfInput(triggering_input,
616 value.substr(0, value.size() / 2)); 616 value.substr(0, value.size() / 2));
617 view->ActivateInput(triggering_input); 617 view->ActivateInput(triggering_input);
618 618
619 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 619 ASSERT_EQ(triggering_input.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 base::string16 expectation = 625 base::string16 expectation =
626 AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY ? 626 AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY ?
627 ASCIIToUTF16("United States") : 627 ASCIIToUTF16("United States") :
628 wrapper.GetInfo(AutofillType(inputs[i].type)); 628 wrapper.GetInfo(AutofillType(inputs[i].type));
629 EXPECT_EQ(expectation, view->GetTextContentsOfInput(inputs[i])); 629 EXPECT_EQ(expectation, view->GetTextContentsOfInput(inputs[i]));
(...skipping 12 matching lines...) Expand all
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_input,
650 value.substr(0, value.size() / 2)); 650 value.substr(0, value.size() / 2));
651 view->ActivateInput(triggering_input); 651 view->ActivateInput(triggering_input);
652 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 652 ASSERT_EQ(triggering_input.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]));
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,
(...skipping 11 matching lines...) Expand all
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 DetailInput& triggering_input = inputs[0];
680 EXPECT_EQ(NAME_BILLING_FULL, triggering_input.type); 680 EXPECT_EQ(NAME_BILLING_FULL, triggering_input.type);
681 TestableAutofillDialogView* view = controller()->GetTestableView(); 681 TestableAutofillDialogView* view = controller()->GetTestableView();
682 view->ActivateInput(triggering_input); 682 view->ActivateInput(triggering_input);
683 683
684 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 684 ASSERT_EQ(triggering_input.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]));
(...skipping 27 matching lines...) Expand all
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 DetailInput& triggering_input = inputs[0];
726 base::string16 value = card1.GetRawInfo(triggering_input.type); 726 base::string16 value = card1.GetRawInfo(triggering_input.type);
727 TestableAutofillDialogView* view = controller()->GetTestableView(); 727 TestableAutofillDialogView* view = controller()->GetTestableView();
728 view->SetTextContentsOfInput(triggering_input, 728 view->SetTextContentsOfInput(triggering_input,
729 value.substr(0, value.size() / 2)); 729 value.substr(0, value.size() / 2));
730 view->ActivateInput(triggering_input); 730 view->ActivateInput(triggering_input);
731 731
732 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 732 ASSERT_EQ(triggering_input.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]));
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_input.type);
745 view->SetTextContentsOfInput(triggering_input, 745 view->SetTextContentsOfInput(triggering_input,
746 value.substr(0, value.size() / 2)); 746 value.substr(0, value.size() / 2));
747 view->ActivateInput(triggering_input); 747 view->ActivateInput(triggering_input);
748 ASSERT_EQ(&triggering_input, controller()->input_showing_popup()); 748 ASSERT_EQ(triggering_input.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 DetailInput& input = inputs[i];
754 if (&input == &triggering_input || 754 if (&input == &triggering_input ||
755 input.type == CREDIT_CARD_EXP_MONTH || 755 input.type == CREDIT_CARD_EXP_MONTH ||
756 input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { 756 input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
757 EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)), 757 EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)),
758 view->GetTextContentsOfInput(input)); 758 view->GetTextContentsOfInput(input));
759 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) { 759 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) {
760 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); 760 EXPECT_TRUE(view->GetTextContentsOfInput(input).empty());
761 } else { 761 } else {
762 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), 762 EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)),
763 view->GetTextContentsOfInput(input)); 763 view->GetTextContentsOfInput(input));
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 DetailInput& billing_triggering_input = billing_inputs[0];
771 value = full_profile.GetRawInfo(triggering_input.type); 771 value = full_profile.GetRawInfo(triggering_input.type);
772 view->SetTextContentsOfInput(billing_triggering_input, 772 view->SetTextContentsOfInput(billing_triggering_input,
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_input);
775 775
776 ASSERT_EQ(&billing_triggering_input, controller()->input_showing_popup()); 776 ASSERT_EQ(billing_triggering_input.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 DetailInput& input = inputs[i];
781 if (&input == &triggering_input || 781 if (&input == &triggering_input ||
782 input.type == CREDIT_CARD_EXP_MONTH || 782 input.type == CREDIT_CARD_EXP_MONTH ||
783 input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { 783 input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
784 EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)), 784 EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)),
785 view->GetTextContentsOfInput(input)); 785 view->GetTextContentsOfInput(input));
786 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) { 786 } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) {
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 MAYBE_DoesntWorkOnBrokenHttps) { 1417 MAYBE_DoesntWorkOnBrokenHttps) {
1418 net::SpawnedTestServer https_server( 1418 net::SpawnedTestServer https_server(
1419 net::SpawnedTestServer::TYPE_HTTPS, 1419 net::SpawnedTestServer::TYPE_HTTPS,
1420 SSLOptions(SSLOptions::CERT_EXPIRED), 1420 SSLOptions(SSLOptions::CERT_EXPIRED),
1421 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 1421 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
1422 ASSERT_TRUE(https_server.Start()); 1422 ASSERT_TRUE(https_server.Start());
1423 EXPECT_FALSE(RunTestPage(https_server)); 1423 EXPECT_FALSE(RunTestPage(https_server));
1424 } 1424 }
1425 1425
1426 } // namespace autofill 1426 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698