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

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

Issue 2849753002: Logs all reasons card upload was not offered in UKM and UMA. (Closed)
Patch Set: Uses bitmask to log both UKM and UMA metrics. 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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
1118 if (!(upload_decision & AutofillMetrics::UPLOAD_OFFERED))
1119 expected_metric_value |= AutofillMetrics::UPLOAD_NOT_OFFERED;
1104 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, 1120 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
1105 internal::kUKMCardUploadDecisionEntryName, 1121 internal::kUKMCardUploadDecisionEntryName,
1106 static_cast<int>(upload_decision), 1122 expected_metric_value, 1 /* expected_num_matching_entries */);
1107 1 /* expected_num_matching_entries */);
1108 } 1123 }
1109 1124
1110 void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) { 1125 void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) {
1111 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, 1126 ExpectMetric(internal::kUKMDeveloperEngagementMetricName,
1112 internal::kUKMDeveloperEngagementEntryName, 1127 internal::kUKMDeveloperEngagementEntryName,
1113 static_cast<int>( 1128 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS,
1114 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS),
1115 num_fillable_forms_parsed); 1129 num_fillable_forms_parsed);
1116 } 1130 }
1117 1131
1118 void ExpectMetric(const char* metric_name, 1132 void ExpectMetric(const char* metric_name,
1119 const char* entry_name, 1133 const char* entry_name,
1120 int metric_value, 1134 int expected_metric_value,
1121 int expected_num_matching_entries) { 1135 int expected_num_matching_entries) {
1122 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); 1136 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
1123 1137
1124 int num_matching_entries = 0; 1138 int num_matching_entries = 0;
1125 for (size_t i = 0; i < ukm_service->entries_count(); ++i) { 1139 for (size_t i = 0; i < ukm_service->entries_count(); ++i) {
1126 const ukm::UkmEntry* entry = ukm_service->GetEntry(i); 1140 const ukm::UkmEntry* entry = ukm_service->GetEntry(i);
1127 1141
1128 ukm::Entry entry_proto; 1142 ukm::Entry entry_proto;
1129 entry->PopulateProto(&entry_proto); 1143 entry->PopulateProto(&entry_proto);
1130 EXPECT_EQ(entry->source_id(), entry_proto.source_id()); 1144 EXPECT_EQ(entry->source_id(), entry_proto.source_id());
1131 1145
1132 // Check if there is an entry for |entry_name|. 1146 // Check if there is an entry for |entry_name|.
1133 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) { 1147 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) {
1134 EXPECT_EQ(1, entry_proto.metrics_size()); 1148 EXPECT_EQ(1, entry_proto.metrics_size());
1135 1149
1136 // Check that the expected |metric_value| is logged. 1150 // Check that the expected |metric_value| is logged.
1137 const ukm::Entry_Metric* metric = 1151 const ukm::Entry_Metric* metric =
1138 FindMetric(metric_name, entry_proto.metrics()); 1152 FindMetric(metric_name, entry_proto.metrics());
1139 ASSERT_NE(nullptr, metric); 1153 ASSERT_NE(nullptr, metric);
1140 EXPECT_EQ(metric_value, metric->value()); 1154 EXPECT_EQ(expected_metric_value, metric->value());
1141 ++num_matching_entries; 1155 ++num_matching_entries;
1142 } 1156 }
1143 } 1157 }
1144 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); 1158 EXPECT_EQ(expected_num_matching_entries, num_matching_entries);
1145 } 1159 }
1146 1160
1147 protected: 1161 protected:
1148 base::test::ScopedTaskEnvironment scoped_task_environment_; 1162 base::test::ScopedTaskEnvironment scoped_task_environment_;
1149 MockAutofillClient autofill_client_; 1163 MockAutofillClient autofill_client_;
1150 std::unique_ptr<MockAutofillDriver> autofill_driver_; 1164 std::unique_ptr<MockAutofillDriver> autofill_driver_;
1151 std::unique_ptr<TestAutofillManager> autofill_manager_; 1165 std::unique_ptr<TestAutofillManager> autofill_manager_;
1152 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; 1166 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_;
1153 scoped_refptr<net::TestURLRequestContextGetter> request_context_; 1167 scoped_refptr<net::TestURLRequestContextGetter> request_context_;
1154 TestAutofillDownloadManager* download_manager_; 1168 TestAutofillDownloadManager* download_manager_;
1155 TestPersonalDataManager personal_data_; 1169 TestPersonalDataManager personal_data_;
1156 base::FieldTrialList field_trial_list_; 1170 base::FieldTrialList field_trial_list_;
1157 base::test::ScopedFeatureList scoped_feature_list_; 1171 base::test::ScopedFeatureList scoped_feature_list_;
1172
1173 private:
1174 int ToHistogramSample(AutofillMetrics::CardUploadDecisionMetric metric) {
1175 for (int sample = 0; sample < metric + 1; ++sample)
1176 if (metric & (1 << sample))
1177 return sample;
1178
1179 NOTREACHED();
1180 return 0;
1181 }
1158 }; 1182 };
1159 1183
1160 class TestFormStructure : public FormStructure { 1184 class TestFormStructure : public FormStructure {
1161 public: 1185 public:
1162 explicit TestFormStructure(const FormData& form) : FormStructure(form) {} 1186 explicit TestFormStructure(const FormData& form) : FormStructure(form) {}
1163 ~TestFormStructure() override {} 1187 ~TestFormStructure() override {}
1164 1188
1165 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, 1189 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types,
1166 const std::vector<ServerFieldType>& server_types) { 1190 const std::vector<ServerFieldType>& server_types) {
1167 ASSERT_EQ(field_count(), heuristic_types.size()); 1191 ASSERT_EQ(field_count(), heuristic_types.size());
(...skipping 3468 matching lines...) Expand 10 before | Expand all | Expand 10 after
4636 4660
4637 base::HistogramTester histogram_tester; 4661 base::HistogramTester histogram_tester;
4638 4662
4639 FormSubmitted(credit_card_form); 4663 FormSubmitted(credit_card_form);
4640 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 4664 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4641 4665
4642 // Server did not send a server_id, expect copy of card is not stored. 4666 // Server did not send a server_id, expect copy of card is not stored.
4643 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty()); 4667 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty());
4644 4668
4645 // Verify that the correct histogram entry (and only that) was logged. 4669 // Verify that the correct histogram entry (and only that) was logged.
4646 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 4670 ExpectUniqueCardUploadDecision(histogram_tester,
4647 AutofillMetrics::UPLOAD_OFFERED, 1); 4671 AutofillMetrics::UPLOAD_OFFERED);
4648 // Verify that the correct UKM was logged. 4672 // Verify that the correct UKM was logged.
4649 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 4673 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
4650 } 4674 }
4651 4675
4652 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 4676 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4653 #if defined(OS_ANDROID) 4677 #if defined(OS_ANDROID)
4654 #define MAYBE_UploadCreditCardAndSaveCopy DISABLED_UploadCreditCardAndSaveCopy 4678 #define MAYBE_UploadCreditCardAndSaveCopy DISABLED_UploadCreditCardAndSaveCopy
4655 #else 4679 #else
4656 #define MAYBE_UploadCreditCardAndSaveCopy UploadCreditCardAndSaveCopy 4680 #define MAYBE_UploadCreditCardAndSaveCopy UploadCreditCardAndSaveCopy
4657 #endif 4681 #endif
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4733 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 4757 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4734 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 4758 credit_card_form.fields[4].value = ASCIIToUTF16("123");
4735 4759
4736 base::HistogramTester histogram_tester; 4760 base::HistogramTester histogram_tester;
4737 4761
4738 // The save prompt should be shown instead of doing an upload. 4762 // The save prompt should be shown instead of doing an upload.
4739 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); 4763 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _));
4740 FormSubmitted(credit_card_form); 4764 FormSubmitted(credit_card_form);
4741 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 4765 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4742 4766
4743 // Verify that no histogram entry was logged called. 4767 // Verify that no histogram entry was logged.
4744 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionExpanded", 0); 4768 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionMetric", 0);
4745 } 4769 }
4746 4770
4747 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 4771 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4748 #if defined(OS_ANDROID) 4772 #if defined(OS_ANDROID)
4749 #define MAYBE_UploadCreditCard_CvcUnavailable \ 4773 #define MAYBE_UploadCreditCard_CvcUnavailable \
4750 DISABLED_UploadCreditCard_CvcUnavailable 4774 DISABLED_UploadCreditCard_CvcUnavailable
4751 #else 4775 #else
4752 #define MAYBE_UploadCreditCard_CvcUnavailable UploadCreditCard_CvcUnavailable 4776 #define MAYBE_UploadCreditCard_CvcUnavailable UploadCreditCard_CvcUnavailable
4753 #endif 4777 #endif
4754 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) { 4778 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) {
(...skipping 24 matching lines...) Expand all
4779 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 4803 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4780 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING 4804 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING
4781 4805
4782 base::HistogramTester histogram_tester; 4806 base::HistogramTester histogram_tester;
4783 4807
4784 // Neither a local save nor an upload should happen in this case. 4808 // Neither a local save nor an upload should happen in this case.
4785 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 4809 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4786 FormSubmitted(credit_card_form); 4810 FormSubmitted(credit_card_form);
4787 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 4811 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4788 4812
4789 // Verify that the correct histogram entry (and only that) was logged. 4813 // Verify that the correct histogram entries were logged.
4790 histogram_tester.ExpectUniqueSample( 4814 ExpectCardUploadDecision(histogram_tester,
4791 "Autofill.CardUploadDecisionExpanded", 4815 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
4792 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 4816 ExpectCardUploadDecision(histogram_tester,
4817 AutofillMetrics::UPLOAD_NOT_OFFERED);
4793 // Verify that the correct UKM was logged. 4818 // Verify that the correct UKM was logged.
4794 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 4819 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
4795 4820
4796 rappor::TestRapporServiceImpl* rappor_service = 4821 rappor::TestRapporServiceImpl* rappor_service =
4797 autofill_client_.test_rappor_service(); 4822 autofill_client_.test_rappor_service();
4798 EXPECT_EQ(1, rappor_service->GetReportsCount()); 4823 EXPECT_EQ(1, rappor_service->GetReportsCount());
4799 std::string sample; 4824 std::string sample;
4800 rappor::RapporType type; 4825 rappor::RapporType type;
4801 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 4826 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4802 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 4827 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4837 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 4862 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4838 credit_card_form.fields[4].value = ASCIIToUTF16("1234"); 4863 credit_card_form.fields[4].value = ASCIIToUTF16("1234");
4839 4864
4840 base::HistogramTester histogram_tester; 4865 base::HistogramTester histogram_tester;
4841 4866
4842 // Neither a local save nor an upload should happen in this case. 4867 // Neither a local save nor an upload should happen in this case.
4843 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 4868 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4844 FormSubmitted(credit_card_form); 4869 FormSubmitted(credit_card_form);
4845 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 4870 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4846 4871
4847 // Verify that the correct histogram entry (and only that) was logged. 4872 // Verify that the correct histogram entries were logged.
4848 histogram_tester.ExpectUniqueSample( 4873 ExpectCardUploadDecision(histogram_tester,
4849 "Autofill.CardUploadDecisionExpanded", 4874 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
4850 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 4875 ExpectCardUploadDecision(histogram_tester,
4876 AutofillMetrics::UPLOAD_NOT_OFFERED);
4851 // Verify that the correct UKM was logged. 4877 // Verify that the correct UKM was logged.
4852 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 4878 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
4853 4879
4854 rappor::TestRapporServiceImpl* rappor_service = 4880 rappor::TestRapporServiceImpl* rappor_service =
4855 autofill_client_.test_rappor_service(); 4881 autofill_client_.test_rappor_service();
4856 EXPECT_EQ(1, rappor_service->GetReportsCount()); 4882 EXPECT_EQ(1, rappor_service->GetReportsCount());
4857 std::string sample; 4883 std::string sample;
4858 rappor::RapporType type; 4884 rappor::RapporType type;
4859 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 4885 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4860 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 4886 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4918 credit_card_form.fields[5].value = ASCIIToUTF16("123"); 4944 credit_card_form.fields[5].value = ASCIIToUTF16("123");
4919 4945
4920 base::HistogramTester histogram_tester; 4946 base::HistogramTester histogram_tester;
4921 4947
4922 // A CVC value appeared in one of the two CVC fields, upload should happen. 4948 // A CVC value appeared in one of the two CVC fields, upload should happen.
4923 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 4949 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4924 FormSubmitted(credit_card_form); 4950 FormSubmitted(credit_card_form);
4925 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 4951 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4926 4952
4927 // Verify that the correct histogram entry (and only that) was logged. 4953 // Verify that the correct histogram entry (and only that) was logged.
4928 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 4954 ExpectUniqueCardUploadDecision(histogram_tester,
4929 AutofillMetrics::UPLOAD_OFFERED, 1); 4955 AutofillMetrics::UPLOAD_OFFERED);
4930 // Verify that the correct UKM was logged. 4956 // Verify that the correct UKM was logged.
4931 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 4957 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
4932 } 4958 }
4933 4959
4934 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 4960 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4935 #if defined(OS_ANDROID) 4961 #if defined(OS_ANDROID)
4936 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ 4962 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \
4937 DISABLED_UploadCreditCard_NoCvcFieldOnForm 4963 DISABLED_UploadCreditCard_NoCvcFieldOnForm
4938 #else 4964 #else
4939 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ 4965 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4980 credit_card_form.fields[2].value = ASCIIToUTF16("11"); 5006 credit_card_form.fields[2].value = ASCIIToUTF16("11");
4981 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5007 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4982 5008
4983 base::HistogramTester histogram_tester; 5009 base::HistogramTester histogram_tester;
4984 5010
4985 // Upload should still happen as long as the user provides CVC in the bubble. 5011 // Upload should still happen as long as the user provides CVC in the bubble.
4986 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5012 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4987 FormSubmitted(credit_card_form); 5013 FormSubmitted(credit_card_form);
4988 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5014 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4989 5015
4990 // Verify that the correct histogram entry (and only that) was logged. 5016 // Verify that the correct histogram entries were logged.
4991 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 5017 ExpectCardUploadDecision(histogram_tester,
4992 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, 5018 AutofillMetrics::UPLOAD_OFFERED_NO_CVC);
4993 1); 5019 ExpectCardUploadDecision(histogram_tester, AutofillMetrics::UPLOAD_OFFERED);
4994 // Verify that the correct UKM was logged. 5020 // Verify that the correct UKM was logged.
4995 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED_NO_CVC); 5021 ExpectMetric(
5022 internal::kUKMCardUploadDecisionMetricName,
5023 internal::kUKMCardUploadDecisionEntryName,
5024 AutofillMetrics::UPLOAD_OFFERED_NO_CVC | AutofillMetrics::UPLOAD_OFFERED,
5025 1 /* expected_num_matching_entries */);
4996 } 5026 }
4997 5027
4998 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5028 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4999 #if defined(OS_ANDROID) 5029 #if defined(OS_ANDROID)
5000 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ 5030 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \
5001 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff 5031 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff
5002 #else 5032 #else
5003 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ 5033 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \
5004 UploadCreditCard_NoCvcFieldOnFormExperimentOff 5034 UploadCreditCard_NoCvcFieldOnFormExperimentOff
5005 #endif 5035 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5045 credit_card_form.fields[2].value = ASCIIToUTF16("11"); 5075 credit_card_form.fields[2].value = ASCIIToUTF16("11");
5046 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5076 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5047 5077
5048 base::HistogramTester histogram_tester; 5078 base::HistogramTester histogram_tester;
5049 5079
5050 // Neither a local save nor an upload should happen in this case. 5080 // Neither a local save nor an upload should happen in this case.
5051 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5081 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5052 FormSubmitted(credit_card_form); 5082 FormSubmitted(credit_card_form);
5053 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5083 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5054 5084
5055 // Verify that the correct histogram entry (and only that) was logged. 5085 // Verify that the correct histogram entries were logged.
5056 histogram_tester.ExpectUniqueSample( 5086 ExpectCardUploadDecision(histogram_tester,
5057 "Autofill.CardUploadDecisionExpanded", 5087 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
5058 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 5088 ExpectCardUploadDecision(histogram_tester,
5089 AutofillMetrics::UPLOAD_NOT_OFFERED);
5059 // Verify that the correct UKM was logged. 5090 // Verify that the correct UKM was logged.
5060 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 5091 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
5061 5092
5062 rappor::TestRapporServiceImpl* rappor_service = 5093 rappor::TestRapporServiceImpl* rappor_service =
5063 autofill_client_.test_rappor_service(); 5094 autofill_client_.test_rappor_service();
5064 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5095 EXPECT_EQ(1, rappor_service->GetReportsCount());
5065 std::string sample; 5096 std::string sample;
5066 rappor::RapporType type; 5097 rappor::RapporType type;
5067 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5098 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5068 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5099 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
(...skipping 28 matching lines...) Expand all
5097 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5128 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5098 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5129 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5099 5130
5100 base::HistogramTester histogram_tester; 5131 base::HistogramTester histogram_tester;
5101 5132
5102 // Neither a local save nor an upload should happen in this case. 5133 // Neither a local save nor an upload should happen in this case.
5103 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5134 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5104 FormSubmitted(credit_card_form); 5135 FormSubmitted(credit_card_form);
5105 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5136 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5106 5137
5107 // Verify that the correct histogram entry (and only that) was logged. 5138 // Verify that the correct histogram entries are logged.
5108 histogram_tester.ExpectUniqueSample( 5139 ExpectCardUploadDecision(histogram_tester,
5109 "Autofill.CardUploadDecisionExpanded", 5140 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS);
5110 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); 5141 ExpectCardUploadDecision(histogram_tester,
5142 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5143 ExpectCardUploadDecision(histogram_tester,
5144 AutofillMetrics::UPLOAD_NOT_OFFERED);
5111 // Verify that the correct UKM was logged. 5145 // Verify that the correct UKM was logged.
5112 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); 5146 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5147 internal::kUKMCardUploadDecisionEntryName,
5148 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS |
5149 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE |
5150 AutofillMetrics::UPLOAD_NOT_OFFERED,
5151 1 /* expected_num_matching_entries */);
5113 5152
5114 rappor::TestRapporServiceImpl* rappor_service = 5153 rappor::TestRapporServiceImpl* rappor_service =
5115 autofill_client_.test_rappor_service(); 5154 autofill_client_.test_rappor_service();
5116 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5155 EXPECT_EQ(1, rappor_service->GetReportsCount());
5117 std::string sample; 5156 std::string sample;
5118 rappor::RapporType type; 5157 rappor::RapporType type;
5119 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5158 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5120 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); 5159 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type));
5121 EXPECT_EQ("myform.com", sample); 5160 EXPECT_EQ("myform.com", sample);
5122 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5161 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
(...skipping 29 matching lines...) Expand all
5152 5191
5153 base::HistogramTester histogram_tester; 5192 base::HistogramTester histogram_tester;
5154 5193
5155 // Neither a local save nor an upload should happen in this case. 5194 // 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 5195 // 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. 5196 // profile, but the no CVC case should have priority over being reported.
5158 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5197 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5159 FormSubmitted(credit_card_form); 5198 FormSubmitted(credit_card_form);
5160 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5199 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5161 5200
5162 // Verify that the correct histogram entry (and only that) was logged. 5201 // Verify that the correct histogram entries were logged.
5163 histogram_tester.ExpectUniqueSample( 5202 ExpectCardUploadDecision(histogram_tester,
5164 "Autofill.CardUploadDecisionExpanded", 5203 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
5165 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 5204 ExpectCardUploadDecision(histogram_tester,
5205 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS);
5206 ExpectCardUploadDecision(histogram_tester,
5207 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5208 ExpectCardUploadDecision(histogram_tester,
5209 AutofillMetrics::UPLOAD_NOT_OFFERED);
5166 // Verify that the correct UKM was logged. 5210 // Verify that the correct UKM was logged.
5167 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 5211 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5212 internal::kUKMCardUploadDecisionEntryName,
5213 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC |
5214 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS |
5215 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE |
5216 AutofillMetrics::UPLOAD_NOT_OFFERED,
5217 1 /* expected_num_matching_entries */);
5168 5218
5169 rappor::TestRapporServiceImpl* rappor_service = 5219 rappor::TestRapporServiceImpl* rappor_service =
5170 autofill_client_.test_rappor_service(); 5220 autofill_client_.test_rappor_service();
5171 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5221 EXPECT_EQ(1, rappor_service->GetReportsCount());
5172 std::string sample; 5222 std::string sample;
5173 rappor::RapporType type; 5223 rappor::RapporType type;
5174 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5224 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5175 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5225 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
5176 EXPECT_EQ("myform.com", sample); 5226 EXPECT_EQ("myform.com", sample);
5177 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5227 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5209 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5259 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5210 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5260 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5211 5261
5212 base::HistogramTester histogram_tester; 5262 base::HistogramTester histogram_tester;
5213 5263
5214 // Neither a local save nor an upload should happen in this case. 5264 // Neither a local save nor an upload should happen in this case.
5215 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5265 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5216 FormSubmitted(credit_card_form); 5266 FormSubmitted(credit_card_form);
5217 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5267 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5218 5268
5219 // Verify that the correct histogram entry (and only that) was logged. 5269 // Verify that the correct histogram entries were logged.
5220 histogram_tester.ExpectUniqueSample( 5270 ExpectCardUploadDecision(histogram_tester,
5221 "Autofill.CardUploadDecisionExpanded", 5271 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
5222 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); 5272 ExpectCardUploadDecision(histogram_tester,
5273 AutofillMetrics::UPLOAD_NOT_OFFERED);
5223 // Verify that the correct UKM was logged. 5274 // Verify that the correct UKM was logged.
5224 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); 5275 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
5225 5276
5226 rappor::TestRapporServiceImpl* rappor_service = 5277 rappor::TestRapporServiceImpl* rappor_service =
5227 autofill_client_.test_rappor_service(); 5278 autofill_client_.test_rappor_service();
5228 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5279 EXPECT_EQ(1, rappor_service->GetReportsCount());
5229 std::string sample; 5280 std::string sample;
5230 rappor::RapporType type; 5281 rappor::RapporType type;
5231 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5282 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5232 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); 5283 "Autofill.CardUploadNotOfferedNoName", &sample, &type));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5277 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5328 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5278 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5329 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5279 5330
5280 base::HistogramTester histogram_tester; 5331 base::HistogramTester histogram_tester;
5281 5332
5282 // Neither a local save nor an upload should happen in this case. 5333 // Neither a local save nor an upload should happen in this case.
5283 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5334 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5284 FormSubmitted(credit_card_form); 5335 FormSubmitted(credit_card_form);
5285 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5336 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5286 5337
5287 // Verify that the correct histogram entry (and only that) was logged. 5338 // Verify that the correct histogram entries were logged.
5288 histogram_tester.ExpectUniqueSample( 5339 ExpectCardUploadDecision(
5289 "Autofill.CardUploadDecisionExpanded", 5340 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5290 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); 5341 ExpectCardUploadDecision(histogram_tester,
5342 AutofillMetrics::UPLOAD_NOT_OFFERED);
5291 // Verify that the correct UKM was logged. 5343 // Verify that the correct UKM was logged.
5292 ExpectCardUploadDecisionUkm( 5344 ExpectCardUploadDecisionUkm(
5293 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); 5345 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5294 } 5346 }
5295 5347
5296 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5348 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5297 #if defined(OS_ANDROID) 5349 #if defined(OS_ANDROID)
5298 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch \ 5350 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch \
5299 DISABLED_UploadCreditCard_ZipCodesHavePrefixMatch 5351 DISABLED_UploadCreditCard_ZipCodesHavePrefixMatch
5300 #else 5352 #else
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
5335 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5387 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5336 5388
5337 base::HistogramTester histogram_tester; 5389 base::HistogramTester histogram_tester;
5338 5390
5339 // One zip is a prefix of the other, upload should happen. 5391 // One zip is a prefix of the other, upload should happen.
5340 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5392 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5341 FormSubmitted(credit_card_form); 5393 FormSubmitted(credit_card_form);
5342 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5394 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5343 5395
5344 // Verify that the correct histogram entry (and only that) was logged. 5396 // Verify that the correct histogram entry (and only that) was logged.
5345 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 5397 ExpectUniqueCardUploadDecision(histogram_tester,
5346 AutofillMetrics::UPLOAD_OFFERED, 1); 5398 AutofillMetrics::UPLOAD_OFFERED);
5347 // Verify that the correct UKM was logged. 5399 // Verify that the correct UKM was logged.
5348 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5400 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5349 } 5401 }
5350 5402
5351 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5403 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5352 #if defined(OS_ANDROID) 5404 #if defined(OS_ANDROID)
5353 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \ 5405 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \
5354 DISABLED_UploadCreditCard_NoZipCodeAvailable 5406 DISABLED_UploadCreditCard_NoZipCodeAvailable
5355 #else 5407 #else
5356 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \ 5408 #define MAYBE_UploadCreditCard_NoZipCodeAvailable \
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5440 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5389 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5441 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5390 5442
5391 base::HistogramTester histogram_tester; 5443 base::HistogramTester histogram_tester;
5392 5444
5393 // Neither a local save nor an upload should happen in this case. 5445 // Neither a local save nor an upload should happen in this case.
5394 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5446 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5395 FormSubmitted(credit_card_form); 5447 FormSubmitted(credit_card_form);
5396 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5448 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5397 5449
5398 // Verify that the correct histogram entry (and only that) was logged. 5450 // Verify that the correct histogram entries were logged.
5399 histogram_tester.ExpectUniqueSample( 5451 ExpectCardUploadDecision(histogram_tester,
5400 "Autofill.CardUploadDecisionExpanded", 5452 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5401 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); 5453 ExpectCardUploadDecision(histogram_tester,
5454 AutofillMetrics::UPLOAD_NOT_OFFERED);
5402 // Verify that the correct UKM was logged. 5455 // Verify that the correct UKM was logged.
5403 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); 5456 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5404 } 5457 }
5405 5458
5406 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5459 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5407 #if defined(OS_ANDROID) 5460 #if defined(OS_ANDROID)
5408 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ 5461 #define MAYBE_UploadCreditCard_NamesMatchLoosely \
5409 DISABLED_UploadCreditCard_NamesMatchLoosely 5462 DISABLED_UploadCreditCard_NamesMatchLoosely
5410 #else 5463 #else
5411 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ 5464 #define MAYBE_UploadCreditCard_NamesMatchLoosely \
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5448 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5501 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5449 5502
5450 base::HistogramTester histogram_tester; 5503 base::HistogramTester histogram_tester;
5451 5504
5452 // Names match loosely, upload should happen. 5505 // Names match loosely, upload should happen.
5453 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5506 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5454 FormSubmitted(credit_card_form); 5507 FormSubmitted(credit_card_form);
5455 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5508 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5456 5509
5457 // Verify that the correct histogram entry (and only that) was logged. 5510 // Verify that the correct histogram entry (and only that) was logged.
5458 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 5511 ExpectUniqueCardUploadDecision(histogram_tester,
5459 AutofillMetrics::UPLOAD_OFFERED, 1); 5512 AutofillMetrics::UPLOAD_OFFERED);
5460 // Verify that the correct UKM was logged. 5513 // Verify that the correct UKM was logged.
5461 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5514 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5462 } 5515 }
5463 5516
5464 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5517 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5465 #if defined(OS_ANDROID) 5518 #if defined(OS_ANDROID)
5466 #define MAYBE_UploadCreditCard_NamesHaveToMatch \ 5519 #define MAYBE_UploadCreditCard_NamesHaveToMatch \
5467 DISABLED_UploadCreditCard_NamesHaveToMatch 5520 DISABLED_UploadCreditCard_NamesHaveToMatch
5468 #else 5521 #else
5469 #define MAYBE_UploadCreditCard_NamesHaveToMatch \ 5522 #define MAYBE_UploadCreditCard_NamesHaveToMatch \
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5555 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5503 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5556 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5504 5557
5505 base::HistogramTester histogram_tester; 5558 base::HistogramTester histogram_tester;
5506 5559
5507 // Names are required to match, upload should not happen. 5560 // Names are required to match, upload should not happen.
5508 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5561 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5509 FormSubmitted(credit_card_form); 5562 FormSubmitted(credit_card_form);
5510 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5563 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5511 5564
5512 // Verify that the correct histogram entry (and only that) was logged. 5565 // Verify that the correct histogram entries were logged.
5513 histogram_tester.ExpectUniqueSample( 5566 ExpectCardUploadDecision(
5514 "Autofill.CardUploadDecisionExpanded", 5567 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
5515 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); 5568 ExpectCardUploadDecision(histogram_tester,
5569 AutofillMetrics::UPLOAD_NOT_OFFERED);
5516 // Verify that the correct UKM was logged. 5570 // Verify that the correct UKM was logged.
5517 ExpectCardUploadDecisionUkm( 5571 ExpectCardUploadDecisionUkm(
5518 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); 5572 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
5519 5573
5520 rappor::TestRapporServiceImpl* rappor_service = 5574 rappor::TestRapporServiceImpl* rappor_service =
5521 autofill_client_.test_rappor_service(); 5575 autofill_client_.test_rappor_service();
5522 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5576 EXPECT_EQ(1, rappor_service->GetReportsCount());
5523 std::string sample; 5577 std::string sample;
5524 rappor::RapporType type; 5578 rappor::RapporType type;
5525 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5579 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5565 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5619 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5566 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5620 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5567 5621
5568 base::HistogramTester histogram_tester; 5622 base::HistogramTester histogram_tester;
5569 5623
5570 // The save prompt should be shown instead of doing an upload. 5624 // The save prompt should be shown instead of doing an upload.
5571 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); 5625 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _));
5572 FormSubmitted(credit_card_form); 5626 FormSubmitted(credit_card_form);
5573 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5627 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5574 5628
5575 // Verify that the correct histogram entry (and only that) was logged. 5629 // Verify that the correct histogram entries were logged.
5576 histogram_tester.ExpectUniqueSample( 5630 ExpectCardUploadDecision(
5577 "Autofill.CardUploadDecisionExpanded", 5631 histogram_tester,
5578 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); 5632 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
5633 ExpectCardUploadDecision(histogram_tester,
5634 AutofillMetrics::UPLOAD_NOT_OFFERED);
5579 // Verify that the correct UKM was logged. 5635 // Verify that the correct UKM was logged.
5580 ExpectCardUploadDecisionUkm( 5636 ExpectCardUploadDecisionUkm(
5581 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); 5637 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
5582 } 5638 }
5583 5639
5584 // Verify that typing "gmail" will match "theking@gmail.com" and 5640 // Verify that typing "gmail" will match "theking@gmail.com" and
5585 // "buddy@gmail.com" when substring matching is enabled. 5641 // "buddy@gmail.com" when substring matching is enabled.
5586 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) { 5642 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) {
5587 // Token matching is currently behind a flag. 5643 // Token matching is currently behind a flag.
5588 base::CommandLine::ForCurrentProcess()->AppendSwitch( 5644 base::CommandLine::ForCurrentProcess()->AppendSwitch(
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
6190 6246
6191 // Wait for upload to complete (will check expected types as well). 6247 // Wait for upload to complete (will check expected types as well).
6192 autofill_manager_->WaitForAsyncUploadProcess(); 6248 autofill_manager_->WaitForAsyncUploadProcess();
6193 6249
6194 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); 6250 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
6195 EXPECT_NE(uploaded_available_types.end(), 6251 EXPECT_NE(uploaded_available_types.end(),
6196 uploaded_available_types.find(autofill::PASSWORD)); 6252 uploaded_available_types.find(autofill::PASSWORD));
6197 } 6253 }
6198 6254
6199 } // namespace autofill 6255 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698