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

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: Encodes enum metrics as bitmask. 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 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 1098
1099 // Check if there is an entry for developer engagement decision. 1099 // Check if there is an entry for developer engagement decision.
1100 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), 1100 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName),
1101 entry_proto.event_hash()); 1101 entry_proto.event_hash());
1102 EXPECT_EQ(1, entry_proto.metrics_size()); 1102 EXPECT_EQ(1, entry_proto.metrics_size());
1103 1103
1104 // Check that the expected developer engagement metric is logged. 1104 // Check that the expected developer engagement metric is logged.
1105 const ukm::Entry_Metric* metric = FindMetric( 1105 const ukm::Entry_Metric* metric = FindMetric(
1106 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); 1106 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics());
1107 ASSERT_NE(nullptr, metric); 1107 ASSERT_NE(nullptr, metric);
1108 EXPECT_EQ(static_cast<int>( 1108 EXPECT_EQ(1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS,
1109 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS),
1110 metric->value()); 1109 metric->value());
1111 } 1110 }
1112 1111
1113 void ExpectCardUploadDecisionUkm( 1112 void ExpectCardUploadDecisionUkm(
1114 AutofillMetrics::CardUploadDecisionMetric upload_decision) { 1113 AutofillMetrics::CardUploadDecisionMetric upload_decision) {
1114 int expected_metric_value = 1 << upload_decision;
1115 if (upload_decision != AutofillMetrics::UPLOAD_OFFERED &&
1116 upload_decision != AutofillMetrics::UPLOAD_OFFERED_NO_CVC)
1117 expected_metric_value |= 1 << AutofillMetrics::UPLOAD_NOT_OFFERED;
1115 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, 1118 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
1116 internal::kUKMCardUploadDecisionEntryName, 1119 internal::kUKMCardUploadDecisionEntryName,
1117 static_cast<int>(upload_decision), 1120 expected_metric_value, 1 /* expected_num_matching_entries */);
1118 1 /* expected_num_matching_entries */);
1119 } 1121 }
1120 1122
1121 void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) { 1123 void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) {
1122 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, 1124 ExpectMetric(internal::kUKMDeveloperEngagementMetricName,
1123 internal::kUKMDeveloperEngagementEntryName, 1125 internal::kUKMDeveloperEngagementEntryName,
1124 static_cast<int>( 1126 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS,
1125 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS),
1126 num_fillable_forms_parsed); 1127 num_fillable_forms_parsed);
1127 } 1128 }
1128 1129
1129 void ExpectMetric(const char* metric_name, 1130 void ExpectMetric(const char* metric_name,
1130 const char* entry_name, 1131 const char* entry_name,
1131 int metric_value, 1132 int expected_metric_value,
1132 int expected_num_matching_entries) { 1133 int expected_num_matching_entries) {
1133 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); 1134 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
1134 1135
1135 int num_matching_entries = 0; 1136 int num_matching_entries = 0;
1136 for (size_t i = 0; i < ukm_service->entries_count(); ++i) { 1137 for (size_t i = 0; i < ukm_service->entries_count(); ++i) {
1137 const ukm::UkmEntry* entry = ukm_service->GetEntry(i); 1138 const ukm::UkmEntry* entry = ukm_service->GetEntry(i);
1138 1139
1139 ukm::Entry entry_proto; 1140 ukm::Entry entry_proto;
1140 entry->PopulateProto(&entry_proto); 1141 entry->PopulateProto(&entry_proto);
1141 EXPECT_EQ(entry->source_id(), entry_proto.source_id()); 1142 EXPECT_EQ(entry->source_id(), entry_proto.source_id());
1142 1143
1143 // Check if there is an entry for |entry_name|. 1144 // Check if there is an entry for |entry_name|.
1144 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) { 1145 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) {
1145 EXPECT_EQ(1, entry_proto.metrics_size()); 1146 EXPECT_EQ(1, entry_proto.metrics_size());
1146 1147
1147 // Check that the expected |metric_value| is logged. 1148 // Check that the expected |metric_value| is logged.
1148 const ukm::Entry_Metric* metric = 1149 const ukm::Entry_Metric* metric =
1149 FindMetric(metric_name, entry_proto.metrics()); 1150 FindMetric(metric_name, entry_proto.metrics());
1150 ASSERT_NE(nullptr, metric); 1151 ASSERT_NE(nullptr, metric);
1151 EXPECT_EQ(metric_value, metric->value()); 1152 EXPECT_EQ(expected_metric_value, metric->value());
1152 ++num_matching_entries; 1153 ++num_matching_entries;
1153 } 1154 }
1154 } 1155 }
1155 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); 1156 EXPECT_EQ(expected_num_matching_entries, num_matching_entries);
1156 } 1157 }
1157 1158
1158 protected: 1159 protected:
1159 base::test::ScopedTaskEnvironment scoped_task_environment_; 1160 base::test::ScopedTaskEnvironment scoped_task_environment_;
1160 MockAutofillClient autofill_client_; 1161 MockAutofillClient autofill_client_;
1161 std::unique_ptr<MockAutofillDriver> autofill_driver_; 1162 std::unique_ptr<MockAutofillDriver> autofill_driver_;
(...skipping 3630 matching lines...) Expand 10 before | Expand all | Expand 10 after
4792 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 4793 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4793 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING 4794 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING
4794 4795
4795 base::HistogramTester histogram_tester; 4796 base::HistogramTester histogram_tester;
4796 4797
4797 // Neither a local save nor an upload should happen in this case. 4798 // Neither a local save nor an upload should happen in this case.
4798 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 4799 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4799 FormSubmitted(credit_card_form); 4800 FormSubmitted(credit_card_form);
4800 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 4801 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4801 4802
4802 // Verify that the correct histogram entry (and only that) was logged. 4803 // Verify that the correct histogram entries were logged.
4803 histogram_tester.ExpectUniqueSample( 4804 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
4804 "Autofill.CardUploadDecisionExpanded", 4805 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
4805 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 4806 1);
4807 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
4808 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
4806 // Verify that the correct UKM was logged. 4809 // Verify that the correct UKM was logged.
4807 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 4810 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
4808 4811
4809 rappor::TestRapporServiceImpl* rappor_service = 4812 rappor::TestRapporServiceImpl* rappor_service =
4810 autofill_client_.test_rappor_service(); 4813 autofill_client_.test_rappor_service();
4811 EXPECT_EQ(1, rappor_service->GetReportsCount()); 4814 EXPECT_EQ(1, rappor_service->GetReportsCount());
4812 std::string sample; 4815 std::string sample;
4813 rappor::RapporType type; 4816 rappor::RapporType type;
4814 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 4817 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4815 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 4818 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4848 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 4851 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4849 credit_card_form.fields[4].value = ASCIIToUTF16("1234"); 4852 credit_card_form.fields[4].value = ASCIIToUTF16("1234");
4850 4853
4851 base::HistogramTester histogram_tester; 4854 base::HistogramTester histogram_tester;
4852 4855
4853 // Neither a local save nor an upload should happen in this case. 4856 // Neither a local save nor an upload should happen in this case.
4854 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 4857 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4855 FormSubmitted(credit_card_form); 4858 FormSubmitted(credit_card_form);
4856 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 4859 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4857 4860
4858 // Verify that the correct histogram entry (and only that) was logged. 4861 // Verify that the correct histogram entries were logged.
4859 histogram_tester.ExpectUniqueSample( 4862 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
4860 "Autofill.CardUploadDecisionExpanded", 4863 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
4861 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 4864 1);
4865 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
4866 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
4862 // Verify that the correct UKM was logged. 4867 // Verify that the correct UKM was logged.
4863 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 4868 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
4864 4869
4865 rappor::TestRapporServiceImpl* rappor_service = 4870 rappor::TestRapporServiceImpl* rappor_service =
4866 autofill_client_.test_rappor_service(); 4871 autofill_client_.test_rappor_service();
4867 EXPECT_EQ(1, rappor_service->GetReportsCount()); 4872 EXPECT_EQ(1, rappor_service->GetReportsCount());
4868 std::string sample; 4873 std::string sample;
4869 rappor::RapporType type; 4874 rappor::RapporType type;
4870 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 4875 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4871 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 4876 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 credit_card_form.fields[2].value = ASCIIToUTF16("11"); 4995 credit_card_form.fields[2].value = ASCIIToUTF16("11");
4991 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 4996 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4992 4997
4993 base::HistogramTester histogram_tester; 4998 base::HistogramTester histogram_tester;
4994 4999
4995 // Upload should still happen as long as the user provides CVC in the bubble. 5000 // Upload should still happen as long as the user provides CVC in the bubble.
4996 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5001 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4997 FormSubmitted(credit_card_form); 5002 FormSubmitted(credit_card_form);
4998 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5003 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4999 5004
5000 // Verify that the correct histogram entry (and only that) was logged. 5005 // Verify that the correct histogram entries were logged.
5001 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 5006 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5002 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, 5007 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, 1);
5003 1); 5008 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5009 AutofillMetrics::UPLOAD_OFFERED, 1);
5004 // Verify that the correct UKM was logged. 5010 // Verify that the correct UKM was logged.
5005 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED_NO_CVC); 5011 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5012 internal::kUKMCardUploadDecisionEntryName,
5013 (1 << AutofillMetrics::UPLOAD_OFFERED_NO_CVC) |
5014 (1 << AutofillMetrics::UPLOAD_OFFERED),
5015 1 /* expected_num_matching_entries */);
5006 } 5016 }
5007 5017
5008 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5018 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5009 #if defined(OS_ANDROID) 5019 #if defined(OS_ANDROID)
5010 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ 5020 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \
5011 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff 5021 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff
5012 #else 5022 #else
5013 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ 5023 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \
5014 UploadCreditCard_NoCvcFieldOnFormExperimentOff 5024 UploadCreditCard_NoCvcFieldOnFormExperimentOff
5015 #endif 5025 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5055 credit_card_form.fields[2].value = ASCIIToUTF16("11"); 5065 credit_card_form.fields[2].value = ASCIIToUTF16("11");
5056 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5066 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5057 5067
5058 base::HistogramTester histogram_tester; 5068 base::HistogramTester histogram_tester;
5059 5069
5060 // Neither a local save nor an upload should happen in this case. 5070 // Neither a local save nor an upload should happen in this case.
5061 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5071 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5062 FormSubmitted(credit_card_form); 5072 FormSubmitted(credit_card_form);
5063 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5073 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5064 5074
5065 // Verify that the correct histogram entry (and only that) was logged. 5075 // Verify that the correct histogram entries were logged.
5066 histogram_tester.ExpectUniqueSample( 5076 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5067 "Autofill.CardUploadDecisionExpanded", 5077 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
5068 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 5078 1);
5079 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5080 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5069 // Verify that the correct UKM was logged. 5081 // Verify that the correct UKM was logged.
5070 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 5082 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
5071 5083
5072 rappor::TestRapporServiceImpl* rappor_service = 5084 rappor::TestRapporServiceImpl* rappor_service =
5073 autofill_client_.test_rappor_service(); 5085 autofill_client_.test_rappor_service();
5074 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5086 EXPECT_EQ(1, rappor_service->GetReportsCount());
5075 std::string sample; 5087 std::string sample;
5076 rappor::RapporType type; 5088 rappor::RapporType type;
5077 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5089 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5078 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5090 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
(...skipping 26 matching lines...) Expand all
5105 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5117 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5106 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5118 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5107 5119
5108 base::HistogramTester histogram_tester; 5120 base::HistogramTester histogram_tester;
5109 5121
5110 // Neither a local save nor an upload should happen in this case. 5122 // Neither a local save nor an upload should happen in this case.
5111 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5123 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5112 FormSubmitted(credit_card_form); 5124 FormSubmitted(credit_card_form);
5113 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5125 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5114 5126
5115 // Verify that the correct histogram entry (and only that) was logged. 5127 // Verify that the correct histogram entries are logged.
5116 histogram_tester.ExpectUniqueSample( 5128 histogram_tester.ExpectBucketCount(
5117 "Autofill.CardUploadDecisionExpanded", 5129 "Autofill.CardUploadDecisionExpanded",
5118 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); 5130 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1);
5131 histogram_tester.ExpectBucketCount(
5132 "Autofill.CardUploadDecisionExpanded",
5133 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
5134 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5135 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5119 // Verify that the correct UKM was logged. 5136 // Verify that the correct UKM was logged.
5120 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); 5137 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5138 internal::kUKMCardUploadDecisionEntryName,
5139 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS) |
5140 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE) |
5141 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED),
5142 1 /* expected_num_matching_entries */);
5121 5143
5122 rappor::TestRapporServiceImpl* rappor_service = 5144 rappor::TestRapporServiceImpl* rappor_service =
5123 autofill_client_.test_rappor_service(); 5145 autofill_client_.test_rappor_service();
5124 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5146 EXPECT_EQ(1, rappor_service->GetReportsCount());
5125 std::string sample; 5147 std::string sample;
5126 rappor::RapporType type; 5148 rappor::RapporType type;
5127 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5149 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5128 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); 5150 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type));
5129 EXPECT_EQ("myform.com", sample); 5151 EXPECT_EQ("myform.com", sample);
5130 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5152 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
(...skipping 27 matching lines...) Expand all
5158 5180
5159 base::HistogramTester histogram_tester; 5181 base::HistogramTester histogram_tester;
5160 5182
5161 // Neither a local save nor an upload should happen in this case. 5183 // Neither a local save nor an upload should happen in this case.
5162 // Note that AutofillManager should *check* for both no CVC and no address 5184 // Note that AutofillManager should *check* for both no CVC and no address
5163 // profile, but the no CVC case should have priority over being reported. 5185 // profile, but the no CVC case should have priority over being reported.
5164 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5186 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5165 FormSubmitted(credit_card_form); 5187 FormSubmitted(credit_card_form);
5166 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5188 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5167 5189
5168 // Verify that the correct histogram entry (and only that) was logged. 5190 // Verify that the correct histogram entries were logged.
5169 histogram_tester.ExpectUniqueSample( 5191 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5192 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
5193 1);
5194 histogram_tester.ExpectBucketCount(
5170 "Autofill.CardUploadDecisionExpanded", 5195 "Autofill.CardUploadDecisionExpanded",
5171 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 5196 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1);
5197 histogram_tester.ExpectBucketCount(
5198 "Autofill.CardUploadDecisionExpanded",
5199 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
5200 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5201 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5172 // Verify that the correct UKM was logged. 5202 // Verify that the correct UKM was logged.
5173 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 5203 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5204 internal::kUKMCardUploadDecisionEntryName,
5205 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC) |
5206 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS) |
5207 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE) |
5208 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED),
5209 1 /* expected_num_matching_entries */);
5174 5210
5175 rappor::TestRapporServiceImpl* rappor_service = 5211 rappor::TestRapporServiceImpl* rappor_service =
5176 autofill_client_.test_rappor_service(); 5212 autofill_client_.test_rappor_service();
5177 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5213 EXPECT_EQ(1, rappor_service->GetReportsCount());
5178 std::string sample; 5214 std::string sample;
5179 rappor::RapporType type; 5215 rappor::RapporType type;
5180 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5216 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5181 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5217 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
5182 EXPECT_EQ("myform.com", sample); 5218 EXPECT_EQ("myform.com", sample);
5183 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5219 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
(...skipping 30 matching lines...) Expand all
5214 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5250 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5215 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5251 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5216 5252
5217 base::HistogramTester histogram_tester; 5253 base::HistogramTester histogram_tester;
5218 5254
5219 // Neither a local save nor an upload should happen in this case. 5255 // Neither a local save nor an upload should happen in this case.
5220 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5256 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5221 FormSubmitted(credit_card_form); 5257 FormSubmitted(credit_card_form);
5222 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5258 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5223 5259
5224 // Verify that the correct histogram entry (and only that) was logged. 5260 // Verify that the correct histogram entries were logged.
5225 histogram_tester.ExpectUniqueSample( 5261 histogram_tester.ExpectBucketCount(
5226 "Autofill.CardUploadDecisionExpanded", 5262 "Autofill.CardUploadDecisionExpanded",
5227 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); 5263 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1);
5264 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5265 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5228 // Verify that the correct UKM was logged. 5266 // Verify that the correct UKM was logged.
5229 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); 5267 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
5230 5268
5231 rappor::TestRapporServiceImpl* rappor_service = 5269 rappor::TestRapporServiceImpl* rappor_service =
5232 autofill_client_.test_rappor_service(); 5270 autofill_client_.test_rappor_service();
5233 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5271 EXPECT_EQ(1, rappor_service->GetReportsCount());
5234 std::string sample; 5272 std::string sample;
5235 rappor::RapporType type; 5273 rappor::RapporType type;
5236 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5274 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5237 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); 5275 "Autofill.CardUploadNotOfferedNoName", &sample, &type));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5318 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5281 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5319 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5282 5320
5283 base::HistogramTester histogram_tester; 5321 base::HistogramTester histogram_tester;
5284 5322
5285 // Neither a local save nor an upload should happen in this case. 5323 // Neither a local save nor an upload should happen in this case.
5286 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5324 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5287 FormSubmitted(credit_card_form); 5325 FormSubmitted(credit_card_form);
5288 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5326 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5289 5327
5290 // Verify that the correct histogram entry (and only that) was logged. 5328 // Verify that the correct histogram entries were logged.
5291 histogram_tester.ExpectUniqueSample( 5329 histogram_tester.ExpectBucketCount(
5292 "Autofill.CardUploadDecisionExpanded", 5330 "Autofill.CardUploadDecisionExpanded",
5293 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); 5331 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1);
5332 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5333 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5294 // Verify that the correct UKM was logged. 5334 // Verify that the correct UKM was logged.
5295 ExpectCardUploadDecisionUkm( 5335 ExpectCardUploadDecisionUkm(
5296 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); 5336 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5297 } 5337 }
5298 5338
5299 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5339 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5300 #if defined(OS_ANDROID) 5340 #if defined(OS_ANDROID)
5301 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch DISABLED_UploadCreditCard _ZipCodesHavePrefixMatch 5341 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch DISABLED_UploadCreditCard _ZipCodesHavePrefixMatch
5302 #else 5342 #else
5303 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch UploadCreditCard_ZipCodes HavePrefixMatch 5343 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch UploadCreditCard_ZipCodes HavePrefixMatch
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5428 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5389 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5429 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5390 5430
5391 base::HistogramTester histogram_tester; 5431 base::HistogramTester histogram_tester;
5392 5432
5393 // Neither a local save nor an upload should happen in this case. 5433 // Neither a local save nor an upload should happen in this case.
5394 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5434 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5395 FormSubmitted(credit_card_form); 5435 FormSubmitted(credit_card_form);
5396 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5436 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5397 5437
5398 // Verify that the correct histogram entry (and only that) was logged. 5438 // Verify that the correct histogram entries were logged.
5399 histogram_tester.ExpectUniqueSample( 5439 histogram_tester.ExpectBucketCount(
5400 "Autofill.CardUploadDecisionExpanded", 5440 "Autofill.CardUploadDecisionExpanded",
5401 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); 5441 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
5442 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5443 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5402 // Verify that the correct UKM was logged. 5444 // Verify that the correct UKM was logged.
5403 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); 5445 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5404 } 5446 }
5405 5447
5406 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5448 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5407 #if defined(OS_ANDROID) 5449 #if defined(OS_ANDROID)
5408 #define MAYBE_UploadCreditCard_NamesMatchLoosely DISABLED_UploadCreditCard_Names MatchLoosely 5450 #define MAYBE_UploadCreditCard_NamesMatchLoosely DISABLED_UploadCreditCard_Names MatchLoosely
5409 #else 5451 #else
5410 #define MAYBE_UploadCreditCard_NamesMatchLoosely UploadCreditCard_NamesMatchLoos ely 5452 #define MAYBE_UploadCreditCard_NamesMatchLoosely UploadCreditCard_NamesMatchLoos ely
5411 #endif 5453 #endif
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
5499 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5541 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5500 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5542 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5501 5543
5502 base::HistogramTester histogram_tester; 5544 base::HistogramTester histogram_tester;
5503 5545
5504 // Names are required to match, upload should not happen. 5546 // Names are required to match, upload should not happen.
5505 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5547 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5506 FormSubmitted(credit_card_form); 5548 FormSubmitted(credit_card_form);
5507 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5549 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5508 5550
5509 // Verify that the correct histogram entry (and only that) was logged. 5551 // Verify that the correct histogram entries were logged.
5510 histogram_tester.ExpectUniqueSample( 5552 histogram_tester.ExpectBucketCount(
5511 "Autofill.CardUploadDecisionExpanded", 5553 "Autofill.CardUploadDecisionExpanded",
5512 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); 5554 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1);
5555 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5556 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5513 // Verify that the correct UKM was logged. 5557 // Verify that the correct UKM was logged.
5514 ExpectCardUploadDecisionUkm( 5558 ExpectCardUploadDecisionUkm(
5515 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); 5559 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
5516 5560
5517 rappor::TestRapporServiceImpl* rappor_service = 5561 rappor::TestRapporServiceImpl* rappor_service =
5518 autofill_client_.test_rappor_service(); 5562 autofill_client_.test_rappor_service();
5519 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5563 EXPECT_EQ(1, rappor_service->GetReportsCount());
5520 std::string sample; 5564 std::string sample;
5521 rappor::RapporType type; 5565 rappor::RapporType type;
5522 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5566 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5560 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5604 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5561 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5605 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5562 5606
5563 base::HistogramTester histogram_tester; 5607 base::HistogramTester histogram_tester;
5564 5608
5565 // The save prompt should be shown instead of doing an upload. 5609 // The save prompt should be shown instead of doing an upload.
5566 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); 5610 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _));
5567 FormSubmitted(credit_card_form); 5611 FormSubmitted(credit_card_form);
5568 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5612 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5569 5613
5570 // Verify that the correct histogram entry (and only that) was logged. 5614 // Verify that the correct histogram entries were logged.
5571 histogram_tester.ExpectUniqueSample( 5615 histogram_tester.ExpectBucketCount(
5572 "Autofill.CardUploadDecisionExpanded", 5616 "Autofill.CardUploadDecisionExpanded",
5573 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); 5617 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1);
5618 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
5619 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5574 // Verify that the correct UKM was logged. 5620 // Verify that the correct UKM was logged.
5575 ExpectCardUploadDecisionUkm( 5621 ExpectCardUploadDecisionUkm(
5576 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); 5622 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
5577 } 5623 }
5578 5624
5579 // Verify that typing "gmail" will match "theking@gmail.com" and 5625 // Verify that typing "gmail" will match "theking@gmail.com" and
5580 // "buddy@gmail.com" when substring matching is enabled. 5626 // "buddy@gmail.com" when substring matching is enabled.
5581 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) { 5627 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) {
5582 // Token matching is currently behind a flag. 5628 // Token matching is currently behind a flag.
5583 base::CommandLine::ForCurrentProcess()->AppendSwitch( 5629 base::CommandLine::ForCurrentProcess()->AppendSwitch(
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
6185 6231
6186 // Wait for upload to complete (will check expected types as well). 6232 // Wait for upload to complete (will check expected types as well).
6187 autofill_manager_->WaitForAsyncUploadProcess(); 6233 autofill_manager_->WaitForAsyncUploadProcess();
6188 6234
6189 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); 6235 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
6190 EXPECT_NE(uploaded_available_types.end(), 6236 EXPECT_NE(uploaded_available_types.end(),
6191 uploaded_available_types.find(autofill::PASSWORD)); 6237 uploaded_available_types.find(autofill::PASSWORD));
6192 } 6238 }
6193 6239
6194 } // namespace autofill 6240 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698