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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1063 DCHECK(autofill_manager_->full_card_request_); | 1063 DCHECK(autofill_manager_->full_card_request_); |
1064 return static_cast<CardUnmaskDelegate*>( | 1064 return static_cast<CardUnmaskDelegate*>( |
1065 autofill_manager_->full_card_request_.get()); | 1065 autofill_manager_->full_card_request_.get()); |
1066 } | 1066 } |
1067 | 1067 |
1068 void SetHttpWarningEnabled() { | 1068 void SetHttpWarningEnabled() { |
1069 scoped_feature_list_.InitAndEnableFeature( | 1069 scoped_feature_list_.InitAndEnableFeature( |
1070 security_state::kHttpFormWarningFeature); | 1070 security_state::kHttpFormWarningFeature); |
1071 } | 1071 } |
1072 | 1072 |
1073 void EnableUkmLogging() { | |
1074 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging); | |
1075 } | |
1076 | |
1077 void EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging() { | 1073 void EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging() { |
csashi
2017/05/15 23:46:33
Update function name?
sebsg
2017/05/16 01:06:25
Done.
| |
1078 scoped_feature_list_.InitWithFeatures( | 1074 scoped_feature_list_.InitWithFeatures( |
1079 {kAutofillUpstreamRequestCvcIfMissing, kAutofillUkmLogging}, {}); | 1075 {kAutofillUpstreamRequestCvcIfMissing}, {}); |
1080 } | 1076 } |
1081 | 1077 |
1082 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { | 1078 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { |
1083 scoped_feature_list_.InitAndDisableFeature( | 1079 scoped_feature_list_.InitAndDisableFeature( |
1084 kAutofillUpstreamUseAutofillProfileComparatorForName); | 1080 kAutofillUpstreamUseAutofillProfileComparatorForName); |
1085 } | 1081 } |
1086 | 1082 |
1087 void ExpectUniqueFillableFormParsedUkm() { | 1083 void ExpectUniqueFillableFormParsedUkm() { |
1088 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1084 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
1089 | 1085 |
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3672 // Verify that FormStructure::ParseQueryResponse was NOT called. | 3668 // Verify that FormStructure::ParseQueryResponse was NOT called. |
3673 histogram_tester.ExpectTotalCount("Autofill.ServerQueryResponse", 0); | 3669 histogram_tester.ExpectTotalCount("Autofill.ServerQueryResponse", 0); |
3674 } | 3670 } |
3675 | 3671 |
3676 // Test that we are able to save form data when forms are submitted and we only | 3672 // Test that we are able to save form data when forms are submitted and we only |
3677 // have server data for the field types. | 3673 // have server data for the field types. |
3678 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { | 3674 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { |
3679 // Set up our form data. | 3675 // Set up our form data. |
3680 FormData form; | 3676 FormData form; |
3681 test::CreateTestAddressFormData(&form); | 3677 test::CreateTestAddressFormData(&form); |
3678 FormsSeen(std::vector<FormData>(1, form)); | |
3682 | 3679 |
3683 // Simulate having seen this form on page load. | 3680 // Simulate having seen this form on page load. |
3684 // |form_structure| will be owned by |autofill_manager_|. | 3681 // |form_structure| will be owned by |autofill_manager_|. |
3685 TestFormStructure* form_structure = new TestFormStructure(form); | 3682 TestFormStructure* form_structure = new TestFormStructure(form); |
3686 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3683 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); |
3687 | 3684 |
3688 // Clear the heuristic types, and instead set the appropriate server types. | 3685 // Clear the heuristic types, and instead set the appropriate server types. |
3689 std::vector<ServerFieldType> heuristic_types, server_types; | 3686 std::vector<ServerFieldType> heuristic_types, server_types; |
3690 for (size_t i = 0; i < form.fields.size(); ++i) { | 3687 for (size_t i = 0; i < form.fields.size(); ++i) { |
3691 heuristic_types.push_back(UNKNOWN_TYPE); | 3688 heuristic_types.push_back(UNKNOWN_TYPE); |
(...skipping 19 matching lines...) Expand all Loading... | |
3711 } | 3708 } |
3712 | 3709 |
3713 // Test that we are able to save form data after the possible types have been | 3710 // Test that we are able to save form data after the possible types have been |
3714 // determined. We do two submissions and verify that only at the second | 3711 // determined. We do two submissions and verify that only at the second |
3715 // submission are the possible types able to be inferred. | 3712 // submission are the possible types able to be inferred. |
3716 TEST_F(AutofillManagerTest, FormSubmittedPossibleTypesTwoSubmissions) { | 3713 TEST_F(AutofillManagerTest, FormSubmittedPossibleTypesTwoSubmissions) { |
3717 // Set up our form data. | 3714 // Set up our form data. |
3718 FormData form; | 3715 FormData form; |
3719 std::vector<ServerFieldTypeSet> expected_types; | 3716 std::vector<ServerFieldTypeSet> expected_types; |
3720 test::CreateTestAddressFormData(&form, &expected_types); | 3717 test::CreateTestAddressFormData(&form, &expected_types); |
3718 FormsSeen(std::vector<FormData>(1, form)); | |
3721 | 3719 |
3722 // Fill the form. | 3720 // Fill the form. |
3723 const char guid[] = "00000000-0000-0000-0000-000000000001"; | 3721 const char guid[] = "00000000-0000-0000-0000-000000000001"; |
3724 int response_page_id = 0; | 3722 int response_page_id = 0; |
3725 FormData response_data; | 3723 FormData response_data; |
3726 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], | 3724 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], |
3727 MakeFrontendID(std::string(), guid), | 3725 MakeFrontendID(std::string(), guid), |
3728 &response_page_id, &response_data); | 3726 &response_page_id, &response_data); |
3729 ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, | 3727 ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, |
3730 false); | 3728 false); |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4631 response.should_store_pan = false; | 4629 response.should_store_pan = false; |
4632 response.cvc = ASCIIToUTF16("123"); | 4630 response.cvc = ASCIIToUTF16("123"); |
4633 response.exp_month = ASCIIToUTF16("02"); | 4631 response.exp_month = ASCIIToUTF16("02"); |
4634 response.exp_year = ASCIIToUTF16("2018"); | 4632 response.exp_year = ASCIIToUTF16("2018"); |
4635 full_card_unmask_delegate()->OnUnmaskResponse(response); | 4633 full_card_unmask_delegate()->OnUnmaskResponse(response); |
4636 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, | 4634 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, |
4637 "4012888888881881"); | 4635 "4012888888881881"); |
4638 } | 4636 } |
4639 | 4637 |
4640 TEST_F(AutofillManagerTest, UploadCreditCard) { | 4638 TEST_F(AutofillManagerTest, UploadCreditCard) { |
4641 EnableUkmLogging(); | |
4642 personal_data_.ClearCreditCards(); | 4639 personal_data_.ClearCreditCards(); |
4643 personal_data_.ClearAutofillProfiles(); | 4640 personal_data_.ClearAutofillProfiles(); |
4644 autofill_manager_->set_credit_card_upload_enabled(true); | 4641 autofill_manager_->set_credit_card_upload_enabled(true); |
4645 | 4642 |
4646 // Create, fill and submit an address form in order to establish a recent | 4643 // Create, fill and submit an address form in order to establish a recent |
4647 // profile which can be selected for the upload request. | 4644 // profile which can be selected for the upload request. |
4648 FormData address_form; | 4645 FormData address_form; |
4649 test::CreateTestAddressFormData(&address_form); | 4646 test::CreateTestAddressFormData(&address_form); |
4650 FormsSeen(std::vector<FormData>(1, address_form)); | 4647 FormsSeen(std::vector<FormData>(1, address_form)); |
4651 ExpectUniqueFillableFormParsedUkm(); | 4648 ExpectUniqueFillableFormParsedUkm(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4763 // The save prompt should be shown instead of doing an upload. | 4760 // The save prompt should be shown instead of doing an upload. |
4764 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); | 4761 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
4765 FormSubmitted(credit_card_form); | 4762 FormSubmitted(credit_card_form); |
4766 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4763 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
4767 | 4764 |
4768 // Verify that no histogram entry was logged. | 4765 // Verify that no histogram entry was logged. |
4769 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionMetric", 0); | 4766 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionMetric", 0); |
4770 } | 4767 } |
4771 | 4768 |
4772 TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) { | 4769 TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) { |
4773 EnableUkmLogging(); | |
4774 personal_data_.ClearAutofillProfiles(); | 4770 personal_data_.ClearAutofillProfiles(); |
4775 autofill_manager_->set_credit_card_upload_enabled(true); | 4771 autofill_manager_->set_credit_card_upload_enabled(true); |
4776 | 4772 |
4777 // Create, fill and submit an address form in order to establish a recent | 4773 // Create, fill and submit an address form in order to establish a recent |
4778 // profile which can be selected for the upload request. | 4774 // profile which can be selected for the upload request. |
4779 FormData address_form; | 4775 FormData address_form; |
4780 test::CreateTestAddressFormData(&address_form); | 4776 test::CreateTestAddressFormData(&address_form); |
4781 FormsSeen(std::vector<FormData>(1, address_form)); | 4777 FormsSeen(std::vector<FormData>(1, address_form)); |
4782 ExpectUniqueFillableFormParsedUkm(); | 4778 ExpectUniqueFillableFormParsedUkm(); |
4783 | 4779 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4815 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4811 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
4816 std::string sample; | 4812 std::string sample; |
4817 rappor::RapporType type; | 4813 rappor::RapporType type; |
4818 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4814 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
4819 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4815 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
4820 EXPECT_EQ("myform.com", sample); | 4816 EXPECT_EQ("myform.com", sample); |
4821 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4817 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
4822 } | 4818 } |
4823 | 4819 |
4824 TEST_F(AutofillManagerTest, UploadCreditCard_CvcInvalidLength) { | 4820 TEST_F(AutofillManagerTest, UploadCreditCard_CvcInvalidLength) { |
4825 EnableUkmLogging(); | |
4826 personal_data_.ClearAutofillProfiles(); | 4821 personal_data_.ClearAutofillProfiles(); |
4827 autofill_manager_->set_credit_card_upload_enabled(true); | 4822 autofill_manager_->set_credit_card_upload_enabled(true); |
4828 | 4823 |
4829 // Create, fill and submit an address form in order to establish a recent | 4824 // Create, fill and submit an address form in order to establish a recent |
4830 // profile which can be selected for the upload request. | 4825 // profile which can be selected for the upload request. |
4831 FormData address_form; | 4826 FormData address_form; |
4832 test::CreateTestAddressFormData(&address_form); | 4827 test::CreateTestAddressFormData(&address_form); |
4833 FormsSeen(std::vector<FormData>(1, address_form)); | 4828 FormsSeen(std::vector<FormData>(1, address_form)); |
4834 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4829 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
4835 FormSubmitted(address_form); | 4830 FormSubmitted(address_form); |
(...skipping 28 matching lines...) Expand all Loading... | |
4864 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4859 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
4865 std::string sample; | 4860 std::string sample; |
4866 rappor::RapporType type; | 4861 rappor::RapporType type; |
4867 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4862 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
4868 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4863 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
4869 EXPECT_EQ("myform.com", sample); | 4864 EXPECT_EQ("myform.com", sample); |
4870 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4865 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
4871 } | 4866 } |
4872 | 4867 |
4873 TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) { | 4868 TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) { |
4874 EnableUkmLogging(); | |
4875 autofill_manager_->set_credit_card_upload_enabled(true); | 4869 autofill_manager_->set_credit_card_upload_enabled(true); |
4876 | 4870 |
4877 // Remove the profiles that were created in the TestPersonalDataManager | 4871 // Remove the profiles that were created in the TestPersonalDataManager |
4878 // constructor because they would result in conflicting names that would | 4872 // constructor because they would result in conflicting names that would |
4879 // prevent the upload. | 4873 // prevent the upload. |
4880 personal_data_.ClearAutofillProfiles(); | 4874 personal_data_.ClearAutofillProfiles(); |
4881 | 4875 |
4882 // Create, fill and submit an address form in order to establish a recent | 4876 // Create, fill and submit an address form in order to establish a recent |
4883 // profile which can be selected for the upload request. | 4877 // profile which can be selected for the upload request. |
4884 FormData address_form; | 4878 FormData address_form; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4925 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4919 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
4926 | 4920 |
4927 // Verify that the correct histogram entry (and only that) was logged. | 4921 // Verify that the correct histogram entry (and only that) was logged. |
4928 ExpectUniqueCardUploadDecision(histogram_tester, | 4922 ExpectUniqueCardUploadDecision(histogram_tester, |
4929 AutofillMetrics::UPLOAD_OFFERED); | 4923 AutofillMetrics::UPLOAD_OFFERED); |
4930 // Verify that the correct UKM was logged. | 4924 // Verify that the correct UKM was logged. |
4931 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 4925 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
4932 } | 4926 } |
4933 | 4927 |
4934 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnForm) { | 4928 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnForm) { |
4935 EnableUkmLogging(); | |
4936 autofill_manager_->set_credit_card_upload_enabled(true); | 4929 autofill_manager_->set_credit_card_upload_enabled(true); |
4937 | 4930 |
4938 // Remove the profiles that were created in the TestPersonalDataManager | 4931 // Remove the profiles that were created in the TestPersonalDataManager |
4939 // constructor because they would result in conflicting names that would | 4932 // constructor because they would result in conflicting names that would |
4940 // prevent the upload. | 4933 // prevent the upload. |
4941 personal_data_.ClearAutofillProfiles(); | 4934 personal_data_.ClearAutofillProfiles(); |
4942 | 4935 |
4943 // Create, fill and submit an address form in order to establish a recent | 4936 // Create, fill and submit an address form in order to establish a recent |
4944 // profile which can be selected for the upload request. | 4937 // profile which can be selected for the upload request. |
4945 FormData address_form; | 4938 FormData address_form; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4988 | 4981 |
4989 #if defined(OS_ANDROID) | 4982 #if defined(OS_ANDROID) |
4990 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField \ | 4983 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField \ |
4991 DISABLED_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField | 4984 DISABLED_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField |
4992 #else | 4985 #else |
4993 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField \ | 4986 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField \ |
4994 UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField | 4987 UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField |
4995 #endif | 4988 #endif |
4996 TEST_F(AutofillManagerTest, | 4989 TEST_F(AutofillManagerTest, |
4997 MAYBE_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField) { | 4990 MAYBE_UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField) { |
4998 EnableUkmLogging(); | |
4999 autofill_manager_->set_credit_card_upload_enabled(true); | 4991 autofill_manager_->set_credit_card_upload_enabled(true); |
5000 | 4992 |
5001 // Remove the profiles that were created in the TestPersonalDataManager | 4993 // Remove the profiles that were created in the TestPersonalDataManager |
5002 // constructor because they would result in conflicting names that would | 4994 // constructor because they would result in conflicting names that would |
5003 // prevent the upload. | 4995 // prevent the upload. |
5004 personal_data_.ClearAutofillProfiles(); | 4996 personal_data_.ClearAutofillProfiles(); |
5005 | 4997 |
5006 // Create, fill and submit an address form in order to establish a recent | 4998 // Create, fill and submit an address form in order to establish a recent |
5007 // profile which can be selected for the upload request. | 4999 // profile which can be selected for the upload request. |
5008 FormData address_form; | 5000 FormData address_form; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5054 | 5046 |
5055 #if defined(OS_ANDROID) | 5047 #if defined(OS_ANDROID) |
5056 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField \ | 5048 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField \ |
5057 DISABLED_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField | 5049 DISABLED_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField |
5058 #else | 5050 #else |
5059 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField \ | 5051 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField \ |
5060 UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField | 5052 UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField |
5061 #endif | 5053 #endif |
5062 TEST_F(AutofillManagerTest, | 5054 TEST_F(AutofillManagerTest, |
5063 MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField) { | 5055 MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField) { |
5064 EnableUkmLogging(); | |
5065 autofill_manager_->set_credit_card_upload_enabled(true); | 5056 autofill_manager_->set_credit_card_upload_enabled(true); |
5066 | 5057 |
5067 // Remove the profiles that were created in the TestPersonalDataManager | 5058 // Remove the profiles that were created in the TestPersonalDataManager |
5068 // constructor because they would result in conflicting names that would | 5059 // constructor because they would result in conflicting names that would |
5069 // prevent the upload. | 5060 // prevent the upload. |
5070 personal_data_.ClearAutofillProfiles(); | 5061 personal_data_.ClearAutofillProfiles(); |
5071 | 5062 |
5072 // Create, fill and submit an address form in order to establish a recent | 5063 // Create, fill and submit an address form in order to establish a recent |
5073 // profile which can be selected for the upload request. | 5064 // profile which can be selected for the upload request. |
5074 FormData address_form; | 5065 FormData address_form; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5122 | 5113 |
5123 #if defined(OS_ANDROID) | 5114 #if defined(OS_ANDROID) |
5124 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField \ | 5115 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField \ |
5125 DISABLED_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField | 5116 DISABLED_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField |
5126 #else | 5117 #else |
5127 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField \ | 5118 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField \ |
5128 UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField | 5119 UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField |
5129 #endif | 5120 #endif |
5130 TEST_F(AutofillManagerTest, | 5121 TEST_F(AutofillManagerTest, |
5131 MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField) { | 5122 MAYBE_UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField) { |
5132 EnableUkmLogging(); | |
5133 autofill_manager_->set_credit_card_upload_enabled(true); | 5123 autofill_manager_->set_credit_card_upload_enabled(true); |
5134 | 5124 |
5135 // Remove the profiles that were created in the TestPersonalDataManager | 5125 // Remove the profiles that were created in the TestPersonalDataManager |
5136 // constructor because they would result in conflicting names that would | 5126 // constructor because they would result in conflicting names that would |
5137 // prevent the upload. | 5127 // prevent the upload. |
5138 personal_data_.ClearAutofillProfiles(); | 5128 personal_data_.ClearAutofillProfiles(); |
5139 | 5129 |
5140 // Create, fill and submit an address form in order to establish a recent | 5130 // Create, fill and submit an address form in order to establish a recent |
5141 // profile which can be selected for the upload request. | 5131 // profile which can be selected for the upload request. |
5142 FormData address_form; | 5132 FormData address_form; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5249 AutofillMetrics::CVC_FIELD_NOT_FOUND); | 5239 AutofillMetrics::CVC_FIELD_NOT_FOUND); |
5250 // Verify that the correct UKM was logged. | 5240 // Verify that the correct UKM was logged. |
5251 ExpectMetric( | 5241 ExpectMetric( |
5252 internal::kUKMCardUploadDecisionMetricName, | 5242 internal::kUKMCardUploadDecisionMetricName, |
5253 internal::kUKMCardUploadDecisionEntryName, | 5243 internal::kUKMCardUploadDecisionEntryName, |
5254 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND, | 5244 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND, |
5255 1 /* expected_num_matching_entries */); | 5245 1 /* expected_num_matching_entries */); |
5256 } | 5246 } |
5257 | 5247 |
5258 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnFormExperimentOff) { | 5248 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnFormExperimentOff) { |
5259 EnableUkmLogging(); | |
5260 autofill_manager_->set_credit_card_upload_enabled(true); | 5249 autofill_manager_->set_credit_card_upload_enabled(true); |
5261 | 5250 |
5262 // Remove the profiles that were created in the TestPersonalDataManager | 5251 // Remove the profiles that were created in the TestPersonalDataManager |
5263 // constructor because they would result in conflicting names that would | 5252 // constructor because they would result in conflicting names that would |
5264 // prevent the upload. | 5253 // prevent the upload. |
5265 personal_data_.ClearAutofillProfiles(); | 5254 personal_data_.ClearAutofillProfiles(); |
5266 | 5255 |
5267 // Create, fill and submit an address form in order to establish a recent | 5256 // Create, fill and submit an address form in order to establish a recent |
5268 // profile which can be selected for the upload request. | 5257 // profile which can be selected for the upload request. |
5269 FormData address_form; | 5258 FormData address_form; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5314 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5303 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
5315 std::string sample; | 5304 std::string sample; |
5316 rappor::RapporType type; | 5305 rappor::RapporType type; |
5317 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5306 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
5318 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 5307 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
5319 EXPECT_EQ("myform.com", sample); | 5308 EXPECT_EQ("myform.com", sample); |
5320 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5309 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
5321 } | 5310 } |
5322 | 5311 |
5323 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { | 5312 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { |
5324 EnableUkmLogging(); | |
5325 personal_data_.ClearAutofillProfiles(); | 5313 personal_data_.ClearAutofillProfiles(); |
5326 autofill_manager_->set_credit_card_upload_enabled(true); | 5314 autofill_manager_->set_credit_card_upload_enabled(true); |
5327 | 5315 |
5328 // Don't fill or submit an address form. | 5316 // Don't fill or submit an address form. |
5329 | 5317 |
5330 // Set up our credit card form data. | 5318 // Set up our credit card form data. |
5331 FormData credit_card_form; | 5319 FormData credit_card_form; |
5332 CreateTestCreditCardFormData(&credit_card_form, true, false); | 5320 CreateTestCreditCardFormData(&credit_card_form, true, false); |
5333 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 5321 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
5334 | 5322 |
(...skipping 27 matching lines...) Expand all Loading... | |
5362 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); | 5350 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); |
5363 EXPECT_EQ("myform.com", sample); | 5351 EXPECT_EQ("myform.com", sample); |
5364 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5352 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
5365 } | 5353 } |
5366 | 5354 |
5367 TEST_F(AutofillManagerTest, UploadCreditCard_NoRecentlyUsedProfile) { | 5355 TEST_F(AutofillManagerTest, UploadCreditCard_NoRecentlyUsedProfile) { |
5368 // Create the test clock and set the time to a specific value. | 5356 // Create the test clock and set the time to a specific value. |
5369 TestAutofillClock test_clock; | 5357 TestAutofillClock test_clock; |
5370 test_clock.SetNow(kArbitraryTime); | 5358 test_clock.SetNow(kArbitraryTime); |
5371 | 5359 |
5372 EnableUkmLogging(); | |
5373 personal_data_.ClearAutofillProfiles(); | 5360 personal_data_.ClearAutofillProfiles(); |
5374 autofill_manager_->set_credit_card_upload_enabled(true); | 5361 autofill_manager_->set_credit_card_upload_enabled(true); |
5375 | 5362 |
5376 // Create, fill and submit an address form in order to establish a profile. | 5363 // Create, fill and submit an address form in order to establish a profile. |
5377 FormData address_form; | 5364 FormData address_form; |
5378 test::CreateTestAddressFormData(&address_form); | 5365 test::CreateTestAddressFormData(&address_form); |
5379 FormsSeen({address_form}); | 5366 FormsSeen({address_form}); |
5380 | 5367 |
5381 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 5368 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
5382 FormSubmitted(address_form); | 5369 FormSubmitted(address_form); |
(...skipping 27 matching lines...) Expand all Loading... | |
5410 // Verify that the correct UKM was logged. | 5397 // Verify that the correct UKM was logged. |
5411 ExpectCardUploadDecisionUkm( | 5398 ExpectCardUploadDecisionUkm( |
5412 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_RECENTLY_USED_ADDRESS); | 5399 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_RECENTLY_USED_ADDRESS); |
5413 // Verify the histogram entry for recent profile modification. | 5400 // Verify the histogram entry for recent profile modification. |
5414 histogram_tester.ExpectUniqueSample( | 5401 histogram_tester.ExpectUniqueSample( |
5415 "Autofill.HasModifiedProfile.CreditCardFormSubmission", false, 1); | 5402 "Autofill.HasModifiedProfile.CreditCardFormSubmission", false, 1); |
5416 } | 5403 } |
5417 | 5404 |
5418 TEST_F(AutofillManagerTest, | 5405 TEST_F(AutofillManagerTest, |
5419 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) { | 5406 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) { |
5420 EnableUkmLogging(); | |
5421 personal_data_.ClearAutofillProfiles(); | 5407 personal_data_.ClearAutofillProfiles(); |
5422 autofill_manager_->set_credit_card_upload_enabled(true); | 5408 autofill_manager_->set_credit_card_upload_enabled(true); |
5423 | 5409 |
5424 // Don't fill or submit an address form. | 5410 // Don't fill or submit an address form. |
5425 | 5411 |
5426 // Set up our credit card form data. | 5412 // Set up our credit card form data. |
5427 FormData credit_card_form; | 5413 FormData credit_card_form; |
5428 CreateTestCreditCardFormData(&credit_card_form, true, false); | 5414 CreateTestCreditCardFormData(&credit_card_form, true, false); |
5429 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 5415 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
5430 | 5416 |
(...skipping 30 matching lines...) Expand all Loading... | |
5461 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5447 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
5462 std::string sample; | 5448 std::string sample; |
5463 rappor::RapporType type; | 5449 rappor::RapporType type; |
5464 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5450 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
5465 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 5451 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
5466 EXPECT_EQ("myform.com", sample); | 5452 EXPECT_EQ("myform.com", sample); |
5467 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5453 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
5468 } | 5454 } |
5469 | 5455 |
5470 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { | 5456 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { |
5471 EnableUkmLogging(); | |
5472 personal_data_.ClearAutofillProfiles(); | 5457 personal_data_.ClearAutofillProfiles(); |
5473 autofill_manager_->set_credit_card_upload_enabled(true); | 5458 autofill_manager_->set_credit_card_upload_enabled(true); |
5474 | 5459 |
5475 // Create, fill and submit an address form in order to establish a recent | 5460 // Create, fill and submit an address form in order to establish a recent |
5476 // profile which can be selected for the upload request. | 5461 // profile which can be selected for the upload request. |
5477 FormData address_form; | 5462 FormData address_form; |
5478 test::CreateTestAddressFormData(&address_form); | 5463 test::CreateTestAddressFormData(&address_form); |
5479 FormsSeen(std::vector<FormData>(1, address_form)); | 5464 FormsSeen(std::vector<FormData>(1, address_form)); |
5480 // But omit the name: | 5465 // But omit the name: |
5481 ManuallyFillAddressForm("", "", "77401", "US", &address_form); | 5466 ManuallyFillAddressForm("", "", "77401", "US", &address_form); |
(...skipping 28 matching lines...) Expand all Loading... | |
5510 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5495 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
5511 std::string sample; | 5496 std::string sample; |
5512 rappor::RapporType type; | 5497 rappor::RapporType type; |
5513 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5498 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
5514 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); | 5499 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); |
5515 EXPECT_EQ("myform.com", sample); | 5500 EXPECT_EQ("myform.com", sample); |
5516 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5501 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
5517 } | 5502 } |
5518 | 5503 |
5519 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { | 5504 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { |
5520 EnableUkmLogging(); | |
5521 personal_data_.ClearAutofillProfiles(); | 5505 personal_data_.ClearAutofillProfiles(); |
5522 autofill_manager_->set_credit_card_upload_enabled(true); | 5506 autofill_manager_->set_credit_card_upload_enabled(true); |
5523 | 5507 |
5524 // Create, fill and submit two address forms with different zip codes. | 5508 // Create, fill and submit two address forms with different zip codes. |
5525 FormData address_form1, address_form2; | 5509 FormData address_form1, address_form2; |
5526 test::CreateTestAddressFormData(&address_form1); | 5510 test::CreateTestAddressFormData(&address_form1); |
5527 test::CreateTestAddressFormData(&address_form2); | 5511 test::CreateTestAddressFormData(&address_form2); |
5528 | 5512 |
5529 std::vector<FormData> address_forms; | 5513 std::vector<FormData> address_forms; |
5530 address_forms.push_back(address_form1); | 5514 address_forms.push_back(address_form1); |
(...skipping 29 matching lines...) Expand all Loading... | |
5560 | 5544 |
5561 // Verify that the correct histogram entry (and only that) was logged. | 5545 // Verify that the correct histogram entry (and only that) was logged. |
5562 ExpectUniqueCardUploadDecision( | 5546 ExpectUniqueCardUploadDecision( |
5563 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); | 5547 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); |
5564 // Verify that the correct UKM was logged. | 5548 // Verify that the correct UKM was logged. |
5565 ExpectCardUploadDecisionUkm( | 5549 ExpectCardUploadDecisionUkm( |
5566 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); | 5550 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); |
5567 } | 5551 } |
5568 | 5552 |
5569 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { | 5553 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { |
5570 EnableUkmLogging(); | |
5571 personal_data_.ClearAutofillProfiles(); | 5554 personal_data_.ClearAutofillProfiles(); |
5572 autofill_manager_->set_credit_card_upload_enabled(true); | 5555 autofill_manager_->set_credit_card_upload_enabled(true); |
5573 | 5556 |
5574 // Create, fill and submit two address forms with different zip codes. | 5557 // Create, fill and submit two address forms with different zip codes. |
5575 FormData address_form1, address_form2; | 5558 FormData address_form1, address_form2; |
5576 test::CreateTestAddressFormData(&address_form1); | 5559 test::CreateTestAddressFormData(&address_form1); |
5577 test::CreateTestAddressFormData(&address_form2); | 5560 test::CreateTestAddressFormData(&address_form2); |
5578 | 5561 |
5579 std::vector<FormData> address_forms; | 5562 std::vector<FormData> address_forms; |
5580 address_forms.push_back(address_form1); | 5563 address_forms.push_back(address_form1); |
(...skipping 26 matching lines...) Expand all Loading... | |
5607 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5590 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
5608 | 5591 |
5609 // Verify that the correct histogram entry (and only that) was logged. | 5592 // Verify that the correct histogram entry (and only that) was logged. |
5610 ExpectUniqueCardUploadDecision(histogram_tester, | 5593 ExpectUniqueCardUploadDecision(histogram_tester, |
5611 AutofillMetrics::UPLOAD_OFFERED); | 5594 AutofillMetrics::UPLOAD_OFFERED); |
5612 // Verify that the correct UKM was logged. | 5595 // Verify that the correct UKM was logged. |
5613 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 5596 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
5614 } | 5597 } |
5615 | 5598 |
5616 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { | 5599 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { |
5617 EnableUkmLogging(); | |
5618 personal_data_.ClearAutofillProfiles(); | 5600 personal_data_.ClearAutofillProfiles(); |
5619 autofill_manager_->set_credit_card_upload_enabled(true); | 5601 autofill_manager_->set_credit_card_upload_enabled(true); |
5620 | 5602 |
5621 // Create, fill and submit an address form in order to establish a recent | 5603 // Create, fill and submit an address form in order to establish a recent |
5622 // profile which can be selected for the upload request. | 5604 // profile which can be selected for the upload request. |
5623 FormData address_form; | 5605 FormData address_form; |
5624 test::CreateTestAddressFormData(&address_form); | 5606 test::CreateTestAddressFormData(&address_form); |
5625 FormsSeen(std::vector<FormData>(1, address_form)); | 5607 FormsSeen(std::vector<FormData>(1, address_form)); |
5626 // Autofill's validation requirements for Venezuala ("VE", see | 5608 // Autofill's validation requirements for Venezuala ("VE", see |
5627 // src/components/autofill/core/browser/country_data.cc) do not require zip | 5609 // src/components/autofill/core/browser/country_data.cc) do not require zip |
(...skipping 25 matching lines...) Expand all Loading... | |
5653 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5635 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
5654 | 5636 |
5655 // Verify that the correct histogram entry (and only that) was logged. | 5637 // Verify that the correct histogram entry (and only that) was logged. |
5656 ExpectUniqueCardUploadDecision( | 5638 ExpectUniqueCardUploadDecision( |
5657 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); | 5639 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
5658 // Verify that the correct UKM was logged. | 5640 // Verify that the correct UKM was logged. |
5659 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); | 5641 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
5660 } | 5642 } |
5661 | 5643 |
5662 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleInitial) { | 5644 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleInitial) { |
5663 EnableUkmLogging(); | |
5664 personal_data_.ClearAutofillProfiles(); | 5645 personal_data_.ClearAutofillProfiles(); |
5665 autofill_manager_->set_credit_card_upload_enabled(true); | 5646 autofill_manager_->set_credit_card_upload_enabled(true); |
5666 | 5647 |
5667 // Create, fill and submit two address forms with different names. | 5648 // Create, fill and submit two address forms with different names. |
5668 FormData address_form1, address_form2; | 5649 FormData address_form1, address_form2; |
5669 test::CreateTestAddressFormData(&address_form1); | 5650 test::CreateTestAddressFormData(&address_form1); |
5670 test::CreateTestAddressFormData(&address_form2); | 5651 test::CreateTestAddressFormData(&address_form2); |
5671 FormsSeen({address_form1, address_form2}); | 5652 FormsSeen({address_form1, address_form2}); |
5672 | 5653 |
5673 // Names can be different case. | 5654 // Names can be different case. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5744 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5725 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
5745 FormSubmitted(credit_card_form); | 5726 FormSubmitted(credit_card_form); |
5746 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5727 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
5747 | 5728 |
5748 // Verify that the correct histogram entry (and only that) was logged. | 5729 // Verify that the correct histogram entry (and only that) was logged. |
5749 ExpectUniqueCardUploadDecision(histogram_tester, | 5730 ExpectUniqueCardUploadDecision(histogram_tester, |
5750 AutofillMetrics::UPLOAD_OFFERED); | 5731 AutofillMetrics::UPLOAD_OFFERED); |
5751 } | 5732 } |
5752 | 5733 |
5753 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { | 5734 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { |
5754 EnableUkmLogging(); | |
5755 personal_data_.ClearAutofillProfiles(); | 5735 personal_data_.ClearAutofillProfiles(); |
5756 autofill_manager_->set_credit_card_upload_enabled(true); | 5736 autofill_manager_->set_credit_card_upload_enabled(true); |
5757 | 5737 |
5758 // Create, fill and submit two address forms with different names. | 5738 // Create, fill and submit two address forms with different names. |
5759 FormData address_form1, address_form2; | 5739 FormData address_form1, address_form2; |
5760 test::CreateTestAddressFormData(&address_form1); | 5740 test::CreateTestAddressFormData(&address_form1); |
5761 test::CreateTestAddressFormData(&address_form2); | 5741 test::CreateTestAddressFormData(&address_form2); |
5762 FormsSeen({address_form1, address_form2}); | 5742 FormsSeen({address_form1, address_form2}); |
5763 | 5743 |
5764 // Names can have different variations of middle initials. | 5744 // Names can have different variations of middle initials. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5829 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5809 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
5830 FormSubmitted(credit_card_form); | 5810 FormSubmitted(credit_card_form); |
5831 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5811 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
5832 | 5812 |
5833 // Verify that the correct histogram entry (and only that) was logged. | 5813 // Verify that the correct histogram entry (and only that) was logged. |
5834 ExpectUniqueCardUploadDecision(histogram_tester, | 5814 ExpectUniqueCardUploadDecision(histogram_tester, |
5835 AutofillMetrics::UPLOAD_OFFERED); | 5815 AutofillMetrics::UPLOAD_OFFERED); |
5836 } | 5816 } |
5837 | 5817 |
5838 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleName) { | 5818 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleName) { |
5839 EnableUkmLogging(); | |
5840 personal_data_.ClearAutofillProfiles(); | 5819 personal_data_.ClearAutofillProfiles(); |
5841 autofill_manager_->set_credit_card_upload_enabled(true); | 5820 autofill_manager_->set_credit_card_upload_enabled(true); |
5842 | 5821 |
5843 // Create, fill and submit address form without middle name. | 5822 // Create, fill and submit address form without middle name. |
5844 FormData address_form; | 5823 FormData address_form; |
5845 test::CreateTestAddressFormData(&address_form); | 5824 test::CreateTestAddressFormData(&address_form); |
5846 FormsSeen({address_form}); | 5825 FormsSeen({address_form}); |
5847 ManuallyFillAddressForm("John", "Adams", "77401", "US", &address_form); | 5826 ManuallyFillAddressForm("John", "Adams", "77401", "US", &address_form); |
5848 FormSubmitted(address_form); | 5827 FormSubmitted(address_form); |
5849 | 5828 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5905 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5884 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
5906 FormSubmitted(credit_card_form); | 5885 FormSubmitted(credit_card_form); |
5907 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5886 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
5908 | 5887 |
5909 // Verify that the correct histogram entry (and only that) was logged. | 5888 // Verify that the correct histogram entry (and only that) was logged. |
5910 ExpectUniqueCardUploadDecision( | 5889 ExpectUniqueCardUploadDecision( |
5911 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); | 5890 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
5912 } | 5891 } |
5913 | 5892 |
5914 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormRemovesMiddleName) { | 5893 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormRemovesMiddleName) { |
5915 EnableUkmLogging(); | |
5916 personal_data_.ClearAutofillProfiles(); | 5894 personal_data_.ClearAutofillProfiles(); |
5917 autofill_manager_->set_credit_card_upload_enabled(true); | 5895 autofill_manager_->set_credit_card_upload_enabled(true); |
5918 | 5896 |
5919 // Create, fill and submit address form with middle name. | 5897 // Create, fill and submit address form with middle name. |
5920 FormData address_form; | 5898 FormData address_form; |
5921 test::CreateTestAddressFormData(&address_form); | 5899 test::CreateTestAddressFormData(&address_form); |
5922 FormsSeen({address_form}); | 5900 FormsSeen({address_form}); |
5923 ManuallyFillAddressForm("John Quincy", "Adams", "77401", "US", &address_form); | 5901 ManuallyFillAddressForm("John Quincy", "Adams", "77401", "US", &address_form); |
5924 FormSubmitted(address_form); | 5902 FormSubmitted(address_form); |
5925 | 5903 |
(...skipping 17 matching lines...) Expand all Loading... | |
5943 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5921 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
5944 | 5922 |
5945 // Verify that the correct histogram entry (and only that) was logged. | 5923 // Verify that the correct histogram entry (and only that) was logged. |
5946 ExpectUniqueCardUploadDecision(histogram_tester, | 5924 ExpectUniqueCardUploadDecision(histogram_tester, |
5947 AutofillMetrics::UPLOAD_OFFERED); | 5925 AutofillMetrics::UPLOAD_OFFERED); |
5948 // Verify that the correct UKM was logged. | 5926 // Verify that the correct UKM was logged. |
5949 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 5927 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
5950 } | 5928 } |
5951 | 5929 |
5952 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { | 5930 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { |
5953 EnableUkmLogging(); | |
5954 personal_data_.ClearAutofillProfiles(); | 5931 personal_data_.ClearAutofillProfiles(); |
5955 autofill_manager_->set_credit_card_upload_enabled(true); | 5932 autofill_manager_->set_credit_card_upload_enabled(true); |
5956 | 5933 |
5957 // Create, fill and submit two address forms with different names. | 5934 // Create, fill and submit two address forms with different names. |
5958 FormData address_form1, address_form2; | 5935 FormData address_form1, address_form2; |
5959 test::CreateTestAddressFormData(&address_form1); | 5936 test::CreateTestAddressFormData(&address_form1); |
5960 test::CreateTestAddressFormData(&address_form2); | 5937 test::CreateTestAddressFormData(&address_form2); |
5961 | 5938 |
5962 std::vector<FormData> address_forms; | 5939 std::vector<FormData> address_forms; |
5963 address_forms.push_back(address_form1); | 5940 address_forms.push_back(address_form1); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6147 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 6124 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
6148 | 6125 |
6149 // Verify that UMA for "DaysSincePreviousUse" is logged. | 6126 // Verify that UMA for "DaysSincePreviousUse" is logged. |
6150 histogram_tester.ExpectUniqueSample( | 6127 histogram_tester.ExpectUniqueSample( |
6151 "Autofill.DaysSincePreviousUseAtSubmission.Profile", | 6128 "Autofill.DaysSincePreviousUseAtSubmission.Profile", |
6152 (kMuchLaterTime - kArbitraryTime).InDays(), | 6129 (kMuchLaterTime - kArbitraryTime).InDays(), |
6153 /*expected_count=*/1); | 6130 /*expected_count=*/1); |
6154 } | 6131 } |
6155 | 6132 |
6156 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { | 6133 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { |
6157 EnableUkmLogging(); | |
6158 personal_data_.ClearAutofillProfiles(); | 6134 personal_data_.ClearAutofillProfiles(); |
6159 autofill_manager_->set_credit_card_upload_enabled(true); | 6135 autofill_manager_->set_credit_card_upload_enabled(true); |
6160 | 6136 |
6161 // Anything other than "en-US" will cause GetUploadDetails to return a failure | 6137 // Anything other than "en-US" will cause GetUploadDetails to return a failure |
6162 // response. | 6138 // response. |
6163 autofill_manager_->set_app_locale("pt-BR"); | 6139 autofill_manager_->set_app_locale("pt-BR"); |
6164 | 6140 |
6165 // Create, fill and submit an address form in order to establish a recent | 6141 // Create, fill and submit an address form in order to establish a recent |
6166 // profile which can be selected for the upload request. | 6142 // profile which can be selected for the upload request. |
6167 FormData address_form; | 6143 FormData address_form; |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6813 | 6789 |
6814 FormFieldData field; | 6790 FormFieldData field; |
6815 test::CreateTestFormField("Email", "email", "theking@gmail.com", "text", | 6791 test::CreateTestFormField("Email", "email", "theking@gmail.com", "text", |
6816 &field); | 6792 &field); |
6817 form.fields.push_back(field); | 6793 form.fields.push_back(field); |
6818 types.insert(EMAIL_ADDRESS); | 6794 types.insert(EMAIL_ADDRESS); |
6819 expected_types.push_back(types); | 6795 expected_types.push_back(types); |
6820 | 6796 |
6821 test::CreateTestFormField("Password", "pw", "secret", "password", &field); | 6797 test::CreateTestFormField("Password", "pw", "secret", "password", &field); |
6822 form.fields.push_back(field); | 6798 form.fields.push_back(field); |
6799 FormsSeen(std::vector<FormData>(1, form)); | |
6823 types.clear(); | 6800 types.clear(); |
6824 types.insert(PASSWORD); | 6801 types.insert(PASSWORD); |
6825 expected_types.push_back(types); | 6802 expected_types.push_back(types); |
6826 | 6803 |
6827 // We will expect these types in the upload and no observed submission. (the | 6804 // We will expect these types in the upload and no observed submission. (the |
6828 // callback initiated by WaitForAsyncUploadProcess checks these expectations.) | 6805 // callback initiated by WaitForAsyncUploadProcess checks these expectations.) |
6829 autofill_manager_->set_expected_submitted_field_types(expected_types); | 6806 autofill_manager_->set_expected_submitted_field_types(expected_types); |
6830 autofill_manager_->set_expected_observed_submission(true); | 6807 autofill_manager_->set_expected_observed_submission(true); |
6831 autofill_manager_->set_call_parent_upload_form_data(true); | 6808 autofill_manager_->set_call_parent_upload_form_data(true); |
6832 autofill_manager_->ResetRunLoop(); | 6809 autofill_manager_->ResetRunLoop(); |
(...skipping 13 matching lines...) Expand all Loading... | |
6846 | 6823 |
6847 // Wait for upload to complete (will check expected types as well). | 6824 // Wait for upload to complete (will check expected types as well). |
6848 autofill_manager_->WaitForAsyncUploadProcess(); | 6825 autofill_manager_->WaitForAsyncUploadProcess(); |
6849 | 6826 |
6850 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); | 6827 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); |
6851 EXPECT_NE(uploaded_available_types.end(), | 6828 EXPECT_NE(uploaded_available_types.end(), |
6852 uploaded_available_types.find(autofill::PASSWORD)); | 6829 uploaded_available_types.find(autofill::PASSWORD)); |
6853 } | 6830 } |
6854 | 6831 |
6855 } // namespace autofill | 6832 } // namespace autofill |
OLD | NEW |