| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 void SimulateSubmitButtonDelayBegin() { | 294 void SimulateSubmitButtonDelayBegin() { |
| 295 AutofillDialogControllerImpl::SubmitButtonDelayBegin(); | 295 AutofillDialogControllerImpl::SubmitButtonDelayBegin(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void SimulateSubmitButtonDelayEnd() { | 298 void SimulateSubmitButtonDelayEnd() { |
| 299 AutofillDialogControllerImpl::SubmitButtonDelayEndForTesting(); | 299 AutofillDialogControllerImpl::SubmitButtonDelayEndForTesting(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 using AutofillDialogControllerImpl:: |
| 303 ClearLastWalletItemsFetchTimestampForTesting; |
| 304 |
| 302 // Returns the number of times that the submit button was delayed. | 305 // Returns the number of times that the submit button was delayed. |
| 303 int get_submit_button_delay_count() const { | 306 int get_submit_button_delay_count() const { |
| 304 return submit_button_delay_count_; | 307 return submit_button_delay_count_; |
| 305 } | 308 } |
| 306 | 309 |
| 307 MOCK_METHOD0(LoadRiskFingerprintData, void()); | 310 MOCK_METHOD0(LoadRiskFingerprintData, void()); |
| 308 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; | 311 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; |
| 309 using AutofillDialogControllerImpl::IsEditingExistingData; | 312 using AutofillDialogControllerImpl::IsEditingExistingData; |
| 310 | 313 |
| 311 protected: | 314 protected: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 controller_ = (new testing::NiceMock<TestAutofillDialogController>( | 444 controller_ = (new testing::NiceMock<TestAutofillDialogController>( |
| 442 web_contents(), | 445 web_contents(), |
| 443 form_data, | 446 form_data, |
| 444 GURL(), | 447 GURL(), |
| 445 metric_logger_, | 448 metric_logger_, |
| 446 callback, | 449 callback, |
| 447 mock_new_card_bubble_controller_.get()))->AsWeakPtr(); | 450 mock_new_card_bubble_controller_.get()))->AsWeakPtr(); |
| 448 controller_->Init(profile()); | 451 controller_->Init(profile()); |
| 449 controller_->Show(); | 452 controller_->Show(); |
| 450 controller_->OnUserNameFetchSuccess(kFakeEmail); | 453 controller_->OnUserNameFetchSuccess(kFakeEmail); |
| 454 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems(_)); |
| 455 controller_->OnDidFetchWalletCookieValue(std::string()); |
| 456 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 451 } | 457 } |
| 452 | 458 |
| 453 void FillCreditCardInputs() { | 459 void FillCreditCardInputs() { |
| 454 DetailOutputMap cc_outputs; | 460 DetailOutputMap cc_outputs; |
| 455 const DetailInputs& cc_inputs = | 461 const DetailInputs& cc_inputs = |
| 456 controller()->RequestedFieldsForSection(SECTION_CC); | 462 controller()->RequestedFieldsForSection(SECTION_CC); |
| 457 for (size_t i = 0; i < cc_inputs.size(); ++i) { | 463 for (size_t i = 0; i < cc_inputs.size(); ++i) { |
| 458 cc_outputs[&cc_inputs[i]] = cc_inputs[i].type == CREDIT_CARD_NUMBER ? | 464 cc_outputs[&cc_inputs[i]] = cc_inputs[i].type == CREDIT_CARD_NUMBER ? |
| 459 ASCIIToUTF16(kTestCCNumberVisa) : ASCIIToUTF16("11"); | 465 ASCIIToUTF16(kTestCCNumberVisa) : ASCIIToUTF16("11"); |
| 460 } | 466 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 // Should accept Visa, Master, Discover, and AMEX. | 905 // Should accept Visa, Master, Discover, and AMEX. |
| 900 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberVisa, true); | 906 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberVisa, true); |
| 901 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberMaster, true); | 907 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberMaster, true); |
| 902 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberDiscover, true); | 908 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberDiscover, true); |
| 903 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberAmex, true); | 909 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberAmex, true); |
| 904 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberIncomplete, false); | 910 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberIncomplete, false); |
| 905 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberInvalid, false); | 911 ValidateCCNumber(SECTION_CC_BILLING, kTestCCNumberInvalid, false); |
| 906 } | 912 } |
| 907 | 913 |
| 908 TEST_F(AutofillDialogControllerTest, AutofillProfiles) { | 914 TEST_F(AutofillDialogControllerTest, AutofillProfiles) { |
| 915 SwitchToAutofill(); |
| 909 ui::MenuModel* shipping_model = | 916 ui::MenuModel* shipping_model = |
| 910 controller()->MenuModelForSection(SECTION_SHIPPING); | 917 controller()->MenuModelForSection(SECTION_SHIPPING); |
| 911 // Since the PersonalDataManager is empty, this should only have the | 918 // Since the PersonalDataManager is empty, this should only have the |
| 912 // "use billing", "add new" and "manage" menu items. | 919 // "use billing", "add new" and "manage" menu items. |
| 913 ASSERT_TRUE(shipping_model); | 920 ASSERT_TRUE(shipping_model); |
| 914 EXPECT_EQ(3, shipping_model->GetItemCount()); | 921 EXPECT_EQ(3, shipping_model->GetItemCount()); |
| 915 // On the other hand, the other models should be NULL when there's no | 922 // On the other hand, the other models should be NULL when there's no |
| 916 // suggestion. | 923 // suggestion. |
| 917 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); | 924 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); |
| 918 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_BILLING)); | 925 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_BILLING)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 941 verified_profile.SetRawInfo(ADDRESS_HOME_LINE2, string16()); | 948 verified_profile.SetRawInfo(ADDRESS_HOME_LINE2, string16()); |
| 942 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); | 949 controller()->GetTestingManager()->AddTestingProfile(&verified_profile); |
| 943 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); | 950 shipping_model = controller()->MenuModelForSection(SECTION_SHIPPING); |
| 944 ASSERT_TRUE(shipping_model); | 951 ASSERT_TRUE(shipping_model); |
| 945 EXPECT_EQ(4, shipping_model->GetItemCount()); | 952 EXPECT_EQ(4, shipping_model->GetItemCount()); |
| 946 } | 953 } |
| 947 | 954 |
| 948 // Makes sure that the choice of which Autofill profile to use for each section | 955 // Makes sure that the choice of which Autofill profile to use for each section |
| 949 // is sticky. | 956 // is sticky. |
| 950 TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) { | 957 TEST_F(AutofillDialogControllerTest, AutofillProfileDefaults) { |
| 958 SwitchToAutofill(); |
| 951 AutofillProfile profile(test::GetVerifiedProfile()); | 959 AutofillProfile profile(test::GetVerifiedProfile()); |
| 952 AutofillProfile profile2(test::GetVerifiedProfile2()); | 960 AutofillProfile profile2(test::GetVerifiedProfile2()); |
| 953 controller()->GetTestingManager()->AddTestingProfile(&profile); | 961 controller()->GetTestingManager()->AddTestingProfile(&profile); |
| 954 controller()->GetTestingManager()->AddTestingProfile(&profile2); | 962 controller()->GetTestingManager()->AddTestingProfile(&profile2); |
| 955 | 963 |
| 956 // Until a selection has been made, the default shipping suggestion is the | 964 // Until a selection has been made, the default shipping suggestion is the |
| 957 // first one (after "use billing"). | 965 // first one (after "use billing"). |
| 958 SuggestionsMenuModel* shipping_model = | 966 SuggestionsMenuModel* shipping_model = |
| 959 GetMenuModelForSection(SECTION_SHIPPING); | 967 GetMenuModelForSection(SECTION_SHIPPING); |
| 960 EXPECT_EQ(1, shipping_model->checked_item()); | 968 EXPECT_EQ(1, shipping_model->checked_item()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1028 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 1021 controller()->GetTestingManager()->AddTestingCreditCard(&new_credit_card); | 1029 controller()->GetTestingManager()->AddTestingCreditCard(&new_credit_card); |
| 1022 | 1030 |
| 1023 // Until a selection has been made, the default suggestion is the first one. | 1031 // Until a selection has been made, the default suggestion is the first one. |
| 1024 // For the shipping section, this follows the "use billing" suggestion. | 1032 // For the shipping section, this follows the "use billing" suggestion. |
| 1025 EXPECT_EQ(1, GetMenuModelForSection(SECTION_CC)->checked_item()); | 1033 EXPECT_EQ(1, GetMenuModelForSection(SECTION_CC)->checked_item()); |
| 1026 EXPECT_EQ(2, GetMenuModelForSection(SECTION_SHIPPING)->checked_item()); | 1034 EXPECT_EQ(2, GetMenuModelForSection(SECTION_SHIPPING)->checked_item()); |
| 1027 } | 1035 } |
| 1028 | 1036 |
| 1029 TEST_F(AutofillDialogControllerTest, AutofillProfileVariants) { | 1037 TEST_F(AutofillDialogControllerTest, AutofillProfileVariants) { |
| 1038 SwitchToAutofill(); |
| 1030 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); | 1039 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(1); |
| 1031 ui::MenuModel* shipping_model = | 1040 ui::MenuModel* shipping_model = |
| 1032 controller()->MenuModelForSection(SECTION_SHIPPING); | 1041 controller()->MenuModelForSection(SECTION_SHIPPING); |
| 1033 ASSERT_TRUE(!!shipping_model); | 1042 ASSERT_TRUE(!!shipping_model); |
| 1034 EXPECT_EQ(3, shipping_model->GetItemCount()); | 1043 EXPECT_EQ(3, shipping_model->GetItemCount()); |
| 1035 | 1044 |
| 1036 // Set up some variant data. | 1045 // Set up some variant data. |
| 1037 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1046 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 1038 std::vector<string16> names; | 1047 std::vector<string16> names; |
| 1039 names.push_back(ASCIIToUTF16("John Doe")); | 1048 names.push_back(ASCIIToUTF16("John Doe")); |
| 1040 names.push_back(ASCIIToUTF16("Jane Doe")); | 1049 names.push_back(ASCIIToUTF16("Jane Doe")); |
| 1041 full_profile.SetRawMultiInfo(NAME_FULL, names); | 1050 full_profile.SetRawMultiInfo(NAME_FULL, names); |
| 1042 std::vector<string16> emails; | 1051 std::vector<string16> emails; |
| 1043 emails.push_back(ASCIIToUTF16(kFakeEmail)); | 1052 emails.push_back(ASCIIToUTF16(kFakeEmail)); |
| 1044 emails.push_back(ASCIIToUTF16("admin@example.com")); | 1053 emails.push_back(ASCIIToUTF16("admin@example.com")); |
| 1045 full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails); | 1054 full_profile.SetRawMultiInfo(EMAIL_ADDRESS, emails); |
| 1046 | 1055 |
| 1047 // Non-default variants are ignored by the dialog. | 1056 // Non-default variants are ignored by the dialog. |
| 1048 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1057 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1049 EXPECT_EQ(4, shipping_model->GetItemCount()); | 1058 EXPECT_EQ(4, shipping_model->GetItemCount()); |
| 1050 } | 1059 } |
| 1051 | 1060 |
| 1052 TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { | 1061 TEST_F(AutofillDialogControllerTest, SuggestValidEmail) { |
| 1062 SwitchToAutofill(); |
| 1053 AutofillProfile profile(test::GetVerifiedProfile()); | 1063 AutofillProfile profile(test::GetVerifiedProfile()); |
| 1054 const string16 kValidEmail = ASCIIToUTF16(kFakeEmail); | 1064 const string16 kValidEmail = ASCIIToUTF16(kFakeEmail); |
| 1055 profile.SetRawInfo(EMAIL_ADDRESS, kValidEmail); | 1065 profile.SetRawInfo(EMAIL_ADDRESS, kValidEmail); |
| 1056 controller()->GetTestingManager()->AddTestingProfile(&profile); | 1066 controller()->GetTestingManager()->AddTestingProfile(&profile); |
| 1057 | 1067 |
| 1058 // "add", "manage", and 1 suggestion. | 1068 // "add", "manage", and 1 suggestion. |
| 1059 EXPECT_EQ( | 1069 EXPECT_EQ( |
| 1060 3, controller()->MenuModelForSection(SECTION_BILLING)->GetItemCount()); | 1070 3, controller()->MenuModelForSection(SECTION_BILLING)->GetItemCount()); |
| 1061 // "add", "manage", 1 suggestion, and "same as billing". | 1071 // "add", "manage", 1 suggestion, and "same as billing". |
| 1062 EXPECT_EQ( | 1072 EXPECT_EQ( |
| 1063 4, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); | 1073 4, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); |
| 1064 } | 1074 } |
| 1065 | 1075 |
| 1066 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidEmail) { | 1076 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidEmail) { |
| 1077 SwitchToAutofill(); |
| 1067 AutofillProfile profile(test::GetVerifiedProfile()); | 1078 AutofillProfile profile(test::GetVerifiedProfile()); |
| 1068 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(".!#$%&'*+/=?^_`-@-..")); | 1079 profile.SetRawInfo(EMAIL_ADDRESS, ASCIIToUTF16(".!#$%&'*+/=?^_`-@-..")); |
| 1069 controller()->GetTestingManager()->AddTestingProfile(&profile); | 1080 controller()->GetTestingManager()->AddTestingProfile(&profile); |
| 1070 | 1081 |
| 1071 EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); | 1082 EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); |
| 1072 // "add", "manage", 1 suggestion, and "same as billing". | 1083 // "add", "manage", 1 suggestion, and "same as billing". |
| 1073 EXPECT_EQ( | 1084 EXPECT_EQ( |
| 1074 4, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); | 1085 4, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); |
| 1075 } | 1086 } |
| 1076 | 1087 |
| 1077 TEST_F(AutofillDialogControllerTest, SuggestValidAddress) { | 1088 TEST_F(AutofillDialogControllerTest, SuggestValidAddress) { |
| 1089 SwitchToAutofill(); |
| 1078 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1090 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 1079 full_profile.set_origin(kSettingsOrigin); | 1091 full_profile.set_origin(kSettingsOrigin); |
| 1080 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1092 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1081 // "add", "manage", and 1 suggestion. | 1093 // "add", "manage", and 1 suggestion. |
| 1082 EXPECT_EQ( | 1094 EXPECT_EQ( |
| 1083 3, controller()->MenuModelForSection(SECTION_BILLING)->GetItemCount()); | 1095 3, controller()->MenuModelForSection(SECTION_BILLING)->GetItemCount()); |
| 1084 } | 1096 } |
| 1085 | 1097 |
| 1086 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidAddress) { | 1098 TEST_F(AutofillDialogControllerTest, DoNotSuggestInvalidAddress) { |
| 1099 SwitchToAutofill(); |
| 1087 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1100 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 1088 full_profile.set_origin(kSettingsOrigin); | 1101 full_profile.set_origin(kSettingsOrigin); |
| 1089 full_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("C")); | 1102 full_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("C")); |
| 1090 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1103 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1091 | 1104 |
| 1092 EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); | 1105 EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); |
| 1093 } | 1106 } |
| 1094 | 1107 |
| 1095 TEST_F(AutofillDialogControllerTest, DoNotSuggestIncompleteAddress) { | 1108 TEST_F(AutofillDialogControllerTest, DoNotSuggestIncompleteAddress) { |
| 1109 SwitchToAutofill(); |
| 1096 AutofillProfile profile(test::GetVerifiedProfile()); | 1110 AutofillProfile profile(test::GetVerifiedProfile()); |
| 1097 profile.SetRawInfo(ADDRESS_HOME_STATE, base::string16()); | 1111 profile.SetRawInfo(ADDRESS_HOME_STATE, base::string16()); |
| 1098 controller()->GetTestingManager()->AddTestingProfile(&profile); | 1112 controller()->GetTestingManager()->AddTestingProfile(&profile); |
| 1099 | 1113 |
| 1100 EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); | 1114 EXPECT_FALSE(!!controller()->MenuModelForSection(SECTION_BILLING)); |
| 1101 } | 1115 } |
| 1102 | 1116 |
| 1103 TEST_F(AutofillDialogControllerTest, AutofillCreditCards) { | 1117 TEST_F(AutofillDialogControllerTest, AutofillCreditCards) { |
| 1118 SwitchToAutofill(); |
| 1104 // Since the PersonalDataManager is empty, this should only have the | 1119 // Since the PersonalDataManager is empty, this should only have the |
| 1105 // default menu items. | 1120 // default menu items. |
| 1106 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); | 1121 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC)); |
| 1107 | 1122 |
| 1108 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(3); | 1123 EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(3); |
| 1109 | 1124 |
| 1110 // Empty cards are ignored. | 1125 // Empty cards are ignored. |
| 1111 CreditCard empty_card(base::GenerateGUID(), kSettingsOrigin); | 1126 CreditCard empty_card(base::GenerateGUID(), kSettingsOrigin); |
| 1112 empty_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John Doe")); | 1127 empty_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John Doe")); |
| 1113 controller()->GetTestingManager()->AddTestingCreditCard(&empty_card); | 1128 controller()->GetTestingManager()->AddTestingCreditCard(&empty_card); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1124 verified_card.set_origin(kSettingsOrigin); | 1139 verified_card.set_origin(kSettingsOrigin); |
| 1125 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); | 1140 controller()->GetTestingManager()->AddTestingCreditCard(&verified_card); |
| 1126 ui::MenuModel* credit_card_model = | 1141 ui::MenuModel* credit_card_model = |
| 1127 controller()->MenuModelForSection(SECTION_CC); | 1142 controller()->MenuModelForSection(SECTION_CC); |
| 1128 ASSERT_TRUE(credit_card_model); | 1143 ASSERT_TRUE(credit_card_model); |
| 1129 EXPECT_EQ(3, credit_card_model->GetItemCount()); | 1144 EXPECT_EQ(3, credit_card_model->GetItemCount()); |
| 1130 } | 1145 } |
| 1131 | 1146 |
| 1132 // Test selecting a shipping address different from billing as address. | 1147 // Test selecting a shipping address different from billing as address. |
| 1133 TEST_F(AutofillDialogControllerTest, DontUseBillingAsShipping) { | 1148 TEST_F(AutofillDialogControllerTest, DontUseBillingAsShipping) { |
| 1149 SwitchToAutofill(); |
| 1134 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1150 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 1135 AutofillProfile full_profile2(test::GetVerifiedProfile2()); | 1151 AutofillProfile full_profile2(test::GetVerifiedProfile2()); |
| 1136 CreditCard credit_card(test::GetVerifiedCreditCard()); | 1152 CreditCard credit_card(test::GetVerifiedCreditCard()); |
| 1137 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1153 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1138 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); | 1154 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); |
| 1139 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1155 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 1140 ui::MenuModel* shipping_model = | 1156 ui::MenuModel* shipping_model = |
| 1141 controller()->MenuModelForSection(SECTION_SHIPPING); | 1157 controller()->MenuModelForSection(SECTION_SHIPPING); |
| 1142 shipping_model->ActivatedAt(2); | 1158 shipping_model->ActivatedAt(2); |
| 1143 | 1159 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1168 EXPECT_FALSE(cc_name.empty()); | 1184 EXPECT_FALSE(cc_name.empty()); |
| 1169 EXPECT_FALSE(billing_name.empty()); | 1185 EXPECT_FALSE(billing_name.empty()); |
| 1170 EXPECT_FALSE(shipping_name.empty()); | 1186 EXPECT_FALSE(shipping_name.empty()); |
| 1171 // Billing name should always be the same as cardholder name. | 1187 // Billing name should always be the same as cardholder name. |
| 1172 EXPECT_EQ(cc_name, billing_name); | 1188 EXPECT_EQ(cc_name, billing_name); |
| 1173 EXPECT_NE(cc_name, shipping_name); | 1189 EXPECT_NE(cc_name, shipping_name); |
| 1174 } | 1190 } |
| 1175 | 1191 |
| 1176 // Test selecting UseBillingForShipping. | 1192 // Test selecting UseBillingForShipping. |
| 1177 TEST_F(AutofillDialogControllerTest, UseBillingAsShipping) { | 1193 TEST_F(AutofillDialogControllerTest, UseBillingAsShipping) { |
| 1194 SwitchToAutofill(); |
| 1178 AutofillProfile full_profile(test::GetVerifiedProfile()); | 1195 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 1179 AutofillProfile full_profile2(test::GetVerifiedProfile2()); | 1196 AutofillProfile full_profile2(test::GetVerifiedProfile2()); |
| 1180 CreditCard credit_card(test::GetVerifiedCreditCard()); | 1197 CreditCard credit_card(test::GetVerifiedCreditCard()); |
| 1181 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1198 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 1182 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); | 1199 controller()->GetTestingManager()->AddTestingProfile(&full_profile2); |
| 1183 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1200 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 1184 | 1201 |
| 1185 // Test after setting use billing for shipping. | 1202 // Test after setting use billing for shipping. |
| 1186 UseBillingForShipping(); | 1203 UseBillingForShipping(); |
| 1187 | 1204 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 FormFieldData shipping_tel; | 1239 FormFieldData shipping_tel; |
| 1223 shipping_tel.autocomplete_attribute = "shipping tel"; | 1240 shipping_tel.autocomplete_attribute = "shipping tel"; |
| 1224 FormFieldData billing_tel; | 1241 FormFieldData billing_tel; |
| 1225 billing_tel.autocomplete_attribute = "billing tel"; | 1242 billing_tel.autocomplete_attribute = "billing tel"; |
| 1226 | 1243 |
| 1227 FormData form_data; | 1244 FormData form_data; |
| 1228 form_data.fields.push_back(shipping_tel); | 1245 form_data.fields.push_back(shipping_tel); |
| 1229 form_data.fields.push_back(billing_tel); | 1246 form_data.fields.push_back(billing_tel); |
| 1230 SetUpControllerWithFormData(form_data); | 1247 SetUpControllerWithFormData(form_data); |
| 1231 | 1248 |
| 1249 SwitchToAutofill(); |
| 1250 |
| 1232 // The profile that will be chosen for the shipping section. | 1251 // The profile that will be chosen for the shipping section. |
| 1233 AutofillProfile shipping_profile(test::GetVerifiedProfile()); | 1252 AutofillProfile shipping_profile(test::GetVerifiedProfile()); |
| 1234 // The profile that will be chosen for the billing section. | 1253 // The profile that will be chosen for the billing section. |
| 1235 AutofillProfile billing_profile(test::GetVerifiedProfile2()); | 1254 AutofillProfile billing_profile(test::GetVerifiedProfile2()); |
| 1236 CreditCard credit_card(test::GetVerifiedCreditCard()); | 1255 CreditCard credit_card(test::GetVerifiedCreditCard()); |
| 1237 controller()->GetTestingManager()->AddTestingProfile(&shipping_profile); | 1256 controller()->GetTestingManager()->AddTestingProfile(&shipping_profile); |
| 1238 controller()->GetTestingManager()->AddTestingProfile(&billing_profile); | 1257 controller()->GetTestingManager()->AddTestingProfile(&billing_profile); |
| 1239 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); | 1258 controller()->GetTestingManager()->AddTestingCreditCard(&credit_card); |
| 1240 ui::MenuModel* billing_model = | 1259 ui::MenuModel* billing_model = |
| 1241 controller()->MenuModelForSection(SECTION_BILLING); | 1260 controller()->MenuModelForSection(SECTION_BILLING); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1749 | 1768 |
| 1750 // Test Wallet banners are show in the right situations. These banners promote | 1769 // Test Wallet banners are show in the right situations. These banners promote |
| 1751 // saving details into Wallet (i.e. "[x] Save details to Wallet"). | 1770 // saving details into Wallet (i.e. "[x] Save details to Wallet"). |
| 1752 TEST_F(AutofillDialogControllerTest, WalletBanners) { | 1771 TEST_F(AutofillDialogControllerTest, WalletBanners) { |
| 1753 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1772 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1754 command_line->AppendSwitch(switches::kWalletServiceUseProd); | 1773 command_line->AppendSwitch(switches::kWalletServiceUseProd); |
| 1755 | 1774 |
| 1756 // Simulate non-signed-in case. | 1775 // Simulate non-signed-in case. |
| 1757 SetUpControllerWithFormData(DefaultFormData()); | 1776 SetUpControllerWithFormData(DefaultFormData()); |
| 1758 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 1777 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
| 1759 controller()->OnUserNameFetchFailure(error); | 1778 controller()->OnPassiveSigninFailure(error); |
| 1760 EXPECT_EQ(0U, NotificationsOfType( | 1779 EXPECT_EQ(0U, NotificationsOfType( |
| 1761 DialogNotification::WALLET_USAGE_CONFIRMATION).size()); | 1780 DialogNotification::WALLET_USAGE_CONFIRMATION).size()); |
| 1762 | 1781 |
| 1763 // Sign in a user with a completed account. | 1782 // Sign in a user with a completed account. |
| 1764 SetUpControllerWithFormData(DefaultFormData()); | 1783 SetUpControllerWithFormData(DefaultFormData()); |
| 1765 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 1784 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 1766 | 1785 |
| 1767 // Full account; should show "Details from Wallet" message. | 1786 // Full account; should show "Details from Wallet" message. |
| 1768 EXPECT_EQ(1U, NotificationsOfType( | 1787 EXPECT_EQ(1U, NotificationsOfType( |
| 1769 DialogNotification::WALLET_USAGE_CONFIRMATION).size()); | 1788 DialogNotification::WALLET_USAGE_CONFIRMATION).size()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 TEST_F(AutofillDialogControllerTest, HideWalletEmail) { | 1917 TEST_F(AutofillDialogControllerTest, HideWalletEmail) { |
| 1899 SwitchToAutofill(); | 1918 SwitchToAutofill(); |
| 1900 | 1919 |
| 1901 // Email field should be showing when using Autofill. | 1920 // Email field should be showing when using Autofill. |
| 1902 EXPECT_TRUE(controller()->SectionIsActive(SECTION_BILLING)); | 1921 EXPECT_TRUE(controller()->SectionIsActive(SECTION_BILLING)); |
| 1903 EXPECT_FALSE(controller()->SectionIsActive(SECTION_CC_BILLING)); | 1922 EXPECT_FALSE(controller()->SectionIsActive(SECTION_CC_BILLING)); |
| 1904 EXPECT_TRUE(SectionContainsField(SECTION_BILLING, EMAIL_ADDRESS)); | 1923 EXPECT_TRUE(SectionContainsField(SECTION_BILLING, EMAIL_ADDRESS)); |
| 1905 | 1924 |
| 1906 SwitchToWallet(); | 1925 SwitchToWallet(); |
| 1907 | 1926 |
| 1927 // Reset the wallet state. |
| 1928 controller()->OnDidGetWalletItems(scoped_ptr<wallet::WalletItems>()); |
| 1929 |
| 1908 // Setup some wallet state, submit, and get a full wallet to end the flow. | 1930 // Setup some wallet state, submit, and get a full wallet to end the flow. |
| 1909 scoped_ptr<wallet::WalletItems> wallet_items = CompleteAndValidWalletItems(); | 1931 scoped_ptr<wallet::WalletItems> wallet_items = CompleteAndValidWalletItems(); |
| 1910 | 1932 |
| 1911 // Filling |form_structure()| depends on the current username and wallet items | 1933 // Filling |form_structure()| depends on the current username and wallet items |
| 1912 // being fetched. Until both of these have occurred, the user should not be | 1934 // being fetched. Until both of these have occurred, the user should not be |
| 1913 // able to click Submit if using Wallet. The username fetch happened earlier. | 1935 // able to click Submit if using Wallet. The username fetch happened earlier. |
| 1914 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1936 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1915 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 1937 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| 1916 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 1938 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 1917 | 1939 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 controller()->OnDidGetWalletItems( | 2071 controller()->OnDidGetWalletItems( |
| 2050 wallet::WalletItems::CreateWalletItems(dict).Pass()); | 2072 wallet::WalletItems::CreateWalletItems(dict).Pass()); |
| 2051 | 2073 |
| 2052 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); | 2074 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); |
| 2053 // "Same as billing" and "Add address...". | 2075 // "Same as billing" and "Add address...". |
| 2054 EXPECT_EQ( | 2076 EXPECT_EQ( |
| 2055 2, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); | 2077 2, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); |
| 2056 } | 2078 } |
| 2057 | 2079 |
| 2058 TEST_F(AutofillDialogControllerTest, ShippingSectionCanBeHidden) { | 2080 TEST_F(AutofillDialogControllerTest, ShippingSectionCanBeHidden) { |
| 2059 SwitchToAutofill(); | |
| 2060 | |
| 2061 FormFieldData email_field; | 2081 FormFieldData email_field; |
| 2062 email_field.autocomplete_attribute = "email"; | 2082 email_field.autocomplete_attribute = "email"; |
| 2063 FormFieldData cc_field; | 2083 FormFieldData cc_field; |
| 2064 cc_field.autocomplete_attribute = "cc-number"; | 2084 cc_field.autocomplete_attribute = "cc-number"; |
| 2065 FormFieldData billing_field; | 2085 FormFieldData billing_field; |
| 2066 billing_field.autocomplete_attribute = "billing region"; | 2086 billing_field.autocomplete_attribute = "billing region"; |
| 2067 | 2087 |
| 2068 FormData form_data; | 2088 FormData form_data; |
| 2069 form_data.fields.push_back(email_field); | 2089 form_data.fields.push_back(email_field); |
| 2070 form_data.fields.push_back(cc_field); | 2090 form_data.fields.push_back(cc_field); |
| 2071 form_data.fields.push_back(billing_field); | 2091 form_data.fields.push_back(billing_field); |
| 2072 | 2092 |
| 2073 AutofillProfile full_profile(test::GetVerifiedProfile()); | 2093 AutofillProfile full_profile(test::GetVerifiedProfile()); |
| 2074 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 2094 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
| 2075 SetUpControllerWithFormData(form_data); | 2095 SetUpControllerWithFormData(form_data); |
| 2096 |
| 2097 SwitchToAutofill(); |
| 2098 |
| 2076 EXPECT_FALSE(controller()->SectionIsActive(SECTION_SHIPPING)); | 2099 EXPECT_FALSE(controller()->SectionIsActive(SECTION_SHIPPING)); |
| 2077 | 2100 |
| 2078 FillCreditCardInputs(); | 2101 FillCreditCardInputs(); |
| 2079 controller()->OnAccept(); | 2102 controller()->OnAccept(); |
| 2080 EXPECT_TRUE(form_structure()); | 2103 EXPECT_TRUE(form_structure()); |
| 2081 } | 2104 } |
| 2082 | 2105 |
| 2083 TEST_F(AutofillDialogControllerTest, ShippingSectionCanBeHiddenForWallet) { | 2106 TEST_F(AutofillDialogControllerTest, ShippingSectionCanBeHiddenForWallet) { |
| 2084 SwitchToWallet(); | 2107 SwitchToWallet(); |
| 2085 | 2108 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 shipping_model->ActivatedAt(1); | 2261 shipping_model->ActivatedAt(1); |
| 2239 // 2 suggestions, "add", and "manage". | 2262 // 2 suggestions, "add", and "manage". |
| 2240 ASSERT_EQ(4, cc_billing_model->GetItemCount()); | 2263 ASSERT_EQ(4, cc_billing_model->GetItemCount()); |
| 2241 EXPECT_TRUE(cc_billing_model->IsItemCheckedAt(1)); | 2264 EXPECT_TRUE(cc_billing_model->IsItemCheckedAt(1)); |
| 2242 // "use billing", 2 suggestions, "add", "manage". | 2265 // "use billing", 2 suggestions, "add", "manage". |
| 2243 ASSERT_EQ(5, shipping_model->GetItemCount()); | 2266 ASSERT_EQ(5, shipping_model->GetItemCount()); |
| 2244 EXPECT_TRUE(shipping_model-> IsItemCheckedAt(1)); | 2267 EXPECT_TRUE(shipping_model-> IsItemCheckedAt(1)); |
| 2245 | 2268 |
| 2246 // Simulate switching away from the tab and back. This should issue a request | 2269 // Simulate switching away from the tab and back. This should issue a request |
| 2247 // for wallet items. | 2270 // for wallet items. |
| 2271 controller()->ClearLastWalletItemsFetchTimestampForTesting(); |
| 2248 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems(_)); | 2272 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems(_)); |
| 2249 controller()->TabActivated(); | 2273 controller()->TabActivated(); |
| 2250 | 2274 |
| 2251 // Simulate a response that includes different items. | 2275 // Simulate a response that includes different items. |
| 2252 wallet_items = wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); | 2276 wallet_items = wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED); |
| 2253 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentExpired()); | 2277 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentExpired()); |
| 2254 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); | 2278 wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); |
| 2255 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument()); | 2279 wallet_items->AddInstrument(wallet::GetTestNonDefaultMaskedInstrument()); |
| 2256 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); | 2280 wallet_items->AddAddress(wallet::GetTestNonDefaultShippingAddress()); |
| 2257 controller()->OnDidGetWalletItems(wallet_items.Pass()); | 2281 controller()->OnDidGetWalletItems(wallet_items.Pass()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2287 controller()->MenuModelForSection(SECTION_SHIPPING); | 2311 controller()->MenuModelForSection(SECTION_SHIPPING); |
| 2288 // 2 suggestions, "add", and "manage". | 2312 // 2 suggestions, "add", and "manage". |
| 2289 ASSERT_EQ(4, cc_billing_model->GetItemCount()); | 2313 ASSERT_EQ(4, cc_billing_model->GetItemCount()); |
| 2290 EXPECT_TRUE(cc_billing_model->IsItemCheckedAt(0)); | 2314 EXPECT_TRUE(cc_billing_model->IsItemCheckedAt(0)); |
| 2291 // "use billing", 2 suggestions, "add", and "manage". | 2315 // "use billing", 2 suggestions, "add", and "manage". |
| 2292 ASSERT_EQ(5, shipping_model->GetItemCount()); | 2316 ASSERT_EQ(5, shipping_model->GetItemCount()); |
| 2293 EXPECT_TRUE(shipping_model->IsItemCheckedAt(2)); | 2317 EXPECT_TRUE(shipping_model->IsItemCheckedAt(2)); |
| 2294 | 2318 |
| 2295 // Simulate switching away from the tab and back. This should issue a request | 2319 // Simulate switching away from the tab and back. This should issue a request |
| 2296 // for wallet items. | 2320 // for wallet items. |
| 2321 controller()->ClearLastWalletItemsFetchTimestampForTesting(); |
| 2297 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems(_)); | 2322 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems(_)); |
| 2298 controller()->TabActivated(); | 2323 controller()->TabActivated(); |
| 2299 | 2324 |
| 2300 // Simulate a response that includes different default values. | 2325 // Simulate a response that includes different default values. |
| 2301 wallet_items = | 2326 wallet_items = |
| 2302 wallet::GetTestWalletItemsWithDefaultIds("new_default_instrument_id", | 2327 wallet::GetTestWalletItemsWithDefaultIds("new_default_instrument_id", |
| 2303 "new_default_address_id", | 2328 "new_default_address_id", |
| 2304 wallet::AMEX_DISALLOWED); | 2329 wallet::AMEX_DISALLOWED); |
| 2305 scoped_ptr<wallet::Address> other_address = wallet::GetTestShippingAddress(); | 2330 scoped_ptr<wallet::Address> other_address = wallet::GetTestShippingAddress(); |
| 2306 other_address->set_object_id("other_address_id"); | 2331 other_address->set_object_id("other_address_id"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2325 EXPECT_TRUE(shipping_model->IsItemCheckedAt(1)); | 2350 EXPECT_TRUE(shipping_model->IsItemCheckedAt(1)); |
| 2326 } | 2351 } |
| 2327 | 2352 |
| 2328 TEST_F(AutofillDialogControllerTest, ReloadWithEmptyWalletItems) { | 2353 TEST_F(AutofillDialogControllerTest, ReloadWithEmptyWalletItems) { |
| 2329 SwitchToWallet(); | 2354 SwitchToWallet(); |
| 2330 | 2355 |
| 2331 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 2356 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 2332 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(1); | 2357 controller()->MenuModelForSection(SECTION_CC_BILLING)->ActivatedAt(1); |
| 2333 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); | 2358 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(1); |
| 2334 | 2359 |
| 2360 controller()->ClearLastWalletItemsFetchTimestampForTesting(); |
| 2335 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems(_)); | 2361 EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems(_)); |
| 2336 controller()->TabActivated(); | 2362 controller()->TabActivated(); |
| 2337 | 2363 |
| 2338 controller()->OnDidGetWalletItems( | 2364 controller()->OnDidGetWalletItems( |
| 2339 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); | 2365 wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); |
| 2340 | 2366 |
| 2341 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); | 2367 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); |
| 2342 EXPECT_EQ( | 2368 EXPECT_EQ( |
| 2343 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); | 2369 3, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); |
| 2344 } | 2370 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2365 EXPECT_TRUE(controller()->ShouldSaveInChrome()); | 2391 EXPECT_TRUE(controller()->ShouldSaveInChrome()); |
| 2366 SwitchToAutofill(); | 2392 SwitchToAutofill(); |
| 2367 FillCreditCardInputs(); | 2393 FillCreditCardInputs(); |
| 2368 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(false); | 2394 controller()->GetView()->CheckSaveDetailsLocallyCheckbox(false); |
| 2369 controller()->OnAccept(); | 2395 controller()->OnAccept(); |
| 2370 EXPECT_FALSE(controller()->ShouldSaveInChrome()); | 2396 EXPECT_FALSE(controller()->ShouldSaveInChrome()); |
| 2371 } | 2397 } |
| 2372 | 2398 |
| 2373 TEST_F(AutofillDialogControllerTest, | 2399 TEST_F(AutofillDialogControllerTest, |
| 2374 SubmitButtonIsDisabled_SpinnerFinishesBeforeDelay) { | 2400 SubmitButtonIsDisabled_SpinnerFinishesBeforeDelay) { |
| 2401 // Reset Wallet state. |
| 2402 controller()->OnDidGetWalletItems(scoped_ptr<wallet::WalletItems>()); |
| 2403 |
| 2375 EXPECT_EQ(1, controller()->get_submit_button_delay_count()); | 2404 EXPECT_EQ(1, controller()->get_submit_button_delay_count()); |
| 2376 | 2405 |
| 2377 // Begin the submit button delay. | 2406 // Begin the submit button delay. |
| 2378 controller()->SimulateSubmitButtonDelayBegin(); | 2407 controller()->SimulateSubmitButtonDelayBegin(); |
| 2379 | 2408 |
| 2380 EXPECT_TRUE(controller()->ShouldShowSpinner()); | 2409 EXPECT_TRUE(controller()->ShouldShowSpinner()); |
| 2381 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2410 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2382 | 2411 |
| 2383 // Stop the spinner. | 2412 // Stop the spinner. |
| 2384 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 2413 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 2385 | 2414 |
| 2386 EXPECT_FALSE(controller()->ShouldShowSpinner()); | 2415 EXPECT_FALSE(controller()->ShouldShowSpinner()); |
| 2387 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2416 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2388 | 2417 |
| 2389 // End the submit button delay. | 2418 // End the submit button delay. |
| 2390 controller()->SimulateSubmitButtonDelayEnd(); | 2419 controller()->SimulateSubmitButtonDelayEnd(); |
| 2391 | 2420 |
| 2392 EXPECT_FALSE(controller()->ShouldShowSpinner()); | 2421 EXPECT_FALSE(controller()->ShouldShowSpinner()); |
| 2393 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2422 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2394 } | 2423 } |
| 2395 | 2424 |
| 2396 TEST_F(AutofillDialogControllerTest, | 2425 TEST_F(AutofillDialogControllerTest, |
| 2397 SubmitButtonIsDisabled_SpinnerFinishesAfterDelay) { | 2426 SubmitButtonIsDisabled_SpinnerFinishesAfterDelay) { |
| 2427 // Reset Wallet state. |
| 2428 controller()->OnDidGetWalletItems(scoped_ptr<wallet::WalletItems>()); |
| 2429 |
| 2398 EXPECT_EQ(1, controller()->get_submit_button_delay_count()); | 2430 EXPECT_EQ(1, controller()->get_submit_button_delay_count()); |
| 2399 | 2431 |
| 2400 // Begin the submit button delay. | 2432 // Begin the submit button delay. |
| 2401 controller()->SimulateSubmitButtonDelayBegin(); | 2433 controller()->SimulateSubmitButtonDelayBegin(); |
| 2402 | 2434 |
| 2403 EXPECT_TRUE(controller()->ShouldShowSpinner()); | 2435 EXPECT_TRUE(controller()->ShouldShowSpinner()); |
| 2404 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2436 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2405 | 2437 |
| 2406 // End the submit button delay. | 2438 // End the submit button delay. |
| 2407 controller()->SimulateSubmitButtonDelayEnd(); | 2439 controller()->SimulateSubmitButtonDelayEnd(); |
| 2408 | 2440 |
| 2409 EXPECT_TRUE(controller()->ShouldShowSpinner()); | 2441 EXPECT_TRUE(controller()->ShouldShowSpinner()); |
| 2410 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2442 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2411 | 2443 |
| 2412 // Stop the spinner. | 2444 // Stop the spinner. |
| 2413 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); | 2445 controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); |
| 2414 | 2446 |
| 2415 EXPECT_FALSE(controller()->ShouldShowSpinner()); | 2447 EXPECT_FALSE(controller()->ShouldShowSpinner()); |
| 2416 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2448 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2417 } | 2449 } |
| 2418 | 2450 |
| 2419 TEST_F(AutofillDialogControllerTest, SubmitButtonIsDisabled_NoSpinner) { | 2451 TEST_F(AutofillDialogControllerTest, SubmitButtonIsDisabled_NoSpinner) { |
| 2452 SwitchToAutofill(); |
| 2453 |
| 2420 EXPECT_EQ(1, controller()->get_submit_button_delay_count()); | 2454 EXPECT_EQ(1, controller()->get_submit_button_delay_count()); |
| 2421 | 2455 |
| 2422 // Begin the submit button delay. | 2456 // Begin the submit button delay. |
| 2423 controller()->SimulateSubmitButtonDelayBegin(); | 2457 controller()->SimulateSubmitButtonDelayBegin(); |
| 2424 | 2458 |
| 2425 EXPECT_TRUE(controller()->ShouldShowSpinner()); | |
| 2426 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | |
| 2427 | |
| 2428 // There's no spinner in Autofill mode. | |
| 2429 SwitchToAutofill(); | |
| 2430 | |
| 2431 EXPECT_FALSE(controller()->ShouldShowSpinner()); | 2459 EXPECT_FALSE(controller()->ShouldShowSpinner()); |
| 2432 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2460 EXPECT_FALSE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2433 | 2461 |
| 2434 // End the submit button delay. | 2462 // End the submit button delay. |
| 2435 controller()->SimulateSubmitButtonDelayEnd(); | 2463 controller()->SimulateSubmitButtonDelayEnd(); |
| 2436 | 2464 |
| 2437 EXPECT_FALSE(controller()->ShouldShowSpinner()); | 2465 EXPECT_FALSE(controller()->ShouldShowSpinner()); |
| 2438 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); | 2466 EXPECT_TRUE(controller()->IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)); |
| 2439 } | 2467 } |
| 2440 | 2468 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2474 EXPECT_EQ(1UL, icons.count(CREDIT_CARD_NUMBER)); | 2502 EXPECT_EQ(1UL, icons.count(CREDIT_CARD_NUMBER)); |
| 2475 } | 2503 } |
| 2476 | 2504 |
| 2477 TEST_F(AutofillDialogControllerTest, FieldControlsIcons) { | 2505 TEST_F(AutofillDialogControllerTest, FieldControlsIcons) { |
| 2478 EXPECT_TRUE(controller()->FieldControlsIcons(CREDIT_CARD_NUMBER)); | 2506 EXPECT_TRUE(controller()->FieldControlsIcons(CREDIT_CARD_NUMBER)); |
| 2479 EXPECT_FALSE(controller()->FieldControlsIcons(CREDIT_CARD_VERIFICATION_CODE)); | 2507 EXPECT_FALSE(controller()->FieldControlsIcons(CREDIT_CARD_VERIFICATION_CODE)); |
| 2480 EXPECT_FALSE(controller()->FieldControlsIcons(EMAIL_ADDRESS)); | 2508 EXPECT_FALSE(controller()->FieldControlsIcons(EMAIL_ADDRESS)); |
| 2481 } | 2509 } |
| 2482 | 2510 |
| 2483 } // namespace autofill | 2511 } // namespace autofill |
| OLD | NEW |