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

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

Issue 2888633002: Revert of [Autofill] Enable Autofill UKM by default. (Closed)
Patch Set: 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 EnableAutofillUpstreamRequestCvcIfMissingExperiment() { 1073 void EnableUkmLogging() {
1074 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging);
1075 }
1076
1077 void EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging() {
1074 scoped_feature_list_.InitWithFeatures( 1078 scoped_feature_list_.InitWithFeatures(
1075 {kAutofillUpstreamRequestCvcIfMissing}, {}); 1079 {kAutofillUpstreamRequestCvcIfMissing, kAutofillUkmLogging}, {});
1076 } 1080 }
1077 1081
1078 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { 1082 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() {
1079 scoped_feature_list_.InitAndDisableFeature( 1083 scoped_feature_list_.InitAndDisableFeature(
1080 kAutofillUpstreamUseAutofillProfileComparatorForName); 1084 kAutofillUpstreamUseAutofillProfileComparatorForName);
1081 } 1085 }
1082 1086
1083 void ExpectUniqueFillableFormParsedUkm() { 1087 void ExpectUniqueFillableFormParsedUkm() {
1084 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); 1088 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
1085 1089
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 // Verify that FormStructure::ParseQueryResponse was NOT called. 3672 // Verify that FormStructure::ParseQueryResponse was NOT called.
3669 histogram_tester.ExpectTotalCount("Autofill.ServerQueryResponse", 0); 3673 histogram_tester.ExpectTotalCount("Autofill.ServerQueryResponse", 0);
3670 } 3674 }
3671 3675
3672 // Test that we are able to save form data when forms are submitted and we only 3676 // Test that we are able to save form data when forms are submitted and we only
3673 // have server data for the field types. 3677 // have server data for the field types.
3674 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { 3678 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) {
3675 // Set up our form data. 3679 // Set up our form data.
3676 FormData form; 3680 FormData form;
3677 test::CreateTestAddressFormData(&form); 3681 test::CreateTestAddressFormData(&form);
3678 FormsSeen(std::vector<FormData>(1, form));
3679 3682
3680 // Simulate having seen this form on page load. 3683 // Simulate having seen this form on page load.
3681 // |form_structure| will be owned by |autofill_manager_|. 3684 // |form_structure| will be owned by |autofill_manager_|.
3682 TestFormStructure* form_structure = new TestFormStructure(form); 3685 TestFormStructure* form_structure = new TestFormStructure(form);
3683 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); 3686 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
3684 3687
3685 // Clear the heuristic types, and instead set the appropriate server types. 3688 // Clear the heuristic types, and instead set the appropriate server types.
3686 std::vector<ServerFieldType> heuristic_types, server_types; 3689 std::vector<ServerFieldType> heuristic_types, server_types;
3687 for (size_t i = 0; i < form.fields.size(); ++i) { 3690 for (size_t i = 0; i < form.fields.size(); ++i) {
3688 heuristic_types.push_back(UNKNOWN_TYPE); 3691 heuristic_types.push_back(UNKNOWN_TYPE);
(...skipping 19 matching lines...) Expand all
3708 } 3711 }
3709 3712
3710 // Test that we are able to save form data after the possible types have been 3713 // Test that we are able to save form data after the possible types have been
3711 // determined. We do two submissions and verify that only at the second 3714 // determined. We do two submissions and verify that only at the second
3712 // submission are the possible types able to be inferred. 3715 // submission are the possible types able to be inferred.
3713 TEST_F(AutofillManagerTest, FormSubmittedPossibleTypesTwoSubmissions) { 3716 TEST_F(AutofillManagerTest, FormSubmittedPossibleTypesTwoSubmissions) {
3714 // Set up our form data. 3717 // Set up our form data.
3715 FormData form; 3718 FormData form;
3716 std::vector<ServerFieldTypeSet> expected_types; 3719 std::vector<ServerFieldTypeSet> expected_types;
3717 test::CreateTestAddressFormData(&form, &expected_types); 3720 test::CreateTestAddressFormData(&form, &expected_types);
3718 FormsSeen(std::vector<FormData>(1, form));
3719 3721
3720 // Fill the form. 3722 // Fill the form.
3721 const char guid[] = "00000000-0000-0000-0000-000000000001"; 3723 const char guid[] = "00000000-0000-0000-0000-000000000001";
3722 int response_page_id = 0; 3724 int response_page_id = 0;
3723 FormData response_data; 3725 FormData response_data;
3724 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0], 3726 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[0],
3725 MakeFrontendID(std::string(), guid), 3727 MakeFrontendID(std::string(), guid),
3726 &response_page_id, &response_data); 3728 &response_page_id, &response_data);
3727 ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID, 3729 ExpectFilledAddressFormElvis(response_page_id, response_data, kDefaultPageID,
3728 false); 3730 false);
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
4629 response.should_store_pan = false; 4631 response.should_store_pan = false;
4630 response.cvc = ASCIIToUTF16("123"); 4632 response.cvc = ASCIIToUTF16("123");
4631 response.exp_month = ASCIIToUTF16("02"); 4633 response.exp_month = ASCIIToUTF16("02");
4632 response.exp_year = ASCIIToUTF16("2018"); 4634 response.exp_year = ASCIIToUTF16("2018");
4633 full_card_unmask_delegate()->OnUnmaskResponse(response); 4635 full_card_unmask_delegate()->OnUnmaskResponse(response);
4634 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, 4636 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
4635 "4012888888881881"); 4637 "4012888888881881");
4636 } 4638 }
4637 4639
4638 TEST_F(AutofillManagerTest, UploadCreditCard) { 4640 TEST_F(AutofillManagerTest, UploadCreditCard) {
4641 EnableUkmLogging();
4639 personal_data_.ClearCreditCards(); 4642 personal_data_.ClearCreditCards();
4640 personal_data_.ClearAutofillProfiles(); 4643 personal_data_.ClearAutofillProfiles();
4641 autofill_manager_->set_credit_card_upload_enabled(true); 4644 autofill_manager_->set_credit_card_upload_enabled(true);
4642 4645
4643 // Create, fill and submit an address form in order to establish a recent 4646 // Create, fill and submit an address form in order to establish a recent
4644 // profile which can be selected for the upload request. 4647 // profile which can be selected for the upload request.
4645 FormData address_form; 4648 FormData address_form;
4646 test::CreateTestAddressFormData(&address_form); 4649 test::CreateTestAddressFormData(&address_form);
4647 FormsSeen(std::vector<FormData>(1, address_form)); 4650 FormsSeen(std::vector<FormData>(1, address_form));
4648 ExpectUniqueFillableFormParsedUkm(); 4651 ExpectUniqueFillableFormParsedUkm();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4760 // The save prompt should be shown instead of doing an upload. 4763 // The save prompt should be shown instead of doing an upload.
4761 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); 4764 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _));
4762 FormSubmitted(credit_card_form); 4765 FormSubmitted(credit_card_form);
4763 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 4766 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4764 4767
4765 // Verify that no histogram entry was logged. 4768 // Verify that no histogram entry was logged.
4766 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionMetric", 0); 4769 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionMetric", 0);
4767 } 4770 }
4768 4771
4769 TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) { 4772 TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) {
4773 EnableUkmLogging();
4770 personal_data_.ClearAutofillProfiles(); 4774 personal_data_.ClearAutofillProfiles();
4771 autofill_manager_->set_credit_card_upload_enabled(true); 4775 autofill_manager_->set_credit_card_upload_enabled(true);
4772 4776
4773 // Create, fill and submit an address form in order to establish a recent 4777 // Create, fill and submit an address form in order to establish a recent
4774 // profile which can be selected for the upload request. 4778 // profile which can be selected for the upload request.
4775 FormData address_form; 4779 FormData address_form;
4776 test::CreateTestAddressFormData(&address_form); 4780 test::CreateTestAddressFormData(&address_form);
4777 FormsSeen(std::vector<FormData>(1, address_form)); 4781 FormsSeen(std::vector<FormData>(1, address_form));
4778 ExpectUniqueFillableFormParsedUkm(); 4782 ExpectUniqueFillableFormParsedUkm();
4779 4783
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4811 EXPECT_EQ(1, rappor_service->GetReportsCount()); 4815 EXPECT_EQ(1, rappor_service->GetReportsCount());
4812 std::string sample; 4816 std::string sample;
4813 rappor::RapporType type; 4817 rappor::RapporType type;
4814 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 4818 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4815 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 4819 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
4816 EXPECT_EQ("myform.com", sample); 4820 EXPECT_EQ("myform.com", sample);
4817 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 4821 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
4818 } 4822 }
4819 4823
4820 TEST_F(AutofillManagerTest, UploadCreditCard_CvcInvalidLength) { 4824 TEST_F(AutofillManagerTest, UploadCreditCard_CvcInvalidLength) {
4825 EnableUkmLogging();
4821 personal_data_.ClearAutofillProfiles(); 4826 personal_data_.ClearAutofillProfiles();
4822 autofill_manager_->set_credit_card_upload_enabled(true); 4827 autofill_manager_->set_credit_card_upload_enabled(true);
4823 4828
4824 // Create, fill and submit an address form in order to establish a recent 4829 // Create, fill and submit an address form in order to establish a recent
4825 // profile which can be selected for the upload request. 4830 // profile which can be selected for the upload request.
4826 FormData address_form; 4831 FormData address_form;
4827 test::CreateTestAddressFormData(&address_form); 4832 test::CreateTestAddressFormData(&address_form);
4828 FormsSeen(std::vector<FormData>(1, address_form)); 4833 FormsSeen(std::vector<FormData>(1, address_form));
4829 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); 4834 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form);
4830 FormSubmitted(address_form); 4835 FormSubmitted(address_form);
(...skipping 28 matching lines...) Expand all
4859 EXPECT_EQ(1, rappor_service->GetReportsCount()); 4864 EXPECT_EQ(1, rappor_service->GetReportsCount());
4860 std::string sample; 4865 std::string sample;
4861 rappor::RapporType type; 4866 rappor::RapporType type;
4862 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 4867 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4863 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 4868 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
4864 EXPECT_EQ("myform.com", sample); 4869 EXPECT_EQ("myform.com", sample);
4865 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 4870 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
4866 } 4871 }
4867 4872
4868 TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) { 4873 TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) {
4874 EnableUkmLogging();
4869 autofill_manager_->set_credit_card_upload_enabled(true); 4875 autofill_manager_->set_credit_card_upload_enabled(true);
4870 4876
4871 // Remove the profiles that were created in the TestPersonalDataManager 4877 // Remove the profiles that were created in the TestPersonalDataManager
4872 // constructor because they would result in conflicting names that would 4878 // constructor because they would result in conflicting names that would
4873 // prevent the upload. 4879 // prevent the upload.
4874 personal_data_.ClearAutofillProfiles(); 4880 personal_data_.ClearAutofillProfiles();
4875 4881
4876 // Create, fill and submit an address form in order to establish a recent 4882 // Create, fill and submit an address form in order to establish a recent
4877 // profile which can be selected for the upload request. 4883 // profile which can be selected for the upload request.
4878 FormData address_form; 4884 FormData address_form;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4919 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 4925 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4920 4926
4921 // Verify that the correct histogram entry (and only that) was logged. 4927 // Verify that the correct histogram entry (and only that) was logged.
4922 ExpectUniqueCardUploadDecision(histogram_tester, 4928 ExpectUniqueCardUploadDecision(histogram_tester,
4923 AutofillMetrics::UPLOAD_OFFERED); 4929 AutofillMetrics::UPLOAD_OFFERED);
4924 // Verify that the correct UKM was logged. 4930 // Verify that the correct UKM was logged.
4925 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 4931 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
4926 } 4932 }
4927 4933
4928 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnForm) { 4934 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnForm) {
4935 EnableUkmLogging();
4929 autofill_manager_->set_credit_card_upload_enabled(true); 4936 autofill_manager_->set_credit_card_upload_enabled(true);
4930 4937
4931 // Remove the profiles that were created in the TestPersonalDataManager 4938 // Remove the profiles that were created in the TestPersonalDataManager
4932 // constructor because they would result in conflicting names that would 4939 // constructor because they would result in conflicting names that would
4933 // prevent the upload. 4940 // prevent the upload.
4934 personal_data_.ClearAutofillProfiles(); 4941 personal_data_.ClearAutofillProfiles();
4935 4942
4936 // Create, fill and submit an address form in order to establish a recent 4943 // Create, fill and submit an address form in order to establish a recent
4937 // profile which can be selected for the upload request. 4944 // profile which can be selected for the upload request.
4938 FormData address_form; 4945 FormData address_form;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4974 4981
4975 // Verify that the correct histogram entry (and only that) was logged. 4982 // Verify that the correct histogram entry (and only that) was logged.
4976 ExpectUniqueCardUploadDecision(histogram_tester, 4983 ExpectUniqueCardUploadDecision(histogram_tester,
4977 AutofillMetrics::CVC_FIELD_NOT_FOUND); 4984 AutofillMetrics::CVC_FIELD_NOT_FOUND);
4978 // Verify that the correct UKM was logged. 4985 // Verify that the correct UKM was logged.
4979 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND); 4986 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND);
4980 } 4987 }
4981 4988
4982 TEST_F(AutofillManagerTest, 4989 TEST_F(AutofillManagerTest,
4983 UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField) { 4990 UploadCreditCard_NoCvcFieldOnForm_InvalidCvcInNonCvcField) {
4991 EnableUkmLogging();
4984 autofill_manager_->set_credit_card_upload_enabled(true); 4992 autofill_manager_->set_credit_card_upload_enabled(true);
4985 4993
4986 // Remove the profiles that were created in the TestPersonalDataManager 4994 // Remove the profiles that were created in the TestPersonalDataManager
4987 // constructor because they would result in conflicting names that would 4995 // constructor because they would result in conflicting names that would
4988 // prevent the upload. 4996 // prevent the upload.
4989 personal_data_.ClearAutofillProfiles(); 4997 personal_data_.ClearAutofillProfiles();
4990 4998
4991 // Create, fill and submit an address form in order to establish a recent 4999 // Create, fill and submit an address form in order to establish a recent
4992 // profile which can be selected for the upload request. 5000 // profile which can be selected for the upload request.
4993 FormData address_form; 5001 FormData address_form;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5032 5040
5033 // Verify that the correct histogram entry (and only that) was logged. 5041 // Verify that the correct histogram entry (and only that) was logged.
5034 ExpectUniqueCardUploadDecision(histogram_tester, 5042 ExpectUniqueCardUploadDecision(histogram_tester,
5035 AutofillMetrics::CVC_FIELD_NOT_FOUND); 5043 AutofillMetrics::CVC_FIELD_NOT_FOUND);
5036 // Verify that the correct UKM was logged. 5044 // Verify that the correct UKM was logged.
5037 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND); 5045 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND);
5038 } 5046 }
5039 5047
5040 TEST_F(AutofillManagerTest, 5048 TEST_F(AutofillManagerTest,
5041 UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField) { 5049 UploadCreditCard_NoCvcFieldOnForm_CvcInNonCvcField) {
5050 EnableUkmLogging();
5042 autofill_manager_->set_credit_card_upload_enabled(true); 5051 autofill_manager_->set_credit_card_upload_enabled(true);
5043 5052
5044 // Remove the profiles that were created in the TestPersonalDataManager 5053 // Remove the profiles that were created in the TestPersonalDataManager
5045 // constructor because they would result in conflicting names that would 5054 // constructor because they would result in conflicting names that would
5046 // prevent the upload. 5055 // prevent the upload.
5047 personal_data_.ClearAutofillProfiles(); 5056 personal_data_.ClearAutofillProfiles();
5048 5057
5049 // Create, fill and submit an address form in order to establish a recent 5058 // Create, fill and submit an address form in order to establish a recent
5050 // profile which can be selected for the upload request. 5059 // profile which can be selected for the upload request.
5051 FormData address_form; 5060 FormData address_form;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5092 ExpectUniqueCardUploadDecision( 5101 ExpectUniqueCardUploadDecision(
5093 histogram_tester, 5102 histogram_tester,
5094 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD); 5103 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD);
5095 // Verify that the correct UKM was logged. 5104 // Verify that the correct UKM was logged.
5096 ExpectCardUploadDecisionUkm( 5105 ExpectCardUploadDecisionUkm(
5097 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD); 5106 AutofillMetrics::FOUND_POSSIBLE_CVC_VALUE_IN_NON_CVC_FIELD);
5098 } 5107 }
5099 5108
5100 TEST_F(AutofillManagerTest, 5109 TEST_F(AutofillManagerTest,
5101 UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField) { 5110 UploadCreditCard_NoCvcFieldOnForm_CvcInAddressField) {
5111 EnableUkmLogging();
5102 autofill_manager_->set_credit_card_upload_enabled(true); 5112 autofill_manager_->set_credit_card_upload_enabled(true);
5103 5113
5104 // Remove the profiles that were created in the TestPersonalDataManager 5114 // Remove the profiles that were created in the TestPersonalDataManager
5105 // constructor because they would result in conflicting names that would 5115 // constructor because they would result in conflicting names that would
5106 // prevent the upload. 5116 // prevent the upload.
5107 personal_data_.ClearAutofillProfiles(); 5117 personal_data_.ClearAutofillProfiles();
5108 5118
5109 // Create, fill and submit an address form in order to establish a recent 5119 // Create, fill and submit an address form in order to establish a recent
5110 // profile which can be selected for the upload request. 5120 // profile which can be selected for the upload request.
5111 FormData address_form; 5121 FormData address_form;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5158 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5168 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5159 #if defined(OS_ANDROID) 5169 #if defined(OS_ANDROID)
5160 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \ 5170 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \
5161 DISABLED_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc 5171 DISABLED_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc
5162 #else 5172 #else
5163 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \ 5173 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \
5164 UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc 5174 UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc
5165 #endif 5175 #endif
5166 TEST_F(AutofillManagerTest, 5176 TEST_F(AutofillManagerTest,
5167 MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc) { 5177 MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc) {
5168 EnableAutofillUpstreamRequestCvcIfMissingExperiment(); 5178 EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging();
5169 autofill_manager_->set_credit_card_upload_enabled(true); 5179 autofill_manager_->set_credit_card_upload_enabled(true);
5170 5180
5171 // Remove the profiles that were created in the TestPersonalDataManager 5181 // Remove the profiles that were created in the TestPersonalDataManager
5172 // constructor because they would result in conflicting names that would 5182 // constructor because they would result in conflicting names that would
5173 // prevent the upload. 5183 // prevent the upload.
5174 personal_data_.ClearAutofillProfiles(); 5184 personal_data_.ClearAutofillProfiles();
5175 5185
5176 // Create, fill and submit an address form in order to establish a recent 5186 // Create, fill and submit an address form in order to establish a recent
5177 // profile which can be selected for the upload request. 5187 // profile which can be selected for the upload request.
5178 FormData address_form; 5188 FormData address_form;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5218 AutofillMetrics::CVC_FIELD_NOT_FOUND); 5228 AutofillMetrics::CVC_FIELD_NOT_FOUND);
5219 // Verify that the correct UKM was logged. 5229 // Verify that the correct UKM was logged.
5220 ExpectMetric( 5230 ExpectMetric(
5221 internal::kUKMCardUploadDecisionMetricName, 5231 internal::kUKMCardUploadDecisionMetricName,
5222 internal::kUKMCardUploadDecisionEntryName, 5232 internal::kUKMCardUploadDecisionEntryName,
5223 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND, 5233 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND,
5224 1 /* expected_num_matching_entries */); 5234 1 /* expected_num_matching_entries */);
5225 } 5235 }
5226 5236
5227 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnFormExperimentOff) { 5237 TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnFormExperimentOff) {
5238 EnableUkmLogging();
5228 autofill_manager_->set_credit_card_upload_enabled(true); 5239 autofill_manager_->set_credit_card_upload_enabled(true);
5229 5240
5230 // Remove the profiles that were created in the TestPersonalDataManager 5241 // Remove the profiles that were created in the TestPersonalDataManager
5231 // constructor because they would result in conflicting names that would 5242 // constructor because they would result in conflicting names that would
5232 // prevent the upload. 5243 // prevent the upload.
5233 personal_data_.ClearAutofillProfiles(); 5244 personal_data_.ClearAutofillProfiles();
5234 5245
5235 // Create, fill and submit an address form in order to establish a recent 5246 // Create, fill and submit an address form in order to establish a recent
5236 // profile which can be selected for the upload request. 5247 // profile which can be selected for the upload request.
5237 FormData address_form; 5248 FormData address_form;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5282 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5293 EXPECT_EQ(1, rappor_service->GetReportsCount());
5283 std::string sample; 5294 std::string sample;
5284 rappor::RapporType type; 5295 rappor::RapporType type;
5285 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5296 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5286 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5297 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
5287 EXPECT_EQ("myform.com", sample); 5298 EXPECT_EQ("myform.com", sample);
5288 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5299 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5289 } 5300 }
5290 5301
5291 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) { 5302 TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) {
5303 EnableUkmLogging();
5292 personal_data_.ClearAutofillProfiles(); 5304 personal_data_.ClearAutofillProfiles();
5293 autofill_manager_->set_credit_card_upload_enabled(true); 5305 autofill_manager_->set_credit_card_upload_enabled(true);
5294 5306
5295 // Don't fill or submit an address form. 5307 // Don't fill or submit an address form.
5296 5308
5297 // Set up our credit card form data. 5309 // Set up our credit card form data.
5298 FormData credit_card_form; 5310 FormData credit_card_form;
5299 CreateTestCreditCardFormData(&credit_card_form, true, false); 5311 CreateTestCreditCardFormData(&credit_card_form, true, false);
5300 FormsSeen(std::vector<FormData>(1, credit_card_form)); 5312 FormsSeen(std::vector<FormData>(1, credit_card_form));
5301 5313
(...skipping 27 matching lines...) Expand all
5329 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); 5341 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type));
5330 EXPECT_EQ("myform.com", sample); 5342 EXPECT_EQ("myform.com", sample);
5331 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5343 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5332 } 5344 }
5333 5345
5334 TEST_F(AutofillManagerTest, UploadCreditCard_NoRecentlyUsedProfile) { 5346 TEST_F(AutofillManagerTest, UploadCreditCard_NoRecentlyUsedProfile) {
5335 // Create the test clock and set the time to a specific value. 5347 // Create the test clock and set the time to a specific value.
5336 TestAutofillClock test_clock; 5348 TestAutofillClock test_clock;
5337 test_clock.SetNow(kArbitraryTime); 5349 test_clock.SetNow(kArbitraryTime);
5338 5350
5351 EnableUkmLogging();
5339 personal_data_.ClearAutofillProfiles(); 5352 personal_data_.ClearAutofillProfiles();
5340 autofill_manager_->set_credit_card_upload_enabled(true); 5353 autofill_manager_->set_credit_card_upload_enabled(true);
5341 5354
5342 // Create, fill and submit an address form in order to establish a profile. 5355 // Create, fill and submit an address form in order to establish a profile.
5343 FormData address_form; 5356 FormData address_form;
5344 test::CreateTestAddressFormData(&address_form); 5357 test::CreateTestAddressFormData(&address_form);
5345 FormsSeen({address_form}); 5358 FormsSeen({address_form});
5346 5359
5347 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); 5360 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form);
5348 FormSubmitted(address_form); 5361 FormSubmitted(address_form);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5429 FormSubmitted(credit_card_form); 5442 FormSubmitted(credit_card_form);
5430 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5443 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5431 5444
5432 // Verify that the correct histogram entry (and only that) was logged. 5445 // Verify that the correct histogram entry (and only that) was logged.
5433 ExpectUniqueCardUploadDecision(histogram_tester, 5446 ExpectUniqueCardUploadDecision(histogram_tester,
5434 AutofillMetrics::UPLOAD_OFFERED); 5447 AutofillMetrics::UPLOAD_OFFERED);
5435 } 5448 }
5436 5449
5437 TEST_F(AutofillManagerTest, 5450 TEST_F(AutofillManagerTest,
5438 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) { 5451 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) {
5452 EnableUkmLogging();
5439 personal_data_.ClearAutofillProfiles(); 5453 personal_data_.ClearAutofillProfiles();
5440 autofill_manager_->set_credit_card_upload_enabled(true); 5454 autofill_manager_->set_credit_card_upload_enabled(true);
5441 5455
5442 // Don't fill or submit an address form. 5456 // Don't fill or submit an address form.
5443 5457
5444 // Set up our credit card form data. 5458 // Set up our credit card form data.
5445 FormData credit_card_form; 5459 FormData credit_card_form;
5446 CreateTestCreditCardFormData(&credit_card_form, true, false); 5460 CreateTestCreditCardFormData(&credit_card_form, true, false);
5447 FormsSeen(std::vector<FormData>(1, credit_card_form)); 5461 FormsSeen(std::vector<FormData>(1, credit_card_form));
5448 5462
(...skipping 30 matching lines...) Expand all
5479 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5493 EXPECT_EQ(1, rappor_service->GetReportsCount());
5480 std::string sample; 5494 std::string sample;
5481 rappor::RapporType type; 5495 rappor::RapporType type;
5482 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5496 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5483 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5497 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
5484 EXPECT_EQ("myform.com", sample); 5498 EXPECT_EQ("myform.com", sample);
5485 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5499 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5486 } 5500 }
5487 5501
5488 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) { 5502 TEST_F(AutofillManagerTest, UploadCreditCard_NoNameAvailable) {
5503 EnableUkmLogging();
5489 personal_data_.ClearAutofillProfiles(); 5504 personal_data_.ClearAutofillProfiles();
5490 autofill_manager_->set_credit_card_upload_enabled(true); 5505 autofill_manager_->set_credit_card_upload_enabled(true);
5491 5506
5492 // Create, fill and submit an address form in order to establish a recent 5507 // Create, fill and submit an address form in order to establish a recent
5493 // profile which can be selected for the upload request. 5508 // profile which can be selected for the upload request.
5494 FormData address_form; 5509 FormData address_form;
5495 test::CreateTestAddressFormData(&address_form); 5510 test::CreateTestAddressFormData(&address_form);
5496 FormsSeen(std::vector<FormData>(1, address_form)); 5511 FormsSeen(std::vector<FormData>(1, address_form));
5497 // But omit the name: 5512 // But omit the name:
5498 ManuallyFillAddressForm("", "", "77401", "US", &address_form); 5513 ManuallyFillAddressForm("", "", "77401", "US", &address_form);
(...skipping 28 matching lines...) Expand all
5527 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5542 EXPECT_EQ(1, rappor_service->GetReportsCount());
5528 std::string sample; 5543 std::string sample;
5529 rappor::RapporType type; 5544 rappor::RapporType type;
5530 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5545 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5531 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); 5546 "Autofill.CardUploadNotOfferedNoName", &sample, &type));
5532 EXPECT_EQ("myform.com", sample); 5547 EXPECT_EQ("myform.com", sample);
5533 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5548 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
5534 } 5549 }
5535 5550
5536 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) { 5551 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesConflict) {
5552 EnableUkmLogging();
5537 personal_data_.ClearAutofillProfiles(); 5553 personal_data_.ClearAutofillProfiles();
5538 autofill_manager_->set_credit_card_upload_enabled(true); 5554 autofill_manager_->set_credit_card_upload_enabled(true);
5539 5555
5540 // Create, fill and submit two address forms with different zip codes. 5556 // Create, fill and submit two address forms with different zip codes.
5541 FormData address_form1, address_form2; 5557 FormData address_form1, address_form2;
5542 test::CreateTestAddressFormData(&address_form1); 5558 test::CreateTestAddressFormData(&address_form1);
5543 test::CreateTestAddressFormData(&address_form2); 5559 test::CreateTestAddressFormData(&address_form2);
5544 5560
5545 std::vector<FormData> address_forms; 5561 std::vector<FormData> address_forms;
5546 address_forms.push_back(address_form1); 5562 address_forms.push_back(address_form1);
(...skipping 29 matching lines...) Expand all
5576 5592
5577 // Verify that the correct histogram entry (and only that) was logged. 5593 // Verify that the correct histogram entry (and only that) was logged.
5578 ExpectUniqueCardUploadDecision( 5594 ExpectUniqueCardUploadDecision(
5579 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); 5595 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5580 // Verify that the correct UKM was logged. 5596 // Verify that the correct UKM was logged.
5581 ExpectCardUploadDecisionUkm( 5597 ExpectCardUploadDecisionUkm(
5582 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); 5598 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5583 } 5599 }
5584 5600
5585 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { 5601 TEST_F(AutofillManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) {
5602 EnableUkmLogging();
5586 personal_data_.ClearAutofillProfiles(); 5603 personal_data_.ClearAutofillProfiles();
5587 autofill_manager_->set_credit_card_upload_enabled(true); 5604 autofill_manager_->set_credit_card_upload_enabled(true);
5588 5605
5589 // Create, fill and submit two address forms with different zip codes. 5606 // Create, fill and submit two address forms with different zip codes.
5590 FormData address_form1, address_form2; 5607 FormData address_form1, address_form2;
5591 test::CreateTestAddressFormData(&address_form1); 5608 test::CreateTestAddressFormData(&address_form1);
5592 test::CreateTestAddressFormData(&address_form2); 5609 test::CreateTestAddressFormData(&address_form2);
5593 5610
5594 std::vector<FormData> address_forms; 5611 std::vector<FormData> address_forms;
5595 address_forms.push_back(address_form1); 5612 address_forms.push_back(address_form1);
(...skipping 26 matching lines...) Expand all
5622 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5639 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5623 5640
5624 // Verify that the correct histogram entry (and only that) was logged. 5641 // Verify that the correct histogram entry (and only that) was logged.
5625 ExpectUniqueCardUploadDecision(histogram_tester, 5642 ExpectUniqueCardUploadDecision(histogram_tester,
5626 AutofillMetrics::UPLOAD_OFFERED); 5643 AutofillMetrics::UPLOAD_OFFERED);
5627 // Verify that the correct UKM was logged. 5644 // Verify that the correct UKM was logged.
5628 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5645 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5629 } 5646 }
5630 5647
5631 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) { 5648 TEST_F(AutofillManagerTest, UploadCreditCard_NoZipCodeAvailable) {
5649 EnableUkmLogging();
5632 personal_data_.ClearAutofillProfiles(); 5650 personal_data_.ClearAutofillProfiles();
5633 autofill_manager_->set_credit_card_upload_enabled(true); 5651 autofill_manager_->set_credit_card_upload_enabled(true);
5634 5652
5635 // Create, fill and submit an address form in order to establish a recent 5653 // Create, fill and submit an address form in order to establish a recent
5636 // profile which can be selected for the upload request. 5654 // profile which can be selected for the upload request.
5637 FormData address_form; 5655 FormData address_form;
5638 test::CreateTestAddressFormData(&address_form); 5656 test::CreateTestAddressFormData(&address_form);
5639 FormsSeen(std::vector<FormData>(1, address_form)); 5657 FormsSeen(std::vector<FormData>(1, address_form));
5640 // Autofill's validation requirements for Venezuala ("VE", see 5658 // Autofill's validation requirements for Venezuala ("VE", see
5641 // src/components/autofill/core/browser/country_data.cc) do not require zip 5659 // src/components/autofill/core/browser/country_data.cc) do not require zip
(...skipping 25 matching lines...) Expand all
5667 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5685 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5668 5686
5669 // Verify that the correct histogram entry (and only that) was logged. 5687 // Verify that the correct histogram entry (and only that) was logged.
5670 ExpectUniqueCardUploadDecision( 5688 ExpectUniqueCardUploadDecision(
5671 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); 5689 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5672 // Verify that the correct UKM was logged. 5690 // Verify that the correct UKM was logged.
5673 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); 5691 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5674 } 5692 }
5675 5693
5676 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleInitial) { 5694 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleInitial) {
5695 EnableUkmLogging();
5677 personal_data_.ClearAutofillProfiles(); 5696 personal_data_.ClearAutofillProfiles();
5678 autofill_manager_->set_credit_card_upload_enabled(true); 5697 autofill_manager_->set_credit_card_upload_enabled(true);
5679 5698
5680 // Create, fill and submit two address forms with different names. 5699 // Create, fill and submit two address forms with different names.
5681 FormData address_form1, address_form2; 5700 FormData address_form1, address_form2;
5682 test::CreateTestAddressFormData(&address_form1); 5701 test::CreateTestAddressFormData(&address_form1);
5683 test::CreateTestAddressFormData(&address_form2); 5702 test::CreateTestAddressFormData(&address_form2);
5684 FormsSeen({address_form1, address_form2}); 5703 FormsSeen({address_form1, address_form2});
5685 5704
5686 // Names can be different case. 5705 // Names can be different case.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5757 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5776 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5758 FormSubmitted(credit_card_form); 5777 FormSubmitted(credit_card_form);
5759 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5778 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5760 5779
5761 // Verify that the correct histogram entry (and only that) was logged. 5780 // Verify that the correct histogram entry (and only that) was logged.
5762 ExpectUniqueCardUploadDecision(histogram_tester, 5781 ExpectUniqueCardUploadDecision(histogram_tester,
5763 AutofillMetrics::UPLOAD_OFFERED); 5782 AutofillMetrics::UPLOAD_OFFERED);
5764 } 5783 }
5765 5784
5766 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { 5785 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) {
5786 EnableUkmLogging();
5767 personal_data_.ClearAutofillProfiles(); 5787 personal_data_.ClearAutofillProfiles();
5768 autofill_manager_->set_credit_card_upload_enabled(true); 5788 autofill_manager_->set_credit_card_upload_enabled(true);
5769 5789
5770 // Create, fill and submit two address forms with different names. 5790 // Create, fill and submit two address forms with different names.
5771 FormData address_form1, address_form2; 5791 FormData address_form1, address_form2;
5772 test::CreateTestAddressFormData(&address_form1); 5792 test::CreateTestAddressFormData(&address_form1);
5773 test::CreateTestAddressFormData(&address_form2); 5793 test::CreateTestAddressFormData(&address_form2);
5774 FormsSeen({address_form1, address_form2}); 5794 FormsSeen({address_form1, address_form2});
5775 5795
5776 // Names can have different variations of middle initials. 5796 // Names can have different variations of middle initials.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5841 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5861 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5842 FormSubmitted(credit_card_form); 5862 FormSubmitted(credit_card_form);
5843 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5863 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5844 5864
5845 // Verify that the correct histogram entry (and only that) was logged. 5865 // Verify that the correct histogram entry (and only that) was logged.
5846 ExpectUniqueCardUploadDecision(histogram_tester, 5866 ExpectUniqueCardUploadDecision(histogram_tester,
5847 AutofillMetrics::UPLOAD_OFFERED); 5867 AutofillMetrics::UPLOAD_OFFERED);
5848 } 5868 }
5849 5869
5850 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleName) { 5870 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormHasMiddleName) {
5871 EnableUkmLogging();
5851 personal_data_.ClearAutofillProfiles(); 5872 personal_data_.ClearAutofillProfiles();
5852 autofill_manager_->set_credit_card_upload_enabled(true); 5873 autofill_manager_->set_credit_card_upload_enabled(true);
5853 5874
5854 // Create, fill and submit address form without middle name. 5875 // Create, fill and submit address form without middle name.
5855 FormData address_form; 5876 FormData address_form;
5856 test::CreateTestAddressFormData(&address_form); 5877 test::CreateTestAddressFormData(&address_form);
5857 FormsSeen({address_form}); 5878 FormsSeen({address_form});
5858 ManuallyFillAddressForm("John", "Adams", "77401", "US", &address_form); 5879 ManuallyFillAddressForm("John", "Adams", "77401", "US", &address_form);
5859 FormSubmitted(address_form); 5880 FormSubmitted(address_form);
5860 5881
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5916 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5937 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5917 FormSubmitted(credit_card_form); 5938 FormSubmitted(credit_card_form);
5918 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5939 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5919 5940
5920 // Verify that the correct histogram entry (and only that) was logged. 5941 // Verify that the correct histogram entry (and only that) was logged.
5921 ExpectUniqueCardUploadDecision( 5942 ExpectUniqueCardUploadDecision(
5922 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); 5943 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
5923 } 5944 }
5924 5945
5925 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormRemovesMiddleName) { 5946 TEST_F(AutofillManagerTest, UploadCreditCard_CCFormRemovesMiddleName) {
5947 EnableUkmLogging();
5926 personal_data_.ClearAutofillProfiles(); 5948 personal_data_.ClearAutofillProfiles();
5927 autofill_manager_->set_credit_card_upload_enabled(true); 5949 autofill_manager_->set_credit_card_upload_enabled(true);
5928 5950
5929 // Create, fill and submit address form with middle name. 5951 // Create, fill and submit address form with middle name.
5930 FormData address_form; 5952 FormData address_form;
5931 test::CreateTestAddressFormData(&address_form); 5953 test::CreateTestAddressFormData(&address_form);
5932 FormsSeen({address_form}); 5954 FormsSeen({address_form});
5933 ManuallyFillAddressForm("John Quincy", "Adams", "77401", "US", &address_form); 5955 ManuallyFillAddressForm("John Quincy", "Adams", "77401", "US", &address_form);
5934 FormSubmitted(address_form); 5956 FormSubmitted(address_form);
5935 5957
(...skipping 17 matching lines...) Expand all
5953 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5975 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5954 5976
5955 // Verify that the correct histogram entry (and only that) was logged. 5977 // Verify that the correct histogram entry (and only that) was logged.
5956 ExpectUniqueCardUploadDecision(histogram_tester, 5978 ExpectUniqueCardUploadDecision(histogram_tester,
5957 AutofillMetrics::UPLOAD_OFFERED); 5979 AutofillMetrics::UPLOAD_OFFERED);
5958 // Verify that the correct UKM was logged. 5980 // Verify that the correct UKM was logged.
5959 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5981 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5960 } 5982 }
5961 5983
5962 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) { 5984 TEST_F(AutofillManagerTest, UploadCreditCard_NamesHaveToMatch) {
5985 EnableUkmLogging();
5963 personal_data_.ClearAutofillProfiles(); 5986 personal_data_.ClearAutofillProfiles();
5964 autofill_manager_->set_credit_card_upload_enabled(true); 5987 autofill_manager_->set_credit_card_upload_enabled(true);
5965 5988
5966 // Create, fill and submit two address forms with different names. 5989 // Create, fill and submit two address forms with different names.
5967 FormData address_form1, address_form2; 5990 FormData address_form1, address_form2;
5968 test::CreateTestAddressFormData(&address_form1); 5991 test::CreateTestAddressFormData(&address_form1);
5969 test::CreateTestAddressFormData(&address_form2); 5992 test::CreateTestAddressFormData(&address_form2);
5970 5993
5971 std::vector<FormData> address_forms; 5994 std::vector<FormData> address_forms;
5972 address_forms.push_back(address_form1); 5995 address_forms.push_back(address_form1);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
6212 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 6235 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
6213 6236
6214 // Verify that UMA for "DaysSincePreviousUse" is logged. 6237 // Verify that UMA for "DaysSincePreviousUse" is logged.
6215 histogram_tester.ExpectUniqueSample( 6238 histogram_tester.ExpectUniqueSample(
6216 "Autofill.DaysSincePreviousUseAtSubmission.Profile", 6239 "Autofill.DaysSincePreviousUseAtSubmission.Profile",
6217 (kMuchLaterTime - kArbitraryTime).InDays(), 6240 (kMuchLaterTime - kArbitraryTime).InDays(),
6218 /*expected_count=*/1); 6241 /*expected_count=*/1);
6219 } 6242 }
6220 6243
6221 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) { 6244 TEST_F(AutofillManagerTest, UploadCreditCard_UploadDetailsFails) {
6245 EnableUkmLogging();
6222 personal_data_.ClearAutofillProfiles(); 6246 personal_data_.ClearAutofillProfiles();
6223 autofill_manager_->set_credit_card_upload_enabled(true); 6247 autofill_manager_->set_credit_card_upload_enabled(true);
6224 6248
6225 // Anything other than "en-US" will cause GetUploadDetails to return a failure 6249 // Anything other than "en-US" will cause GetUploadDetails to return a failure
6226 // response. 6250 // response.
6227 autofill_manager_->set_app_locale("pt-BR"); 6251 autofill_manager_->set_app_locale("pt-BR");
6228 6252
6229 // Create, fill and submit an address form in order to establish a recent 6253 // Create, fill and submit an address form in order to establish a recent
6230 // profile which can be selected for the upload request. 6254 // profile which can be selected for the upload request.
6231 FormData address_form; 6255 FormData address_form;
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
6860 // Suggestions should be displayed. 6884 // Suggestions should be displayed.
6861 for (const FormFieldData& field : form.fields) { 6885 for (const FormFieldData& field : form.fields) {
6862 GetAutofillSuggestions(form, field); 6886 GetAutofillSuggestions(form, field);
6863 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 6887 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
6864 } 6888 }
6865 } 6889 }
6866 6890
6867 // Test that a sign-in form submission sends an upload with types matching the 6891 // Test that a sign-in form submission sends an upload with types matching the
6868 // fields. 6892 // fields.
6869 TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) { 6893 TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) {
6894 EnableUkmLogging();
6870 // Set up our form data (it's already filled out with user data). 6895 // Set up our form data (it's already filled out with user data).
6871 FormData form; 6896 FormData form;
6872 form.origin = GURL("http://myform.com/form.html"); 6897 form.origin = GURL("http://myform.com/form.html");
6873 form.action = GURL("http://myform.com/submit.html"); 6898 form.action = GURL("http://myform.com/submit.html");
6874 6899
6875 std::vector<ServerFieldTypeSet> expected_types; 6900 std::vector<ServerFieldTypeSet> expected_types;
6876 ServerFieldTypeSet types; 6901 ServerFieldTypeSet types;
6877 6902
6878 FormFieldData field; 6903 FormFieldData field;
6879 test::CreateTestFormField("Email", "email", "theking@gmail.com", "text", 6904 test::CreateTestFormField("Email", "email", "theking@gmail.com", "text",
6880 &field); 6905 &field);
6881 form.fields.push_back(field); 6906 form.fields.push_back(field);
6882 types.insert(EMAIL_ADDRESS); 6907 types.insert(EMAIL_ADDRESS);
6883 expected_types.push_back(types); 6908 expected_types.push_back(types);
6884 6909
6885 test::CreateTestFormField("Password", "pw", "secret", "password", &field); 6910 test::CreateTestFormField("Password", "pw", "secret", "password", &field);
6886 form.fields.push_back(field); 6911 form.fields.push_back(field);
6887 FormsSeen(std::vector<FormData>(1, form));
6888 types.clear(); 6912 types.clear();
6889 types.insert(PASSWORD); 6913 types.insert(PASSWORD);
6890 expected_types.push_back(types); 6914 expected_types.push_back(types);
6891 6915
6892 FormsSeen({form}); 6916 FormsSeen({form});
6893 6917
6894 // We will expect these types in the upload and no observed submission. (the 6918 // We will expect these types in the upload and no observed submission. (the
6895 // callback initiated by WaitForAsyncUploadProcess checks these expectations.) 6919 // callback initiated by WaitForAsyncUploadProcess checks these expectations.)
6896 autofill_manager_->set_expected_submitted_field_types(expected_types); 6920 autofill_manager_->set_expected_submitted_field_types(expected_types);
6897 autofill_manager_->set_expected_observed_submission(true); 6921 autofill_manager_->set_expected_observed_submission(true);
(...skipping 15 matching lines...) Expand all
6913 6937
6914 // Wait for upload to complete (will check expected types as well). 6938 // Wait for upload to complete (will check expected types as well).
6915 autofill_manager_->WaitForAsyncUploadProcess(); 6939 autofill_manager_->WaitForAsyncUploadProcess();
6916 6940
6917 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); 6941 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
6918 EXPECT_NE(uploaded_available_types.end(), 6942 EXPECT_NE(uploaded_available_types.end(),
6919 uploaded_available_types.find(autofill::PASSWORD)); 6943 uploaded_available_types.find(autofill::PASSWORD));
6920 } 6944 }
6921 6945
6922 } // namespace autofill 6946 } // 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