| 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 4482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4493 base::HistogramTester histogram_tester; | 4493 base::HistogramTester histogram_tester; |
| 4494 | 4494 |
| 4495 FormSubmitted(credit_card_form); | 4495 FormSubmitted(credit_card_form); |
| 4496 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4496 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4497 | 4497 |
| 4498 // Verify that the correct histogram entry (and only that) was logged. | 4498 // Verify that the correct histogram entry (and only that) was logged. |
| 4499 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 4499 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", |
| 4500 AutofillMetrics::UPLOAD_OFFERED, 1); | 4500 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4501 } | 4501 } |
| 4502 | 4502 |
| 4503 TEST_F(AutofillManagerTest, UploadCreditCard_FeatureNotEnabled) { | 4503 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4504 #if defined(OS_ANDROID) |
| 4505 #define MAYBE_UploadCreditCard_FeatureNotEnabled DISABLED_UploadCreditCard_Featu
reNotEnabled |
| 4506 #else |
| 4507 #define MAYBE_UploadCreditCard_FeatureNotEnabled UploadCreditCard_FeatureNotEnab
led |
| 4508 #endif |
| 4509 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_FeatureNotEnabled) { |
| 4504 personal_data_.ClearAutofillProfiles(); | 4510 personal_data_.ClearAutofillProfiles(); |
| 4505 autofill_manager_->set_credit_card_upload_enabled(false); | 4511 autofill_manager_->set_credit_card_upload_enabled(false); |
| 4506 | 4512 |
| 4507 // Create, fill and submit an address form in order to establish a recent | 4513 // Create, fill and submit an address form in order to establish a recent |
| 4508 // profile which can be selected for the upload request. | 4514 // profile which can be selected for the upload request. |
| 4509 FormData address_form; | 4515 FormData address_form; |
| 4510 test::CreateTestAddressFormData(&address_form); | 4516 test::CreateTestAddressFormData(&address_form); |
| 4511 FormsSeen(std::vector<FormData>(1, address_form)); | 4517 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4512 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4518 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4513 FormSubmitted(address_form); | 4519 FormSubmitted(address_form); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4528 | 4534 |
| 4529 // The save prompt should be shown instead of doing an upload. | 4535 // The save prompt should be shown instead of doing an upload. |
| 4530 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); | 4536 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
| 4531 FormSubmitted(credit_card_form); | 4537 FormSubmitted(credit_card_form); |
| 4532 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4538 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4533 | 4539 |
| 4534 // Verify that no histogram entry was logged called. | 4540 // Verify that no histogram entry was logged called. |
| 4535 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionExpanded", 0); | 4541 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionExpanded", 0); |
| 4536 } | 4542 } |
| 4537 | 4543 |
| 4538 TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) { | 4544 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4545 #if defined(OS_ANDROID) |
| 4546 #define MAYBE_UploadCreditCard_CvcUnavailable DISABLED_UploadCreditCard_CvcUnava
ilable |
| 4547 #else |
| 4548 #define MAYBE_UploadCreditCard_CvcUnavailable UploadCreditCard_CvcUnavailable |
| 4549 #endif |
| 4550 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) { |
| 4539 personal_data_.ClearAutofillProfiles(); | 4551 personal_data_.ClearAutofillProfiles(); |
| 4540 autofill_manager_->set_credit_card_upload_enabled(true); | 4552 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4541 | 4553 |
| 4542 // Create, fill and submit an address form in order to establish a recent | 4554 // Create, fill and submit an address form in order to establish a recent |
| 4543 // profile which can be selected for the upload request. | 4555 // profile which can be selected for the upload request. |
| 4544 FormData address_form; | 4556 FormData address_form; |
| 4545 test::CreateTestAddressFormData(&address_form); | 4557 test::CreateTestAddressFormData(&address_form); |
| 4546 FormsSeen(std::vector<FormData>(1, address_form)); | 4558 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4547 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4559 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4548 FormSubmitted(address_form); | 4560 FormSubmitted(address_form); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4575 autofill_client_.test_rappor_service(); | 4587 autofill_client_.test_rappor_service(); |
| 4576 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4588 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4577 std::string sample; | 4589 std::string sample; |
| 4578 rappor::RapporType type; | 4590 rappor::RapporType type; |
| 4579 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4591 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4580 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4592 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 4581 EXPECT_EQ("myform.com", sample); | 4593 EXPECT_EQ("myform.com", sample); |
| 4582 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4594 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| 4583 } | 4595 } |
| 4584 | 4596 |
| 4585 TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) { | 4597 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4598 #if defined(OS_ANDROID) |
| 4599 #define MAYBE_UploadCreditCard_MultipleCvcFields DISABLED_UploadCreditCard_Multi
pleCvcFields |
| 4600 #else |
| 4601 #define MAYBE_UploadCreditCard_MultipleCvcFields UploadCreditCard_MultipleCvcFie
lds |
| 4602 #endif |
| 4603 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_MultipleCvcFields) { |
| 4586 autofill_manager_->set_credit_card_upload_enabled(true); | 4604 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4587 | 4605 |
| 4588 // Remove the profiles that were created in the TestPersonalDataManager | 4606 // Remove the profiles that were created in the TestPersonalDataManager |
| 4589 // constructor because they would result in conflicting names that would | 4607 // constructor because they would result in conflicting names that would |
| 4590 // prevent the upload. | 4608 // prevent the upload. |
| 4591 personal_data_.ClearAutofillProfiles(); | 4609 personal_data_.ClearAutofillProfiles(); |
| 4592 | 4610 |
| 4593 // Create, fill and submit an address form in order to establish a recent | 4611 // Create, fill and submit an address form in order to establish a recent |
| 4594 // profile which can be selected for the upload request. | 4612 // profile which can be selected for the upload request. |
| 4595 FormData address_form; | 4613 FormData address_form; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4634 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4652 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4635 FormSubmitted(credit_card_form); | 4653 FormSubmitted(credit_card_form); |
| 4636 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4654 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4637 | 4655 |
| 4638 // Verify that the correct histogram entry (and only that) was logged. | 4656 // Verify that the correct histogram entry (and only that) was logged. |
| 4639 histogram_tester.ExpectUniqueSample( | 4657 histogram_tester.ExpectUniqueSample( |
| 4640 "Autofill.CardUploadDecisionExpanded", | 4658 "Autofill.CardUploadDecisionExpanded", |
| 4641 AutofillMetrics::UPLOAD_OFFERED, 1); | 4659 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4642 } | 4660 } |
| 4643 | 4661 |
| 4644 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { | 4662 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4663 #if defined(OS_ANDROID) |
| 4664 #define MAYBE_UploadCreditCard_NoProfileAvailable DISABLED_UploadCreditCard_NoPr
ofileAvailable |
| 4665 #else |
| 4666 #define MAYBE_UploadCreditCard_NoProfileAvailable UploadCreditCard_NoProfileAvai
lable |
| 4667 #endif |
| 4668 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoProfileAvailable) { |
| 4645 personal_data_.ClearAutofillProfiles(); | 4669 personal_data_.ClearAutofillProfiles(); |
| 4646 autofill_manager_->set_credit_card_upload_enabled(true); | 4670 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4647 | 4671 |
| 4648 // Don't fill or submit an address form. | 4672 // Don't fill or submit an address form. |
| 4649 | 4673 |
| 4650 // Set up our credit card form data. | 4674 // Set up our credit card form data. |
| 4651 FormData credit_card_form; | 4675 FormData credit_card_form; |
| 4652 CreateTestCreditCardFormData(&credit_card_form, true, false); | 4676 CreateTestCreditCardFormData(&credit_card_form, true, false); |
| 4653 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 4677 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
| 4654 | 4678 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4675 autofill_client_.test_rappor_service(); | 4699 autofill_client_.test_rappor_service(); |
| 4676 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4700 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4677 std::string sample; | 4701 std::string sample; |
| 4678 rappor::RapporType type; | 4702 rappor::RapporType type; |
| 4679 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4703 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4680 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); | 4704 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); |
| 4681 EXPECT_EQ("myform.com", sample); | 4705 EXPECT_EQ("myform.com", sample); |
| 4682 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4706 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| 4683 } | 4707 } |
| 4684 | 4708 |
| 4685 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { | 4709 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4710 #if defined(OS_ANDROID) |
| 4711 #define MAYBE_UploadCreditCard_NoNameAvailable DISABLED_UploadCreditCard_NoNameA
vailable |
| 4712 #else |
| 4713 #define MAYBE_UploadCreditCard_NoNameAvailable UploadCreditCard_NoNameAvailable |
| 4714 #endif |
| 4715 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoNameAvailable) { |
| 4686 personal_data_.ClearAutofillProfiles(); | 4716 personal_data_.ClearAutofillProfiles(); |
| 4687 autofill_manager_->set_credit_card_upload_enabled(true); | 4717 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4688 | 4718 |
| 4689 // Create, fill and submit an address form in order to establish a recent | 4719 // Create, fill and submit an address form in order to establish a recent |
| 4690 // profile which can be selected for the upload request. | 4720 // profile which can be selected for the upload request. |
| 4691 FormData address_form; | 4721 FormData address_form; |
| 4692 test::CreateTestAddressFormData(&address_form); | 4722 test::CreateTestAddressFormData(&address_form); |
| 4693 FormsSeen(std::vector<FormData>(1, address_form)); | 4723 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4694 // But omit the name: | 4724 // But omit the name: |
| 4695 ManuallyFillAddressForm("", "", "77401", "US", &address_form); | 4725 ManuallyFillAddressForm("", "", "77401", "US", &address_form); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4722 autofill_client_.test_rappor_service(); | 4752 autofill_client_.test_rappor_service(); |
| 4723 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4753 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4724 std::string sample; | 4754 std::string sample; |
| 4725 rappor::RapporType type; | 4755 rappor::RapporType type; |
| 4726 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4756 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4727 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); | 4757 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); |
| 4728 EXPECT_EQ("myform.com", sample); | 4758 EXPECT_EQ("myform.com", sample); |
| 4729 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4759 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| 4730 } | 4760 } |
| 4731 | 4761 |
| 4732 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { | 4762 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4763 #if defined(OS_ANDROID) |
| 4764 #define MAYBE_UploadCreditCard_ZipCodesConflict DISABLED_UploadCreditCard_ZipCod
esConflict |
| 4765 #else |
| 4766 #define MAYBE_UploadCreditCard_ZipCodesConflict UploadCreditCard_ZipCodesConflic
t |
| 4767 #endif |
| 4768 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_ZipCodesConflict) { |
| 4733 personal_data_.ClearAutofillProfiles(); | 4769 personal_data_.ClearAutofillProfiles(); |
| 4734 autofill_manager_->set_credit_card_upload_enabled(true); | 4770 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4735 | 4771 |
| 4736 // Create, fill and submit two address forms with different zip codes. | 4772 // Create, fill and submit two address forms with different zip codes. |
| 4737 FormData address_form1, address_form2; | 4773 FormData address_form1, address_form2; |
| 4738 test::CreateTestAddressFormData(&address_form1); | 4774 test::CreateTestAddressFormData(&address_form1); |
| 4739 test::CreateTestAddressFormData(&address_form2); | 4775 test::CreateTestAddressFormData(&address_form2); |
| 4740 | 4776 |
| 4741 std::vector<FormData> address_forms; | 4777 std::vector<FormData> address_forms; |
| 4742 address_forms.push_back(address_form1); | 4778 address_forms.push_back(address_form1); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4767 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4803 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4768 FormSubmitted(credit_card_form); | 4804 FormSubmitted(credit_card_form); |
| 4769 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4805 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4770 | 4806 |
| 4771 // Verify that the correct histogram entry (and only that) was logged. | 4807 // Verify that the correct histogram entry (and only that) was logged. |
| 4772 histogram_tester.ExpectUniqueSample( | 4808 histogram_tester.ExpectUniqueSample( |
| 4773 "Autofill.CardUploadDecisionExpanded", | 4809 "Autofill.CardUploadDecisionExpanded", |
| 4774 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); | 4810 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); |
| 4775 } | 4811 } |
| 4776 | 4812 |
| 4777 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { | 4813 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4814 #if defined(OS_ANDROID) |
| 4815 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch DISABLED_UploadCreditCard
_ZipCodesHavePrefixMatch |
| 4816 #else |
| 4817 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch UploadCreditCard_ZipCodes
HavePrefixMatch |
| 4818 #endif |
| 4819 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch) { |
| 4778 personal_data_.ClearAutofillProfiles(); | 4820 personal_data_.ClearAutofillProfiles(); |
| 4779 autofill_manager_->set_credit_card_upload_enabled(true); | 4821 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4780 | 4822 |
| 4781 // Create, fill and submit two address forms with different zip codes. | 4823 // Create, fill and submit two address forms with different zip codes. |
| 4782 FormData address_form1, address_form2; | 4824 FormData address_form1, address_form2; |
| 4783 test::CreateTestAddressFormData(&address_form1); | 4825 test::CreateTestAddressFormData(&address_form1); |
| 4784 test::CreateTestAddressFormData(&address_form2); | 4826 test::CreateTestAddressFormData(&address_form2); |
| 4785 | 4827 |
| 4786 std::vector<FormData> address_forms; | 4828 std::vector<FormData> address_forms; |
| 4787 address_forms.push_back(address_form1); | 4829 address_forms.push_back(address_form1); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4812 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4854 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4813 FormSubmitted(credit_card_form); | 4855 FormSubmitted(credit_card_form); |
| 4814 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4856 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4815 | 4857 |
| 4816 // Verify that the correct histogram entry (and only that) was logged. | 4858 // Verify that the correct histogram entry (and only that) was logged. |
| 4817 histogram_tester.ExpectUniqueSample( | 4859 histogram_tester.ExpectUniqueSample( |
| 4818 "Autofill.CardUploadDecisionExpanded", | 4860 "Autofill.CardUploadDecisionExpanded", |
| 4819 AutofillMetrics::UPLOAD_OFFERED, 1); | 4861 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4820 } | 4862 } |
| 4821 | 4863 |
| 4822 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { | 4864 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4865 #if defined(OS_ANDROID) |
| 4866 #define MAYBE_UploadCreditCard_NoZipCodeAvailable DISABLED_UploadCreditCard_NoZi
pCodeAvailable |
| 4867 #else |
| 4868 #define MAYBE_UploadCreditCard_NoZipCodeAvailable UploadCreditCard_NoZipCodeAvai
lable |
| 4869 #endif |
| 4870 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoZipCodeAvailable) { |
| 4823 personal_data_.ClearAutofillProfiles(); | 4871 personal_data_.ClearAutofillProfiles(); |
| 4824 autofill_manager_->set_credit_card_upload_enabled(true); | 4872 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4825 | 4873 |
| 4826 // Create, fill and submit an address form in order to establish a recent | 4874 // Create, fill and submit an address form in order to establish a recent |
| 4827 // profile which can be selected for the upload request. | 4875 // profile which can be selected for the upload request. |
| 4828 FormData address_form; | 4876 FormData address_form; |
| 4829 test::CreateTestAddressFormData(&address_form); | 4877 test::CreateTestAddressFormData(&address_form); |
| 4830 FormsSeen(std::vector<FormData>(1, address_form)); | 4878 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4831 // Autofill's validation requirements for Venezuala ("VE", see | 4879 // Autofill's validation requirements for Venezuala ("VE", see |
| 4832 // src/components/autofill/core/browser/country_data.cc) do not require zip | 4880 // src/components/autofill/core/browser/country_data.cc) do not require zip |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4856 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4904 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4857 FormSubmitted(credit_card_form); | 4905 FormSubmitted(credit_card_form); |
| 4858 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4906 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4859 | 4907 |
| 4860 // Verify that the correct histogram entry (and only that) was logged. | 4908 // Verify that the correct histogram entry (and only that) was logged. |
| 4861 histogram_tester.ExpectUniqueSample( | 4909 histogram_tester.ExpectUniqueSample( |
| 4862 "Autofill.CardUploadDecisionExpanded", | 4910 "Autofill.CardUploadDecisionExpanded", |
| 4863 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); | 4911 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); |
| 4864 } | 4912 } |
| 4865 | 4913 |
| 4866 TEST_F(AutofillManagerTest, UploadCreditCard_NamesMatchLoosely) { | 4914 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4915 #if defined(OS_ANDROID) |
| 4916 #define MAYBE_UploadCreditCard_NamesMatchLoosely DISABLED_UploadCreditCard_Names
MatchLoosely |
| 4917 #else |
| 4918 #define MAYBE_UploadCreditCard_NamesMatchLoosely UploadCreditCard_NamesMatchLoos
ely |
| 4919 #endif |
| 4920 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesMatchLoosely) { |
| 4867 personal_data_.ClearAutofillProfiles(); | 4921 personal_data_.ClearAutofillProfiles(); |
| 4868 autofill_manager_->set_credit_card_upload_enabled(true); | 4922 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4869 | 4923 |
| 4870 // Create, fill and submit two address forms with different names. | 4924 // Create, fill and submit two address forms with different names. |
| 4871 FormData address_form1, address_form2; | 4925 FormData address_form1, address_form2; |
| 4872 test::CreateTestAddressFormData(&address_form1); | 4926 test::CreateTestAddressFormData(&address_form1); |
| 4873 test::CreateTestAddressFormData(&address_form2); | 4927 test::CreateTestAddressFormData(&address_form2); |
| 4874 | 4928 |
| 4875 std::vector<FormData> address_forms; | 4929 std::vector<FormData> address_forms; |
| 4876 address_forms.push_back(address_form1); | 4930 address_forms.push_back(address_form1); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4904 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4958 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4905 FormSubmitted(credit_card_form); | 4959 FormSubmitted(credit_card_form); |
| 4906 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4960 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4907 | 4961 |
| 4908 // Verify that the correct histogram entry (and only that) was logged. | 4962 // Verify that the correct histogram entry (and only that) was logged. |
| 4909 histogram_tester.ExpectUniqueSample( | 4963 histogram_tester.ExpectUniqueSample( |
| 4910 "Autofill.CardUploadDecisionExpanded", | 4964 "Autofill.CardUploadDecisionExpanded", |
| 4911 AutofillMetrics::UPLOAD_OFFERED, 1); | 4965 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4912 } | 4966 } |
| 4913 | 4967 |
| 4914 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { | 4968 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4969 #if defined(OS_ANDROID) |
| 4970 #define MAYBE_UploadCreditCard_NamesHaveToMatch DISABLED_UploadCreditCard_NamesH
aveToMatch |
| 4971 #else |
| 4972 #define MAYBE_UploadCreditCard_NamesHaveToMatch UploadCreditCard_NamesHaveToMatc
h |
| 4973 #endif |
| 4974 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesHaveToMatch) { |
| 4915 personal_data_.ClearAutofillProfiles(); | 4975 personal_data_.ClearAutofillProfiles(); |
| 4916 autofill_manager_->set_credit_card_upload_enabled(true); | 4976 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4917 | 4977 |
| 4918 // Create, fill and submit two address forms with different names. | 4978 // Create, fill and submit two address forms with different names. |
| 4919 FormData address_form1, address_form2; | 4979 FormData address_form1, address_form2; |
| 4920 test::CreateTestAddressFormData(&address_form1); | 4980 test::CreateTestAddressFormData(&address_form1); |
| 4921 test::CreateTestAddressFormData(&address_form2); | 4981 test::CreateTestAddressFormData(&address_form2); |
| 4922 | 4982 |
| 4923 std::vector<FormData> address_forms; | 4983 std::vector<FormData> address_forms; |
| 4924 address_forms.push_back(address_form1); | 4984 address_forms.push_back(address_form1); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4959 autofill_client_.test_rappor_service(); | 5019 autofill_client_.test_rappor_service(); |
| 4960 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5020 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4961 std::string sample; | 5021 std::string sample; |
| 4962 rappor::RapporType type; | 5022 rappor::RapporType type; |
| 4963 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5023 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4964 "Autofill.CardUploadNotOfferedConflictingNames", &sample, &type)); | 5024 "Autofill.CardUploadNotOfferedConflictingNames", &sample, &type)); |
| 4965 EXPECT_EQ("myform.com", sample); | 5025 EXPECT_EQ("myform.com", sample); |
| 4966 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5026 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| 4967 } | 5027 } |
| 4968 | 5028 |
| 4969 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { | 5029 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5030 #if defined(OS_ANDROID) |
| 5031 #define MAYBE_UploadCreditCard_UploadDetailsFails DISABLED_UploadCreditCard_Uplo
adDetailsFails |
| 5032 #else |
| 5033 #define MAYBE_UploadCreditCard_UploadDetailsFails UploadCreditCard_UploadDetails
Fails |
| 5034 #endif |
| 5035 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_UploadDetailsFails) { |
| 4970 personal_data_.ClearAutofillProfiles(); | 5036 personal_data_.ClearAutofillProfiles(); |
| 4971 autofill_manager_->set_credit_card_upload_enabled(true); | 5037 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4972 | 5038 |
| 4973 // Anything other than "en-US" will cause GetUploadDetails to return a failure | 5039 // Anything other than "en-US" will cause GetUploadDetails to return a failure |
| 4974 // response. | 5040 // response. |
| 4975 autofill_manager_->set_app_locale("pt-BR"); | 5041 autofill_manager_->set_app_locale("pt-BR"); |
| 4976 | 5042 |
| 4977 // Create, fill and submit an address form in order to establish a recent | 5043 // Create, fill and submit an address form in order to establish a recent |
| 4978 // profile which can be selected for the upload request. | 5044 // profile which can be selected for the upload request. |
| 4979 FormData address_form; | 5045 FormData address_form; |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5460 | 5526 |
| 5461 // The driver should always be notified. | 5527 // The driver should always be notified. |
| 5462 for (const FormFieldData& field : form.fields) { | 5528 for (const FormFieldData& field : form.fields) { |
| 5463 GetAutofillSuggestions(form, field); | 5529 GetAutofillSuggestions(form, field); |
| 5464 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form()); | 5530 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form()); |
| 5465 autofill_driver_->ClearDidInteractWithCreditCardForm(); | 5531 autofill_driver_->ClearDidInteractWithCreditCardForm(); |
| 5466 } | 5532 } |
| 5467 } | 5533 } |
| 5468 | 5534 |
| 5469 } // namespace autofill | 5535 } // namespace autofill |
| OLD | NEW |