Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 4276 FormSubmitted(credit_card_form); | 4280 FormSubmitted(credit_card_form); |
| 4277 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4281 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 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_NoProfileAvailable) { | 4289 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { |
| 4290 personal_data_.ClearAutofillProfiles(); | |
| 4286 autofill_manager_->set_credit_card_upload_enabled(true); | 4291 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4287 | 4292 |
| 4288 // Don't fill or submit an address form. | 4293 // Don't fill or submit an address form. |
| 4289 | 4294 |
| 4290 // Set up our credit card form data. | 4295 // Set up our credit card form data. |
| 4291 FormData credit_card_form; | 4296 FormData credit_card_form; |
| 4292 CreateTestCreditCardFormData(&credit_card_form, true, false); | 4297 CreateTestCreditCardFormData(&credit_card_form, true, false); |
| 4293 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 4298 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
| 4294 | 4299 |
| 4295 // Edit the data, and submit. | 4300 // Edit the data, and submit. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 4306 FormSubmitted(credit_card_form); | 4311 FormSubmitted(credit_card_form); |
| 4307 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4312 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4308 | 4313 |
| 4309 // Verify that the correct histogram entry (and only that) was logged. | 4314 // Verify that the correct histogram entry (and only that) was logged. |
| 4310 histogram_tester.ExpectUniqueSample( | 4315 histogram_tester.ExpectUniqueSample( |
| 4311 "Autofill.CardUploadDecisionExpanded", | 4316 "Autofill.CardUploadDecisionExpanded", |
| 4312 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); | 4317 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); |
| 4313 } | 4318 } |
| 4314 | 4319 |
| 4315 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { | 4320 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { |
| 4321 personal_data_.ClearAutofillProfiles(); | |
| 4316 autofill_manager_->set_credit_card_upload_enabled(true); | 4322 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4317 | 4323 |
| 4318 // Create, fill and submit an address form in order to establish a recent | 4324 // Create, fill and submit an address form in order to establish a recent |
| 4319 // profile which can be selected for the upload request. | 4325 // profile which can be selected for the upload request. |
| 4320 FormData address_form; | 4326 FormData address_form; |
| 4321 test::CreateTestAddressFormData(&address_form); | 4327 test::CreateTestAddressFormData(&address_form); |
| 4322 FormsSeen(std::vector<FormData>(1, address_form)); | 4328 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4323 // But omit the name: | 4329 // But omit the name: |
| 4324 ManuallyFillAddressForm("", "", "77401", "US", &address_form); | 4330 ManuallyFillAddressForm("", "", "77401", "US", &address_form); |
| 4325 FormSubmitted(address_form); | 4331 FormSubmitted(address_form); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 4342 FormSubmitted(credit_card_form); | 4348 FormSubmitted(credit_card_form); |
| 4343 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4349 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4344 | 4350 |
| 4345 // Verify that the correct histogram entry (and only that) was logged. | 4351 // Verify that the correct histogram entry (and only that) was logged. |
| 4346 histogram_tester.ExpectUniqueSample( | 4352 histogram_tester.ExpectUniqueSample( |
| 4347 "Autofill.CardUploadDecisionExpanded", | 4353 "Autofill.CardUploadDecisionExpanded", |
| 4348 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); | 4354 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); |
| 4349 } | 4355 } |
| 4350 | 4356 |
| 4351 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { | 4357 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { |
| 4358 personal_data_.ClearAutofillProfiles(); | |
| 4352 autofill_manager_->set_credit_card_upload_enabled(true); | 4359 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4353 | 4360 |
| 4354 // Create, fill and submit two address forms with different zip codes. | 4361 // Create, fill and submit two address forms with different zip codes. |
| 4355 FormData address_form1, address_form2; | 4362 FormData address_form1, address_form2; |
| 4356 test::CreateTestAddressFormData(&address_form1); | 4363 test::CreateTestAddressFormData(&address_form1); |
| 4357 test::CreateTestAddressFormData(&address_form2); | 4364 test::CreateTestAddressFormData(&address_form2); |
| 4358 | 4365 |
| 4359 std::vector<FormData> address_forms; | 4366 std::vector<FormData> address_forms; |
| 4360 address_forms.push_back(address_form1); | 4367 address_forms.push_back(address_form1); |
| 4361 address_forms.push_back(address_form2); | 4368 address_forms.push_back(address_form2); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 4386 FormSubmitted(credit_card_form); | 4393 FormSubmitted(credit_card_form); |
| 4387 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4394 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4388 | 4395 |
| 4389 // Verify that the correct histogram entry (and only that) was logged. | 4396 // Verify that the correct histogram entry (and only that) was logged. |
| 4390 histogram_tester.ExpectUniqueSample( | 4397 histogram_tester.ExpectUniqueSample( |
| 4391 "Autofill.CardUploadDecisionExpanded", | 4398 "Autofill.CardUploadDecisionExpanded", |
| 4392 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); | 4399 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); |
| 4393 } | 4400 } |
| 4394 | 4401 |
| 4395 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { | 4402 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { |
| 4403 personal_data_.ClearAutofillProfiles(); | |
| 4396 autofill_manager_->set_credit_card_upload_enabled(true); | 4404 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4397 | 4405 |
| 4398 // Create, fill and submit two address forms with different zip codes. | 4406 // Create, fill and submit two address forms with different zip codes. |
| 4399 FormData address_form1, address_form2; | 4407 FormData address_form1, address_form2; |
| 4400 test::CreateTestAddressFormData(&address_form1); | 4408 test::CreateTestAddressFormData(&address_form1); |
| 4401 test::CreateTestAddressFormData(&address_form2); | 4409 test::CreateTestAddressFormData(&address_form2); |
| 4402 | 4410 |
| 4403 std::vector<FormData> address_forms; | 4411 std::vector<FormData> address_forms; |
| 4404 address_forms.push_back(address_form1); | 4412 address_forms.push_back(address_form1); |
| 4405 address_forms.push_back(address_form2); | 4413 address_forms.push_back(address_form2); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 4430 FormSubmitted(credit_card_form); | 4438 FormSubmitted(credit_card_form); |
| 4431 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4439 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4432 | 4440 |
| 4433 // Verify that the correct histogram entry (and only that) was logged. | 4441 // Verify that the correct histogram entry (and only that) was logged. |
| 4434 histogram_tester.ExpectUniqueSample( | 4442 histogram_tester.ExpectUniqueSample( |
| 4435 "Autofill.CardUploadDecisionExpanded", | 4443 "Autofill.CardUploadDecisionExpanded", |
| 4436 AutofillMetrics::UPLOAD_OFFERED, 1); | 4444 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4437 } | 4445 } |
| 4438 | 4446 |
| 4439 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { | 4447 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { |
| 4448 personal_data_.ClearAutofillProfiles(); | |
| 4440 autofill_manager_->set_credit_card_upload_enabled(true); | 4449 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4441 | 4450 |
| 4442 // Create, fill and submit an address form in order to establish a recent | 4451 // Create, fill and submit an address form in order to establish a recent |
| 4443 // profile which can be selected for the upload request. | 4452 // profile which can be selected for the upload request. |
| 4444 FormData address_form; | 4453 FormData address_form; |
| 4445 test::CreateTestAddressFormData(&address_form); | 4454 test::CreateTestAddressFormData(&address_form); |
| 4446 FormsSeen(std::vector<FormData>(1, address_form)); | 4455 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4447 // Autofill's validation requirements for Venezuala ("VE", see | 4456 // Autofill's validation requirements for Venezuala ("VE", see |
| 4448 // src/components/autofill/core/browser/country_data.cc) do not require zip | 4457 // src/components/autofill/core/browser/country_data.cc) do not require zip |
| 4449 // codes. We use Venezuala here because to use the US (or one of many other | 4458 // codes. We use Venezuala here because to use the US (or one of many other |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 4473 FormSubmitted(credit_card_form); | 4482 FormSubmitted(credit_card_form); |
| 4474 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4483 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4475 | 4484 |
| 4476 // Verify that the correct histogram entry (and only that) was logged. | 4485 // Verify that the correct histogram entry (and only that) was logged. |
| 4477 histogram_tester.ExpectUniqueSample( | 4486 histogram_tester.ExpectUniqueSample( |
| 4478 "Autofill.CardUploadDecisionExpanded", | 4487 "Autofill.CardUploadDecisionExpanded", |
| 4479 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); | 4488 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); |
| 4480 } | 4489 } |
| 4481 | 4490 |
| 4482 TEST_F(AutofillManagerTest, UploadCreditCard_NamesMatchLoosely) { | 4491 TEST_F(AutofillManagerTest, UploadCreditCard_NamesMatchLoosely) { |
| 4492 personal_data_.ClearAutofillProfiles(); | |
| 4483 autofill_manager_->set_credit_card_upload_enabled(true); | 4493 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4484 | 4494 |
| 4485 // Create, fill and submit two address forms with different names. | 4495 // Create, fill and submit two address forms with different names. |
| 4486 FormData address_form1, address_form2; | 4496 FormData address_form1, address_form2; |
| 4487 test::CreateTestAddressFormData(&address_form1); | 4497 test::CreateTestAddressFormData(&address_form1); |
| 4488 test::CreateTestAddressFormData(&address_form2); | 4498 test::CreateTestAddressFormData(&address_form2); |
| 4489 | 4499 |
| 4490 std::vector<FormData> address_forms; | 4500 std::vector<FormData> address_forms; |
| 4491 address_forms.push_back(address_form1); | 4501 address_forms.push_back(address_form1); |
| 4492 address_forms.push_back(address_form2); | 4502 address_forms.push_back(address_form2); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 4520 FormSubmitted(credit_card_form); | 4530 FormSubmitted(credit_card_form); |
| 4521 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4531 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4522 | 4532 |
| 4523 // Verify that the correct histogram entry (and only that) was logged. | 4533 // Verify that the correct histogram entry (and only that) was logged. |
| 4524 histogram_tester.ExpectUniqueSample( | 4534 histogram_tester.ExpectUniqueSample( |
| 4525 "Autofill.CardUploadDecisionExpanded", | 4535 "Autofill.CardUploadDecisionExpanded", |
| 4526 AutofillMetrics::UPLOAD_OFFERED, 1); | 4536 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4527 } | 4537 } |
| 4528 | 4538 |
| 4529 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { | 4539 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { |
| 4540 personal_data_.ClearAutofillProfiles(); | |
| 4530 autofill_manager_->set_credit_card_upload_enabled(true); | 4541 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4531 | 4542 |
| 4532 // Create, fill and submit two address forms with different names. | 4543 // Create, fill and submit two address forms with different names. |
| 4533 FormData address_form1, address_form2; | 4544 FormData address_form1, address_form2; |
| 4534 test::CreateTestAddressFormData(&address_form1); | 4545 test::CreateTestAddressFormData(&address_form1); |
| 4535 test::CreateTestAddressFormData(&address_form2); | 4546 test::CreateTestAddressFormData(&address_form2); |
| 4536 | 4547 |
| 4537 std::vector<FormData> address_forms; | 4548 std::vector<FormData> address_forms; |
| 4538 address_forms.push_back(address_form1); | 4549 address_forms.push_back(address_form1); |
| 4539 address_forms.push_back(address_form2); | 4550 address_forms.push_back(address_form2); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 4564 FormSubmitted(credit_card_form); | 4575 FormSubmitted(credit_card_form); |
| 4565 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4576 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4566 | 4577 |
| 4567 // Verify that the correct histogram entry (and only that) was logged. | 4578 // Verify that the correct histogram entry (and only that) was logged. |
| 4568 histogram_tester.ExpectUniqueSample( | 4579 histogram_tester.ExpectUniqueSample( |
| 4569 "Autofill.CardUploadDecisionExpanded", | 4580 "Autofill.CardUploadDecisionExpanded", |
| 4570 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); | 4581 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); |
| 4571 } | 4582 } |
| 4572 | 4583 |
| 4573 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { | 4584 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { |
| 4585 personal_data_.ClearAutofillProfiles(); | |
|
Mathieu
2016/04/19 14:29:35
unclear why we need to call this at the beginning
sebsg
2016/04/20 20:25:46
It's because test profiles and credit cards are cr
| |
| 4574 autofill_manager_->set_credit_card_upload_enabled(true); | 4586 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4575 | 4587 |
| 4576 // Anything other than "en-US" will cause GetUploadDetails to return a failure | 4588 // Anything other than "en-US" will cause GetUploadDetails to return a failure |
| 4577 // response. | 4589 // response. |
| 4578 autofill_manager_->set_app_locale("pt-BR"); | 4590 autofill_manager_->set_app_locale("pt-BR"); |
| 4579 | 4591 |
| 4580 // Create, fill and submit an address form in order to establish a recent | 4592 // Create, fill and submit an address form in order to establish a recent |
| 4581 // profile which can be selected for the upload request. | 4593 // profile which can be selected for the upload request. |
| 4582 FormData address_form; | 4594 FormData address_form; |
| 4583 test::CreateTestAddressFormData(&address_form); | 4595 test::CreateTestAddressFormData(&address_form); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4893 FormsSeen(mixed_forms); | 4905 FormsSeen(mixed_forms); |
| 4894 | 4906 |
| 4895 // Suggestions should always be displayed. | 4907 // Suggestions should always be displayed. |
| 4896 for (const FormFieldData& field : mixed_form.fields) { | 4908 for (const FormFieldData& field : mixed_form.fields) { |
| 4897 GetAutofillSuggestions(mixed_form, field); | 4909 GetAutofillSuggestions(mixed_form, field); |
| 4898 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4910 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4899 } | 4911 } |
| 4900 } | 4912 } |
| 4901 | 4913 |
| 4902 } // namespace autofill | 4914 } // namespace autofill |
| OLD | NEW |