| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 | 1087 |
| 1088 // Check if there is an entry for developer engagement decision. | 1088 // Check if there is an entry for developer engagement decision. |
| 1089 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), | 1089 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), |
| 1090 entry_proto.event_hash()); | 1090 entry_proto.event_hash()); |
| 1091 EXPECT_EQ(1, entry_proto.metrics_size()); | 1091 EXPECT_EQ(1, entry_proto.metrics_size()); |
| 1092 | 1092 |
| 1093 // Check that the expected developer engagement metric is logged. | 1093 // Check that the expected developer engagement metric is logged. |
| 1094 const ukm::Entry_Metric* metric = FindMetric( | 1094 const ukm::Entry_Metric* metric = FindMetric( |
| 1095 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); | 1095 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); |
| 1096 ASSERT_NE(nullptr, metric); | 1096 ASSERT_NE(nullptr, metric); |
| 1097 EXPECT_EQ(static_cast<int>( | 1097 EXPECT_EQ(1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, |
| 1098 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS), | |
| 1099 metric->value()); | 1098 metric->value()); |
| 1100 } | 1099 } |
| 1101 | 1100 |
| 1101 void ExpectUniqueCardUploadDecision( |
| 1102 const base::HistogramTester& histogram_tester, |
| 1103 AutofillMetrics::CardUploadDecisionMetric metric) { |
| 1104 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric", |
| 1105 ToHistogramSample(metric), 1); |
| 1106 } |
| 1107 |
| 1108 void ExpectCardUploadDecision( |
| 1109 const base::HistogramTester& histogram_tester, |
| 1110 AutofillMetrics::CardUploadDecisionMetric metric) { |
| 1111 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric", |
| 1112 ToHistogramSample(metric), 1); |
| 1113 } |
| 1114 |
| 1102 void ExpectCardUploadDecisionUkm( | 1115 void ExpectCardUploadDecisionUkm( |
| 1103 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | 1116 AutofillMetrics::CardUploadDecisionMetric upload_decision) { |
| 1117 int expected_metric_value = upload_decision; |
| 1104 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, | 1118 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, |
| 1105 internal::kUKMCardUploadDecisionEntryName, | 1119 internal::kUKMCardUploadDecisionEntryName, |
| 1106 static_cast<int>(upload_decision), | 1120 expected_metric_value, 1 /* expected_num_matching_entries */); |
| 1107 1 /* expected_num_matching_entries */); | |
| 1108 } | 1121 } |
| 1109 | 1122 |
| 1110 void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) { | 1123 void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) { |
| 1111 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, | 1124 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, |
| 1112 internal::kUKMDeveloperEngagementEntryName, | 1125 internal::kUKMDeveloperEngagementEntryName, |
| 1113 static_cast<int>( | 1126 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, |
| 1114 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS), | |
| 1115 num_fillable_forms_parsed); | 1127 num_fillable_forms_parsed); |
| 1116 } | 1128 } |
| 1117 | 1129 |
| 1118 void ExpectMetric(const char* metric_name, | 1130 void ExpectMetric(const char* metric_name, |
| 1119 const char* entry_name, | 1131 const char* entry_name, |
| 1120 int metric_value, | 1132 int expected_metric_value, |
| 1121 int expected_num_matching_entries) { | 1133 int expected_num_matching_entries) { |
| 1122 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1134 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 1123 | 1135 |
| 1124 int num_matching_entries = 0; | 1136 int num_matching_entries = 0; |
| 1125 for (size_t i = 0; i < ukm_service->entries_count(); ++i) { | 1137 for (size_t i = 0; i < ukm_service->entries_count(); ++i) { |
| 1126 const ukm::UkmEntry* entry = ukm_service->GetEntry(i); | 1138 const ukm::UkmEntry* entry = ukm_service->GetEntry(i); |
| 1127 | 1139 |
| 1128 ukm::Entry entry_proto; | 1140 ukm::Entry entry_proto; |
| 1129 entry->PopulateProto(&entry_proto); | 1141 entry->PopulateProto(&entry_proto); |
| 1130 EXPECT_EQ(entry->source_id(), entry_proto.source_id()); | 1142 EXPECT_EQ(entry->source_id(), entry_proto.source_id()); |
| 1131 | 1143 |
| 1132 // Check if there is an entry for |entry_name|. | 1144 // Check if there is an entry for |entry_name|. |
| 1133 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) { | 1145 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) { |
| 1134 EXPECT_EQ(1, entry_proto.metrics_size()); | 1146 EXPECT_EQ(1, entry_proto.metrics_size()); |
| 1135 | 1147 |
| 1136 // Check that the expected |metric_value| is logged. | 1148 // Check that the expected |metric_value| is logged. |
| 1137 const ukm::Entry_Metric* metric = | 1149 const ukm::Entry_Metric* metric = |
| 1138 FindMetric(metric_name, entry_proto.metrics()); | 1150 FindMetric(metric_name, entry_proto.metrics()); |
| 1139 ASSERT_NE(nullptr, metric); | 1151 ASSERT_NE(nullptr, metric); |
| 1140 EXPECT_EQ(metric_value, metric->value()); | 1152 EXPECT_EQ(expected_metric_value, metric->value()); |
| 1141 ++num_matching_entries; | 1153 ++num_matching_entries; |
| 1142 } | 1154 } |
| 1143 } | 1155 } |
| 1144 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); | 1156 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); |
| 1145 } | 1157 } |
| 1146 | 1158 |
| 1147 protected: | 1159 protected: |
| 1148 base::test::ScopedTaskEnvironment scoped_task_environment_; | 1160 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 1149 MockAutofillClient autofill_client_; | 1161 MockAutofillClient autofill_client_; |
| 1150 std::unique_ptr<MockAutofillDriver> autofill_driver_; | 1162 std::unique_ptr<MockAutofillDriver> autofill_driver_; |
| 1151 std::unique_ptr<TestAutofillManager> autofill_manager_; | 1163 std::unique_ptr<TestAutofillManager> autofill_manager_; |
| 1152 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; | 1164 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; |
| 1153 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 1165 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
| 1154 TestAutofillDownloadManager* download_manager_; | 1166 TestAutofillDownloadManager* download_manager_; |
| 1155 TestPersonalDataManager personal_data_; | 1167 TestPersonalDataManager personal_data_; |
| 1156 base::FieldTrialList field_trial_list_; | 1168 base::FieldTrialList field_trial_list_; |
| 1157 base::test::ScopedFeatureList scoped_feature_list_; | 1169 base::test::ScopedFeatureList scoped_feature_list_; |
| 1170 |
| 1171 private: |
| 1172 int ToHistogramSample(AutofillMetrics::CardUploadDecisionMetric metric) { |
| 1173 for (int sample = 0; sample < metric + 1; ++sample) |
| 1174 if (metric & (1 << sample)) |
| 1175 return sample; |
| 1176 |
| 1177 NOTREACHED(); |
| 1178 return 0; |
| 1179 } |
| 1158 }; | 1180 }; |
| 1159 | 1181 |
| 1160 class TestFormStructure : public FormStructure { | 1182 class TestFormStructure : public FormStructure { |
| 1161 public: | 1183 public: |
| 1162 explicit TestFormStructure(const FormData& form) : FormStructure(form) {} | 1184 explicit TestFormStructure(const FormData& form) : FormStructure(form) {} |
| 1163 ~TestFormStructure() override {} | 1185 ~TestFormStructure() override {} |
| 1164 | 1186 |
| 1165 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, | 1187 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, |
| 1166 const std::vector<ServerFieldType>& server_types) { | 1188 const std::vector<ServerFieldType>& server_types) { |
| 1167 ASSERT_EQ(field_count(), heuristic_types.size()); | 1189 ASSERT_EQ(field_count(), heuristic_types.size()); |
| (...skipping 3468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4636 | 4658 |
| 4637 base::HistogramTester histogram_tester; | 4659 base::HistogramTester histogram_tester; |
| 4638 | 4660 |
| 4639 FormSubmitted(credit_card_form); | 4661 FormSubmitted(credit_card_form); |
| 4640 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4662 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4641 | 4663 |
| 4642 // Server did not send a server_id, expect copy of card is not stored. | 4664 // Server did not send a server_id, expect copy of card is not stored. |
| 4643 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty()); | 4665 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty()); |
| 4644 | 4666 |
| 4645 // Verify that the correct histogram entry (and only that) was logged. | 4667 // Verify that the correct histogram entry (and only that) was logged. |
| 4646 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 4668 ExpectUniqueCardUploadDecision(histogram_tester, |
| 4647 AutofillMetrics::UPLOAD_OFFERED, 1); | 4669 AutofillMetrics::UPLOAD_OFFERED); |
| 4648 // Verify that the correct UKM was logged. | 4670 // Verify that the correct UKM was logged. |
| 4649 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 4671 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 4650 } | 4672 } |
| 4651 | 4673 |
| 4652 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 4674 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4653 #if defined(OS_ANDROID) | 4675 #if defined(OS_ANDROID) |
| 4654 #define MAYBE_UploadCreditCardAndSaveCopy DISABLED_UploadCreditCardAndSaveCopy | 4676 #define MAYBE_UploadCreditCardAndSaveCopy DISABLED_UploadCreditCardAndSaveCopy |
| 4655 #else | 4677 #else |
| 4656 #define MAYBE_UploadCreditCardAndSaveCopy UploadCreditCardAndSaveCopy | 4678 #define MAYBE_UploadCreditCardAndSaveCopy UploadCreditCardAndSaveCopy |
| 4657 #endif | 4679 #endif |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4733 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4755 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4734 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 4756 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 4735 | 4757 |
| 4736 base::HistogramTester histogram_tester; | 4758 base::HistogramTester histogram_tester; |
| 4737 | 4759 |
| 4738 // The save prompt should be shown instead of doing an upload. | 4760 // The save prompt should be shown instead of doing an upload. |
| 4739 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); | 4761 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
| 4740 FormSubmitted(credit_card_form); | 4762 FormSubmitted(credit_card_form); |
| 4741 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4763 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4742 | 4764 |
| 4743 // Verify that no histogram entry was logged called. | 4765 // Verify that no histogram entry was logged. |
| 4744 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionExpanded", 0); | 4766 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionMetric", 0); |
| 4745 } | 4767 } |
| 4746 | 4768 |
| 4747 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 4769 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4748 #if defined(OS_ANDROID) | 4770 #if defined(OS_ANDROID) |
| 4749 #define MAYBE_UploadCreditCard_CvcUnavailable \ | 4771 #define MAYBE_UploadCreditCard_CvcUnavailable \ |
| 4750 DISABLED_UploadCreditCard_CvcUnavailable | 4772 DISABLED_UploadCreditCard_CvcUnavailable |
| 4751 #else | 4773 #else |
| 4752 #define MAYBE_UploadCreditCard_CvcUnavailable UploadCreditCard_CvcUnavailable | 4774 #define MAYBE_UploadCreditCard_CvcUnavailable UploadCreditCard_CvcUnavailable |
| 4753 #endif | 4775 #endif |
| 4754 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) { | 4776 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4779 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4801 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4780 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING | 4802 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING |
| 4781 | 4803 |
| 4782 base::HistogramTester histogram_tester; | 4804 base::HistogramTester histogram_tester; |
| 4783 | 4805 |
| 4784 // Neither a local save nor an upload should happen in this case. | 4806 // Neither a local save nor an upload should happen in this case. |
| 4785 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4807 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4786 FormSubmitted(credit_card_form); | 4808 FormSubmitted(credit_card_form); |
| 4787 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4809 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4788 | 4810 |
| 4789 // Verify that the correct histogram entry (and only that) was logged. | 4811 // Verify that the correct histogram entries were logged. |
| 4790 histogram_tester.ExpectUniqueSample( | 4812 ExpectCardUploadDecision(histogram_tester, |
| 4791 "Autofill.CardUploadDecisionExpanded", | 4813 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 4792 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | |
| 4793 // Verify that the correct UKM was logged. | 4814 // Verify that the correct UKM was logged. |
| 4794 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4815 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 4795 | 4816 |
| 4796 rappor::TestRapporServiceImpl* rappor_service = | 4817 rappor::TestRapporServiceImpl* rappor_service = |
| 4797 autofill_client_.test_rappor_service(); | 4818 autofill_client_.test_rappor_service(); |
| 4798 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4819 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4799 std::string sample; | 4820 std::string sample; |
| 4800 rappor::RapporType type; | 4821 rappor::RapporType type; |
| 4801 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4822 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4802 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4823 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4837 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4858 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4838 credit_card_form.fields[4].value = ASCIIToUTF16("1234"); | 4859 credit_card_form.fields[4].value = ASCIIToUTF16("1234"); |
| 4839 | 4860 |
| 4840 base::HistogramTester histogram_tester; | 4861 base::HistogramTester histogram_tester; |
| 4841 | 4862 |
| 4842 // Neither a local save nor an upload should happen in this case. | 4863 // Neither a local save nor an upload should happen in this case. |
| 4843 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4864 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4844 FormSubmitted(credit_card_form); | 4865 FormSubmitted(credit_card_form); |
| 4845 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4866 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4846 | 4867 |
| 4847 // Verify that the correct histogram entry (and only that) was logged. | 4868 // Verify that the correct histogram entries were logged. |
| 4848 histogram_tester.ExpectUniqueSample( | 4869 ExpectCardUploadDecision(histogram_tester, |
| 4849 "Autofill.CardUploadDecisionExpanded", | 4870 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 4850 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | |
| 4851 // Verify that the correct UKM was logged. | 4871 // Verify that the correct UKM was logged. |
| 4852 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4872 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 4853 | 4873 |
| 4854 rappor::TestRapporServiceImpl* rappor_service = | 4874 rappor::TestRapporServiceImpl* rappor_service = |
| 4855 autofill_client_.test_rappor_service(); | 4875 autofill_client_.test_rappor_service(); |
| 4856 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4876 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4857 std::string sample; | 4877 std::string sample; |
| 4858 rappor::RapporType type; | 4878 rappor::RapporType type; |
| 4859 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4879 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4860 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4880 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4918 credit_card_form.fields[5].value = ASCIIToUTF16("123"); | 4938 credit_card_form.fields[5].value = ASCIIToUTF16("123"); |
| 4919 | 4939 |
| 4920 base::HistogramTester histogram_tester; | 4940 base::HistogramTester histogram_tester; |
| 4921 | 4941 |
| 4922 // A CVC value appeared in one of the two CVC fields, upload should happen. | 4942 // A CVC value appeared in one of the two CVC fields, upload should happen. |
| 4923 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4943 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4924 FormSubmitted(credit_card_form); | 4944 FormSubmitted(credit_card_form); |
| 4925 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4945 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4926 | 4946 |
| 4927 // Verify that the correct histogram entry (and only that) was logged. | 4947 // Verify that the correct histogram entry (and only that) was logged. |
| 4928 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 4948 ExpectUniqueCardUploadDecision(histogram_tester, |
| 4929 AutofillMetrics::UPLOAD_OFFERED, 1); | 4949 AutofillMetrics::UPLOAD_OFFERED); |
| 4930 // Verify that the correct UKM was logged. | 4950 // Verify that the correct UKM was logged. |
| 4931 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 4951 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 4932 } | 4952 } |
| 4933 | 4953 |
| 4934 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 4954 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4935 #if defined(OS_ANDROID) | 4955 #if defined(OS_ANDROID) |
| 4936 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ | 4956 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ |
| 4937 DISABLED_UploadCreditCard_NoCvcFieldOnForm | 4957 DISABLED_UploadCreditCard_NoCvcFieldOnForm |
| 4938 #else | 4958 #else |
| 4939 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ | 4959 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4980 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 5000 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 4981 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5001 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4982 | 5002 |
| 4983 base::HistogramTester histogram_tester; | 5003 base::HistogramTester histogram_tester; |
| 4984 | 5004 |
| 4985 // Upload should still happen as long as the user provides CVC in the bubble. | 5005 // Upload should still happen as long as the user provides CVC in the bubble. |
| 4986 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5006 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4987 FormSubmitted(credit_card_form); | 5007 FormSubmitted(credit_card_form); |
| 4988 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5008 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4989 | 5009 |
| 4990 // Verify that the correct histogram entry (and only that) was logged. | 5010 // Verify that the correct histogram entries were logged. |
| 4991 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 5011 ExpectCardUploadDecision(histogram_tester, |
| 4992 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, | 5012 AutofillMetrics::UPLOAD_OFFERED_NO_CVC); |
| 4993 1); | |
| 4994 // Verify that the correct UKM was logged. | 5013 // Verify that the correct UKM was logged. |
| 4995 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED_NO_CVC); | 5014 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, |
| 5015 internal::kUKMCardUploadDecisionEntryName, |
| 5016 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, |
| 5017 1 /* expected_num_matching_entries */); |
| 4996 } | 5018 } |
| 4997 | 5019 |
| 4998 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5020 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4999 #if defined(OS_ANDROID) | 5021 #if defined(OS_ANDROID) |
| 5000 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ | 5022 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ |
| 5001 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff | 5023 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff |
| 5002 #else | 5024 #else |
| 5003 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ | 5025 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ |
| 5004 UploadCreditCard_NoCvcFieldOnFormExperimentOff | 5026 UploadCreditCard_NoCvcFieldOnFormExperimentOff |
| 5005 #endif | 5027 #endif |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5045 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 5067 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 5046 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5068 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5047 | 5069 |
| 5048 base::HistogramTester histogram_tester; | 5070 base::HistogramTester histogram_tester; |
| 5049 | 5071 |
| 5050 // Neither a local save nor an upload should happen in this case. | 5072 // Neither a local save nor an upload should happen in this case. |
| 5051 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5073 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5052 FormSubmitted(credit_card_form); | 5074 FormSubmitted(credit_card_form); |
| 5053 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5075 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5054 | 5076 |
| 5055 // Verify that the correct histogram entry (and only that) was logged. | 5077 // Verify that the correct histogram entries were logged. |
| 5056 histogram_tester.ExpectUniqueSample( | 5078 ExpectCardUploadDecision(histogram_tester, |
| 5057 "Autofill.CardUploadDecisionExpanded", | 5079 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 5058 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | |
| 5059 // Verify that the correct UKM was logged. | 5080 // Verify that the correct UKM was logged. |
| 5060 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 5081 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 5061 | 5082 |
| 5062 rappor::TestRapporServiceImpl* rappor_service = | 5083 rappor::TestRapporServiceImpl* rappor_service = |
| 5063 autofill_client_.test_rappor_service(); | 5084 autofill_client_.test_rappor_service(); |
| 5064 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5085 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5065 std::string sample; | 5086 std::string sample; |
| 5066 rappor::RapporType type; | 5087 rappor::RapporType type; |
| 5067 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5088 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5068 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 5089 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5097 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5118 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5098 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5119 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5099 | 5120 |
| 5100 base::HistogramTester histogram_tester; | 5121 base::HistogramTester histogram_tester; |
| 5101 | 5122 |
| 5102 // Neither a local save nor an upload should happen in this case. | 5123 // Neither a local save nor an upload should happen in this case. |
| 5103 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5124 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5104 FormSubmitted(credit_card_form); | 5125 FormSubmitted(credit_card_form); |
| 5105 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5126 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5106 | 5127 |
| 5107 // Verify that the correct histogram entry (and only that) was logged. | 5128 // Verify that the correct histogram entries are logged. |
| 5108 histogram_tester.ExpectUniqueSample( | 5129 ExpectCardUploadDecision(histogram_tester, |
| 5109 "Autofill.CardUploadDecisionExpanded", | 5130 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); |
| 5110 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); | 5131 ExpectCardUploadDecision(histogram_tester, |
| 5132 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5111 // Verify that the correct UKM was logged. | 5133 // Verify that the correct UKM was logged. |
| 5112 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); | 5134 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, |
| 5135 internal::kUKMCardUploadDecisionEntryName, |
| 5136 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS | |
| 5137 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, |
| 5138 1 /* expected_num_matching_entries */); |
| 5113 | 5139 |
| 5114 rappor::TestRapporServiceImpl* rappor_service = | 5140 rappor::TestRapporServiceImpl* rappor_service = |
| 5115 autofill_client_.test_rappor_service(); | 5141 autofill_client_.test_rappor_service(); |
| 5116 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5142 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5117 std::string sample; | 5143 std::string sample; |
| 5118 rappor::RapporType type; | 5144 rappor::RapporType type; |
| 5119 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5145 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5120 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); | 5146 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); |
| 5121 EXPECT_EQ("myform.com", sample); | 5147 EXPECT_EQ("myform.com", sample); |
| 5122 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5148 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5152 | 5178 |
| 5153 base::HistogramTester histogram_tester; | 5179 base::HistogramTester histogram_tester; |
| 5154 | 5180 |
| 5155 // Neither a local save nor an upload should happen in this case. | 5181 // Neither a local save nor an upload should happen in this case. |
| 5156 // Note that AutofillManager should *check* for both no CVC and no address | 5182 // Note that AutofillManager should *check* for both no CVC and no address |
| 5157 // profile, but the no CVC case should have priority over being reported. | 5183 // profile, but the no CVC case should have priority over being reported. |
| 5158 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5184 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5159 FormSubmitted(credit_card_form); | 5185 FormSubmitted(credit_card_form); |
| 5160 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5186 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5161 | 5187 |
| 5162 // Verify that the correct histogram entry (and only that) was logged. | 5188 // Verify that the correct histogram entries were logged. |
| 5163 histogram_tester.ExpectUniqueSample( | 5189 ExpectCardUploadDecision(histogram_tester, |
| 5164 "Autofill.CardUploadDecisionExpanded", | 5190 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 5165 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | 5191 ExpectCardUploadDecision(histogram_tester, |
| 5192 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); |
| 5193 ExpectCardUploadDecision(histogram_tester, |
| 5194 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5166 // Verify that the correct UKM was logged. | 5195 // Verify that the correct UKM was logged. |
| 5167 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 5196 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, |
| 5197 internal::kUKMCardUploadDecisionEntryName, |
| 5198 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC | |
| 5199 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS | |
| 5200 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, |
| 5201 1 /* expected_num_matching_entries */); |
| 5168 | 5202 |
| 5169 rappor::TestRapporServiceImpl* rappor_service = | 5203 rappor::TestRapporServiceImpl* rappor_service = |
| 5170 autofill_client_.test_rappor_service(); | 5204 autofill_client_.test_rappor_service(); |
| 5171 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5205 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5172 std::string sample; | 5206 std::string sample; |
| 5173 rappor::RapporType type; | 5207 rappor::RapporType type; |
| 5174 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5208 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5175 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 5209 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 5176 EXPECT_EQ("myform.com", sample); | 5210 EXPECT_EQ("myform.com", sample); |
| 5177 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5211 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5209 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5243 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5210 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5244 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5211 | 5245 |
| 5212 base::HistogramTester histogram_tester; | 5246 base::HistogramTester histogram_tester; |
| 5213 | 5247 |
| 5214 // Neither a local save nor an upload should happen in this case. | 5248 // Neither a local save nor an upload should happen in this case. |
| 5215 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5249 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5216 FormSubmitted(credit_card_form); | 5250 FormSubmitted(credit_card_form); |
| 5217 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5251 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5218 | 5252 |
| 5219 // Verify that the correct histogram entry (and only that) was logged. | 5253 // Verify that the correct histogram entries were logged. |
| 5220 histogram_tester.ExpectUniqueSample( | 5254 ExpectCardUploadDecision(histogram_tester, |
| 5221 "Autofill.CardUploadDecisionExpanded", | 5255 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); |
| 5222 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); | |
| 5223 // Verify that the correct UKM was logged. | 5256 // Verify that the correct UKM was logged. |
| 5224 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); | 5257 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); |
| 5225 | 5258 |
| 5226 rappor::TestRapporServiceImpl* rappor_service = | 5259 rappor::TestRapporServiceImpl* rappor_service = |
| 5227 autofill_client_.test_rappor_service(); | 5260 autofill_client_.test_rappor_service(); |
| 5228 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5261 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5229 std::string sample; | 5262 std::string sample; |
| 5230 rappor::RapporType type; | 5263 rappor::RapporType type; |
| 5231 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5264 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5232 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); | 5265 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5277 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5310 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5278 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5311 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5279 | 5312 |
| 5280 base::HistogramTester histogram_tester; | 5313 base::HistogramTester histogram_tester; |
| 5281 | 5314 |
| 5282 // Neither a local save nor an upload should happen in this case. | 5315 // Neither a local save nor an upload should happen in this case. |
| 5283 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5316 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5284 FormSubmitted(credit_card_form); | 5317 FormSubmitted(credit_card_form); |
| 5285 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5318 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5286 | 5319 |
| 5287 // Verify that the correct histogram entry (and only that) was logged. | 5320 // Verify that the correct histogram entries were logged. |
| 5288 histogram_tester.ExpectUniqueSample( | 5321 ExpectCardUploadDecision( |
| 5289 "Autofill.CardUploadDecisionExpanded", | 5322 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); |
| 5290 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); | |
| 5291 // Verify that the correct UKM was logged. | 5323 // Verify that the correct UKM was logged. |
| 5292 ExpectCardUploadDecisionUkm( | 5324 ExpectCardUploadDecisionUkm( |
| 5293 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); | 5325 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); |
| 5294 } | 5326 } |
| 5295 | 5327 |
| 5296 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5328 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5297 #if defined(OS_ANDROID) | 5329 #if defined(OS_ANDROID) |
| 5298 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch \ | 5330 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch \ |
| 5299 DISABLED_UploadCreditCard_ZipCodesHavePrefixMatch | 5331 DISABLED_UploadCreditCard_ZipCodesHavePrefixMatch |
| 5300 #else | 5332 #else |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5335 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5367 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5336 | 5368 |
| 5337 base::HistogramTester histogram_tester; | 5369 base::HistogramTester histogram_tester; |
| 5338 | 5370 |
| 5339 // One zip is a prefix of the other, upload should happen. | 5371 // One zip is a prefix of the other, upload should happen. |
| 5340 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5372 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5341 FormSubmitted(credit_card_form); | 5373 FormSubmitted(credit_card_form); |
| 5342 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5374 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5343 | 5375 |
| 5344 // Verify that the correct histogram entry (and only that) was logged. | 5376 // Verify that the correct histogram entry (and only that) was logged. |
| 5345 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 5377 ExpectUniqueCardUploadDecision(histogram_tester, |
| 5346 AutofillMetrics::UPLOAD_OFFERED, 1); | 5378 AutofillMetrics::UPLOAD_OFFERED); |
| 5347 // Verify that the correct UKM was logged. | 5379 // Verify that the correct UKM was logged. |
| 5348 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 5380 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 5349 } | 5381 } |
| 5350 | 5382 |
| 5351 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5383 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5352 #if defined(OS_ANDROID) | 5384 #if defined(OS_ANDROID) |
| 5353 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \ | 5385 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \ |
| 5354 DISABLED_UploadCreditCard_NoZipCodeAvailable | 5386 DISABLED_UploadCreditCard_NoZipCodeAvailable |
| 5355 #else | 5387 #else |
| 5356 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \ | 5388 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5388 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5420 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5389 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5421 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5390 | 5422 |
| 5391 base::HistogramTester histogram_tester; | 5423 base::HistogramTester histogram_tester; |
| 5392 | 5424 |
| 5393 // Neither a local save nor an upload should happen in this case. | 5425 // Neither a local save nor an upload should happen in this case. |
| 5394 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5426 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5395 FormSubmitted(credit_card_form); | 5427 FormSubmitted(credit_card_form); |
| 5396 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5428 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5397 | 5429 |
| 5398 // Verify that the correct histogram entry (and only that) was logged. | 5430 // Verify that the correct histogram entries were logged. |
| 5399 histogram_tester.ExpectUniqueSample( | 5431 ExpectCardUploadDecision(histogram_tester, |
| 5400 "Autofill.CardUploadDecisionExpanded", | 5432 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5401 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); | |
| 5402 // Verify that the correct UKM was logged. | 5433 // Verify that the correct UKM was logged. |
| 5403 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); | 5434 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5404 } | 5435 } |
| 5405 | 5436 |
| 5406 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5437 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5407 #if defined(OS_ANDROID) | 5438 #if defined(OS_ANDROID) |
| 5408 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ | 5439 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ |
| 5409 DISABLED_UploadCreditCard_NamesMatchLoosely | 5440 DISABLED_UploadCreditCard_NamesMatchLoosely |
| 5410 #else | 5441 #else |
| 5411 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ | 5442 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5448 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5479 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5449 | 5480 |
| 5450 base::HistogramTester histogram_tester; | 5481 base::HistogramTester histogram_tester; |
| 5451 | 5482 |
| 5452 // Names match loosely, upload should happen. | 5483 // Names match loosely, upload should happen. |
| 5453 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5484 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5454 FormSubmitted(credit_card_form); | 5485 FormSubmitted(credit_card_form); |
| 5455 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5486 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5456 | 5487 |
| 5457 // Verify that the correct histogram entry (and only that) was logged. | 5488 // Verify that the correct histogram entry (and only that) was logged. |
| 5458 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 5489 ExpectUniqueCardUploadDecision(histogram_tester, |
| 5459 AutofillMetrics::UPLOAD_OFFERED, 1); | 5490 AutofillMetrics::UPLOAD_OFFERED); |
| 5460 // Verify that the correct UKM was logged. | 5491 // Verify that the correct UKM was logged. |
| 5461 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 5492 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 5462 } | 5493 } |
| 5463 | 5494 |
| 5464 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5495 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5465 #if defined(OS_ANDROID) | 5496 #if defined(OS_ANDROID) |
| 5466 #define MAYBE_UploadCreditCard_NamesHaveToMatch \ | 5497 #define MAYBE_UploadCreditCard_NamesHaveToMatch \ |
| 5467 DISABLED_UploadCreditCard_NamesHaveToMatch | 5498 DISABLED_UploadCreditCard_NamesHaveToMatch |
| 5468 #else | 5499 #else |
| 5469 #define MAYBE_UploadCreditCard_NamesHaveToMatch \ | 5500 #define MAYBE_UploadCreditCard_NamesHaveToMatch \ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5502 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5533 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5503 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5534 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5504 | 5535 |
| 5505 base::HistogramTester histogram_tester; | 5536 base::HistogramTester histogram_tester; |
| 5506 | 5537 |
| 5507 // Names are required to match, upload should not happen. | 5538 // Names are required to match, upload should not happen. |
| 5508 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5539 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5509 FormSubmitted(credit_card_form); | 5540 FormSubmitted(credit_card_form); |
| 5510 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5541 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5511 | 5542 |
| 5512 // Verify that the correct histogram entry (and only that) was logged. | 5543 // Verify that the correct histogram entries were logged. |
| 5513 histogram_tester.ExpectUniqueSample( | 5544 ExpectCardUploadDecision( |
| 5514 "Autofill.CardUploadDecisionExpanded", | 5545 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
| 5515 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); | |
| 5516 // Verify that the correct UKM was logged. | 5546 // Verify that the correct UKM was logged. |
| 5517 ExpectCardUploadDecisionUkm( | 5547 ExpectCardUploadDecisionUkm( |
| 5518 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); | 5548 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
| 5519 | 5549 |
| 5520 rappor::TestRapporServiceImpl* rappor_service = | 5550 rappor::TestRapporServiceImpl* rappor_service = |
| 5521 autofill_client_.test_rappor_service(); | 5551 autofill_client_.test_rappor_service(); |
| 5522 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5552 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5523 std::string sample; | 5553 std::string sample; |
| 5524 rappor::RapporType type; | 5554 rappor::RapporType type; |
| 5525 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5555 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5565 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5595 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5566 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5596 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5567 | 5597 |
| 5568 base::HistogramTester histogram_tester; | 5598 base::HistogramTester histogram_tester; |
| 5569 | 5599 |
| 5570 // The save prompt should be shown instead of doing an upload. | 5600 // The save prompt should be shown instead of doing an upload. |
| 5571 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); | 5601 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
| 5572 FormSubmitted(credit_card_form); | 5602 FormSubmitted(credit_card_form); |
| 5573 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5603 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5574 | 5604 |
| 5575 // Verify that the correct histogram entry (and only that) was logged. | 5605 // Verify that the correct histogram entries were logged. |
| 5576 histogram_tester.ExpectUniqueSample( | 5606 ExpectCardUploadDecision( |
| 5577 "Autofill.CardUploadDecisionExpanded", | 5607 histogram_tester, |
| 5578 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); | 5608 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 5579 // Verify that the correct UKM was logged. | 5609 // Verify that the correct UKM was logged. |
| 5580 ExpectCardUploadDecisionUkm( | 5610 ExpectCardUploadDecisionUkm( |
| 5581 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 5611 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 5582 } | 5612 } |
| 5583 | 5613 |
| 5584 // Verify that typing "gmail" will match "theking@gmail.com" and | 5614 // Verify that typing "gmail" will match "theking@gmail.com" and |
| 5585 // "buddy@gmail.com" when substring matching is enabled. | 5615 // "buddy@gmail.com" when substring matching is enabled. |
| 5586 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) { | 5616 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) { |
| 5587 // Token matching is currently behind a flag. | 5617 // Token matching is currently behind a flag. |
| 5588 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 5618 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6190 | 6220 |
| 6191 // Wait for upload to complete (will check expected types as well). | 6221 // Wait for upload to complete (will check expected types as well). |
| 6192 autofill_manager_->WaitForAsyncUploadProcess(); | 6222 autofill_manager_->WaitForAsyncUploadProcess(); |
| 6193 | 6223 |
| 6194 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); | 6224 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); |
| 6195 EXPECT_NE(uploaded_available_types.end(), | 6225 EXPECT_NE(uploaded_available_types.end(), |
| 6196 uploaded_available_types.find(autofill::PASSWORD)); | 6226 uploaded_available_types.find(autofill::PASSWORD)); |
| 6197 } | 6227 } |
| 6198 | 6228 |
| 6199 } // namespace autofill | 6229 } // namespace autofill |
| OLD | NEW |