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 <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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const char kTestCCNumberVisa[] = "4111111111111111"; | 79 const char kTestCCNumberVisa[] = "4111111111111111"; |
80 const char kTestCCNumberMaster[] = "5555555555554444"; | 80 const char kTestCCNumberMaster[] = "5555555555554444"; |
81 const char kTestCCNumberDiscover[] = "6011111111111117"; | 81 const char kTestCCNumberDiscover[] = "6011111111111117"; |
82 const char kTestCCNumberIncomplete[] = "4111111111"; | 82 const char kTestCCNumberIncomplete[] = "4111111111"; |
83 // Credit card number fails Luhn check. | 83 // Credit card number fails Luhn check. |
84 const char kTestCCNumberInvalid[] = "4111111111111112"; | 84 const char kTestCCNumberInvalid[] = "4111111111111112"; |
85 | 85 |
86 | 86 |
87 void SetOutputValue(const DetailInputs& inputs, | 87 void SetOutputValue(const DetailInputs& inputs, |
88 DetailOutputMap* outputs, | 88 DetailOutputMap* outputs, |
89 AutofillFieldType type, | 89 ServerFieldType type, |
90 const base::string16& value) { | 90 const base::string16& value) { |
91 for (size_t i = 0; i < inputs.size(); ++i) { | 91 for (size_t i = 0; i < inputs.size(); ++i) { |
92 const DetailInput& input = inputs[i]; | 92 const DetailInput& input = inputs[i]; |
93 (*outputs)[&input] = input.type == type ? | 93 (*outputs)[&input] = input.type == type ? |
94 value : | 94 value : |
95 input.initial_value; | 95 input.initial_value; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 scoped_ptr<wallet::WalletItems> CompleteAndValidWalletItems() { | 99 scoped_ptr<wallet::WalletItems> CompleteAndValidWalletItems() { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 510 |
511 // Test for phone number validation. | 511 // Test for phone number validation. |
512 TEST_F(AutofillDialogControllerTest, PhoneNumberValidation) { | 512 TEST_F(AutofillDialogControllerTest, PhoneNumberValidation) { |
513 // Construct DetailOutputMap from existing data. | 513 // Construct DetailOutputMap from existing data. |
514 SwitchToAutofill(); | 514 SwitchToAutofill(); |
515 | 515 |
516 AutofillProfile full_profile(test::GetVerifiedProfile()); | 516 AutofillProfile full_profile(test::GetVerifiedProfile()); |
517 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 517 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
518 | 518 |
519 for (size_t i = 0; i < 2; ++i) { | 519 for (size_t i = 0; i < 2; ++i) { |
520 AutofillFieldType phone = i == 0 ? PHONE_HOME_WHOLE_NUMBER : | 520 ServerFieldType phone = i == 0 ? PHONE_HOME_WHOLE_NUMBER : |
521 PHONE_BILLING_WHOLE_NUMBER; | 521 PHONE_BILLING_WHOLE_NUMBER; |
522 AutofillFieldType address = i == 0 ? ADDRESS_HOME_COUNTRY : | 522 ServerFieldType address = i == 0 ? ADDRESS_HOME_COUNTRY : |
523 ADDRESS_BILLING_COUNTRY; | 523 ADDRESS_BILLING_COUNTRY; |
524 DialogSection section = i == 0 ? SECTION_SHIPPING : SECTION_BILLING; | 524 DialogSection section = i == 0 ? SECTION_SHIPPING : SECTION_BILLING; |
525 | 525 |
526 controller()->EditClickedForSection(section); | 526 controller()->EditClickedForSection(section); |
527 | 527 |
528 DetailOutputMap outputs; | 528 DetailOutputMap outputs; |
529 const DetailInputs& inputs = | 529 const DetailInputs& inputs = |
530 controller()->RequestedFieldsForSection(section); | 530 controller()->RequestedFieldsForSection(section); |
531 // Make sure country is United States. | 531 // Make sure country is United States. |
532 SetOutputValue(inputs, &outputs, address, ASCIIToUTF16("United States")); | 532 SetOutputValue(inputs, &outputs, address, ASCIIToUTF16("United States")); |
533 | 533 |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 CreditCard credit_card(test::GetVerifiedCreditCard()); | 1004 CreditCard credit_card(test::GetVerifiedCreditCard()); |
1005 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1005 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1006 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); | 1006 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); |
1007 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1007 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
1008 ui::MenuModel* shipping_model = | 1008 ui::MenuModel* shipping_model = |
1009 controller()->MenuModelForSection(SECTION_SHIPPING); | 1009 controller()->MenuModelForSection(SECTION_SHIPPING); |
1010 shipping_model->ActivatedAt(2); | 1010 shipping_model->ActivatedAt(2); |
1011 | 1011 |
1012 controller()->OnAccept(); | 1012 controller()->OnAccept(); |
1013 ASSERT_EQ(20U, form_structure()->field_count()); | 1013 ASSERT_EQ(20U, form_structure()->field_count()); |
1014 EXPECT_EQ(ADDRESS_BILLING_STATE, form_structure()->field(9)->type()); | 1014 EXPECT_EQ(ADDRESS_BILLING_STATE, |
1015 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure()->field(16)->type()); | 1015 form_structure()->field(9)->Type().server_type()); |
| 1016 EXPECT_EQ(ADDRESS_HOME_STATE, |
| 1017 form_structure()->field(16)->Type().server_type()); |
1016 string16 billing_state = form_structure()->field(9)->value; | 1018 string16 billing_state = form_structure()->field(9)->value; |
1017 string16 shipping_state = form_structure()->field(16)->value; | 1019 string16 shipping_state = form_structure()->field(16)->value; |
1018 EXPECT_FALSE(billing_state.empty()); | 1020 EXPECT_FALSE(billing_state.empty()); |
1019 EXPECT_FALSE(shipping_state.empty()); | 1021 EXPECT_FALSE(shipping_state.empty()); |
1020 EXPECT_NE(billing_state, shipping_state); | 1022 EXPECT_NE(billing_state, shipping_state); |
1021 | 1023 |
1022 EXPECT_EQ(CREDIT_CARD_NAME, form_structure()->field(1)->type()); | 1024 EXPECT_EQ(CREDIT_CARD_NAME, form_structure()->field(1)->Type().server_type()); |
1023 string16 cc_name = form_structure()->field(1)->value; | 1025 string16 cc_name = form_structure()->field(1)->value; |
1024 EXPECT_EQ(NAME_BILLING_FULL, form_structure()->field(6)->type()); | 1026 EXPECT_EQ(NAME_BILLING_FULL, |
| 1027 form_structure()->field(6)->Type().server_type()); |
1025 string16 billing_name = form_structure()->field(6)->value; | 1028 string16 billing_name = form_structure()->field(6)->value; |
1026 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->type()); | 1029 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().server_type()); |
1027 string16 shipping_name = form_structure()->field(13)->value; | 1030 string16 shipping_name = form_structure()->field(13)->value; |
1028 | 1031 |
1029 EXPECT_FALSE(cc_name.empty()); | 1032 EXPECT_FALSE(cc_name.empty()); |
1030 EXPECT_FALSE(billing_name.empty()); | 1033 EXPECT_FALSE(billing_name.empty()); |
1031 EXPECT_FALSE(shipping_name.empty()); | 1034 EXPECT_FALSE(shipping_name.empty()); |
1032 // Billing name should always be the same as cardholder name. | 1035 // Billing name should always be the same as cardholder name. |
1033 EXPECT_EQ(cc_name, billing_name); | 1036 EXPECT_EQ(cc_name, billing_name); |
1034 EXPECT_NE(cc_name, shipping_name); | 1037 EXPECT_NE(cc_name, shipping_name); |
1035 } | 1038 } |
1036 | 1039 |
1037 // Test selecting UseBillingForShipping. | 1040 // Test selecting UseBillingForShipping. |
1038 TEST_F(AutofillDialogControllerTest, UseBillingAsShipping) { | 1041 TEST_F(AutofillDialogControllerTest, UseBillingAsShipping) { |
1039 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1042 AutofillProfile full_profile(test::GetVerifiedProfile()); |
1040 AutofillProfile full_profile2(test::GetVerifiedProfile2()); | 1043 AutofillProfile full_profile2(test::GetVerifiedProfile2()); |
1041 CreditCard credit_card(test::GetVerifiedCreditCard()); | 1044 CreditCard credit_card(test::GetVerifiedCreditCard()); |
1042 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1045 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1043 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); | 1046 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); |
1044 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1047 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
1045 | 1048 |
1046 // Test after setting use billing for shipping. | 1049 // Test after setting use billing for shipping. |
1047 UseBillingForShipping(); | 1050 UseBillingForShipping(); |
1048 | 1051 |
1049 controller()->OnAccept(); | 1052 controller()->OnAccept(); |
1050 ASSERT_EQ(20U, form_structure()->field_count()); | 1053 ASSERT_EQ(20U, form_structure()->field_count()); |
1051 EXPECT_EQ(ADDRESS_BILLING_STATE, form_structure()->field(9)->type()); | 1054 EXPECT_EQ(ADDRESS_BILLING_STATE, |
1052 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure()->field(16)->type()); | 1055 form_structure()->field(9)->Type().server_type()); |
| 1056 EXPECT_EQ(ADDRESS_HOME_STATE, |
| 1057 form_structure()->field(16)->Type().server_type()); |
1053 string16 billing_state = form_structure()->field(9)->value; | 1058 string16 billing_state = form_structure()->field(9)->value; |
1054 string16 shipping_state = form_structure()->field(16)->value; | 1059 string16 shipping_state = form_structure()->field(16)->value; |
1055 EXPECT_FALSE(billing_state.empty()); | 1060 EXPECT_FALSE(billing_state.empty()); |
1056 EXPECT_FALSE(shipping_state.empty()); | 1061 EXPECT_FALSE(shipping_state.empty()); |
1057 EXPECT_EQ(billing_state, shipping_state); | 1062 EXPECT_EQ(billing_state, shipping_state); |
1058 | 1063 |
1059 EXPECT_EQ(CREDIT_CARD_NAME, form_structure()->field(1)->type()); | 1064 EXPECT_EQ(CREDIT_CARD_NAME, |
| 1065 form_structure()->field(1)->Type().server_type()); |
1060 string16 cc_name = form_structure()->field(1)->value; | 1066 string16 cc_name = form_structure()->field(1)->value; |
1061 EXPECT_EQ(NAME_BILLING_FULL, form_structure()->field(6)->type()); | 1067 EXPECT_EQ(NAME_BILLING_FULL, |
| 1068 form_structure()->field(6)->Type().server_type()); |
1062 string16 billing_name = form_structure()->field(6)->value; | 1069 string16 billing_name = form_structure()->field(6)->value; |
1063 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->type()); | 1070 EXPECT_EQ(NAME_FULL, form_structure()->field(13)->Type().server_type()); |
1064 string16 shipping_name = form_structure()->field(13)->value; | 1071 string16 shipping_name = form_structure()->field(13)->value; |
1065 | 1072 |
1066 EXPECT_FALSE(cc_name.empty()); | 1073 EXPECT_FALSE(cc_name.empty()); |
1067 EXPECT_FALSE(billing_name.empty()); | 1074 EXPECT_FALSE(billing_name.empty()); |
1068 EXPECT_FALSE(shipping_name.empty()); | 1075 EXPECT_FALSE(shipping_name.empty()); |
1069 EXPECT_EQ(cc_name, billing_name); | 1076 EXPECT_EQ(cc_name, billing_name); |
1070 EXPECT_EQ(cc_name, shipping_name); | 1077 EXPECT_EQ(cc_name, shipping_name); |
1071 } | 1078 } |
1072 | 1079 |
1073 // Tests that shipping and billing telephone fields are supported, and filled | 1080 // Tests that shipping and billing telephone fields are supported, and filled |
(...skipping 16 matching lines...) Expand all Loading... |
1090 CreditCard credit_card(test::GetVerifiedCreditCard()); | 1097 CreditCard credit_card(test::GetVerifiedCreditCard()); |
1091 controller()->GetTestingManager()->AddTestingProfile(&shipping_profile); | 1098 controller()->GetTestingManager()->AddTestingProfile(&shipping_profile); |
1092 controller()->GetTestingManager()->AddTestingProfile(&billing_profile); | 1099 controller()->GetTestingManager()->AddTestingProfile(&billing_profile); |
1093 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1100 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
1094 ui::MenuModel* billing_model = | 1101 ui::MenuModel* billing_model = |
1095 controller()->MenuModelForSection(SECTION_BILLING); | 1102 controller()->MenuModelForSection(SECTION_BILLING); |
1096 billing_model->ActivatedAt(1); | 1103 billing_model->ActivatedAt(1); |
1097 | 1104 |
1098 controller()->OnAccept(); | 1105 controller()->OnAccept(); |
1099 ASSERT_EQ(2U, form_structure()->field_count()); | 1106 ASSERT_EQ(2U, form_structure()->field_count()); |
1100 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, form_structure()->field(0)->type()); | 1107 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, |
1101 EXPECT_EQ(PHONE_BILLING_WHOLE_NUMBER, form_structure()->field(1)->type()); | 1108 form_structure()->field(0)->Type().server_type()); |
| 1109 EXPECT_EQ(PHONE_BILLING_WHOLE_NUMBER, |
| 1110 form_structure()->field(1)->Type().server_type()); |
1102 EXPECT_EQ(shipping_profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER), | 1111 EXPECT_EQ(shipping_profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER), |
1103 form_structure()->field(0)->value); | 1112 form_structure()->field(0)->value); |
1104 EXPECT_EQ(billing_profile.GetRawInfo(PHONE_BILLING_WHOLE_NUMBER), | 1113 EXPECT_EQ(billing_profile.GetRawInfo(PHONE_BILLING_WHOLE_NUMBER), |
1105 form_structure()->field(1)->value); | 1114 form_structure()->field(1)->value); |
1106 EXPECT_NE(form_structure()->field(1)->value, | 1115 EXPECT_NE(form_structure()->field(1)->value, |
1107 form_structure()->field(0)->value); | 1116 form_structure()->field(0)->value); |
1108 } | 1117 } |
1109 | 1118 |
1110 TEST_F(AutofillDialogControllerTest, AcceptLegalDocuments) { | 1119 TEST_F(AutofillDialogControllerTest, AcceptLegalDocuments) { |
1111 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1120 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 FillCreditCardInputs(); | 1499 FillCreditCardInputs(); |
1491 | 1500 |
1492 controller()->OnAccept(); | 1501 controller()->OnAccept(); |
1493 const AutofillProfile& edited_profile = | 1502 const AutofillProfile& edited_profile = |
1494 controller()->GetTestingManager()->imported_profile(); | 1503 controller()->GetTestingManager()->imported_profile(); |
1495 | 1504 |
1496 for (size_t i = 0; i < inputs.size(); ++i) { | 1505 for (size_t i = 0; i < inputs.size(); ++i) { |
1497 const DetailInput& input = inputs[i]; | 1506 const DetailInput& input = inputs[i]; |
1498 EXPECT_EQ(input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") : | 1507 EXPECT_EQ(input.type == NAME_FULL ? ASCIIToUTF16("Edited Name") : |
1499 input.initial_value, | 1508 input.initial_value, |
1500 edited_profile.GetInfo(input.type, "en-US")); | 1509 edited_profile.GetInfo(AutofillType(input.type), "en-US")); |
1501 } | 1510 } |
1502 } | 1511 } |
1503 | 1512 |
1504 // Tests that adding an autofill profile and then submitting works. | 1513 // Tests that adding an autofill profile and then submitting works. |
1505 TEST_F(AutofillDialogControllerTest, AddAutofillProfile) { | 1514 TEST_F(AutofillDialogControllerTest, AddAutofillProfile) { |
1506 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); | 1515 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); |
1507 | 1516 |
1508 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1517 AutofillProfile full_profile(test::GetVerifiedProfile()); |
1509 CreditCard credit_card(test::GetVerifiedCreditCard()); | 1518 CreditCard credit_card(test::GetVerifiedCreditCard()); |
1510 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1519 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1511 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1520 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
1512 | 1521 |
1513 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_BILLING); | 1522 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_BILLING); |
1514 // Activate the "Add billing address" menu item. | 1523 // Activate the "Add billing address" menu item. |
1515 model->ActivatedAt(model->GetItemCount() - 2); | 1524 model->ActivatedAt(model->GetItemCount() - 2); |
1516 | 1525 |
1517 // Fill in the inputs from the profile. | 1526 // Fill in the inputs from the profile. |
1518 DetailOutputMap outputs; | 1527 DetailOutputMap outputs; |
1519 const DetailInputs& inputs = | 1528 const DetailInputs& inputs = |
1520 controller()->RequestedFieldsForSection(SECTION_BILLING); | 1529 controller()->RequestedFieldsForSection(SECTION_BILLING); |
1521 AutofillProfile full_profile2(test::GetVerifiedProfile2()); | 1530 AutofillProfile full_profile2(test::GetVerifiedProfile2()); |
1522 for (size_t i = 0; i < inputs.size(); ++i) { | 1531 for (size_t i = 0; i < inputs.size(); ++i) { |
1523 const DetailInput& input = inputs[i]; | 1532 const DetailInput& input = inputs[i]; |
1524 outputs[&input] = full_profile2.GetInfo(input.type, "en-US"); | 1533 outputs[&input] = full_profile2.GetInfo(AutofillType(input.type), "en-US"); |
1525 } | 1534 } |
1526 controller()->GetView()->SetUserInput(SECTION_BILLING, outputs); | 1535 controller()->GetView()->SetUserInput(SECTION_BILLING, outputs); |
1527 | 1536 |
1528 controller()->OnAccept(); | 1537 controller()->OnAccept(); |
1529 const AutofillProfile& added_profile = | 1538 const AutofillProfile& added_profile = |
1530 controller()->GetTestingManager()->imported_profile(); | 1539 controller()->GetTestingManager()->imported_profile(); |
1531 | 1540 |
1532 const DetailInputs& shipping_inputs = | 1541 const DetailInputs& shipping_inputs = |
1533 controller()->RequestedFieldsForSection(SECTION_SHIPPING); | 1542 controller()->RequestedFieldsForSection(SECTION_SHIPPING); |
1534 for (size_t i = 0; i < shipping_inputs.size(); ++i) { | 1543 for (size_t i = 0; i < shipping_inputs.size(); ++i) { |
1535 const DetailInput& input = shipping_inputs[i]; | 1544 const DetailInput& input = shipping_inputs[i]; |
1536 EXPECT_EQ(full_profile2.GetInfo(input.type, "en-US"), | 1545 EXPECT_EQ(full_profile2.GetInfo(AutofillType(input.type), "en-US"), |
1537 added_profile.GetInfo(input.type, "en-US")); | 1546 added_profile.GetInfo(AutofillType(input.type), "en-US")); |
1538 } | 1547 } |
1539 | 1548 |
1540 // Also, the currently selected email address should get added to the new | 1549 // Also, the currently selected email address should get added to the new |
1541 // profile. | 1550 // profile. |
1542 string16 original_email = full_profile.GetInfo(EMAIL_ADDRESS, "en-US"); | 1551 string16 original_email = |
| 1552 full_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US"); |
1543 EXPECT_FALSE(original_email.empty()); | 1553 EXPECT_FALSE(original_email.empty()); |
1544 EXPECT_EQ(original_email, | 1554 EXPECT_EQ(original_email, |
1545 added_profile.GetInfo(EMAIL_ADDRESS, "en-US")); | 1555 added_profile.GetInfo(AutofillType(EMAIL_ADDRESS), "en-US")); |
1546 } | 1556 } |
1547 | 1557 |
1548 // Makes sure that a newly added email address gets added to an existing profile | 1558 // Makes sure that a newly added email address gets added to an existing profile |
1549 // (as opposed to creating its own profile). http://crbug.com/240926 | 1559 // (as opposed to creating its own profile). http://crbug.com/240926 |
1550 TEST_F(AutofillDialogControllerTest, AddEmail) { | 1560 TEST_F(AutofillDialogControllerTest, AddEmail) { |
1551 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1561 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
1552 | 1562 |
1553 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1563 AutofillProfile full_profile(test::GetVerifiedProfile()); |
1554 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1564 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1555 | 1565 |
1556 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL); | 1566 ui::MenuModel* model = controller()->MenuModelForSection(SECTION_EMAIL); |
1557 ASSERT_TRUE(model); | 1567 ASSERT_TRUE(model); |
1558 // Activate the "Add email address" menu item. | 1568 // Activate the "Add email address" menu item. |
1559 model->ActivatedAt(model->GetItemCount() - 2); | 1569 model->ActivatedAt(model->GetItemCount() - 2); |
1560 | 1570 |
1561 // Fill in the inputs from the profile. | 1571 // Fill in the inputs from the profile. |
1562 DetailOutputMap outputs; | 1572 DetailOutputMap outputs; |
1563 const DetailInputs& inputs = | 1573 const DetailInputs& inputs = |
1564 controller()->RequestedFieldsForSection(SECTION_EMAIL); | 1574 controller()->RequestedFieldsForSection(SECTION_EMAIL); |
1565 const DetailInput& input = inputs[0]; | 1575 const DetailInput& input = inputs[0]; |
1566 string16 new_email = ASCIIToUTF16("addemailtest@example.com"); | 1576 string16 new_email = ASCIIToUTF16("addemailtest@example.com"); |
1567 outputs[&input] = new_email; | 1577 outputs[&input] = new_email; |
1568 controller()->GetView()->SetUserInput(SECTION_EMAIL, outputs); | 1578 controller()->GetView()->SetUserInput(SECTION_EMAIL, outputs); |
1569 | 1579 |
1570 FillCreditCardInputs(); | 1580 FillCreditCardInputs(); |
1571 controller()->OnAccept(); | 1581 controller()->OnAccept(); |
1572 std::vector<base::string16> email_values; | 1582 std::vector<base::string16> email_values; |
1573 full_profile.GetMultiInfo(EMAIL_ADDRESS, "en-US", &email_values); | 1583 full_profile.GetMultiInfo( |
| 1584 AutofillType(EMAIL_ADDRESS), "en-US", &email_values); |
1574 ASSERT_EQ(2U, email_values.size()); | 1585 ASSERT_EQ(2U, email_values.size()); |
1575 EXPECT_EQ(new_email, email_values[1]); | 1586 EXPECT_EQ(new_email, email_values[1]); |
1576 } | 1587 } |
1577 | 1588 |
1578 TEST_F(AutofillDialogControllerTest, VerifyCvv) { | 1589 TEST_F(AutofillDialogControllerTest, VerifyCvv) { |
1579 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1590 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
1580 GetFullWallet(_)).Times(1); | 1591 GetFullWallet(_)).Times(1); |
1581 EXPECT_CALL(*controller()->GetTestingWalletClient(), | 1592 EXPECT_CALL(*controller()->GetTestingWalletClient(), |
1582 AuthenticateInstrument(_, _)).Times(1); | 1593 AuthenticateInstrument(_, _)).Times(1); |
1583 | 1594 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2034 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
2024 | 2035 |
2025 // Email section should be hidden when using Wallet. | 2036 // Email section should be hidden when using Wallet. |
2026 EXPECT_FALSE(controller()->SectionIsActive(SECTION_EMAIL)); | 2037 EXPECT_FALSE(controller()->SectionIsActive(SECTION_EMAIL)); |
2027 | 2038 |
2028 controller()->OnAccept(); | 2039 controller()->OnAccept(); |
2029 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2040 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
2030 | 2041 |
2031 size_t i = 0; | 2042 size_t i = 0; |
2032 for (; i < form_structure()->field_count(); ++i) { | 2043 for (; i < form_structure()->field_count(); ++i) { |
2033 if (form_structure()->field(i)->type() == EMAIL_ADDRESS) { | 2044 if (form_structure()->field(i)->Type().server_type() == EMAIL_ADDRESS) { |
2034 EXPECT_EQ(ASCIIToUTF16(kFakeEmail), form_structure()->field(i)->value); | 2045 EXPECT_EQ(ASCIIToUTF16(kFakeEmail), form_structure()->field(i)->value); |
2035 break; | 2046 break; |
2036 } | 2047 } |
2037 } | 2048 } |
2038 ASSERT_LT(i, form_structure()->field_count()); | 2049 ASSERT_LT(i, form_structure()->field_count()); |
2039 } | 2050 } |
2040 | 2051 |
2041 // Test if autofill types of returned form structure are correct for billing | 2052 // Test if autofill types of returned form structure are correct for billing |
2042 // entries. | 2053 // entries. |
2043 TEST_F(AutofillDialogControllerTest, AutofillTypes) { | 2054 TEST_F(AutofillDialogControllerTest, AutofillTypes) { |
2044 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 2055 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
2045 controller()->OnAccept(); | 2056 controller()->OnAccept(); |
2046 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2057 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
2047 ASSERT_EQ(20U, form_structure()->field_count()); | 2058 ASSERT_EQ(20U, form_structure()->field_count()); |
2048 EXPECT_EQ(EMAIL_ADDRESS, form_structure()->field(0)->type()); | 2059 EXPECT_EQ(EMAIL_ADDRESS, form_structure()->field(0)->Type().server_type()); |
2049 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure()->field(2)->type()); | 2060 EXPECT_EQ(CREDIT_CARD_NUMBER, |
2050 EXPECT_EQ(ADDRESS_BILLING_STATE, form_structure()->field(9)->type()); | 2061 form_structure()->field(2)->Type().server_type()); |
2051 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure()->field(16)->type()); | 2062 EXPECT_EQ(ADDRESS_BILLING_STATE, |
| 2063 form_structure()->field(9)->Type().server_type()); |
| 2064 EXPECT_EQ(ADDRESS_HOME_STATE, |
| 2065 form_structure()->field(16)->Type().server_type()); |
2052 } | 2066 } |
2053 | 2067 |
2054 TEST_F(AutofillDialogControllerTest, SaveDetailsInChrome) { | 2068 TEST_F(AutofillDialogControllerTest, SaveDetailsInChrome) { |
2055 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); | 2069 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2); |
2056 | 2070 |
2057 AutofillProfile full_profile(test::GetVerifiedProfile()); | 2071 AutofillProfile full_profile(test::GetVerifiedProfile()); |
2058 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 2072 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
2059 | 2073 |
2060 CreditCard card(test::GetVerifiedCreditCard()); | 2074 CreditCard card(test::GetVerifiedCreditCard()); |
2061 controller()->GetTestingManager()->AddTestingCreditCard(&card); | 2075 controller()->GetTestingManager()->AddTestingCreditCard(&card); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 } | 2230 } |
2217 | 2231 |
2218 // Ensure Wallet instruments marked expired by the server are shown as invalid. | 2232 // Ensure Wallet instruments marked expired by the server are shown as invalid. |
2219 TEST_F(AutofillDialogControllerTest, WalletExpiredCard) { | 2233 TEST_F(AutofillDialogControllerTest, WalletExpiredCard) { |
2220 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); | 2234 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); |
2221 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentExpired()); | 2235 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentExpired()); |
2222 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 2236 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
2223 | 2237 |
2224 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC_BILLING)); | 2238 EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC_BILLING)); |
2225 | 2239 |
2226 // Use |SetOutputValue()| to put the right AutofillFieldTypes into the map. | 2240 // Use |SetOutputValue()| to put the right ServerFieldTypes into the map. |
2227 const DetailInputs& inputs = | 2241 const DetailInputs& inputs = |
2228 controller()->RequestedFieldsForSection(SECTION_CC_BILLING); | 2242 controller()->RequestedFieldsForSection(SECTION_CC_BILLING); |
2229 DetailOutputMap outputs; | 2243 DetailOutputMap outputs; |
2230 SetOutputValue(inputs, &outputs, COMPANY_NAME, ASCIIToUTF16("Bluth Company")); | 2244 SetOutputValue(inputs, &outputs, COMPANY_NAME, ASCIIToUTF16("Bluth Company")); |
2231 | 2245 |
2232 ValidityData validity_data = | 2246 ValidityData validity_data = |
2233 controller()->InputsAreValid(SECTION_CC_BILLING, outputs, VALIDATE_EDIT); | 2247 controller()->InputsAreValid(SECTION_CC_BILLING, outputs, VALIDATE_EDIT); |
2234 EXPECT_EQ(1U, validity_data.count(CREDIT_CARD_EXP_MONTH)); | 2248 EXPECT_EQ(1U, validity_data.count(CREDIT_CARD_EXP_MONTH)); |
2235 EXPECT_EQ(1U, validity_data.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 2249 EXPECT_EQ(1U, validity_data.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
2236 | 2250 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2467 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); | 2481 EXPECT_CALL(*test_bubble_controller(), ShowAsNewCardSavedBubble(_)).Times(0); |
2468 | 2482 |
2469 SubmitWithWalletItems(CompleteAndValidWalletItems()); | 2483 SubmitWithWalletItems(CompleteAndValidWalletItems()); |
2470 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); | 2484 controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); |
2471 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); | 2485 controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); |
2472 controller()->OnAutocheckoutError(); | 2486 controller()->OnAutocheckoutError(); |
2473 controller()->ViewClosed(); | 2487 controller()->ViewClosed(); |
2474 } | 2488 } |
2475 | 2489 |
2476 } // namespace autofill | 2490 } // namespace autofill |
OLD | NEW |