| 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 <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 form_structure()->field(18)->Type().GetStorableType()); | 476 form_structure()->field(18)->Type().GetStorableType()); |
| 477 EXPECT_EQ(ADDRESS_HOME, form_structure()->field(18)->Type().group()); | 477 EXPECT_EQ(ADDRESS_HOME, form_structure()->field(18)->Type().group()); |
| 478 base::string16 billing_country = form_structure()->field(11)->value; | 478 base::string16 billing_country = form_structure()->field(11)->value; |
| 479 EXPECT_EQ(2U, billing_country.size()); | 479 EXPECT_EQ(2U, billing_country.size()); |
| 480 base::string16 shipping_country = form_structure()->field(18)->value; | 480 base::string16 shipping_country = form_structure()->field(18)->value; |
| 481 EXPECT_EQ(2U, shipping_country.size()); | 481 EXPECT_EQ(2U, shipping_country.size()); |
| 482 EXPECT_FALSE(billing_country.empty()); | 482 EXPECT_FALSE(billing_country.empty()); |
| 483 EXPECT_FALSE(shipping_country.empty()); | 483 EXPECT_FALSE(shipping_country.empty()); |
| 484 EXPECT_EQ(billing_country, shipping_country); | 484 EXPECT_EQ(billing_country, shipping_country); |
| 485 | 485 |
| 486 EXPECT_EQ(CREDIT_CARD_NAME, | 486 EXPECT_EQ(CREDIT_CARD_NAME_FULL, |
| 487 form_structure()->field(1)->Type().GetStorableType()); | 487 form_structure()->field(1)->Type().GetStorableType()); |
| 488 base::string16 cc_name = form_structure()->field(1)->value; | 488 base::string16 cc_name = form_structure()->field(1)->value; |
| 489 EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType()); | 489 EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType()); |
| 490 EXPECT_EQ(NAME_BILLING, form_structure()->field(6)->Type().group()); | 490 EXPECT_EQ(NAME_BILLING, form_structure()->field(6)->Type().group()); |
| 491 base::string16 billing_name = form_structure()->field(6)->value; | 491 base::string16 billing_name = form_structure()->field(6)->value; |
| 492 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().GetStorableType()); | 492 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().GetStorableType()); |
| 493 EXPECT_EQ(NAME, form_structure()->field(13)->Type().group()); | 493 EXPECT_EQ(NAME, form_structure()->field(13)->Type().group()); |
| 494 base::string16 shipping_name = form_structure()->field(13)->value; | 494 base::string16 shipping_name = form_structure()->field(13)->value; |
| 495 | 495 |
| 496 EXPECT_FALSE(cc_name.empty()); | 496 EXPECT_FALSE(cc_name.empty()); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 | 977 |
| 978 TEST_F(AutofillDialogControllerTest, AutofillCreditCards) { | 978 TEST_F(AutofillDialogControllerTest, AutofillCreditCards) { |
| 979 // Since the PersonalDataManager is empty, this should only have the | 979 // Since the PersonalDataManager is empty, this should only have the |
| 980 // default menu items. | 980 // default menu items. |
| 981 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); | 981 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); |
| 982 | 982 |
| 983 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(3); | 983 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(3); |
| 984 | 984 |
| 985 // Empty cards are ignored. | 985 // Empty cards are ignored. |
| 986 CreditCard empty_card(base::GenerateGUID(), kSettingsOrigin); | 986 CreditCard empty_card(base::GenerateGUID(), kSettingsOrigin); |
| 987 empty_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John Doe")); | 987 empty_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("John Doe")); |
| 988 controller()->GetTestingManager()->AddTestingCreditCard(&empty_card); | 988 controller()->GetTestingManager()->AddTestingCreditCard(&empty_card); |
| 989 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); | 989 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); |
| 990 | 990 |
| 991 // An otherwise full but unverified card should be ignored. | 991 // An otherwise full but unverified card should be ignored. |
| 992 CreditCard full_card(test::GetCreditCard()); | 992 CreditCard full_card(test::GetCreditCard()); |
| 993 full_card.set_origin("https://www.example.com"); | 993 full_card.set_origin("https://www.example.com"); |
| 994 controller()->GetTestingManager()->AddTestingCreditCard(&full_card); | 994 controller()->GetTestingManager()->AddTestingCreditCard(&full_card); |
| 995 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); | 995 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); |
| 996 | 996 |
| 997 // A full, verified card should be picked up. | 997 // A full, verified card should be picked up. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1023 EXPECT_EQ(ADDRESS_BILLING, form_structure()->field(9)->Type().group()); | 1023 EXPECT_EQ(ADDRESS_BILLING, form_structure()->field(9)->Type().group()); |
| 1024 EXPECT_EQ(ADDRESS_HOME_STATE, | 1024 EXPECT_EQ(ADDRESS_HOME_STATE, |
| 1025 form_structure()->field(16)->Type().GetStorableType()); | 1025 form_structure()->field(16)->Type().GetStorableType()); |
| 1026 EXPECT_EQ(ADDRESS_HOME, form_structure()->field(16)->Type().group()); | 1026 EXPECT_EQ(ADDRESS_HOME, form_structure()->field(16)->Type().group()); |
| 1027 base::string16 billing_state = form_structure()->field(9)->value; | 1027 base::string16 billing_state = form_structure()->field(9)->value; |
| 1028 base::string16 shipping_state = form_structure()->field(16)->value; | 1028 base::string16 shipping_state = form_structure()->field(16)->value; |
| 1029 EXPECT_FALSE(billing_state.empty()); | 1029 EXPECT_FALSE(billing_state.empty()); |
| 1030 EXPECT_FALSE(shipping_state.empty()); | 1030 EXPECT_FALSE(shipping_state.empty()); |
| 1031 EXPECT_NE(billing_state, shipping_state); | 1031 EXPECT_NE(billing_state, shipping_state); |
| 1032 | 1032 |
| 1033 EXPECT_EQ(CREDIT_CARD_NAME, | 1033 EXPECT_EQ(CREDIT_CARD_NAME_FULL, |
| 1034 form_structure()->field(1)->Type().GetStorableType()); | 1034 form_structure()->field(1)->Type().GetStorableType()); |
| 1035 base::string16 cc_name = form_structure()->field(1)->value; | 1035 base::string16 cc_name = form_structure()->field(1)->value; |
| 1036 EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType()); | 1036 EXPECT_EQ(NAME_FULL, form_structure()->field(6)->Type().GetStorableType()); |
| 1037 EXPECT_EQ(NAME_BILLING, form_structure()->field(6)->Type().group()); | 1037 EXPECT_EQ(NAME_BILLING, form_structure()->field(6)->Type().group()); |
| 1038 base::string16 billing_name = form_structure()->field(6)->value; | 1038 base::string16 billing_name = form_structure()->field(6)->value; |
| 1039 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().GetStorableType()); | 1039 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().GetStorableType()); |
| 1040 EXPECT_EQ(NAME, form_structure()->field(13)->Type().group()); | 1040 EXPECT_EQ(NAME, form_structure()->field(13)->Type().group()); |
| 1041 base::string16 shipping_name = form_structure()->field(13)->value; | 1041 base::string16 shipping_name = form_structure()->field(13)->value; |
| 1042 | 1042 |
| 1043 EXPECT_FALSE(cc_name.empty()); | 1043 EXPECT_FALSE(cc_name.empty()); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 FillInputs(SECTION_BILLING, test_profile); | 1473 FillInputs(SECTION_BILLING, test_profile); |
| 1474 | 1474 |
| 1475 UseBillingForShipping(); | 1475 UseBillingForShipping(); |
| 1476 | 1476 |
| 1477 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(true); | 1477 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(true); |
| 1478 controller()->OnAccept(); | 1478 controller()->OnAccept(); |
| 1479 | 1479 |
| 1480 TestPersonalDataManager* test_pdm = controller()->GetTestingManager(); | 1480 TestPersonalDataManager* test_pdm = controller()->GetTestingManager(); |
| 1481 const CreditCard& imported_card = test_pdm->imported_credit_card(); | 1481 const CreditCard& imported_card = test_pdm->imported_credit_card(); |
| 1482 EXPECT_EQ(test_profile.GetInfo(AutofillType(NAME_FULL), "en-US"), | 1482 EXPECT_EQ(test_profile.GetInfo(AutofillType(NAME_FULL), "en-US"), |
| 1483 imported_card.GetRawInfo(CREDIT_CARD_NAME)); | 1483 imported_card.GetRawInfo(CREDIT_CARD_NAME_FULL)); |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 TEST_F(AutofillDialogControllerTest, SaveCreditCardIncludesName_WithBilling) { | 1486 TEST_F(AutofillDialogControllerTest, SaveCreditCardIncludesName_WithBilling) { |
| 1487 TestPersonalDataManager* test_pdm = controller()->GetTestingManager(); | 1487 TestPersonalDataManager* test_pdm = controller()->GetTestingManager(); |
| 1488 AutofillProfile test_profile(test::GetVerifiedProfile()); | 1488 AutofillProfile test_profile(test::GetVerifiedProfile()); |
| 1489 | 1489 |
| 1490 EXPECT_CALL(*controller()->GetView(), ModelChanged()); | 1490 EXPECT_CALL(*controller()->GetView(), ModelChanged()); |
| 1491 test_pdm->AddTestingProfile(&test_profile); | 1491 test_pdm->AddTestingProfile(&test_profile); |
| 1492 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_BILLING)); | 1492 ASSERT_TRUE(controller()->MenuModelForSection(SECTION_BILLING)); |
| 1493 | 1493 |
| 1494 CreditCard test_credit_card(test::GetVerifiedCreditCard()); | 1494 CreditCard test_credit_card(test::GetVerifiedCreditCard()); |
| 1495 FillInputs(SECTION_CC, test_credit_card); | 1495 FillInputs(SECTION_CC, test_credit_card); |
| 1496 | 1496 |
| 1497 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(true); | 1497 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(true); |
| 1498 controller()->OnAccept(); | 1498 controller()->OnAccept(); |
| 1499 | 1499 |
| 1500 const CreditCard& imported_card = test_pdm->imported_credit_card(); | 1500 const CreditCard& imported_card = test_pdm->imported_credit_card(); |
| 1501 EXPECT_EQ(test_profile.GetInfo(AutofillType(NAME_FULL), "en-US"), | 1501 EXPECT_EQ(test_profile.GetInfo(AutofillType(NAME_FULL), "en-US"), |
| 1502 imported_card.GetRawInfo(CREDIT_CARD_NAME)); | 1502 imported_card.GetRawInfo(CREDIT_CARD_NAME_FULL)); |
| 1503 | 1503 |
| 1504 controller()->ViewClosed(); | 1504 controller()->ViewClosed(); |
| 1505 } | 1505 } |
| 1506 | 1506 |
| 1507 // Verifies that a call to the IconsForFields() method before the card type is | 1507 // Verifies that a call to the IconsForFields() method before the card type is |
| 1508 // known returns a placeholder image that is at least as large as the icons for | 1508 // known returns a placeholder image that is at least as large as the icons for |
| 1509 // all of the supported major credit card issuers. | 1509 // all of the supported major credit card issuers. |
| 1510 TEST_F(AutofillDialogControllerTest, IconReservedForCreditCardField) { | 1510 TEST_F(AutofillDialogControllerTest, IconReservedForCreditCardField) { |
| 1511 FieldValueMap inputs; | 1511 FieldValueMap inputs; |
| 1512 inputs[CREDIT_CARD_NUMBER] = base::string16(); | 1512 inputs[CREDIT_CARD_NUMBER] = base::string16(); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 SECTION_SHIPPING, | 1834 SECTION_SHIPPING, |
| 1835 NAME_FULL, | 1835 NAME_FULL, |
| 1836 gfx::NativeView(), | 1836 gfx::NativeView(), |
| 1837 gfx::Rect(), | 1837 gfx::Rect(), |
| 1838 profile.GetRawInfo(NAME_FULL).substr(0, 1), | 1838 profile.GetRawInfo(NAME_FULL).substr(0, 1), |
| 1839 true); | 1839 true); |
| 1840 EXPECT_EQ(NAME_FULL, controller()->popup_input_type()); | 1840 EXPECT_EQ(NAME_FULL, controller()->popup_input_type()); |
| 1841 } | 1841 } |
| 1842 | 1842 |
| 1843 } // namespace autofill | 1843 } // namespace autofill |
| OLD | NEW |