Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1160)

Side by Side Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 2897573003: Reland - [Autofill] Enable Autofill UKM by default. (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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() { 1073 void EnableAutofillUpstreamRequestCvcIfMissingExperiment() {
1074 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging);
1075 }
1076
1077 void EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging() {
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
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
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
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
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
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
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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4981 4974
4982 // Verify that the correct histogram entry (and only that) was logged. 4975 // Verify that the correct histogram entry (and only that) was logged.
4983 ExpectUniqueCardUploadDecision(histogram_tester, 4976 ExpectUniqueCardUploadDecision(histogram_tester,
4984 AutofillMetrics::CVC_FIELD_NOT_FOUND); 4977 AutofillMetrics::CVC_FIELD_NOT_FOUND);
4985 // Verify that the correct UKM was logged. 4978 // Verify that the correct UKM was logged.
4986 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND); 4979 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND);
4987 } 4980 }
4988 4981
4989 TEST_F(AutofillManagerTest, 4982 TEST_F(AutofillManagerTest,
4990 UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField) { 4983 UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField) {
4991 EnableUkmLogging();
4992 autofill_manager_->set_credit_card_upload_enabled(true); 4984 autofill_manager_->set_credit_card_upload_enabled(true);
4993 4985
4994 // Remove the profiles that were created in the TestPersonalDataManager 4986 // Remove the profiles that were created in the TestPersonalDataManager
4995 // constructor because they would result in conflicting names that would 4987 // constructor because they would result in conflicting names that would
4996 // prevent the upload. 4988 // prevent the upload.
4997 personal_data_.ClearAutofillProfiles(); 4989 personal_data_.ClearAutofillProfiles();
4998 4990
4999 // Create, fill and submit an address form in order to establish a recent 4991 // Create, fill and submit an address form in order to establish a recent
5000 // profile which can be selected for the upload request. 4992 // profile which can be selected for the upload request.
5001 FormData address_form; 4993 FormData address_form;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5040 5032
5041 // Verify that the correct histogram entry (and only that) was logged. 5033 // Verify that the correct histogram entry (and only that) was logged.
5042 ExpectUniqueCardUploadDecision(histogram_tester, 5034 ExpectUniqueCardUploadDecision(histogram_tester,
5043 AutofillMetrics::CVC_FIELD_NOT_FOUND); 5035 AutofillMetrics::CVC_FIELD_NOT_FOUND);
5044 // Verify that the correct UKM was logged. 5036 // Verify that the correct UKM was logged.
5045 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND); 5037 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND);
5046 } 5038 }
5047 5039
5048 TEST_F(AutofillManagerTest, 5040 TEST_F(AutofillManagerTest,
5049 UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField) { 5041 UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField) {
5050 EnableUkmLogging();
5051 autofill_manager_->set_credit_card_upload_enabled(true); 5042 autofill_manager_->set_credit_card_upload_enabled(true);
5052 5043
5053 // Remove the profiles that were created in the TestPersonalDataManager 5044 // Remove the profiles that were created in the TestPersonalDataManager
5054 // constructor because they would result in conflicting names that would 5045 // constructor because they would result in conflicting names that would
5055 // prevent the upload. 5046 // prevent the upload.
5056 personal_data_.ClearAutofillProfiles(); 5047 personal_data_.ClearAutofillProfiles();
5057 5048
5058 // Create, fill and submit an address form in order to establish a recent 5049 // Create, fill and submit an address form in order to establish a recent
5059 // profile which can be selected for the upload request. 5050 // profile which can be selected for the upload request.
5060 FormData address_form; 5051 FormData address_form;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5101 ExpectUniqueCardUploadDecision( 5092 ExpectUniqueCardUploadDecision(
5102 histogram_tester, 5093 histogram_tester,
5103 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD); 5094 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD);
5104 // Verify that the correct UKM was logged. 5095 // Verify that the correct UKM was logged.
5105 ExpectCardUploadDecisionUkm( 5096 ExpectCardUploadDecisionUkm(
5106 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD); 5097 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD);
5107 } 5098 }
5108 5099
5109 TEST_F(AutofillManagerTest, 5100 TEST_F(AutofillManagerTest,
5110 UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField) { 5101 UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField) {
5111 EnableUkmLogging();
5112 autofill_manager_->set_credit_card_upload_enabled(true); 5102 autofill_manager_->set_credit_card_upload_enabled(true);
5113 5103
5114 // Remove the profiles that were created in the TestPersonalDataManager 5104 // Remove the profiles that were created in the TestPersonalDataManager
5115 // constructor because they would result in conflicting names that would 5105 // constructor because they would result in conflicting names that would
5116 // prevent the upload. 5106 // prevent the upload.
5117 personal_data_.ClearAutofillProfiles(); 5107 personal_data_.ClearAutofillProfiles();
5118 5108
5119 // Create, fill and submit an address form in order to establish a recent 5109 // Create, fill and submit an address form in order to establish a recent
5120 // profile which can be selected for the upload request. 5110 // profile which can be selected for the upload request.
5121 FormData address_form; 5111 FormData address_form;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5158 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5169 #if defined(OS_ANDROID) 5159 #if defined(OS_ANDROID)
5170 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \ 5160 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \
5171 DISABLED_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc 5161 DISABLED_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc
5172 #else 5162 #else
5173 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \ 5163 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \
5174 UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc 5164 UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc
5175 #endif 5165 #endif
5176 TEST_F(AutofillManagerTest, 5166 TEST_F(AutofillManagerTest,
5177 MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc) { 5167 MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc) {
5178 EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging(); 5168 EnableAutofillUpstreamRequestCvcIfMissingExperiment();
5179 autofill_manager_->set_credit_card_upload_enabled(true); 5169 autofill_manager_->set_credit_card_upload_enabled(true);
5180 5170
5181 // Remove the profiles that were created in the TestPersonalDataManager 5171 // Remove the profiles that were created in the TestPersonalDataManager
5182 // constructor because they would result in conflicting names that would 5172 // constructor because they would result in conflicting names that would
5183 // prevent the upload. 5173 // prevent the upload.
5184 personal_data_.ClearAutofillProfiles(); 5174 personal_data_.ClearAutofillProfiles();
5185 5175
5186 // Create, fill and submit an address form in order to establish a recent 5176 // Create, fill and submit an address form in order to establish a recent
5187 // profile which can be selected for the upload request. 5177 // profile which can be selected for the upload request.
5188 FormData address_form; 5178 FormData address_form;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5228 AutofillMetrics::CVC_FIELD_NOT_FOUND); 5218 AutofillMetrics::CVC_FIELD_NOT_FOUND);
5229 // Verify that the correct UKM was logged. 5219 // Verify that the correct UKM was logged.
5230 ExpectMetric( 5220 ExpectMetric(
5231 internal::kUKMCardUploadDecisionMetricName, 5221 internal::kUKMCardUploadDecisionMetricName,
5232 internal::kUKMCardUploadDecisionEntryName, 5222 internal::kUKMCardUploadDecisionEntryName,
5233 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND, 5223 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND,
5234 1 /* expected_num_matching_entries */); 5224 1 /* expected_num_matching_entries */);
5235 } 5225 }
5236 5226
5237 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnFormExperimentOff) { 5227 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnFormExperimentOff) {
5238 EnableUkmLogging();
5239 autofill_manager_->set_credit_card_upload_enabled(true); 5228 autofill_manager_->set_credit_card_upload_enabled(true);
5240 5229
5241 // Remove the profiles that were created in the TestPersonalDataManager 5230 // Remove the profiles that were created in the TestPersonalDataManager
5242 // constructor because they would result in conflicting names that would 5231 // constructor because they would result in conflicting names that would
5243 // prevent the upload. 5232 // prevent the upload.
5244 personal_data_.ClearAutofillProfiles(); 5233 personal_data_.ClearAutofillProfiles();
5245 5234
5246 // Create, fill and submit an address form in order to establish a recent 5235 // Create, fill and submit an address form in order to establish a recent
5247 // profile which can be selected for the upload request. 5236 // profile which can be selected for the upload request.
5248 FormData address_form; 5237 FormData address_form;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5293 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5282 EXPECT_EQ(1, rappor_service->GetReportsCount());
5294 std::string sample; 5283 std::string sample;
5295 rappor::RapporType type; 5284 rappor::RapporType type;
5296 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5285 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5297 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5286 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
5298 EXPECT_EQ("myform.com", sample); 5287 EXPECT_EQ("myform.com", sample);
5299 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5288 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5300 } 5289 }
5301 5290
5302 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { 5291 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) {
5303 EnableUkmLogging();
5304 personal_data_.ClearAutofillProfiles(); 5292 personal_data_.ClearAutofillProfiles();
5305 autofill_manager_->set_credit_card_upload_enabled(true); 5293 autofill_manager_->set_credit_card_upload_enabled(true);
5306 5294
5307 // Don't fill or submit an address form. 5295 // Don't fill or submit an address form.
5308 5296
5309 // Set up our credit card form data. 5297 // Set up our credit card form data.
5310 FormData credit_card_form; 5298 FormData credit_card_form;
5311 CreateTestCreditCardFormData(&credit_card_form, true, false); 5299 CreateTestCreditCardFormData(&credit_card_form, true, false);
5312 FormsSeen(std::vector<FormData>(1, credit_card_form)); 5300 FormsSeen(std::vector<FormData>(1, credit_card_form));
5313 5301
(...skipping 27 matching lines...) Expand all
5341 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); 5329 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type));
5342 EXPECT_EQ("myform.com", sample); 5330 EXPECT_EQ("myform.com", sample);
5343 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5331 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5344 } 5332 }
5345 5333
5346 TEST_F(AutofillManagerTest, UploadCreditCard_NoRecentlyUsedProfile) { 5334 TEST_F(AutofillManagerTest, UploadCreditCard_NoRecentlyUsedProfile) {
5347 // Create the test clock and set the time to a specific value. 5335 // Create the test clock and set the time to a specific value.
5348 TestAutofillClock test_clock; 5336 TestAutofillClock test_clock;
5349 test_clock.SetNow(kArbitraryTime); 5337 test_clock.SetNow(kArbitraryTime);
5350 5338
5351 EnableUkmLogging();
5352 personal_data_.ClearAutofillProfiles(); 5339 personal_data_.ClearAutofillProfiles();
5353 autofill_manager_->set_credit_card_upload_enabled(true); 5340 autofill_manager_->set_credit_card_upload_enabled(true);
5354 5341
5355 // Create, fill and submit an address form in order to establish a profile. 5342 // Create, fill and submit an address form in order to establish a profile.
5356 FormData address_form; 5343 FormData address_form;
5357 test::CreateTestAddressFormData(&address_form); 5344 test::CreateTestAddressFormData(&address_form);
5358 FormsSeen({address_form}); 5345 FormsSeen({address_form});
5359 5346
5360 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); 5347 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form);
5361 FormSubmitted(address_form); 5348 FormSubmitted(address_form);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5442 FormSubmitted(credit_card_form); 5429 FormSubmitted(credit_card_form);
5443 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5430 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5444 5431
5445 // Verify that the correct histogram entry (and only that) was logged. 5432 // Verify that the correct histogram entry (and only that) was logged.
5446 ExpectUniqueCardUploadDecision(histogram_tester, 5433 ExpectUniqueCardUploadDecision(histogram_tester,
5447 AutofillMetrics::UPLOAD_OFFERED); 5434 AutofillMetrics::UPLOAD_OFFERED);
5448 } 5435 }
5449 5436
5450 TEST_F(AutofillManagerTest, 5437 TEST_F(AutofillManagerTest,
5451 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) { 5438 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) {
5452 EnableUkmLogging();
5453 personal_data_.ClearAutofillProfiles(); 5439 personal_data_.ClearAutofillProfiles();
5454 autofill_manager_->set_credit_card_upload_enabled(true); 5440 autofill_manager_->set_credit_card_upload_enabled(true);
5455 5441
5456 // Don't fill or submit an address form. 5442 // Don't fill or submit an address form.
5457 5443
5458 // Set up our credit card form data. 5444 // Set up our credit card form data.
5459 FormData credit_card_form; 5445 FormData credit_card_form;
5460 CreateTestCreditCardFormData(&credit_card_form, true, false); 5446 CreateTestCreditCardFormData(&credit_card_form, true, false);
5461 FormsSeen(std::vector<FormData>(1, credit_card_form)); 5447 FormsSeen(std::vector<FormData>(1, credit_card_form));
5462 5448
(...skipping 30 matching lines...) Expand all
5493 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5479 EXPECT_EQ(1, rappor_service->GetReportsCount());
5494 std::string sample; 5480 std::string sample;
5495 rappor::RapporType type; 5481 rappor::RapporType type;
5496 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5482 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5497 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5483 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
5498 EXPECT_EQ("myform.com", sample); 5484 EXPECT_EQ("myform.com", sample);
5499 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5485 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5500 } 5486 }
5501 5487
5502 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { 5488 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) {
5503 EnableUkmLogging();
5504 personal_data_.ClearAutofillProfiles(); 5489 personal_data_.ClearAutofillProfiles();
5505 autofill_manager_->set_credit_card_upload_enabled(true); 5490 autofill_manager_->set_credit_card_upload_enabled(true);
5506 5491
5507 // Create, fill and submit an address form in order to establish a recent 5492 // Create, fill and submit an address form in order to establish a recent
5508 // profile which can be selected for the upload request. 5493 // profile which can be selected for the upload request.
5509 FormData address_form; 5494 FormData address_form;
5510 test::CreateTestAddressFormData(&address_form); 5495 test::CreateTestAddressFormData(&address_form);
5511 FormsSeen(std::vector<FormData>(1, address_form)); 5496 FormsSeen(std::vector<FormData>(1, address_form));
5512 // But omit the name: 5497 // But omit the name:
5513 ManuallyFillAddressForm("", "", "77401", "US", &address_form); 5498 ManuallyFillAddressForm("", "", "77401", "US", &address_form);
(...skipping 28 matching lines...) Expand all
5542 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5527 EXPECT_EQ(1, rappor_service->GetReportsCount());
5543 std::string sample; 5528 std::string sample;
5544 rappor::RapporType type; 5529 rappor::RapporType type;
5545 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5530 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5546 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); 5531 "Autofill.CardUploadNotOfferedNoName", &sample, &type));
5547 EXPECT_EQ("myform.com", sample); 5532 EXPECT_EQ("myform.com", sample);
5548 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5533 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5549 } 5534 }
5550 5535
5551 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { 5536 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) {
5552 EnableUkmLogging();
5553 personal_data_.ClearAutofillProfiles(); 5537 personal_data_.ClearAutofillProfiles();
5554 autofill_manager_->set_credit_card_upload_enabled(true); 5538 autofill_manager_->set_credit_card_upload_enabled(true);
5555 5539
5556 // Create, fill and submit two address forms with different zip codes. 5540 // Create, fill and submit two address forms with different zip codes.
5557 FormData address_form1, address_form2; 5541 FormData address_form1, address_form2;
5558 test::CreateTestAddressFormData(&address_form1); 5542 test::CreateTestAddressFormData(&address_form1);
5559 test::CreateTestAddressFormData(&address_form2); 5543 test::CreateTestAddressFormData(&address_form2);
5560 5544
5561 std::vector<FormData> address_forms; 5545 std::vector<FormData> address_forms;
5562 address_forms.push_back(address_form1); 5546 address_forms.push_back(address_form1);
(...skipping 29 matching lines...) Expand all
5592 5576
5593 // Verify that the correct histogram entry (and only that) was logged. 5577 // Verify that the correct histogram entry (and only that) was logged.
5594 ExpectUniqueCardUploadDecision( 5578 ExpectUniqueCardUploadDecision(
5595 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); 5579 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5596 // Verify that the correct UKM was logged. 5580 // Verify that the correct UKM was logged.
5597 ExpectCardUploadDecisionUkm( 5581 ExpectCardUploadDecisionUkm(
5598 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); 5582 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5599 } 5583 }
5600 5584
5601 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { 5585 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) {
5602 EnableUkmLogging();
5603 personal_data_.ClearAutofillProfiles(); 5586 personal_data_.ClearAutofillProfiles();
5604 autofill_manager_->set_credit_card_upload_enabled(true); 5587 autofill_manager_->set_credit_card_upload_enabled(true);
5605 5588
5606 // Create, fill and submit two address forms with different zip codes. 5589 // Create, fill and submit two address forms with different zip codes.
5607 FormData address_form1, address_form2; 5590 FormData address_form1, address_form2;
5608 test::CreateTestAddressFormData(&address_form1); 5591 test::CreateTestAddressFormData(&address_form1);
5609 test::CreateTestAddressFormData(&address_form2); 5592 test::CreateTestAddressFormData(&address_form2);
5610 5593
5611 std::vector<FormData> address_forms; 5594 std::vector<FormData> address_forms;
5612 address_forms.push_back(address_form1); 5595 address_forms.push_back(address_form1);
(...skipping 26 matching lines...) Expand all
5639 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5622 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5640 5623
5641 // Verify that the correct histogram entry (and only that) was logged. 5624 // Verify that the correct histogram entry (and only that) was logged.
5642 ExpectUniqueCardUploadDecision(histogram_tester, 5625 ExpectUniqueCardUploadDecision(histogram_tester,
5643 AutofillMetrics::UPLOAD_OFFERED); 5626 AutofillMetrics::UPLOAD_OFFERED);
5644 // Verify that the correct UKM was logged. 5627 // Verify that the correct UKM was logged.
5645 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5628 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5646 } 5629 }
5647 5630
5648 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { 5631 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) {
5649 EnableUkmLogging();
5650 personal_data_.ClearAutofillProfiles(); 5632 personal_data_.ClearAutofillProfiles();
5651 autofill_manager_->set_credit_card_upload_enabled(true); 5633 autofill_manager_->set_credit_card_upload_enabled(true);
5652 5634
5653 // Create, fill and submit an address form in order to establish a recent 5635 // Create, fill and submit an address form in order to establish a recent
5654 // profile which can be selected for the upload request. 5636 // profile which can be selected for the upload request.
5655 FormData address_form; 5637 FormData address_form;
5656 test::CreateTestAddressFormData(&address_form); 5638 test::CreateTestAddressFormData(&address_form);
5657 FormsSeen(std::vector<FormData>(1, address_form)); 5639 FormsSeen(std::vector<FormData>(1, address_form));
5658 // Autofill's validation requirements for Venezuala ("VE", see 5640 // Autofill's validation requirements for Venezuala ("VE", see
5659 // src/components/autofill/core/browser/country_data.cc) do not require zip 5641 // src/components/autofill/core/browser/country_data.cc) do not require zip
(...skipping 25 matching lines...) Expand all
5685 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5667 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5686 5668
5687 // Verify that the correct histogram entry (and only that) was logged. 5669 // Verify that the correct histogram entry (and only that) was logged.
5688 ExpectUniqueCardUploadDecision( 5670 ExpectUniqueCardUploadDecision(
5689 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); 5671 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5690 // Verify that the correct UKM was logged. 5672 // Verify that the correct UKM was logged.
5691 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); 5673 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5692 } 5674 }
5693 5675
5694 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleInitial) { 5676 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleInitial) {
5695 EnableUkmLogging();
5696 personal_data_.ClearAutofillProfiles(); 5677 personal_data_.ClearAutofillProfiles();
5697 autofill_manager_->set_credit_card_upload_enabled(true); 5678 autofill_manager_->set_credit_card_upload_enabled(true);
5698 5679
5699 // Create, fill and submit two address forms with different names. 5680 // Create, fill and submit two address forms with different names.
5700 FormData address_form1, address_form2; 5681 FormData address_form1, address_form2;
5701 test::CreateTestAddressFormData(&address_form1); 5682 test::CreateTestAddressFormData(&address_form1);
5702 test::CreateTestAddressFormData(&address_form2); 5683 test::CreateTestAddressFormData(&address_form2);
5703 FormsSeen({address_form1, address_form2}); 5684 FormsSeen({address_form1, address_form2});
5704 5685
5705 // Names can be different case. 5686 // Names can be different case.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5776 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5757 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5777 FormSubmitted(credit_card_form); 5758 FormSubmitted(credit_card_form);
5778 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5759 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5779 5760
5780 // Verify that the correct histogram entry (and only that) was logged. 5761 // Verify that the correct histogram entry (and only that) was logged.
5781 ExpectUniqueCardUploadDecision(histogram_tester, 5762 ExpectUniqueCardUploadDecision(histogram_tester,
5782 AutofillMetrics::UPLOAD_OFFERED); 5763 AutofillMetrics::UPLOAD_OFFERED);
5783 } 5764 }
5784 5765
5785 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { 5766 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) {
5786 EnableUkmLogging();
5787 personal_data_.ClearAutofillProfiles(); 5767 personal_data_.ClearAutofillProfiles();
5788 autofill_manager_->set_credit_card_upload_enabled(true); 5768 autofill_manager_->set_credit_card_upload_enabled(true);
5789 5769
5790 // Create, fill and submit two address forms with different names. 5770 // Create, fill and submit two address forms with different names.
5791 FormData address_form1, address_form2; 5771 FormData address_form1, address_form2;
5792 test::CreateTestAddressFormData(&address_form1); 5772 test::CreateTestAddressFormData(&address_form1);
5793 test::CreateTestAddressFormData(&address_form2); 5773 test::CreateTestAddressFormData(&address_form2);
5794 FormsSeen({address_form1, address_form2}); 5774 FormsSeen({address_form1, address_form2});
5795 5775
5796 // Names can have different variations of middle initials. 5776 // Names can have different variations of middle initials.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5861 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5841 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5862 FormSubmitted(credit_card_form); 5842 FormSubmitted(credit_card_form);
5863 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5843 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5864 5844
5865 // Verify that the correct histogram entry (and only that) was logged. 5845 // Verify that the correct histogram entry (and only that) was logged.
5866 ExpectUniqueCardUploadDecision(histogram_tester, 5846 ExpectUniqueCardUploadDecision(histogram_tester,
5867 AutofillMetrics::UPLOAD_OFFERED); 5847 AutofillMetrics::UPLOAD_OFFERED);
5868 } 5848 }
5869 5849
5870 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleName) { 5850 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleName) {
5871 EnableUkmLogging();
5872 personal_data_.ClearAutofillProfiles(); 5851 personal_data_.ClearAutofillProfiles();
5873 autofill_manager_->set_credit_card_upload_enabled(true); 5852 autofill_manager_->set_credit_card_upload_enabled(true);
5874 5853
5875 // Create, fill and submit address form without middle name. 5854 // Create, fill and submit address form without middle name.
5876 FormData address_form; 5855 FormData address_form;
5877 test::CreateTestAddressFormData(&address_form); 5856 test::CreateTestAddressFormData(&address_form);
5878 FormsSeen({address_form}); 5857 FormsSeen({address_form});
5879 ManuallyFillAddressForm("John", "Adams", "77401", "US", &address_form); 5858 ManuallyFillAddressForm("John", "Adams", "77401", "US", &address_form);
5880 FormSubmitted(address_form); 5859 FormSubmitted(address_form);
5881 5860
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5937 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5916 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5938 FormSubmitted(credit_card_form); 5917 FormSubmitted(credit_card_form);
5939 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5918 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5940 5919
5941 // Verify that the correct histogram entry (and only that) was logged. 5920 // Verify that the correct histogram entry (and only that) was logged.
5942 ExpectUniqueCardUploadDecision( 5921 ExpectUniqueCardUploadDecision(
5943 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); 5922 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
5944 } 5923 }
5945 5924
5946 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormRemovesMiddleName) { 5925 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormRemovesMiddleName) {
5947 EnableUkmLogging();
5948 personal_data_.ClearAutofillProfiles(); 5926 personal_data_.ClearAutofillProfiles();
5949 autofill_manager_->set_credit_card_upload_enabled(true); 5927 autofill_manager_->set_credit_card_upload_enabled(true);
5950 5928
5951 // Create, fill and submit address form with middle name. 5929 // Create, fill and submit address form with middle name.
5952 FormData address_form; 5930 FormData address_form;
5953 test::CreateTestAddressFormData(&address_form); 5931 test::CreateTestAddressFormData(&address_form);
5954 FormsSeen({address_form}); 5932 FormsSeen({address_form});
5955 ManuallyFillAddressForm("John Quincy", "Adams", "77401", "US", &address_form); 5933 ManuallyFillAddressForm("John Quincy", "Adams", "77401", "US", &address_form);
5956 FormSubmitted(address_form); 5934 FormSubmitted(address_form);
5957 5935
(...skipping 17 matching lines...) Expand all
5975 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5953 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5976 5954
5977 // Verify that the correct histogram entry (and only that) was logged. 5955 // Verify that the correct histogram entry (and only that) was logged.
5978 ExpectUniqueCardUploadDecision(histogram_tester, 5956 ExpectUniqueCardUploadDecision(histogram_tester,
5979 AutofillMetrics::UPLOAD_OFFERED); 5957 AutofillMetrics::UPLOAD_OFFERED);
5980 // Verify that the correct UKM was logged. 5958 // Verify that the correct UKM was logged.
5981 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5959 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5982 } 5960 }
5983 5961
5984 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { 5962 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) {
5985 EnableUkmLogging();
5986 personal_data_.ClearAutofillProfiles(); 5963 personal_data_.ClearAutofillProfiles();
5987 autofill_manager_->set_credit_card_upload_enabled(true); 5964 autofill_manager_->set_credit_card_upload_enabled(true);
5988 5965
5989 // Create, fill and submit two address forms with different names. 5966 // Create, fill and submit two address forms with different names.
5990 FormData address_form1, address_form2; 5967 FormData address_form1, address_form2;
5991 test::CreateTestAddressFormData(&address_form1); 5968 test::CreateTestAddressFormData(&address_form1);
5992 test::CreateTestAddressFormData(&address_form2); 5969 test::CreateTestAddressFormData(&address_form2);
5993 5970
5994 std::vector<FormData> address_forms; 5971 std::vector<FormData> address_forms;
5995 address_forms.push_back(address_form1); 5972 address_forms.push_back(address_form1);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
6235 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 6212 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
6236 6213
6237 // Verify that UMA for "DaysSincePreviousUse" is logged. 6214 // Verify that UMA for "DaysSincePreviousUse" is logged.
6238 histogram_tester.ExpectUniqueSample( 6215 histogram_tester.ExpectUniqueSample(
6239 "Autofill.DaysSincePreviousUseAtSubmission.Profile", 6216 "Autofill.DaysSincePreviousUseAtSubmission.Profile",
6240 (kMuchLaterTime - kArbitraryTime).InDays(), 6217 (kMuchLaterTime - kArbitraryTime).InDays(),
6241 /*expected_count=*/1); 6218 /*expected_count=*/1);
6242 } 6219 }
6243 6220
6244 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { 6221 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) {
6245 EnableUkmLogging();
6246 personal_data_.ClearAutofillProfiles(); 6222 personal_data_.ClearAutofillProfiles();
6247 autofill_manager_->set_credit_card_upload_enabled(true); 6223 autofill_manager_->set_credit_card_upload_enabled(true);
6248 6224
6249 // Anything other than "en-US" will cause GetUploadDetails to return a failure 6225 // Anything other than "en-US" will cause GetUploadDetails to return a failure
6250 // response. 6226 // response.
6251 autofill_manager_->set_app_locale("pt-BR"); 6227 autofill_manager_->set_app_locale("pt-BR");
6252 6228
6253 // Create, fill and submit an address form in order to establish a recent 6229 // Create, fill and submit an address form in order to establish a recent
6254 // profile which can be selected for the upload request. 6230 // profile which can be selected for the upload request.
6255 FormData address_form; 6231 FormData address_form;
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
6884 // Suggestions should be displayed. 6860 // Suggestions should be displayed.
6885 for (const FormFieldData& field : form.fields) { 6861 for (const FormFieldData& field : form.fields) {
6886 GetAutofillSuggestions(form, field); 6862 GetAutofillSuggestions(form, field);
6887 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 6863 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
6888 } 6864 }
6889 } 6865 }
6890 6866
6891 // Test that a sign-in form submission sends an upload with types matching the 6867 // Test that a sign-in form submission sends an upload with types matching the
6892 // fields. 6868 // fields.
6893 TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) { 6869 TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) {
6894 EnableUkmLogging();
6895 // Set up our form data (it's already filled out with user data). 6870 // Set up our form data (it's already filled out with user data).
6896 FormData form; 6871 FormData form;
6897 form.origin = GURL("http://myform.com/form.html"); 6872 form.origin = GURL("http://myform.com/form.html");
6898 form.action = GURL("http://myform.com/submit.html"); 6873 form.action = GURL("http://myform.com/submit.html");
6899 6874
6900 std::vector<ServerFieldTypeSet> expected_types; 6875 std::vector<ServerFieldTypeSet> expected_types;
6901 ServerFieldTypeSet types; 6876 ServerFieldTypeSet types;
6902 6877
6903 FormFieldData field; 6878 FormFieldData field;
6904 test::CreateTestFormField("Email", "email", "theking@gmail.com", "text", 6879 test::CreateTestFormField("Email", "email", "theking@gmail.com", "text",
6905 &field); 6880 &field);
6906 form.fields.push_back(field); 6881 form.fields.push_back(field);
6907 types.insert(EMAIL_ADDRESS); 6882 types.insert(EMAIL_ADDRESS);
6908 expected_types.push_back(types); 6883 expected_types.push_back(types);
6909 6884
6910 test::CreateTestFormField("Password", "pw", "secret", "password", &field); 6885 test::CreateTestFormField("Password", "pw", "secret", "password", &field);
6911 form.fields.push_back(field); 6886 form.fields.push_back(field);
6887 FormsSeen(std::vector<FormData>(1, form));
6912 types.clear(); 6888 types.clear();
6913 types.insert(PASSWORD); 6889 types.insert(PASSWORD);
6914 expected_types.push_back(types); 6890 expected_types.push_back(types);
6915 6891
6916 FormsSeen({form}); 6892 FormsSeen({form});
6917 6893
6918 // We will expect these types in the upload and no observed submission. (the 6894 // We will expect these types in the upload and no observed submission. (the
6919 // callback initiated by WaitForAsyncUploadProcess checks these expectations.) 6895 // callback initiated by WaitForAsyncUploadProcess checks these expectations.)
6920 autofill_manager_->set_expected_submitted_field_types(expected_types); 6896 autofill_manager_->set_expected_submitted_field_types(expected_types);
6921 autofill_manager_->set_expected_observed_submission(true); 6897 autofill_manager_->set_expected_observed_submission(true);
(...skipping 15 matching lines...) Expand all
6937 6913
6938 // Wait for upload to complete (will check expected types as well). 6914 // Wait for upload to complete (will check expected types as well).
6939 autofill_manager_->WaitForAsyncUploadProcess(); 6915 autofill_manager_->WaitForAsyncUploadProcess();
6940 6916
6941 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); 6917 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
6942 EXPECT_NE(uploaded_available_types.end(), 6918 EXPECT_NE(uploaded_available_types.end(),
6943 uploaded_available_types.find(autofill::PASSWORD)); 6919 uploaded_available_types.find(autofill::PASSWORD));
6944 } 6920 }
6945 6921
6946 } // namespace autofill 6922 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_experiments.cc ('k') | components/autofill/core/browser/autofill_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698