| 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 409e9bdd5b5782426e5dc08d188a32f28ca042e9..674e77d3a254e22a1c8ba160c38220b9c9f5318c 100644
|
| --- a/components/autofill/core/browser/autofill_metrics_unittest.cc
|
| +++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
|
| @@ -696,6 +696,92 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
|
| 1);
|
| }
|
|
|
| +// Test that we log user submitted forms appropriately.
|
| +TEST_F(AutofillMetricsTest, LogIsFormUserSubmitted_UserSubmitted) {
|
| + // Set up our form data.
|
| + 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;
|
| +
|
| + std::vector<ServerFieldType> heuristic_types, server_types;
|
| + FormFieldData field;
|
| +
|
| + test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
|
| + "text", &field);
|
| + field.is_autofilled = true;
|
| + form.fields.push_back(field);
|
| + heuristic_types.push_back(NAME_FIRST);
|
| + server_types.push_back(NO_SERVER_DATA);
|
| +
|
| + test::CreateTestFormField("Autofill Failed", "autofillfailed",
|
| + "buddy@gmail.com", "text", &field);
|
| + field.is_autofilled = false;
|
| + form.fields.push_back(field);
|
| + heuristic_types.push_back(PHONE_HOME_WHOLE_NUMBER);
|
| + server_types.push_back(EMAIL_ADDRESS);
|
| +
|
| + test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
|
| + field.is_autofilled = true;
|
| + form.fields.push_back(field);
|
| + heuristic_types.push_back(PHONE_HOME_NUMBER);
|
| + server_types.push_back(PHONE_HOME_CITY_AND_NUMBER);
|
| +
|
| + // Simulate having seen this form on page load.
|
| + autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
|
| +
|
| + // Simulate form submission.
|
| + base::HistogramTester histogram_tester;
|
| + autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
|
| +
|
| + // An autofillable form was user submitted.
|
| + histogram_tester.ExpectUniqueSample("Autofill.IsFormUserSubmitted", true, 1);
|
| +}
|
| +
|
| +// Test that we log non-user submitted forms appropriately.
|
| +TEST_F(AutofillMetricsTest, LogIsFormUserSubmitted_NotUserSubmitted) {
|
| + // Set up our form data.
|
| + 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 = false;
|
| +
|
| + std::vector<ServerFieldType> heuristic_types, server_types;
|
| + FormFieldData field;
|
| +
|
| + test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
|
| + "text", &field);
|
| + field.is_autofilled = true;
|
| + form.fields.push_back(field);
|
| + heuristic_types.push_back(NAME_FIRST);
|
| + server_types.push_back(NO_SERVER_DATA);
|
| +
|
| + test::CreateTestFormField("Autofill Failed", "autofillfailed",
|
| + "buddy@gmail.com", "text", &field);
|
| + field.is_autofilled = false;
|
| + form.fields.push_back(field);
|
| + heuristic_types.push_back(PHONE_HOME_WHOLE_NUMBER);
|
| + server_types.push_back(EMAIL_ADDRESS);
|
| +
|
| + test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
|
| + field.is_autofilled = true;
|
| + form.fields.push_back(field);
|
| + heuristic_types.push_back(PHONE_HOME_NUMBER);
|
| + server_types.push_back(PHONE_HOME_CITY_AND_NUMBER);
|
| +
|
| + // Simulate having seen this form on page load.
|
| + autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
|
| +
|
| + // Simulate form submission.
|
| + base::HistogramTester histogram_tester;
|
| + autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
|
| +
|
| + // An autofillable form was NOT user submitted.
|
| + histogram_tester.ExpectUniqueSample("Autofill.IsFormUserSubmitted", false, 1);
|
| +}
|
| +
|
| // Verify that when submitting an autofillable form, the stored profile metric
|
| // is logged.
|
| TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) {
|
|
|