| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 // Test that we return all credit card suggestions in the case that two cards | 1510 // Test that we return all credit card suggestions in the case that two cards |
| 1511 // have the same obfuscated number. | 1511 // have the same obfuscated number. |
| 1512 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsRepeatedObfuscatedNumber) { | 1512 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsRepeatedObfuscatedNumber) { |
| 1513 // Add a credit card with the same obfuscated number as Elvis's. | 1513 // Add a credit card with the same obfuscated number as Elvis's. |
| 1514 // |credit_card| will be owned by the mock PersonalDataManager. | 1514 // |credit_card| will be owned by the mock PersonalDataManager. |
| 1515 CreditCard* credit_card = new CreditCard; | 1515 CreditCard* credit_card = new CreditCard; |
| 1516 test::SetCreditCardInfo(credit_card, "Elvis Presley", | 1516 test::SetCreditCardInfo(credit_card, "Elvis Presley", |
| 1517 "5231567890123456", // Mastercard | 1517 "5231567890123456", // Mastercard |
| 1518 "05", "2999"); | 1518 "05", "2999"); |
| 1519 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); | 1519 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); |
| 1520 credit_card->set_use_date(base::Time::Now() - base::TimeDelta::FromDays(15)); |
| 1520 autofill_manager_->AddCreditCard(credit_card); | 1521 autofill_manager_->AddCreditCard(credit_card); |
| 1521 | 1522 |
| 1522 // Set up our form data. | 1523 // Set up our form data. |
| 1523 FormData form; | 1524 FormData form; |
| 1524 CreateTestCreditCardFormData(&form, true, false); | 1525 CreateTestCreditCardFormData(&form, true, false); |
| 1525 std::vector<FormData> forms(1, form); | 1526 std::vector<FormData> forms(1, form); |
| 1526 FormsSeen(forms); | 1527 FormsSeen(forms); |
| 1527 | 1528 |
| 1528 FormFieldData field = form.fields[1]; | 1529 FormFieldData field = form.fields[1]; |
| 1529 GetAutofillSuggestions(form, field); | 1530 GetAutofillSuggestions(form, field); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 TEST_F(AutofillManagerTest, FillAddressForm) { | 1772 TEST_F(AutofillManagerTest, FillAddressForm) { |
| 1772 // Set up our form data. | 1773 // Set up our form data. |
| 1773 FormData form; | 1774 FormData form; |
| 1774 test::CreateTestAddressFormData(&form); | 1775 test::CreateTestAddressFormData(&form); |
| 1775 std::vector<FormData> forms(1, form); | 1776 std::vector<FormData> forms(1, form); |
| 1776 FormsSeen(forms); | 1777 FormsSeen(forms); |
| 1777 | 1778 |
| 1778 const char guid[] = "00000000-0000-0000-0000-000000000001"; | 1779 const char guid[] = "00000000-0000-0000-0000-000000000001"; |
| 1779 AutofillProfile* profile = autofill_manager_->GetProfileWithGUID(guid); | 1780 AutofillProfile* profile = autofill_manager_->GetProfileWithGUID(guid); |
| 1780 ASSERT_TRUE(profile); | 1781 ASSERT_TRUE(profile); |
| 1781 EXPECT_EQ(0U, profile->use_count()); | 1782 EXPECT_EQ(1U, profile->use_count()); |
| 1782 EXPECT_EQ(base::Time(), profile->use_date()); | 1783 EXPECT_NE(base::Time(), profile->use_date()); |
| 1783 | 1784 |
| 1784 int response_page_id = 0; | 1785 int response_page_id = 0; |
| 1785 FormData response_data; | 1786 FormData response_data; |
| 1786 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], | 1787 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], |
| 1787 MakeFrontendID(std::string(), guid), | 1788 MakeFrontendID(std::string(), guid), |
| 1788 &response_page_id, &response_data); | 1789 &response_page_id, &response_data); |
| 1789 ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, | 1790 ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, |
| 1790 false); | 1791 false); |
| 1791 | 1792 |
| 1792 EXPECT_EQ(1U, profile->use_count()); | 1793 EXPECT_EQ(2U, profile->use_count()); |
| 1793 EXPECT_NE(base::Time(), profile->use_date()); | 1794 EXPECT_NE(base::Time(), profile->use_date()); |
| 1794 } | 1795 } |
| 1795 | 1796 |
| 1796 TEST_F(AutofillManagerTest, WillFillCreditCardNumber) { | 1797 TEST_F(AutofillManagerTest, WillFillCreditCardNumber) { |
| 1797 // Set up our form data. | 1798 // Set up our form data. |
| 1798 FormData form; | 1799 FormData form; |
| 1799 CreateTestCreditCardFormData(&form, true, false); | 1800 CreateTestCreditCardFormData(&form, true, false); |
| 1800 std::vector<FormData> forms(1, form); | 1801 std::vector<FormData> forms(1, form); |
| 1801 FormsSeen(forms); | 1802 FormsSeen(forms); |
| 1802 | 1803 |
| (...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4173 | 4174 |
| 4174 EXPECT_EQ(ASCIIToUTF16("02"), | 4175 EXPECT_EQ(ASCIIToUTF16("02"), |
| 4175 autofill_manager_->unmask_request_.card.GetRawInfo( | 4176 autofill_manager_->unmask_request_.card.GetRawInfo( |
| 4176 CREDIT_CARD_EXP_MONTH)); | 4177 CREDIT_CARD_EXP_MONTH)); |
| 4177 EXPECT_EQ(ASCIIToUTF16("2018"), | 4178 EXPECT_EQ(ASCIIToUTF16("2018"), |
| 4178 autofill_manager_->unmask_request_.card.GetRawInfo( | 4179 autofill_manager_->unmask_request_.card.GetRawInfo( |
| 4179 CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 4180 CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 4180 } | 4181 } |
| 4181 | 4182 |
| 4182 TEST_F(AutofillManagerTest, UploadCreditCard) { | 4183 TEST_F(AutofillManagerTest, UploadCreditCard) { |
| 4184 personal_data_.ClearAutofillProfiles(); |
| 4183 autofill_manager_->set_credit_card_upload_enabled(true); | 4185 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4184 | 4186 |
| 4185 // Create, fill and submit an address form in order to establish a recent | 4187 // Create, fill and submit an address form in order to establish a recent |
| 4186 // profile which can be selected for the upload request. | 4188 // profile which can be selected for the upload request. |
| 4187 FormData address_form; | 4189 FormData address_form; |
| 4188 test::CreateTestAddressFormData(&address_form); | 4190 test::CreateTestAddressFormData(&address_form); |
| 4189 FormsSeen(std::vector<FormData>(1, address_form)); | 4191 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4190 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4192 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4191 FormSubmitted(address_form); | 4193 FormSubmitted(address_form); |
| 4192 | 4194 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4206 | 4208 |
| 4207 FormSubmitted(credit_card_form); | 4209 FormSubmitted(credit_card_form); |
| 4208 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4210 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4209 | 4211 |
| 4210 // Verify that the correct histogram entry (and only that) was logged. | 4212 // Verify that the correct histogram entry (and only that) was logged. |
| 4211 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 4213 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", |
| 4212 AutofillMetrics::UPLOAD_OFFERED, 1); | 4214 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4213 } | 4215 } |
| 4214 | 4216 |
| 4215 TEST_F(AutofillManagerTest, UploadCreditCard_FeatureNotEnabled) { | 4217 TEST_F(AutofillManagerTest, UploadCreditCard_FeatureNotEnabled) { |
| 4218 personal_data_.ClearAutofillProfiles(); |
| 4216 autofill_manager_->set_credit_card_upload_enabled(false); | 4219 autofill_manager_->set_credit_card_upload_enabled(false); |
| 4217 | 4220 |
| 4218 // Create, fill and submit an address form in order to establish a recent | 4221 // Create, fill and submit an address form in order to establish a recent |
| 4219 // profile which can be selected for the upload request. | 4222 // profile which can be selected for the upload request. |
| 4220 FormData address_form; | 4223 FormData address_form; |
| 4221 test::CreateTestAddressFormData(&address_form); | 4224 test::CreateTestAddressFormData(&address_form); |
| 4222 FormsSeen(std::vector<FormData>(1, address_form)); | 4225 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4223 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4226 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4224 FormSubmitted(address_form); | 4227 FormSubmitted(address_form); |
| 4225 | 4228 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4240 // The save prompt should be shown instead of doing an upload. | 4243 // The save prompt should be shown instead of doing an upload. |
| 4241 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); | 4244 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
| 4242 FormSubmitted(credit_card_form); | 4245 FormSubmitted(credit_card_form); |
| 4243 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4246 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4244 | 4247 |
| 4245 // Verify that no histogram entry was logged called. | 4248 // Verify that no histogram entry was logged called. |
| 4246 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionExpanded", 0); | 4249 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionExpanded", 0); |
| 4247 } | 4250 } |
| 4248 | 4251 |
| 4249 TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) { | 4252 TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) { |
| 4253 personal_data_.ClearAutofillProfiles(); |
| 4250 autofill_manager_->set_credit_card_upload_enabled(true); | 4254 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4251 | 4255 |
| 4252 // Create, fill and submit an address form in order to establish a recent | 4256 // Create, fill and submit an address form in order to establish a recent |
| 4253 // profile which can be selected for the upload request. | 4257 // profile which can be selected for the upload request. |
| 4254 FormData address_form; | 4258 FormData address_form; |
| 4255 test::CreateTestAddressFormData(&address_form); | 4259 test::CreateTestAddressFormData(&address_form); |
| 4256 FormsSeen(std::vector<FormData>(1, address_form)); | 4260 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4257 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4261 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4258 FormSubmitted(address_form); | 4262 FormSubmitted(address_form); |
| 4259 | 4263 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4278 | 4282 |
| 4279 // Verify that the correct histogram entry (and only that) was logged. | 4283 // Verify that the correct histogram entry (and only that) was logged. |
| 4280 histogram_tester.ExpectUniqueSample( | 4284 histogram_tester.ExpectUniqueSample( |
| 4281 "Autofill.CardUploadDecisionExpanded", | 4285 "Autofill.CardUploadDecisionExpanded", |
| 4282 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | 4286 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); |
| 4283 } | 4287 } |
| 4284 | 4288 |
| 4285 TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) { | 4289 TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) { |
| 4286 autofill_manager_->set_credit_card_upload_enabled(true); | 4290 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4287 | 4291 |
| 4292 // Remove the profiles that were created in the TestPersonalDataManager |
| 4293 // constructor because they would result in conflicting names that would |
| 4294 // prevent the upload. |
| 4295 personal_data_.ClearAutofillProfiles(); |
| 4296 |
| 4288 // Create, fill and submit an address form in order to establish a recent | 4297 // Create, fill and submit an address form in order to establish a recent |
| 4289 // profile which can be selected for the upload request. | 4298 // profile which can be selected for the upload request. |
| 4290 FormData address_form; | 4299 FormData address_form; |
| 4291 test::CreateTestAddressFormData(&address_form); | 4300 test::CreateTestAddressFormData(&address_form); |
| 4292 FormsSeen(std::vector<FormData>(1, address_form)); | 4301 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4293 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4302 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4294 FormSubmitted(address_form); | 4303 FormSubmitted(address_form); |
| 4295 | 4304 |
| 4296 // Set up our credit card form data. | 4305 // Set up our credit card form data. |
| 4297 FormData credit_card_form; | 4306 FormData credit_card_form; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4330 FormSubmitted(credit_card_form); | 4339 FormSubmitted(credit_card_form); |
| 4331 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4340 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4332 | 4341 |
| 4333 // Verify that the correct histogram entry (and only that) was logged. | 4342 // Verify that the correct histogram entry (and only that) was logged. |
| 4334 histogram_tester.ExpectUniqueSample( | 4343 histogram_tester.ExpectUniqueSample( |
| 4335 "Autofill.CardUploadDecisionExpanded", | 4344 "Autofill.CardUploadDecisionExpanded", |
| 4336 AutofillMetrics::UPLOAD_OFFERED, 1); | 4345 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4337 } | 4346 } |
| 4338 | 4347 |
| 4339 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { | 4348 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { |
| 4349 personal_data_.ClearAutofillProfiles(); |
| 4340 autofill_manager_->set_credit_card_upload_enabled(true); | 4350 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4341 | 4351 |
| 4342 // Don't fill or submit an address form. | 4352 // Don't fill or submit an address form. |
| 4343 | 4353 |
| 4344 // Set up our credit card form data. | 4354 // Set up our credit card form data. |
| 4345 FormData credit_card_form; | 4355 FormData credit_card_form; |
| 4346 CreateTestCreditCardFormData(&credit_card_form, true, false); | 4356 CreateTestCreditCardFormData(&credit_card_form, true, false); |
| 4347 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 4357 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
| 4348 | 4358 |
| 4349 // Edit the data, and submit. | 4359 // Edit the data, and submit. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4360 FormSubmitted(credit_card_form); | 4370 FormSubmitted(credit_card_form); |
| 4361 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4371 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4362 | 4372 |
| 4363 // Verify that the correct histogram entry (and only that) was logged. | 4373 // Verify that the correct histogram entry (and only that) was logged. |
| 4364 histogram_tester.ExpectUniqueSample( | 4374 histogram_tester.ExpectUniqueSample( |
| 4365 "Autofill.CardUploadDecisionExpanded", | 4375 "Autofill.CardUploadDecisionExpanded", |
| 4366 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); | 4376 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); |
| 4367 } | 4377 } |
| 4368 | 4378 |
| 4369 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { | 4379 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { |
| 4380 personal_data_.ClearAutofillProfiles(); |
| 4370 autofill_manager_->set_credit_card_upload_enabled(true); | 4381 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4371 | 4382 |
| 4372 // Create, fill and submit an address form in order to establish a recent | 4383 // Create, fill and submit an address form in order to establish a recent |
| 4373 // profile which can be selected for the upload request. | 4384 // profile which can be selected for the upload request. |
| 4374 FormData address_form; | 4385 FormData address_form; |
| 4375 test::CreateTestAddressFormData(&address_form); | 4386 test::CreateTestAddressFormData(&address_form); |
| 4376 FormsSeen(std::vector<FormData>(1, address_form)); | 4387 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4377 // But omit the name: | 4388 // But omit the name: |
| 4378 ManuallyFillAddressForm("", "", "77401", "US", &address_form); | 4389 ManuallyFillAddressForm("", "", "77401", "US", &address_form); |
| 4379 FormSubmitted(address_form); | 4390 FormSubmitted(address_form); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4396 FormSubmitted(credit_card_form); | 4407 FormSubmitted(credit_card_form); |
| 4397 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4408 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4398 | 4409 |
| 4399 // Verify that the correct histogram entry (and only that) was logged. | 4410 // Verify that the correct histogram entry (and only that) was logged. |
| 4400 histogram_tester.ExpectUniqueSample( | 4411 histogram_tester.ExpectUniqueSample( |
| 4401 "Autofill.CardUploadDecisionExpanded", | 4412 "Autofill.CardUploadDecisionExpanded", |
| 4402 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); | 4413 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); |
| 4403 } | 4414 } |
| 4404 | 4415 |
| 4405 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { | 4416 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { |
| 4417 personal_data_.ClearAutofillProfiles(); |
| 4406 autofill_manager_->set_credit_card_upload_enabled(true); | 4418 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4407 | 4419 |
| 4408 // Create, fill and submit two address forms with different zip codes. | 4420 // Create, fill and submit two address forms with different zip codes. |
| 4409 FormData address_form1, address_form2; | 4421 FormData address_form1, address_form2; |
| 4410 test::CreateTestAddressFormData(&address_form1); | 4422 test::CreateTestAddressFormData(&address_form1); |
| 4411 test::CreateTestAddressFormData(&address_form2); | 4423 test::CreateTestAddressFormData(&address_form2); |
| 4412 | 4424 |
| 4413 std::vector<FormData> address_forms; | 4425 std::vector<FormData> address_forms; |
| 4414 address_forms.push_back(address_form1); | 4426 address_forms.push_back(address_form1); |
| 4415 address_forms.push_back(address_form2); | 4427 address_forms.push_back(address_form2); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4440 FormSubmitted(credit_card_form); | 4452 FormSubmitted(credit_card_form); |
| 4441 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4453 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4442 | 4454 |
| 4443 // Verify that the correct histogram entry (and only that) was logged. | 4455 // Verify that the correct histogram entry (and only that) was logged. |
| 4444 histogram_tester.ExpectUniqueSample( | 4456 histogram_tester.ExpectUniqueSample( |
| 4445 "Autofill.CardUploadDecisionExpanded", | 4457 "Autofill.CardUploadDecisionExpanded", |
| 4446 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); | 4458 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); |
| 4447 } | 4459 } |
| 4448 | 4460 |
| 4449 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { | 4461 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { |
| 4462 personal_data_.ClearAutofillProfiles(); |
| 4450 autofill_manager_->set_credit_card_upload_enabled(true); | 4463 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4451 | 4464 |
| 4452 // Create, fill and submit two address forms with different zip codes. | 4465 // Create, fill and submit two address forms with different zip codes. |
| 4453 FormData address_form1, address_form2; | 4466 FormData address_form1, address_form2; |
| 4454 test::CreateTestAddressFormData(&address_form1); | 4467 test::CreateTestAddressFormData(&address_form1); |
| 4455 test::CreateTestAddressFormData(&address_form2); | 4468 test::CreateTestAddressFormData(&address_form2); |
| 4456 | 4469 |
| 4457 std::vector<FormData> address_forms; | 4470 std::vector<FormData> address_forms; |
| 4458 address_forms.push_back(address_form1); | 4471 address_forms.push_back(address_form1); |
| 4459 address_forms.push_back(address_form2); | 4472 address_forms.push_back(address_form2); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4484 FormSubmitted(credit_card_form); | 4497 FormSubmitted(credit_card_form); |
| 4485 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4498 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4486 | 4499 |
| 4487 // Verify that the correct histogram entry (and only that) was logged. | 4500 // Verify that the correct histogram entry (and only that) was logged. |
| 4488 histogram_tester.ExpectUniqueSample( | 4501 histogram_tester.ExpectUniqueSample( |
| 4489 "Autofill.CardUploadDecisionExpanded", | 4502 "Autofill.CardUploadDecisionExpanded", |
| 4490 AutofillMetrics::UPLOAD_OFFERED, 1); | 4503 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4491 } | 4504 } |
| 4492 | 4505 |
| 4493 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { | 4506 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { |
| 4507 personal_data_.ClearAutofillProfiles(); |
| 4494 autofill_manager_->set_credit_card_upload_enabled(true); | 4508 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4495 | 4509 |
| 4496 // Create, fill and submit an address form in order to establish a recent | 4510 // Create, fill and submit an address form in order to establish a recent |
| 4497 // profile which can be selected for the upload request. | 4511 // profile which can be selected for the upload request. |
| 4498 FormData address_form; | 4512 FormData address_form; |
| 4499 test::CreateTestAddressFormData(&address_form); | 4513 test::CreateTestAddressFormData(&address_form); |
| 4500 FormsSeen(std::vector<FormData>(1, address_form)); | 4514 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4501 // Autofill's validation requirements for Venezuala ("VE", see | 4515 // Autofill's validation requirements for Venezuala ("VE", see |
| 4502 // src/components/autofill/core/browser/country_data.cc) do not require zip | 4516 // src/components/autofill/core/browser/country_data.cc) do not require zip |
| 4503 // codes. We use Venezuala here because to use the US (or one of many other | 4517 // codes. We use Venezuala here because to use the US (or one of many other |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4527 FormSubmitted(credit_card_form); | 4541 FormSubmitted(credit_card_form); |
| 4528 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4542 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4529 | 4543 |
| 4530 // Verify that the correct histogram entry (and only that) was logged. | 4544 // Verify that the correct histogram entry (and only that) was logged. |
| 4531 histogram_tester.ExpectUniqueSample( | 4545 histogram_tester.ExpectUniqueSample( |
| 4532 "Autofill.CardUploadDecisionExpanded", | 4546 "Autofill.CardUploadDecisionExpanded", |
| 4533 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); | 4547 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); |
| 4534 } | 4548 } |
| 4535 | 4549 |
| 4536 TEST_F(AutofillManagerTest, UploadCreditCard_NamesMatchLoosely) { | 4550 TEST_F(AutofillManagerTest, UploadCreditCard_NamesMatchLoosely) { |
| 4551 personal_data_.ClearAutofillProfiles(); |
| 4537 autofill_manager_->set_credit_card_upload_enabled(true); | 4552 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4538 | 4553 |
| 4539 // Create, fill and submit two address forms with different names. | 4554 // Create, fill and submit two address forms with different names. |
| 4540 FormData address_form1, address_form2; | 4555 FormData address_form1, address_form2; |
| 4541 test::CreateTestAddressFormData(&address_form1); | 4556 test::CreateTestAddressFormData(&address_form1); |
| 4542 test::CreateTestAddressFormData(&address_form2); | 4557 test::CreateTestAddressFormData(&address_form2); |
| 4543 | 4558 |
| 4544 std::vector<FormData> address_forms; | 4559 std::vector<FormData> address_forms; |
| 4545 address_forms.push_back(address_form1); | 4560 address_forms.push_back(address_form1); |
| 4546 address_forms.push_back(address_form2); | 4561 address_forms.push_back(address_form2); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4574 FormSubmitted(credit_card_form); | 4589 FormSubmitted(credit_card_form); |
| 4575 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4590 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4576 | 4591 |
| 4577 // Verify that the correct histogram entry (and only that) was logged. | 4592 // Verify that the correct histogram entry (and only that) was logged. |
| 4578 histogram_tester.ExpectUniqueSample( | 4593 histogram_tester.ExpectUniqueSample( |
| 4579 "Autofill.CardUploadDecisionExpanded", | 4594 "Autofill.CardUploadDecisionExpanded", |
| 4580 AutofillMetrics::UPLOAD_OFFERED, 1); | 4595 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4581 } | 4596 } |
| 4582 | 4597 |
| 4583 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { | 4598 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { |
| 4599 personal_data_.ClearAutofillProfiles(); |
| 4584 autofill_manager_->set_credit_card_upload_enabled(true); | 4600 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4585 | 4601 |
| 4586 // Create, fill and submit two address forms with different names. | 4602 // Create, fill and submit two address forms with different names. |
| 4587 FormData address_form1, address_form2; | 4603 FormData address_form1, address_form2; |
| 4588 test::CreateTestAddressFormData(&address_form1); | 4604 test::CreateTestAddressFormData(&address_form1); |
| 4589 test::CreateTestAddressFormData(&address_form2); | 4605 test::CreateTestAddressFormData(&address_form2); |
| 4590 | 4606 |
| 4591 std::vector<FormData> address_forms; | 4607 std::vector<FormData> address_forms; |
| 4592 address_forms.push_back(address_form1); | 4608 address_forms.push_back(address_form1); |
| 4593 address_forms.push_back(address_form2); | 4609 address_forms.push_back(address_form2); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4618 FormSubmitted(credit_card_form); | 4634 FormSubmitted(credit_card_form); |
| 4619 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4635 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4620 | 4636 |
| 4621 // Verify that the correct histogram entry (and only that) was logged. | 4637 // Verify that the correct histogram entry (and only that) was logged. |
| 4622 histogram_tester.ExpectUniqueSample( | 4638 histogram_tester.ExpectUniqueSample( |
| 4623 "Autofill.CardUploadDecisionExpanded", | 4639 "Autofill.CardUploadDecisionExpanded", |
| 4624 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); | 4640 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); |
| 4625 } | 4641 } |
| 4626 | 4642 |
| 4627 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { | 4643 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { |
| 4644 personal_data_.ClearAutofillProfiles(); |
| 4628 autofill_manager_->set_credit_card_upload_enabled(true); | 4645 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4629 | 4646 |
| 4630 // Anything other than "en-US" will cause GetUploadDetails to return a failure | 4647 // Anything other than "en-US" will cause GetUploadDetails to return a failure |
| 4631 // response. | 4648 // response. |
| 4632 autofill_manager_->set_app_locale("pt-BR"); | 4649 autofill_manager_->set_app_locale("pt-BR"); |
| 4633 | 4650 |
| 4634 // Create, fill and submit an address form in order to establish a recent | 4651 // Create, fill and submit an address form in order to establish a recent |
| 4635 // profile which can be selected for the upload request. | 4652 // profile which can be selected for the upload request. |
| 4636 FormData address_form; | 4653 FormData address_form; |
| 4637 test::CreateTestAddressFormData(&address_form); | 4654 test::CreateTestAddressFormData(&address_form); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4947 FormsSeen(mixed_forms); | 4964 FormsSeen(mixed_forms); |
| 4948 | 4965 |
| 4949 // Suggestions should always be displayed. | 4966 // Suggestions should always be displayed. |
| 4950 for (const FormFieldData& field : mixed_form.fields) { | 4967 for (const FormFieldData& field : mixed_form.fields) { |
| 4951 GetAutofillSuggestions(mixed_form, field); | 4968 GetAutofillSuggestions(mixed_form, field); |
| 4952 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4969 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4953 } | 4970 } |
| 4954 } | 4971 } |
| 4955 | 4972 |
| 4956 } // namespace autofill | 4973 } // namespace autofill |
| OLD | NEW |