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 "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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, | 665 EXPECT_EQ(AutofillMetrics::DIALOG_CANCELED, |
666 metric_logger().dialog_dismissal_action()); | 666 metric_logger().dialog_dismissal_action()); |
667 } | 667 } |
668 | 668 |
669 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { | 669 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { |
670 AutofillProfile full_profile(test::GetFullProfile()); | 670 AutofillProfile full_profile(test::GetFullProfile()); |
671 const base::string16 formatted_phone(ASCIIToUTF16("+1 (310) 555 1234")); | 671 const base::string16 formatted_phone(ASCIIToUTF16("+1 (310) 555 1234")); |
672 full_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, formatted_phone); | 672 full_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, formatted_phone); |
673 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 673 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
674 | 674 |
675 // Adding a new billing address. | |
groby-ooo-7-16
2014/06/30 22:01:31
Who is adding that address? Not sure I get what th
Evan Stade
2014/06/30 22:16:46
sorry, should read: "Dialog is already asking for
| |
676 EXPECT_TRUE(controller()->IsManuallyEditingSection(SECTION_BILLING)); | |
677 | |
675 // Select "Add new shipping address...". | 678 // Select "Add new shipping address...". |
676 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); | 679 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_SHIPPING); |
677 model->ActivatedAt(model->GetItemCount() - 2); | 680 model->ActivatedAt(model->GetItemCount() - 2); |
678 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); | 681 ASSERT_TRUE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); |
679 | 682 |
683 // Enter something in a shipping input. | |
680 const DetailInputs& inputs = | 684 const DetailInputs& inputs = |
681 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 685 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
682 const ServerFieldType triggering_type = inputs[0].type; | 686 const ServerFieldType triggering_type = inputs[0].type; |
683 base::string16 value = full_profile.GetRawInfo(triggering_type); | 687 base::string16 value = full_profile.GetRawInfo(triggering_type); |
684 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 688 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
685 view->SetTextContentsOfInput(triggering_type, | 689 view->SetTextContentsOfInput(triggering_type, |
686 value.substr(0, value.size() / 2)); | 690 value.substr(0, value.size() / 2)); |
687 view->ActivateInput(triggering_type); | 691 view->ActivateInput(triggering_type); |
688 | 692 |
689 ASSERT_EQ(triggering_type, controller()->popup_input_type()); | 693 ASSERT_EQ(triggering_type, controller()->popup_input_type()); |
690 controller()->DidAcceptSuggestion(base::string16(), 0); | 694 controller()->DidAcceptSuggestion(base::string16(), 0); |
691 | 695 |
692 // All inputs should be filled. | 696 // All inputs should be filled. |
693 AutofillProfileWrapper wrapper(&full_profile); | 697 AutofillProfileWrapper wrapper(&full_profile); |
694 for (size_t i = 0; i < inputs.size(); ++i) { | 698 for (size_t i = 0; i < inputs.size(); ++i) { |
695 EXPECT_EQ(wrapper.GetInfoForDisplay(AutofillType(inputs[i].type)), | 699 EXPECT_EQ(wrapper.GetInfoForDisplay(AutofillType(inputs[i].type)), |
696 view->GetTextContentsOfInput(inputs[i].type)); | 700 view->GetTextContentsOfInput(inputs[i].type)); |
697 | 701 |
698 // Double check the correct formatting is used for the phone number. | 702 // Double check the correct formatting is used for the phone number. |
699 if (inputs[i].type == PHONE_HOME_WHOLE_NUMBER) | 703 if (inputs[i].type == PHONE_HOME_WHOLE_NUMBER) |
700 EXPECT_EQ(formatted_phone, view->GetTextContentsOfInput(inputs[i].type)); | 704 EXPECT_EQ(formatted_phone, view->GetTextContentsOfInput(inputs[i].type)); |
701 } | 705 } |
702 | 706 |
707 // Inputs from the other section (billing) should be left alone. | |
708 const DetailInputs& other_section_inputs = | |
709 controller()->RequestedFieldsForSection(SECTION_BILLING); | |
710 for (size_t i = 0; i < inputs.size(); ++i) { | |
711 base::string16 input_value = | |
712 view->GetTextContentsOfInput(other_section_inputs[i].type); | |
713 // If there's a combobox, the string should be non-empty. | |
714 if (controller()->ComboboxModelForAutofillType( | |
715 other_section_inputs[i].type)) { | |
716 EXPECT_NE(base::string16(), input_value); | |
717 } else { | |
718 EXPECT_EQ(base::string16(), input_value); | |
719 } | |
720 } | |
721 | |
703 // Now simulate some user edits and try again. | 722 // Now simulate some user edits and try again. |
704 std::vector<base::string16> expectations; | 723 std::vector<base::string16> expectations; |
705 for (size_t i = 0; i < inputs.size(); ++i) { | 724 for (size_t i = 0; i < inputs.size(); ++i) { |
706 if (controller()->ComboboxModelForAutofillType(inputs[i].type)) { | 725 if (controller()->ComboboxModelForAutofillType(inputs[i].type)) { |
707 expectations.push_back(base::string16()); | 726 expectations.push_back(base::string16()); |
708 continue; | 727 continue; |
709 } | 728 } |
710 base::string16 users_input = i % 2 == 0 ? base::string16() | 729 base::string16 users_input = i % 2 == 0 ? base::string16() |
711 : ASCIIToUTF16("dummy"); | 730 : ASCIIToUTF16("dummy"); |
712 view->SetTextContentsOfInput(inputs[i].type, users_input); | 731 view->SetTextContentsOfInput(inputs[i].type, users_input); |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1664 | 1683 |
1665 // Select "Add new shipping address...". | 1684 // Select "Add new shipping address...". |
1666 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 1685 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
1667 | 1686 |
1668 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); | 1687 scoped_ptr<AutofillDialogViewTester> view = GetViewTester(); |
1669 ASSERT_EQ(ASCIIToUTF16("United States"), | 1688 ASSERT_EQ(ASCIIToUTF16("United States"), |
1670 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1689 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
1671 ASSERT_EQ(ASCIIToUTF16("United States"), | 1690 ASSERT_EQ(ASCIIToUTF16("United States"), |
1672 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1691 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
1673 | 1692 |
1674 base::string16 name = full_profile.GetRawInfo(NAME_FULL); | 1693 const ServerFieldType input_type = EMAIL_ADDRESS; |
1675 view->SetTextContentsOfInput(NAME_FULL, name.substr(0, name.size() / 2)); | 1694 base::string16 name = full_profile.GetRawInfo(input_type); |
1676 view->ActivateInput(NAME_FULL); | 1695 view->SetTextContentsOfInput(input_type, name.substr(0, name.size() / 2)); |
1677 ASSERT_EQ(NAME_FULL, controller()->popup_input_type()); | 1696 view->ActivateInput(input_type); |
1697 ASSERT_EQ(input_type, controller()->popup_input_type()); | |
1678 controller()->DidAcceptSuggestion(base::string16(), 0); | 1698 controller()->DidAcceptSuggestion(base::string16(), 0); |
1679 | 1699 |
1680 EXPECT_EQ(ASCIIToUTF16("Germany"), | 1700 EXPECT_EQ(ASCIIToUTF16("Germany"), |
1681 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); | 1701 view->GetTextContentsOfInput(ADDRESS_BILLING_COUNTRY)); |
1682 EXPECT_EQ(ASCIIToUTF16("Germany"), | 1702 EXPECT_EQ(ASCIIToUTF16("United States"), |
1683 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); | 1703 view->GetTextContentsOfInput(ADDRESS_HOME_COUNTRY)); |
1684 } | 1704 } |
1685 | 1705 |
1686 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, | 1706 IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, |
1687 FillingFormPreservesChangedCountry) { | 1707 FillingFormPreservesChangedCountry) { |
1688 AutofillProfile full_profile(test::GetFullProfile()); | 1708 AutofillProfile full_profile(test::GetFullProfile()); |
1689 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); | 1709 full_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("DE")); |
1690 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1710 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1691 | 1711 |
1692 // Select "Add new shipping address...". | 1712 // Select "Add new shipping address...". |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 "<input autocomplete='transaction-currency' value='USD'>" | 1768 "<input autocomplete='transaction-currency' value='USD'>" |
1749 "<input autocomplete='cc-csc'>"); | 1769 "<input autocomplete='cc-csc'>"); |
1750 AutofillDialogControllerImpl* controller = SetUpHtmlAndInvoke(html); | 1770 AutofillDialogControllerImpl* controller = SetUpHtmlAndInvoke(html); |
1751 ASSERT_TRUE(controller); | 1771 ASSERT_TRUE(controller); |
1752 | 1772 |
1753 EXPECT_EQ(ASCIIToUTF16("24"), controller->transaction_amount_); | 1773 EXPECT_EQ(ASCIIToUTF16("24"), controller->transaction_amount_); |
1754 EXPECT_EQ(ASCIIToUTF16("USD"), controller->transaction_currency_); | 1774 EXPECT_EQ(ASCIIToUTF16("USD"), controller->transaction_currency_); |
1755 } | 1775 } |
1756 | 1776 |
1757 } // namespace autofill | 1777 } // namespace autofill |
OLD | NEW |