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

Unified Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 880353002: [Autofill] Log the number of autofill profiles available at form submission (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved log statement Created 5 years, 10 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
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_metrics_unittest.cc
diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc
index faf5e9de24b4d2987c10329b1c634ab639ac00ab..48c78475fe9f5245aed12de19e3291eede89c174 100644
--- a/components/autofill/core/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
@@ -686,6 +686,68 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
1);
}
+// Verify that when submitting an autofillable form, the stored profile metric
+// is logged.
+TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) {
+ // Construct a fillable form.
+ FormData form;
+ form.name = ASCIIToUTF16("TestForm");
+ form.origin = GURL("http://example.com/form.html");
+ form.action = GURL("http://example.com/submit.html");
+ form.user_submitted = true;
+
+ // Three fields is enough to make it an autofillable form.
+ FormFieldData field;
+ test::CreateTestFormField("Name", "name", "", "text", &field);
+ form.fields.push_back(field);
+ test::CreateTestFormField("Email", "email", "", "text", &field);
+ form.fields.push_back(field);
+ test::CreateTestFormField("Phone", "phone", "", "text", &field);
+ form.fields.push_back(field);
+
+ std::vector<FormData> forms(1, form);
+
+ // Simulate form submission.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnFormsSeen(forms, TimeTicks());
+ autofill_manager_->FormSubmitted(form, TimeTicks::Now());
+
+ // An autofillable form was submitted, and the number of stored profiles is
+ // logged.
+ histogram_tester.ExpectUniqueSample(
+ "Autofill.StoredProfileCountAtAutofillableFormSubmission", 2, 1);
+}
+
+// Verify that when submitting a non-autofillable form, the stored profile
+// metric is not logged.
+TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) {
+ // Construct a non-fillable form.
+ FormData form;
+ form.name = ASCIIToUTF16("TestForm");
+ form.origin = GURL("http://example.com/form.html");
+ form.action = GURL("http://example.com/submit.html");
+ form.user_submitted = true;
+
+ // Two fields is not enough to make it an autofillable form.
+ FormFieldData field;
+ test::CreateTestFormField("Name", "name", "", "text", &field);
+ form.fields.push_back(field);
+ test::CreateTestFormField("Email", "email", "", "text", &field);
+ form.fields.push_back(field);
+
+ std::vector<FormData> forms(1, form);
+
+ // Simulate form submission.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnFormsSeen(forms, TimeTicks());
+ autofill_manager_->FormSubmitted(form, TimeTicks::Now());
+
+ // A non-autofillable form was submitted, and number of stored profiles is NOT
+ // logged.
+ histogram_tester.ExpectTotalCount(
+ "Autofill.StoredProfileCountAtAutofillableFormSubmission", 0);
+}
+
// Verify that we correctly log metrics regarding developer engagement.
TEST_F(AutofillMetricsTest, DeveloperEngagement) {
// Start with a non-fillable form.
« no previous file with comments | « components/autofill/core/browser/autofill_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698