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

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: Replaces CardUploadDecisionExpanded with CardUploadDecisionMetric. 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 3490 matching lines...) Expand 10 before | Expand all | Expand 10 after
4652 4653
4653 base::HistogramTester histogram_tester; 4654 base::HistogramTester histogram_tester;
4654 4655
4655 FormSubmitted(credit_card_form); 4656 FormSubmitted(credit_card_form);
4656 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 4657 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4657 4658
4658 // Server did not send a server_id, expect copy of card is not stored. 4659 // Server did not send a server_id, expect copy of card is not stored.
4659 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty()); 4660 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty());
4660 4661
4661 // Verify that the correct histogram entry (and only that) was logged. 4662 // Verify that the correct histogram entry (and only that) was logged.
4662 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 4663 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric",
4663 AutofillMetrics::UPLOAD_OFFERED, 1); 4664 AutofillMetrics::UPLOAD_OFFERED, 1);
4664 // Verify that the correct UKM was logged. 4665 // Verify that the correct UKM was logged.
4665 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 4666 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
4666 } 4667 }
4667 4668
4668 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 4669 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4669 #if defined(OS_ANDROID) 4670 #if defined(OS_ANDROID)
4670 #define MAYBE_UploadCreditCardAndSaveCopy DISABLED_UploadCreditCardAndSaveCopy 4671 #define MAYBE_UploadCreditCardAndSaveCopy DISABLED_UploadCreditCardAndSaveCopy
4671 #else 4672 #else
4672 #define MAYBE_UploadCreditCardAndSaveCopy UploadCreditCardAndSaveCopy 4673 #define MAYBE_UploadCreditCardAndSaveCopy UploadCreditCardAndSaveCopy
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
4748 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 4749 credit_card_form.fields[4].value = ASCIIToUTF16("123");
4749 4750
4750 base::HistogramTester histogram_tester; 4751 base::HistogramTester histogram_tester;
4751 4752
4752 // The save prompt should be shown instead of doing an upload. 4753 // The save prompt should be shown instead of doing an upload.
4753 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); 4754 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _));
4754 FormSubmitted(credit_card_form); 4755 FormSubmitted(credit_card_form);
4755 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 4756 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4756 4757
4757 // Verify that no histogram entry was logged called. 4758 // Verify that no histogram entry was logged called.
4758 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionExpanded", 0); 4759 histogram_tester.ExpectTotalCount("Autofill.CardUploadDecisionMetric", 0);
4759 } 4760 }
4760 4761
4761 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 4762 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4762 #if defined(OS_ANDROID) 4763 #if defined(OS_ANDROID)
4763 #define MAYBE_UploadCreditCard_CvcUnavailable DISABLED_UploadCreditCard_CvcUnava ilable 4764 #define MAYBE_UploadCreditCard_CvcUnavailable DISABLED_UploadCreditCard_CvcUnava ilable
4764 #else 4765 #else
4765 #define MAYBE_UploadCreditCard_CvcUnavailable UploadCreditCard_CvcUnavailable 4766 #define MAYBE_UploadCreditCard_CvcUnavailable UploadCreditCard_CvcUnavailable
4766 #endif 4767 #endif
4767 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) { 4768 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) {
4768 EnableUkmLogging(); 4769 EnableUkmLogging();
(...skipping 23 matching lines...) Expand all
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.CardUploadDecisionMetric",
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.CardUploadDecisionMetric",
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.CardUploadDecisionMetric",
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.CardUploadDecisionMetric",
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4927 credit_card_form.fields[5].value = ASCIIToUTF16("123"); 4932 credit_card_form.fields[5].value = ASCIIToUTF16("123");
4928 4933
4929 base::HistogramTester histogram_tester; 4934 base::HistogramTester histogram_tester;
4930 4935
4931 // A CVC value appeared in one of the two CVC fields, upload should happen. 4936 // A CVC value appeared in one of the two CVC fields, upload should happen.
4932 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 4937 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4933 FormSubmitted(credit_card_form); 4938 FormSubmitted(credit_card_form);
4934 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 4939 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4935 4940
4936 // Verify that the correct histogram entry (and only that) was logged. 4941 // Verify that the correct histogram entry (and only that) was logged.
4937 histogram_tester.ExpectUniqueSample( 4942 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric",
4938 "Autofill.CardUploadDecisionExpanded", 4943 AutofillMetrics::UPLOAD_OFFERED, 1);
4939 AutofillMetrics::UPLOAD_OFFERED, 1);
4940 // Verify that the correct UKM was logged. 4944 // Verify that the correct UKM was logged.
4941 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 4945 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
4942 } 4946 }
4943 4947
4944 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 4948 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4945 #if defined(OS_ANDROID) 4949 #if defined(OS_ANDROID)
4946 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ 4950 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \
4947 DISABLED_UploadCreditCard_NoCvcFieldOnForm 4951 DISABLED_UploadCreditCard_NoCvcFieldOnForm
4948 #else 4952 #else
4949 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ 4953 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 credit_card_form.fields[2].value = ASCIIToUTF16("11"); 4994 credit_card_form.fields[2].value = ASCIIToUTF16("11");
4991 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 4995 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4992 4996
4993 base::HistogramTester histogram_tester; 4997 base::HistogramTester histogram_tester;
4994 4998
4995 // Upload should still happen as long as the user provides CVC in the bubble. 4999 // Upload should still happen as long as the user provides CVC in the bubble.
4996 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5000 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4997 FormSubmitted(credit_card_form); 5001 FormSubmitted(credit_card_form);
4998 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5002 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
4999 5003
5000 // Verify that the correct histogram entry (and only that) was logged. 5004 // Verify that the correct histogram entries were logged.
5001 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", 5005 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5002 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, 5006 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, 1);
5003 1); 5007 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5008 AutofillMetrics::UPLOAD_OFFERED, 1);
5004 // Verify that the correct UKM was logged. 5009 // Verify that the correct UKM was logged.
5005 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED_NO_CVC); 5010 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5011 internal::kUKMCardUploadDecisionEntryName,
5012 (1 << AutofillMetrics::UPLOAD_OFFERED_NO_CVC) |
5013 (1 << AutofillMetrics::UPLOAD_OFFERED),
5014 1 /* expected_num_matching_entries */);
5006 } 5015 }
5007 5016
5008 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5017 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5009 #if defined(OS_ANDROID) 5018 #if defined(OS_ANDROID)
5010 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ 5019 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \
5011 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff 5020 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff
5012 #else 5021 #else
5013 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ 5022 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \
5014 UploadCreditCard_NoCvcFieldOnFormExperimentOff 5023 UploadCreditCard_NoCvcFieldOnFormExperimentOff
5015 #endif 5024 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5055 credit_card_form.fields[2].value = ASCIIToUTF16("11"); 5064 credit_card_form.fields[2].value = ASCIIToUTF16("11");
5056 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5065 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5057 5066
5058 base::HistogramTester histogram_tester; 5067 base::HistogramTester histogram_tester;
5059 5068
5060 // Neither a local save nor an upload should happen in this case. 5069 // Neither a local save nor an upload should happen in this case.
5061 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5070 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5062 FormSubmitted(credit_card_form); 5071 FormSubmitted(credit_card_form);
5063 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5072 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5064 5073
5065 // Verify that the correct histogram entry (and only that) was logged. 5074 // Verify that the correct histogram entries were logged.
5066 histogram_tester.ExpectUniqueSample( 5075 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5067 "Autofill.CardUploadDecisionExpanded", 5076 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
5068 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 5077 1);
5078 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5079 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5069 // Verify that the correct UKM was logged. 5080 // Verify that the correct UKM was logged.
5070 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 5081 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
5071 5082
5072 rappor::TestRapporServiceImpl* rappor_service = 5083 rappor::TestRapporServiceImpl* rappor_service =
5073 autofill_client_.test_rappor_service(); 5084 autofill_client_.test_rappor_service();
5074 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5085 EXPECT_EQ(1, rappor_service->GetReportsCount());
5075 std::string sample; 5086 std::string sample;
5076 rappor::RapporType type; 5087 rappor::RapporType type;
5077 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5088 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5078 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5089 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
(...skipping 26 matching lines...) Expand all
5105 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5116 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5106 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5117 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5107 5118
5108 base::HistogramTester histogram_tester; 5119 base::HistogramTester histogram_tester;
5109 5120
5110 // Neither a local save nor an upload should happen in this case. 5121 // Neither a local save nor an upload should happen in this case.
5111 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5122 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5112 FormSubmitted(credit_card_form); 5123 FormSubmitted(credit_card_form);
5113 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5124 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5114 5125
5115 // Verify that the correct histogram entry (and only that) was logged. 5126 // Verify that the correct histogram entries are logged.
5116 histogram_tester.ExpectUniqueSample( 5127 histogram_tester.ExpectBucketCount(
5117 "Autofill.CardUploadDecisionExpanded", 5128 "Autofill.CardUploadDecisionMetric",
5118 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); 5129 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1);
5130 histogram_tester.ExpectBucketCount(
5131 "Autofill.CardUploadDecisionMetric",
5132 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
5133 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5134 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5119 // Verify that the correct UKM was logged. 5135 // Verify that the correct UKM was logged.
5120 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); 5136 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5137 internal::kUKMCardUploadDecisionEntryName,
5138 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS) |
5139 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE) |
5140 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED),
5141 1 /* expected_num_matching_entries */);
5121 5142
5122 rappor::TestRapporServiceImpl* rappor_service = 5143 rappor::TestRapporServiceImpl* rappor_service =
5123 autofill_client_.test_rappor_service(); 5144 autofill_client_.test_rappor_service();
5124 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5145 EXPECT_EQ(1, rappor_service->GetReportsCount());
5125 std::string sample; 5146 std::string sample;
5126 rappor::RapporType type; 5147 rappor::RapporType type;
5127 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5148 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5128 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); 5149 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type));
5129 EXPECT_EQ("myform.com", sample); 5150 EXPECT_EQ("myform.com", sample);
5130 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5151 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
(...skipping 27 matching lines...) Expand all
5158 5179
5159 base::HistogramTester histogram_tester; 5180 base::HistogramTester histogram_tester;
5160 5181
5161 // Neither a local save nor an upload should happen in this case. 5182 // 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 5183 // 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. 5184 // profile, but the no CVC case should have priority over being reported.
5164 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5185 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5165 FormSubmitted(credit_card_form); 5186 FormSubmitted(credit_card_form);
5166 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5187 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5167 5188
5168 // Verify that the correct histogram entry (and only that) was logged. 5189 // Verify that the correct histogram entries were logged.
5169 histogram_tester.ExpectUniqueSample( 5190 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5170 "Autofill.CardUploadDecisionExpanded", 5191 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
5171 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); 5192 1);
5193 histogram_tester.ExpectBucketCount(
5194 "Autofill.CardUploadDecisionMetric",
5195 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1);
5196 histogram_tester.ExpectBucketCount(
5197 "Autofill.CardUploadDecisionMetric",
5198 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
5199 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5200 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5172 // Verify that the correct UKM was logged. 5201 // Verify that the correct UKM was logged.
5173 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 5202 ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
5203 internal::kUKMCardUploadDecisionEntryName,
5204 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC) |
5205 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS) |
5206 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE) |
5207 (1 << AutofillMetrics::UPLOAD_NOT_OFFERED),
5208 1 /* expected_num_matching_entries */);
5174 5209
5175 rappor::TestRapporServiceImpl* rappor_service = 5210 rappor::TestRapporServiceImpl* rappor_service =
5176 autofill_client_.test_rappor_service(); 5211 autofill_client_.test_rappor_service();
5177 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5212 EXPECT_EQ(1, rappor_service->GetReportsCount());
5178 std::string sample; 5213 std::string sample;
5179 rappor::RapporType type; 5214 rappor::RapporType type;
5180 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5215 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5181 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 5216 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
5182 EXPECT_EQ("myform.com", sample); 5217 EXPECT_EQ("myform.com", sample);
5183 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 5218 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
(...skipping 30 matching lines...) Expand all
5214 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5249 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5215 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5250 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5216 5251
5217 base::HistogramTester histogram_tester; 5252 base::HistogramTester histogram_tester;
5218 5253
5219 // Neither a local save nor an upload should happen in this case. 5254 // Neither a local save nor an upload should happen in this case.
5220 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5255 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5221 FormSubmitted(credit_card_form); 5256 FormSubmitted(credit_card_form);
5222 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5257 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5223 5258
5224 // Verify that the correct histogram entry (and only that) was logged. 5259 // Verify that the correct histogram entries were logged.
5225 histogram_tester.ExpectUniqueSample( 5260 histogram_tester.ExpectBucketCount(
5226 "Autofill.CardUploadDecisionExpanded", 5261 "Autofill.CardUploadDecisionMetric",
5227 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); 5262 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1);
5263 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5264 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5228 // Verify that the correct UKM was logged. 5265 // Verify that the correct UKM was logged.
5229 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); 5266 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
5230 5267
5231 rappor::TestRapporServiceImpl* rappor_service = 5268 rappor::TestRapporServiceImpl* rappor_service =
5232 autofill_client_.test_rappor_service(); 5269 autofill_client_.test_rappor_service();
5233 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5270 EXPECT_EQ(1, rappor_service->GetReportsCount());
5234 std::string sample; 5271 std::string sample;
5235 rappor::RapporType type; 5272 rappor::RapporType type;
5236 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5273 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
5237 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); 5274 "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"); 5317 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5281 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5318 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5282 5319
5283 base::HistogramTester histogram_tester; 5320 base::HistogramTester histogram_tester;
5284 5321
5285 // Neither a local save nor an upload should happen in this case. 5322 // Neither a local save nor an upload should happen in this case.
5286 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5323 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5287 FormSubmitted(credit_card_form); 5324 FormSubmitted(credit_card_form);
5288 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5325 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5289 5326
5290 // Verify that the correct histogram entry (and only that) was logged. 5327 // Verify that the correct histogram entries were logged.
5291 histogram_tester.ExpectUniqueSample( 5328 histogram_tester.ExpectBucketCount(
5292 "Autofill.CardUploadDecisionExpanded", 5329 "Autofill.CardUploadDecisionMetric",
5293 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); 5330 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1);
5331 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5332 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5294 // Verify that the correct UKM was logged. 5333 // Verify that the correct UKM was logged.
5295 ExpectCardUploadDecisionUkm( 5334 ExpectCardUploadDecisionUkm(
5296 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); 5335 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
5297 } 5336 }
5298 5337
5299 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5338 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5300 #if defined(OS_ANDROID) 5339 #if defined(OS_ANDROID)
5301 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch DISABLED_UploadCreditCard _ZipCodesHavePrefixMatch 5340 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch DISABLED_UploadCreditCard _ZipCodesHavePrefixMatch
5302 #else 5341 #else
5303 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch UploadCreditCard_ZipCodes HavePrefixMatch 5342 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch UploadCreditCard_ZipCodes HavePrefixMatch
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5336 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5375 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5337 5376
5338 base::HistogramTester histogram_tester; 5377 base::HistogramTester histogram_tester;
5339 5378
5340 // One zip is a prefix of the other, upload should happen. 5379 // One zip is a prefix of the other, upload should happen.
5341 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5380 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5342 FormSubmitted(credit_card_form); 5381 FormSubmitted(credit_card_form);
5343 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5382 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5344 5383
5345 // Verify that the correct histogram entry (and only that) was logged. 5384 // Verify that the correct histogram entry (and only that) was logged.
5346 histogram_tester.ExpectUniqueSample( 5385 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric",
5347 "Autofill.CardUploadDecisionExpanded", 5386 AutofillMetrics::UPLOAD_OFFERED, 1);
5348 AutofillMetrics::UPLOAD_OFFERED, 1);
5349 // Verify that the correct UKM was logged. 5387 // Verify that the correct UKM was logged.
5350 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5388 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5351 } 5389 }
5352 5390
5353 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5391 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5354 #if defined(OS_ANDROID) 5392 #if defined(OS_ANDROID)
5355 #define MAYBE_UploadCreditCard_NoZipCodeAvailable DISABLED_UploadCreditCard_NoZi pCodeAvailable 5393 #define MAYBE_UploadCreditCard_NoZipCodeAvailable DISABLED_UploadCreditCard_NoZi pCodeAvailable
5356 #else 5394 #else
5357 #define MAYBE_UploadCreditCard_NoZipCodeAvailable UploadCreditCard_NoZipCodeAvai lable 5395 #define MAYBE_UploadCreditCard_NoZipCodeAvailable UploadCreditCard_NoZipCodeAvai lable
5358 #endif 5396 #endif
(...skipping 29 matching lines...) Expand all
5388 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5426 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5389 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5427 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5390 5428
5391 base::HistogramTester histogram_tester; 5429 base::HistogramTester histogram_tester;
5392 5430
5393 // Neither a local save nor an upload should happen in this case. 5431 // Neither a local save nor an upload should happen in this case.
5394 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5432 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5395 FormSubmitted(credit_card_form); 5433 FormSubmitted(credit_card_form);
5396 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5434 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5397 5435
5398 // Verify that the correct histogram entry (and only that) was logged. 5436 // Verify that the correct histogram entries were logged.
5399 histogram_tester.ExpectUniqueSample( 5437 histogram_tester.ExpectBucketCount(
5400 "Autofill.CardUploadDecisionExpanded", 5438 "Autofill.CardUploadDecisionMetric",
5401 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); 5439 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
5440 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5441 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5402 // Verify that the correct UKM was logged. 5442 // Verify that the correct UKM was logged.
5403 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); 5443 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
5404 } 5444 }
5405 5445
5406 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5446 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5407 #if defined(OS_ANDROID) 5447 #if defined(OS_ANDROID)
5408 #define MAYBE_UploadCreditCard_NamesMatchLoosely DISABLED_UploadCreditCard_Names MatchLoosely 5448 #define MAYBE_UploadCreditCard_NamesMatchLoosely DISABLED_UploadCreditCard_Names MatchLoosely
5409 #else 5449 #else
5410 #define MAYBE_UploadCreditCard_NamesMatchLoosely UploadCreditCard_NamesMatchLoos ely 5450 #define MAYBE_UploadCreditCard_NamesMatchLoosely UploadCreditCard_NamesMatchLoos ely
5411 #endif 5451 #endif
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
5446 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5486 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5447 5487
5448 base::HistogramTester histogram_tester; 5488 base::HistogramTester histogram_tester;
5449 5489
5450 // Names match loosely, upload should happen. 5490 // Names match loosely, upload should happen.
5451 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5491 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5452 FormSubmitted(credit_card_form); 5492 FormSubmitted(credit_card_form);
5453 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); 5493 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
5454 5494
5455 // Verify that the correct histogram entry (and only that) was logged. 5495 // Verify that the correct histogram entry (and only that) was logged.
5456 histogram_tester.ExpectUniqueSample( 5496 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric",
5457 "Autofill.CardUploadDecisionExpanded", 5497 AutofillMetrics::UPLOAD_OFFERED, 1);
5458 AutofillMetrics::UPLOAD_OFFERED, 1);
5459 // Verify that the correct UKM was logged. 5498 // Verify that the correct UKM was logged.
5460 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); 5499 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
5461 } 5500 }
5462 5501
5463 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 5502 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
5464 #if defined(OS_ANDROID) 5503 #if defined(OS_ANDROID)
5465 #define MAYBE_UploadCreditCard_NamesHaveToMatch DISABLED_UploadCreditCard_NamesH aveToMatch 5504 #define MAYBE_UploadCreditCard_NamesHaveToMatch DISABLED_UploadCreditCard_NamesH aveToMatch
5466 #else 5505 #else
5467 #define MAYBE_UploadCreditCard_NamesHaveToMatch UploadCreditCard_NamesHaveToMatc h 5506 #define MAYBE_UploadCreditCard_NamesHaveToMatch UploadCreditCard_NamesHaveToMatc h
5468 #endif 5507 #endif
(...skipping 30 matching lines...) Expand all
5499 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); 5538 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5500 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5539 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5501 5540
5502 base::HistogramTester histogram_tester; 5541 base::HistogramTester histogram_tester;
5503 5542
5504 // Names are required to match, upload should not happen. 5543 // Names are required to match, upload should not happen.
5505 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); 5544 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
5506 FormSubmitted(credit_card_form); 5545 FormSubmitted(credit_card_form);
5507 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5546 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5508 5547
5509 // Verify that the correct histogram entry (and only that) was logged. 5548 // Verify that the correct histogram entries were logged.
5510 histogram_tester.ExpectUniqueSample( 5549 histogram_tester.ExpectBucketCount(
5511 "Autofill.CardUploadDecisionExpanded", 5550 "Autofill.CardUploadDecisionMetric",
5512 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); 5551 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1);
5552 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5553 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5513 // Verify that the correct UKM was logged. 5554 // Verify that the correct UKM was logged.
5514 ExpectCardUploadDecisionUkm( 5555 ExpectCardUploadDecisionUkm(
5515 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); 5556 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
5516 5557
5517 rappor::TestRapporServiceImpl* rappor_service = 5558 rappor::TestRapporServiceImpl* rappor_service =
5518 autofill_client_.test_rappor_service(); 5559 autofill_client_.test_rappor_service();
5519 EXPECT_EQ(1, rappor_service->GetReportsCount()); 5560 EXPECT_EQ(1, rappor_service->GetReportsCount());
5520 std::string sample; 5561 std::string sample;
5521 rappor::RapporType type; 5562 rappor::RapporType type;
5522 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 5563 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"); 5601 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
5561 credit_card_form.fields[4].value = ASCIIToUTF16("123"); 5602 credit_card_form.fields[4].value = ASCIIToUTF16("123");
5562 5603
5563 base::HistogramTester histogram_tester; 5604 base::HistogramTester histogram_tester;
5564 5605
5565 // The save prompt should be shown instead of doing an upload. 5606 // The save prompt should be shown instead of doing an upload.
5566 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); 5607 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _));
5567 FormSubmitted(credit_card_form); 5608 FormSubmitted(credit_card_form);
5568 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); 5609 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
5569 5610
5570 // Verify that the correct histogram entry (and only that) was logged. 5611 // Verify that the correct histogram entries were logged.
5571 histogram_tester.ExpectUniqueSample( 5612 histogram_tester.ExpectBucketCount(
5572 "Autofill.CardUploadDecisionExpanded", 5613 "Autofill.CardUploadDecisionMetric",
5573 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); 5614 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1);
5615 histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionMetric",
5616 AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
5574 // Verify that the correct UKM was logged. 5617 // Verify that the correct UKM was logged.
5575 ExpectCardUploadDecisionUkm( 5618 ExpectCardUploadDecisionUkm(
5576 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); 5619 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
5577 } 5620 }
5578 5621
5579 // Verify that typing "gmail" will match "theking@gmail.com" and 5622 // Verify that typing "gmail" will match "theking@gmail.com" and
5580 // "buddy@gmail.com" when substring matching is enabled. 5623 // "buddy@gmail.com" when substring matching is enabled.
5581 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) { 5624 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) {
5582 // Token matching is currently behind a flag. 5625 // Token matching is currently behind a flag.
5583 base::CommandLine::ForCurrentProcess()->AppendSwitch( 5626 base::CommandLine::ForCurrentProcess()->AppendSwitch(
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
6185 6228
6186 // Wait for upload to complete (will check expected types as well). 6229 // Wait for upload to complete (will check expected types as well).
6187 autofill_manager_->WaitForAsyncUploadProcess(); 6230 autofill_manager_->WaitForAsyncUploadProcess();
6188 6231
6189 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); 6232 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
6190 EXPECT_NE(uploaded_available_types.end(), 6233 EXPECT_NE(uploaded_available_types.end(),
6191 uploaded_available_types.find(autofill::PASSWORD)); 6234 uploaded_available_types.find(autofill::PASSWORD));
6192 } 6235 }
6193 6236
6194 } // namespace autofill 6237 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698