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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 305 } |
306 | 306 |
307 content::WebContents* GetActiveWebContents() { | 307 content::WebContents* GetActiveWebContents() { |
308 return browser()->tab_strip_model()->GetActiveWebContents(); | 308 return browser()->tab_strip_model()->GetActiveWebContents(); |
309 } | 309 } |
310 | 310 |
311 content::RenderViewHost* GetRenderViewHost() { | 311 content::RenderViewHost* GetRenderViewHost() { |
312 return GetActiveWebContents()->GetRenderViewHost(); | 312 return GetActiveWebContents()->GetRenderViewHost(); |
313 } | 313 } |
314 | 314 |
315 scoped_ptr<AutofillDialogViewTester> GetViewTester() { | 315 std::unique_ptr<AutofillDialogViewTester> GetViewTester() { |
316 return AutofillDialogViewTester::For(controller()->view()); | 316 return AutofillDialogViewTester::For(controller()->view()); |
317 } | 317 } |
318 | 318 |
319 TestAutofillDialogController* controller() { return controller_; } | 319 TestAutofillDialogController* controller() { return controller_; } |
320 | 320 |
321 void RunMessageLoop() { | 321 void RunMessageLoop() { |
322 message_loop_runner_->Run(); | 322 message_loop_runner_->Run(); |
323 } | 323 } |
324 | 324 |
325 // Loads an HTML page in |GetActiveWebContents()| with markup as follows: | 325 // Loads an HTML page in |GetActiveWebContents()| with markup as follows: |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 WaitForWebDB(); | 503 WaitForWebDB(); |
504 } | 504 } |
505 | 505 |
506 private: | 506 private: |
507 void WaitForWebDB() { | 507 void WaitForWebDB() { |
508 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); | 508 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); |
509 } | 509 } |
510 | 510 |
511 TestAutofillDialogController* controller_; // Weak reference. | 511 TestAutofillDialogController* controller_; // Weak reference. |
512 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 512 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
513 scoped_ptr<content::DOMMessageQueue> dom_message_queue_; | 513 std::unique_ptr<content::DOMMessageQueue> dom_message_queue_; |
514 | 514 |
515 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); | 515 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerTest); |
516 }; | 516 }; |
517 | 517 |
518 // Submit the form data. | 518 // Submit the form data. |
519 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { | 519 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Submit) { |
520 base::HistogramTester histogram; | 520 base::HistogramTester histogram; |
521 AddCreditcardToProfile(controller()->profile(), | 521 AddCreditcardToProfile(controller()->profile(), |
522 test::GetVerifiedCreditCard()); | 522 test::GetVerifiedCreditCard()); |
523 AddAutofillProfileToProfile(controller()->profile(), | 523 AddAutofillProfileToProfile(controller()->profile(), |
524 test::GetVerifiedProfile()); | 524 test::GetVerifiedProfile()); |
525 scoped_ptr<AutofillDialogViewTester> view = AutofillDialogViewTester::For( | 525 std::unique_ptr<AutofillDialogViewTester> view = |
526 controller()->view()); | 526 AutofillDialogViewTester::For(controller()->view()); |
527 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 527 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
528 GetViewTester()->SubmitForTesting(); | 528 GetViewTester()->SubmitForTesting(); |
529 RunMessageLoop(); | 529 RunMessageLoop(); |
530 | 530 |
531 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Submit", 1); | 531 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Submit", 1); |
532 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Cancel", 0); | 532 histogram.ExpectTotalCount("RequestAutocomplete.UiDuration.Cancel", 0); |
533 } | 533 } |
534 | 534 |
535 // Cancel out of the dialog. | 535 // Cancel out of the dialog. |
536 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { | 536 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, Cancel) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 // Select "Add new shipping address...". | 628 // Select "Add new shipping address...". |
629 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); | 629 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); |
630 model->ActivatedAt(model->GetItemCount() - 2); | 630 model->ActivatedAt(model->GetItemCount() - 2); |
631 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 631 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
632 | 632 |
633 // Enter something in a shipping input. | 633 // Enter something in a shipping input. |
634 const DetailInputs& inputs = | 634 const DetailInputs& inputs = |
635 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 635 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
636 const ServerFieldType triggering_type = inputs[0].type; | 636 const ServerFieldType triggering_type = inputs[0].type; |
637 base::string16 value = full_profile.GetRawInfo(triggering_type); | 637 base::string16 value = full_profile.GetRawInfo(triggering_type); |
638 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 638 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
639 view->SetTextContentsOfInput(triggering_type, | 639 view->SetTextContentsOfInput(triggering_type, |
640 value.substr(0, value.size() / 2)); | 640 value.substr(0, value.size() / 2)); |
641 view->ActivateInput(triggering_type); | 641 view->ActivateInput(triggering_type); |
642 | 642 |
643 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 643 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
644 controller()->DidAcceptSuggestion(base::string16(), 0, 1); | 644 controller()->DidAcceptSuggestion(base::string16(), 0, 1); |
645 | 645 |
646 // All inputs should be filled. | 646 // All inputs should be filled. |
647 AutofillProfileWrapper wrapper(&full_profile); | 647 AutofillProfileWrapper wrapper(&full_profile); |
648 for (size_t i = 0; i < inputs.size(); ++i) { | 648 for (size_t i = 0; i < inputs.size(); ++i) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 CreditCard card2; | 723 CreditCard card2; |
724 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); | 724 test::SetCreditCardInfo(&card2, "B Bird", "3111111111111111", "11", "2017"); |
725 controller()->GetTestingManager()->AddTestingCreditCard(&card2); | 725 controller()->GetTestingManager()->AddTestingCreditCard(&card2); |
726 AutofillProfile full_profile(test::GetFullProfile()); | 726 AutofillProfile full_profile(test::GetFullProfile()); |
727 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 727 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
728 | 728 |
729 const DetailInputs& inputs = | 729 const DetailInputs& inputs = |
730 controller()->RequestedFieldsForSection(SECTION_CC); | 730 controller()->RequestedFieldsForSection(SECTION_CC); |
731 const ServerFieldType triggering_type = inputs[0].type; | 731 const ServerFieldType triggering_type = inputs[0].type; |
732 base::string16 value = card1.GetRawInfo(triggering_type); | 732 base::string16 value = card1.GetRawInfo(triggering_type); |
733 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 733 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
734 view->SetTextContentsOfInput(triggering_type, | 734 view->SetTextContentsOfInput(triggering_type, |
735 value.substr(0, value.size() / 2)); | 735 value.substr(0, value.size() / 2)); |
736 view->ActivateInput(triggering_type); | 736 view->ActivateInput(triggering_type); |
737 | 737 |
738 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 738 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
739 controller()->DidAcceptSuggestion(base::string16(), 0, 1); | 739 controller()->DidAcceptSuggestion(base::string16(), 0, 1); |
740 | 740 |
741 // All inputs should be filled. | 741 // All inputs should be filled. |
742 AutofillCreditCardWrapper wrapper1(&card1); | 742 AutofillCreditCardWrapper wrapper1(&card1); |
743 for (size_t i = 0; i < inputs.size(); ++i) { | 743 for (size_t i = 0; i < inputs.size(); ++i) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 | 800 |
801 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) { | 801 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) { |
802 controller()->set_use_validation(true); | 802 controller()->set_use_validation(true); |
803 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); | 803 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); |
804 | 804 |
805 CreditCard card(test::GetCreditCard()); | 805 CreditCard card(test::GetCreditCard()); |
806 ASSERT_FALSE(card.IsVerified()); | 806 ASSERT_FALSE(card.IsVerified()); |
807 controller()->GetTestingManager()->AddTestingCreditCard(&card); | 807 controller()->GetTestingManager()->AddTestingCreditCard(&card); |
808 | 808 |
809 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_CC)); | 809 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_CC)); |
810 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 810 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
811 view->SetTextContentsOfInput( | 811 view->SetTextContentsOfInput( |
812 CREDIT_CARD_NUMBER, | 812 CREDIT_CARD_NUMBER, |
813 card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1)); | 813 card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1)); |
814 | 814 |
815 view->ActivateInput(CREDIT_CARD_NUMBER); | 815 view->ActivateInput(CREDIT_CARD_NUMBER); |
816 EXPECT_FALSE(controller()->ShouldShowErrorBubble()); | 816 EXPECT_FALSE(controller()->ShouldShowErrorBubble()); |
817 | 817 |
818 controller()->FocusMoved(); | 818 controller()->FocusMoved(); |
819 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); | 819 EXPECT_TRUE(controller()->ShouldShowErrorBubble()); |
820 | 820 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 | 878 |
879 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocompleteEvent) { | 879 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocompleteEvent) { |
880 AutofillDialogControllerImpl* controller = | 880 AutofillDialogControllerImpl* controller = |
881 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); | 881 SetUpHtmlAndInvoke("<input autocomplete='cc-name'>"); |
882 ASSERT_TRUE(controller); | 882 ASSERT_TRUE(controller); |
883 | 883 |
884 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); | 884 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); |
885 AddAutofillProfileToProfile(controller->profile(), | 885 AddAutofillProfileToProfile(controller->profile(), |
886 test::GetVerifiedProfile()); | 886 test::GetVerifiedProfile()); |
887 | 887 |
888 scoped_ptr<AutofillDialogViewTester> view = | 888 std::unique_ptr<AutofillDialogViewTester> view = |
889 AutofillDialogViewTester::For(controller->view()); | 889 AutofillDialogViewTester::For(controller->view()); |
890 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 890 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
891 view->SubmitForTesting(); | 891 view->SubmitForTesting(); |
892 ExpectDomMessage("success"); | 892 ExpectDomMessage("success"); |
893 } | 893 } |
894 | 894 |
895 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 895 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
896 AutocompleteErrorEventReasonInvalid) { | 896 AutocompleteErrorEventReasonInvalid) { |
897 AutofillDialogControllerImpl* controller = | 897 AutofillDialogControllerImpl* controller = |
898 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>"); | 898 SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>"); |
899 ASSERT_TRUE(controller); | 899 ASSERT_TRUE(controller); |
900 | 900 |
901 const CreditCard& credit_card = test::GetVerifiedCreditCard(); | 901 const CreditCard& credit_card = test::GetVerifiedCreditCard(); |
902 ASSERT_TRUE(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL) | 902 ASSERT_TRUE(credit_card.GetRawInfo(CREDIT_CARD_NAME_FULL) |
903 .find(ASCIIToUTF16("zebra")) == base::string16::npos); | 903 .find(ASCIIToUTF16("zebra")) == base::string16::npos); |
904 AddCreditcardToProfile(controller->profile(), credit_card); | 904 AddCreditcardToProfile(controller->profile(), credit_card); |
905 AddAutofillProfileToProfile(controller->profile(), | 905 AddAutofillProfileToProfile(controller->profile(), |
906 test::GetVerifiedProfile()); | 906 test::GetVerifiedProfile()); |
907 | 907 |
908 scoped_ptr<AutofillDialogViewTester> view = | 908 std::unique_ptr<AutofillDialogViewTester> view = |
909 AutofillDialogViewTester::For(controller->view()); | 909 AutofillDialogViewTester::For(controller->view()); |
910 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 910 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
911 view->SubmitForTesting(); | 911 view->SubmitForTesting(); |
912 ExpectDomMessage("error: invalid"); | 912 ExpectDomMessage("error: invalid"); |
913 | 913 |
914 int invalid_count = -1; | 914 int invalid_count = -1; |
915 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 915 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
916 GetRenderViewHost(), "send(invalidEvents.length);", &invalid_count)); | 916 GetRenderViewHost(), "send(invalidEvents.length);", &invalid_count)); |
917 EXPECT_EQ(1, invalid_count); | 917 EXPECT_EQ(1, invalid_count); |
918 | 918 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 972 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
973 FillFormIncludesCVC) { | 973 FillFormIncludesCVC) { |
974 AutofillDialogControllerImpl* controller = | 974 AutofillDialogControllerImpl* controller = |
975 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>"); | 975 SetUpHtmlAndInvoke("<input autocomplete='cc-csc'>"); |
976 ASSERT_TRUE(controller); | 976 ASSERT_TRUE(controller); |
977 | 977 |
978 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); | 978 AddCreditcardToProfile(controller->profile(), test::GetVerifiedCreditCard()); |
979 AddAutofillProfileToProfile(controller->profile(), | 979 AddAutofillProfileToProfile(controller->profile(), |
980 test::GetVerifiedProfile()); | 980 test::GetVerifiedProfile()); |
981 | 981 |
982 scoped_ptr<AutofillDialogViewTester> view = | 982 std::unique_ptr<AutofillDialogViewTester> view = |
983 AutofillDialogViewTester::For(controller->view()); | 983 AutofillDialogViewTester::For(controller->view()); |
984 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); | 984 view->SetTextContentsOfSuggestionInput(SECTION_CC, ASCIIToUTF16("123")); |
985 view->SubmitForTesting(); | 985 view->SubmitForTesting(); |
986 ExpectDomMessage("success"); | 986 ExpectDomMessage("success"); |
987 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc")); | 987 EXPECT_EQ("123", GetValueForHTMLFieldOfType("cc-csc")); |
988 } | 988 } |
989 | 989 |
990 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { | 990 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { |
991 // Ensure the input under test is a combobox. | 991 // Ensure the input under test is a combobox. |
992 ASSERT_TRUE( | 992 ASSERT_TRUE( |
993 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)); | 993 controller()->ComboboxModelForAutofillType(CREDIT_CARD_EXP_MONTH)); |
994 | 994 |
995 // Set up an expired card. | 995 // Set up an expired card. |
996 CreditCard card; | 996 CreditCard card; |
997 test::SetCreditCardInfo(&card, "Roy Demeo", "4111111111111111", "8", "2013"); | 997 test::SetCreditCardInfo(&card, "Roy Demeo", "4111111111111111", "8", "2013"); |
998 card.set_origin("Chrome settings"); | 998 card.set_origin("Chrome settings"); |
999 ASSERT_TRUE(card.IsVerified()); | 999 ASSERT_TRUE(card.IsVerified()); |
1000 | 1000 |
1001 // Add the card and check that there's a menu for that section. | 1001 // Add the card and check that there's a menu for that section. |
1002 controller()->GetTestingManager()->AddTestingCreditCard(&card); | 1002 controller()->GetTestingManager()->AddTestingCreditCard(&card); |
1003 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_CC)); | 1003 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_CC)); |
1004 | 1004 |
1005 // Select the invalid, suggested card from the menu. | 1005 // Select the invalid, suggested card from the menu. |
1006 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(0); | 1006 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(0); |
1007 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); | 1007 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); |
1008 | 1008 |
1009 // Get the contents of the combobox of the credit card's expiration month. | 1009 // Get the contents of the combobox of the credit card's expiration month. |
1010 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1010 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
1011 base::string16 cc_exp_month_text = | 1011 base::string16 cc_exp_month_text = |
1012 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH); | 1012 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH); |
1013 | 1013 |
1014 // Select "New X..." from the suggestion menu to clear the section's inputs. | 1014 // Select "New X..." from the suggestion menu to clear the section's inputs. |
1015 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(1); | 1015 controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(1); |
1016 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); | 1016 EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); |
1017 | 1017 |
1018 // Ensure that the credit card expiration month has changed. | 1018 // Ensure that the credit card expiration month has changed. |
1019 EXPECT_NE(cc_exp_month_text, | 1019 EXPECT_NE(cc_exp_month_text, |
1020 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH)); | 1020 view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 | 1123 |
1124 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 1124 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
1125 CountryChangeRebuildsSection) { | 1125 CountryChangeRebuildsSection) { |
1126 EXPECT_FALSE(SectionHasField(SECTION_BILLING, ADDRESS_BILLING_SORTING_CODE)); | 1126 EXPECT_FALSE(SectionHasField(SECTION_BILLING, ADDRESS_BILLING_SORTING_CODE)); |
1127 EXPECT_FALSE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); | 1127 EXPECT_FALSE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); |
1128 | 1128 |
1129 // Select "Add new shipping address...". | 1129 // Select "Add new shipping address...". |
1130 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1130 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
1131 | 1131 |
1132 // Add some valid user input that should be preserved when country changes. | 1132 // Add some valid user input that should be preserved when country changes. |
1133 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1133 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
1134 view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw")); | 1134 view->SetTextContentsOfInput(NAME_FULL, ASCIIToUTF16("B. Loblaw")); |
1135 | 1135 |
1136 // Change both sections' countries. | 1136 // Change both sections' countries. |
1137 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("France")); | 1137 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("France")); |
1138 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1138 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
1139 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Belarus")); | 1139 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Belarus")); |
1140 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1140 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
1141 | 1141 |
1142 // Verify the name is still there. | 1142 // Verify the name is still there. |
1143 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); | 1143 EXPECT_EQ(ASCIIToUTF16("B. Loblaw"), view->GetTextContentsOfInput(NAME_FULL)); |
1144 | 1144 |
1145 EXPECT_TRUE(SectionHasField(SECTION_BILLING, ADDRESS_BILLING_SORTING_CODE)); | 1145 EXPECT_TRUE(SectionHasField(SECTION_BILLING, ADDRESS_BILLING_SORTING_CODE)); |
1146 EXPECT_TRUE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); | 1146 EXPECT_TRUE(SectionHasField(SECTION_SHIPPING, ADDRESS_HOME_SORTING_CODE)); |
1147 } | 1147 } |
1148 | 1148 |
1149 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewResetsCountry) { | 1149 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewResetsCountry) { |
1150 AutofillProfile verified_profile(test::GetVerifiedProfile()); | 1150 AutofillProfile verified_profile(test::GetVerifiedProfile()); |
1151 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 1151 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
1152 | 1152 |
1153 // Select "Add new billing/shipping address...". | 1153 // Select "Add new billing/shipping address...". |
1154 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); | 1154 controller()->MenuModelForSection(SECTION_BILLING)->ActivatedAt(1); |
1155 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); | 1155 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(2); |
1156 | 1156 |
1157 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1157 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
1158 ASSERT_EQ(ASCIIToUTF16("United States"), | 1158 ASSERT_EQ(ASCIIToUTF16("United States"), |
1159 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1159 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
1160 ASSERT_EQ(ASCIIToUTF16("United States"), | 1160 ASSERT_EQ(ASCIIToUTF16("United States"), |
1161 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1161 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
1162 | 1162 |
1163 // Switch both billing and shipping countries. | 1163 // Switch both billing and shipping countries. |
1164 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("Brazil")); | 1164 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("Brazil")); |
1165 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1165 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
1166 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); | 1166 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("France")); |
1167 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1167 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
(...skipping 10 matching lines...) Expand all Loading... |
1178 | 1178 |
1179 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 1179 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
1180 FillingFormRebuildsInputs) { | 1180 FillingFormRebuildsInputs) { |
1181 AutofillProfile full_profile(test::GetFullProfile()); | 1181 AutofillProfile full_profile(test::GetFullProfile()); |
1182 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); | 1182 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); |
1183 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1183 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1184 | 1184 |
1185 // Select "Add new shipping address...". | 1185 // Select "Add new shipping address...". |
1186 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1186 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
1187 | 1187 |
1188 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1188 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
1189 ASSERT_EQ(ASCIIToUTF16("United States"), | 1189 ASSERT_EQ(ASCIIToUTF16("United States"), |
1190 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1190 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
1191 ASSERT_EQ(ASCIIToUTF16("United States"), | 1191 ASSERT_EQ(ASCIIToUTF16("United States"), |
1192 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1192 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
1193 | 1193 |
1194 const ServerFieldType input_type = EMAIL_ADDRESS; | 1194 const ServerFieldType input_type = EMAIL_ADDRESS; |
1195 base::string16 name = full_profile.GetRawInfo(input_type); | 1195 base::string16 name = full_profile.GetRawInfo(input_type); |
1196 view->SetTextContentsOfInput(input_type, name.substr(0, name.size() / 2)); | 1196 view->SetTextContentsOfInput(input_type, name.substr(0, name.size() / 2)); |
1197 view->ActivateInput(input_type); | 1197 view->ActivateInput(input_type); |
1198 ASSERT_EQ(input_type, controller()->popup_input_type()); | 1198 ASSERT_EQ(input_type, controller()->popup_input_type()); |
1199 controller()->DidAcceptSuggestion(base::string16(), 0, 1); | 1199 controller()->DidAcceptSuggestion(base::string16(), 0, 1); |
1200 | 1200 |
1201 EXPECT_EQ(ASCIIToUTF16("Germany"), | 1201 EXPECT_EQ(ASCIIToUTF16("Germany"), |
1202 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1202 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
1203 EXPECT_EQ(ASCIIToUTF16("United States"), | 1203 EXPECT_EQ(ASCIIToUTF16("United States"), |
1204 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1204 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
1205 } | 1205 } |
1206 | 1206 |
1207 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 1207 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
1208 FillingFormPreservesChangedCountry) { | 1208 FillingFormPreservesChangedCountry) { |
1209 AutofillProfile full_profile(test::GetFullProfile()); | 1209 AutofillProfile full_profile(test::GetFullProfile()); |
1210 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); | 1210 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); |
1211 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1211 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1212 | 1212 |
1213 // Select "Add new shipping address...". | 1213 // Select "Add new shipping address...". |
1214 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1214 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
1215 | 1215 |
1216 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1216 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
1217 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("France")); | 1217 view->SetTextContentsOfInput(ADDRESS_BILLING_COUNTRY, ASCIIToUTF16("France")); |
1218 view->ActivateInput(ADDRESS_BILLING_COUNTRY); | 1218 view->ActivateInput(ADDRESS_BILLING_COUNTRY); |
1219 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Belarus")); | 1219 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Belarus")); |
1220 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1220 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
1221 | 1221 |
1222 base::string16 name = full_profile.GetRawInfo(NAME_FULL); | 1222 base::string16 name = full_profile.GetRawInfo(NAME_FULL); |
1223 view->SetTextContentsOfInput(NAME_FULL, name.substr(0, name.size() / 2)); | 1223 view->SetTextContentsOfInput(NAME_FULL, name.substr(0, name.size() / 2)); |
1224 view->ActivateInput(NAME_FULL); | 1224 view->ActivateInput(NAME_FULL); |
1225 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); | 1225 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); |
1226 controller()->DidAcceptSuggestion(base::string16(), 0, 1); | 1226 controller()->DidAcceptSuggestion(base::string16(), 0, 1); |
1227 | 1227 |
1228 EXPECT_EQ(ASCIIToUTF16("France"), | 1228 EXPECT_EQ(ASCIIToUTF16("France"), |
1229 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1229 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
1230 EXPECT_EQ(ASCIIToUTF16("Belarus"), | 1230 EXPECT_EQ(ASCIIToUTF16("Belarus"), |
1231 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1231 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
1232 } | 1232 } |
1233 | 1233 |
1234 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, RulesLoaded) { | 1234 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, RulesLoaded) { |
1235 // Select "Add new shipping address...". | 1235 // Select "Add new shipping address...". |
1236 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1236 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
1237 controller()->set_use_validation(true); | 1237 controller()->set_use_validation(true); |
1238 | 1238 |
1239 EXPECT_CALL(*controller()->GetMockValidator(), | 1239 EXPECT_CALL(*controller()->GetMockValidator(), |
1240 ValidateAddress(CountryCodeMatcher("DE"), _, _)).Times(2). | 1240 ValidateAddress(CountryCodeMatcher("DE"), _, _)).Times(2). |
1241 WillOnce(Return(AddressValidator::RULES_NOT_READY)); | 1241 WillOnce(Return(AddressValidator::RULES_NOT_READY)); |
1242 | 1242 |
1243 // Validation should occur on country change and see the rules haven't loaded. | 1243 // Validation should occur on country change and see the rules haven't loaded. |
1244 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1244 std::unique_ptr<AutofillDialogViewTester> view = GetViewTester(); |
1245 view->SetTextContentsOfInput(ADDRESS_HOME_ZIP, ASCIIToUTF16("123")); | 1245 view->SetTextContentsOfInput(ADDRESS_HOME_ZIP, ASCIIToUTF16("123")); |
1246 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Germany")); | 1246 view->SetTextContentsOfInput(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Germany")); |
1247 view->ActivateInput(ADDRESS_HOME_COUNTRY); | 1247 view->ActivateInput(ADDRESS_HOME_COUNTRY); |
1248 | 1248 |
1249 // Different country loaded, validation should not occur. | 1249 // Different country loaded, validation should not occur. |
1250 controller()->OnAddressValidationRulesLoaded("FR", true); | 1250 controller()->OnAddressValidationRulesLoaded("FR", true); |
1251 | 1251 |
1252 // Relevant country loaded, validation should occur. | 1252 // Relevant country loaded, validation should occur. |
1253 controller()->OnAddressValidationRulesLoaded("DE", true); | 1253 controller()->OnAddressValidationRulesLoaded("DE", true); |
1254 | 1254 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), | 1324 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), |
1325 "navigateFrame();", | 1325 "navigateFrame();", |
1326 &unused)); | 1326 &unused)); |
1327 ExpectDomMessage("iframe loaded"); | 1327 ExpectDomMessage("iframe loaded"); |
1328 ChromeAutofillClient* client = | 1328 ChromeAutofillClient* client = |
1329 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); | 1329 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); |
1330 EXPECT_FALSE(client->GetDialogControllerForTesting()); | 1330 EXPECT_FALSE(client->GetDialogControllerForTesting()); |
1331 } | 1331 } |
1332 | 1332 |
1333 } // namespace autofill | 1333 } // namespace autofill |
OLD | NEW |