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

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

Issue 23579009: [rAc] Move email address into billing address section. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Include email address in suggestion preview text, fix some compile errors (unittests need more fixi… Created 7 years, 3 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 <map> 5 #include <map>
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/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 ui::MenuModel* shipping_model = 807 ui::MenuModel* shipping_model =
808 controller()->MenuModelForSection(SECTION_SHIPPING); 808 controller()->MenuModelForSection(SECTION_SHIPPING);
809 // Since the PersonalDataManager is empty, this should only have the 809 // Since the PersonalDataManager is empty, this should only have the
810 // "use billing", "add new" and "manage" menu items. 810 // "use billing", "add new" and "manage" menu items.
811 ASSERT_TRUE(shipping_model); 811 ASSERT_TRUE(shipping_model);
812 EXPECT_EQ(3, shipping_model->GetItemCount()); 812 EXPECT_EQ(3, shipping_model->GetItemCount());
813 // On the other hand, the other models should be NULL when there's no 813 // On the other hand, the other models should be NULL when there's no
814 // suggestion. 814 // suggestion.
815 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); 815 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC));
816 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_BILLING)); 816 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_BILLING));
817 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_EMAIL));
818 817
819 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(3); 818 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(3);
820 819
821 // Empty profiles are ignored. 820 // Empty profiles are ignored.
822 AutofillProfile empty_profile(base::GenerateGUID(), kSettingsOrigin); 821 AutofillProfile empty_profile(base::GenerateGUID(), kSettingsOrigin);
823 empty_profile.SetRawInfo(NAME_FULL, ASCIIToUTF16("John Doe")); 822 empty_profile.SetRawInfo(NAME_FULL, ASCIIToUTF16("John Doe"));
824 controller()->GetTestingManager()->AddTestingProfile(&empty_profile); 823 controller()->GetTestingManager()->AddTestingProfile(&empty_profile);
825 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); 824 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING);
826 ASSERT_TRUE(shipping_model); 825 ASSERT_TRUE(shipping_model);
827 EXPECT_EQ(3, shipping_model->GetItemCount()); 826 EXPECT_EQ(3, shipping_model->GetItemCount());
828 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_EMAIL));
829 827
830 // An otherwise full but unverified profile should be ignored. 828 // An otherwise full but unverified profile should be ignored.
831 AutofillProfile full_profile(test::GetFullProfile()); 829 AutofillProfile full_profile(test::GetFullProfile());
832 full_profile.set_origin("https://www.example.com"); 830 full_profile.set_origin("https://www.example.com");
833 full_profile.SetRawInfo(ADDRESS_HOME_LINE2, string16()); 831 full_profile.SetRawInfo(ADDRESS_HOME_LINE2, string16());
834 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 832 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
835 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); 833 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING);
836 ASSERT_TRUE(shipping_model); 834 ASSERT_TRUE(shipping_model);
837 EXPECT_EQ(3, shipping_model->GetItemCount()); 835 EXPECT_EQ(3, shipping_model->GetItemCount());
838 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_EMAIL));
839 836
840 // A full, verified profile should be picked up. 837 // A full, verified profile should be picked up.
841 AutofillProfile verified_profile(test::GetVerifiedProfile()); 838 AutofillProfile verified_profile(test::GetVerifiedProfile());
842 verified_profile.SetRawInfo(ADDRESS_HOME_LINE2, string16()); 839 verified_profile.SetRawInfo(ADDRESS_HOME_LINE2, string16());
843 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); 840 controller()->GetTestingManager()->AddTestingProfile(&verified_profile);
844 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); 841 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING);
845 ASSERT_TRUE(shipping_model); 842 ASSERT_TRUE(shipping_model);
846 EXPECT_EQ(4, shipping_model->GetItemCount()); 843 EXPECT_EQ(4, shipping_model->GetItemCount());
847 EXPECT_TRUE(!!controller()->MenuModelForSection(SECTION_EMAIL));
848 } 844 }
849 845
850 // Makes sure that the choice of which Autofill profile to use for each section 846 // Makes sure that the choice of which Autofill profile to use for each section
851 // is sticky. 847 // is sticky.
852 TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) { 848 TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) {
853 AutofillProfile full_profile(test::GetFullProfile()); 849 AutofillProfile full_profile(test::GetFullProfile());
854 full_profile.set_origin(kSettingsOrigin); 850 full_profile.set_origin(kSettingsOrigin);
855 controller()->GetTestingManager()->AddTestingProfile(&full_profile); 851 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
856 AutofillProfile full_profile2(test::GetFullProfile2()); 852 AutofillProfile full_profile2(test::GetFullProfile2());
857 full_profile2.set_origin(kSettingsOrigin); 853 full_profile2.set_origin(kSettingsOrigin);
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1585
1590 // Also, the currently selected email address should get added to the new 1586 // Also, the currently selected email address should get added to the new
1591 // profile. 1587 // profile.
1592 string16 original_email = 1588 string16 original_email =
1593 full_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US"); 1589 full_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US");
1594 EXPECT_FALSE(original_email.empty()); 1590 EXPECT_FALSE(original_email.empty());
1595 EXPECT_EQ(original_email, 1591 EXPECT_EQ(original_email,
1596 added_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US")); 1592 added_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US"));
1597 } 1593 }
1598 1594
1599 // Makes sure that a newly added email address gets added to an existing profile
1600 // (as opposed to creating its own profile). http://crbug.com/240926
1601 TEST_F(AutofillDialogControllerTest, AddEmail) {
1602 SwitchToAutofill();
1603 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2);
1604
1605 AutofillProfile full_profile(test::GetVerifiedProfile());
1606 CreditCard credit_card(test::GetVerifiedCreditCard());
1607 controller()->GetTestingManager()->AddTestingProfile(&full_profile);
1608 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card);
1609
1610 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL);
1611 ASSERT_TRUE(model);
1612 // Activate the "Add email address" menu item.
1613 model->ActivatedAt(model->GetItemCount() - 2);
1614
1615 // Fill in the inputs from the profile.
1616 DetailOutputMap outputs;
1617 const DetailInputs& inputs =
1618 controller()->RequestedFieldsForSection(SECTION_EMAIL);
1619 const DetailInput& input = inputs[0];
1620 string16 new_email = ASCIIToUTF16("addemailtest@example.com");
1621 outputs[&input] = new_email;
1622 controller()->GetView()->SetUserInput(SECTION_EMAIL, outputs);
1623
1624 FillCreditCardInputs();
1625 controller()->OnAccept();
1626 std::vector<base::string16> email_values;
1627 full_profile.GetMultiInfo(
1628 AutofillType(EMAIL_ADDRESS), "en-US", &email_values);
1629 ASSERT_EQ(2U, email_values.size());
1630 EXPECT_EQ(new_email, email_values[1]);
1631 }
1632
1633 TEST_F(AutofillDialogControllerTest, VerifyCvv) { 1595 TEST_F(AutofillDialogControllerTest, VerifyCvv) {
1634 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1596 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1635 GetFullWallet(_)).Times(1); 1597 GetFullWallet(_)).Times(1);
1636 EXPECT_CALL(*controller()->GetTestingWalletClient(), 1598 EXPECT_CALL(*controller()->GetTestingWalletClient(),
1637 AuthenticateInstrument(_, _)).Times(1); 1599 AuthenticateInstrument(_, _)).Times(1);
1638 1600
1639 SubmitWithWalletItems(CompleteAndValidWalletItems()); 1601 SubmitWithWalletItems(CompleteAndValidWalletItems());
1640 1602
1641 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty()); 1603 EXPECT_TRUE(NotificationsOfType(DialogNotification::REQUIRED_ACTION).empty());
1642 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING)); 1604 EXPECT_TRUE(controller()->SectionIsActive(SECTION_SHIPPING));
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 controller()->TabActivated(); 2313 controller()->TabActivated();
2352 2314
2353 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems()); 2315 controller()->OnDidGetWalletItems(wallet::GetTestWalletItems());
2354 2316
2355 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); 2317 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING));
2356 EXPECT_EQ( 2318 EXPECT_EQ(
2357 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); 2319 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount());
2358 } 2320 }
2359 2321
2360 } // namespace autofill 2322 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698