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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 3abf510efd78d002afd780b208caccf1773bdff7..4b5fc89fe9f2af1b1829f0abf17863b5ee02d30a 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -1105,30 +1105,31 @@ class AutofillManagerTest : public testing::Test {
const ukm::Entry_Metric* metric = FindMetric(
internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics());
ASSERT_NE(nullptr, metric);
- EXPECT_EQ(static_cast<int>(
- AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS),
+ EXPECT_EQ(1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS,
metric->value());
}
void ExpectCardUploadDecisionUkm(
AutofillMetrics::CardUploadDecisionMetric upload_decision) {
+ int expected_metric_value = 1 << upload_decision;
+ if (upload_decision != AutofillMetrics::UPLOAD_OFFERED &&
+ upload_decision != AutofillMetrics::UPLOAD_OFFERED_NO_CVC)
+ expected_metric_value |= 1 << AutofillMetrics::UPLOAD_NOT_OFFERED;
ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
internal::kUKMCardUploadDecisionEntryName,
- static_cast<int>(upload_decision),
- 1 /* expected_num_matching_entries */);
+ expected_metric_value, 1 /* expected_num_matching_entries */);
}
void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) {
ExpectMetric(internal::kUKMDeveloperEngagementMetricName,
internal::kUKMDeveloperEngagementEntryName,
- static_cast<int>(
- AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS),
+ 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS,
num_fillable_forms_parsed);
}
void ExpectMetric(const char* metric_name,
const char* entry_name,
- int metric_value,
+ int expected_metric_value,
int expected_num_matching_entries) {
ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService();
@@ -1148,7 +1149,7 @@ class AutofillManagerTest : public testing::Test {
const ukm::Entry_Metric* metric =
FindMetric(metric_name, entry_proto.metrics());
ASSERT_NE(nullptr, metric);
- EXPECT_EQ(metric_value, metric->value());
+ EXPECT_EQ(expected_metric_value, metric->value());
++num_matching_entries;
}
}
@@ -4799,10 +4800,12 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
- "Autofill.CardUploadDecisionExpanded",
- AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1);
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
+ 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
@@ -4855,10 +4858,12 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcInvalidLength) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
- "Autofill.CardUploadDecisionExpanded",
- AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1);
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
+ 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
@@ -4997,12 +5002,17 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoCvcFieldOnForm) {
FormSubmitted(credit_card_form);
EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded",
- AutofillMetrics::UPLOAD_OFFERED_NO_CVC,
- 1);
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_OFFERED_NO_CVC, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_OFFERED, 1);
// Verify that the correct UKM was logged.
- ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED_NO_CVC);
+ ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
+ internal::kUKMCardUploadDecisionEntryName,
+ (1 << AutofillMetrics::UPLOAD_OFFERED_NO_CVC) |
+ (1 << AutofillMetrics::UPLOAD_OFFERED),
+ 1 /* expected_num_matching_entries */);
}
// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
@@ -5062,10 +5072,12 @@ TEST_F(AutofillManagerTest,
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
- "Autofill.CardUploadDecisionExpanded",
- AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1);
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
+ 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
@@ -5112,12 +5124,22 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoProfileAvailable) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
+ // Verify that the correct histogram entries are logged.
+ histogram_tester.ExpectBucketCount(
"Autofill.CardUploadDecisionExpanded",
AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
- ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS);
+ ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
+ internal::kUKMCardUploadDecisionEntryName,
+ (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS) |
+ (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE) |
+ (1 << AutofillMetrics::UPLOAD_NOT_OFFERED),
+ 1 /* expected_num_matching_entries */);
rappor::TestRapporServiceImpl* rappor_service =
autofill_client_.test_rappor_service();
@@ -5165,12 +5187,26 @@ TEST_F(AutofillManagerTest,
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC,
+ 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1);
+ histogram_tester.ExpectBucketCount(
"Autofill.CardUploadDecisionExpanded",
- AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1);
+ AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
- ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
+ ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
+ internal::kUKMCardUploadDecisionEntryName,
+ (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC) |
+ (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS) |
+ (1 << AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE) |
+ (1 << AutofillMetrics::UPLOAD_NOT_OFFERED),
+ 1 /* expected_num_matching_entries */);
rappor::TestRapporServiceImpl* rappor_service =
autofill_client_.test_rappor_service();
@@ -5221,10 +5257,12 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoNameAvailable) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount(
"Autofill.CardUploadDecisionExpanded",
AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
@@ -5287,10 +5325,12 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_ZipCodesConflict) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount(
"Autofill.CardUploadDecisionExpanded",
AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(
AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
@@ -5395,10 +5435,12 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoZipCodeAvailable) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount(
"Autofill.CardUploadDecisionExpanded",
AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
}
@@ -5506,10 +5548,12 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesHaveToMatch) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount(
"Autofill.CardUploadDecisionExpanded",
AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(
AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
@@ -5567,10 +5611,12 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_UploadDetailsFails) {
FormSubmitted(credit_card_form);
EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
- // Verify that the correct histogram entry (and only that) was logged.
- histogram_tester.ExpectUniqueSample(
+ // Verify that the correct histogram entries were logged.
+ histogram_tester.ExpectBucketCount(
"Autofill.CardUploadDecisionExpanded",
AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1);
+ histogram_tester.ExpectBucketCount("Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_NOT_OFFERED, 1);
// Verify that the correct UKM was logged.
ExpectCardUploadDecisionUkm(
AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);

Powered by Google App Engine
This is Rietveld 408576698