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

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

Issue 1010263002: [Autofill] Add FormEvent logging for "will submit form". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split Created 5 years, 9 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 973a6d560b9a5f2c7bd6c377522889020e74bf75..46a18e1083398125da21090c1a1b028834debf63 100644
--- a/components/autofill/core/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
@@ -229,6 +229,7 @@ class TestAutofillManager : public AutofillManager {
form_structures()->push_back(form_structure);
}
+ // Calls AutofillManager::OnWillSubmitForm and waits for it to complete.
void WillSubmitForm(const FormData& form, const TimeTicks& timestamp) {
run_loop_.reset(new base::RunLoop());
if (!OnWillSubmitForm(form, timestamp))
@@ -238,6 +239,13 @@ class TestAutofillManager : public AutofillManager {
run_loop_->Run();
}
+ // Calls both AutofillManager::OnWillSubmitForm and
+ // AutofillManager::OnFormSubmitted.
+ void SubmitForm(const FormData& form, const TimeTicks& timestamp) {
+ WillSubmitForm(form, timestamp);
+ OnFormSubmitted(form);
+ }
+
void UploadFormDataAsyncCallback(
const FormStructure* submitted_form,
const base::TimeTicks& load_time,
@@ -377,7 +385,7 @@ TEST_F(AutofillMetricsTest, QualityMetrics) {
// Simulate form submission.
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// Heuristic predictions.
// Unknown:
@@ -499,7 +507,7 @@ TEST_F(AutofillMetricsTest, Rappor_LowMismatchRate_NoMetricsReported) {
autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
// Simulate form submission.
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// The number of mismatches did not trigger the RAPPOR metric logging.
EXPECT_EQ(0, autofill_client_.test_rappor_service()->GetReportsCount());
@@ -542,7 +550,7 @@ TEST_F(AutofillMetricsTest, Rappor_NoDataServerAndHeuristic_NoMetricsReported) {
autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
// Simulate form submission.
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// No RAPPOR metrics are logged in the case of multiple UNKNOWN_TYPE and
// NO_SERVER_DATA for heuristics and server predictions, respectively.
@@ -585,7 +593,7 @@ TEST_F(AutofillMetricsTest, Rappor_HighServerMismatchRate_MetricsReported) {
autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
// Simulate form submission.
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// The number of mismatches did trigger the RAPPOR metric logging for server
// predictions.
@@ -638,7 +646,7 @@ TEST_F(AutofillMetricsTest, Rappor_HighHeuristicMismatchRate_MetricsReported) {
autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
// Simulate form submission.
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// The number of mismatches did trigger the RAPPOR metric logging for
// heuristic predictions.
@@ -691,7 +699,7 @@ TEST_F(AutofillMetricsTest, PredictedMetricsWithAutocomplete) {
// match what is in the test profile.
form.fields[1].value = base::ASCIIToUTF16("79401");
form.fields[2].value = base::ASCIIToUTF16("2345678901");
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// First verify that country was not predicted by client or server.
histogram_tester.ExpectBucketCount(
@@ -804,7 +812,7 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
// Simulate form submission.
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// Heuristic predictions.
// Unknown:
@@ -914,7 +922,7 @@ TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) {
// Simulate form submission.
base::HistogramTester histogram_tester;
autofill_manager_->OnFormsSeen(forms, TimeTicks());
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// An autofillable form was submitted, and the number of stored profiles is
// logged.
@@ -944,7 +952,7 @@ TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) {
// Simulate form submission.
base::HistogramTester histogram_tester;
autofill_manager_->OnFormsSeen(forms, TimeTicks());
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
// A non-autofillable form was submitted, and number of stored profiles is NOT
// logged.
@@ -1490,7 +1498,10 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
false);
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1511,7 +1522,10 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) {
AutofillDriver::FORM_DATA_ACTION_FILL,
0, form, form.fields.front(),
autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1532,7 +1546,10 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) {
AutofillDriver::FORM_DATA_ACTION_FILL,
0, form, form.fields.front(),
autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1578,11 +1595,218 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
false);
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::
+ FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE,
+ 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::
+ FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE,
+ 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission without previous interaction.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+}
+
+// Test that we log "will submit" (but not submitted) form events for credit
+// cards. Mirrors CreditCardSubmittedFormEvents test but does not expect any
+// "submitted" metrics.
+TEST_F(AutofillMetricsTest, CreditCardWillSubmitFormEvents) {
+ EnableWalletSync();
+ // Creating all kinds of cards.
+ personal_data_->RecreateCreditCards(
+ true /* include_local_credit_card */,
+ true /* include_masked_server_credit_card */,
+ true /* include_full_server_credit_card */);
+ // 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;
+
+ FormFieldData field;
+ std::vector<ServerFieldType> field_types;
+ test::CreateTestFormField("Month", "card_month", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(CREDIT_CARD_EXP_MONTH);
+ test::CreateTestFormField("Year", "card_year", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR);
+ test::CreateTestFormField("Credit card", "card", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(CREDIT_CARD_NUMBER);
+
+ // Simulate having seen this form on page load.
+ // |form_structure| will be owned by |autofill_manager_|.
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission with no filled data.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission with filled local data.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
+ SuggestionBackendID guid("10000000-0000-0000-0000-000000000001",
+ 0); // local card
+ autofill_manager_->FillOrPreviewForm(
+ AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
+ autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
- AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission with filled server data.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
+ SuggestionBackendID guid("10000000-0000-0000-0000-000000000003",
+ 0); // full server card
+ autofill_manager_->FillOrPreviewForm(
+ AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
+ autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission with a masked card server suggestion.
+ base::HistogramTester histogram_tester;
+ SuggestionBackendID guid("10000000-0000-0000-0000-000000000002",
+ 0); // masked server card
+ autofill_manager_->FillOrPreviewForm(
+ AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
+ autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
+ autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
+ "6011000990139424");
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE,
+ 1);
+ }
+
+ // Recreating cards as the previous test should have upgraded the masked
+ // card to a full card.
+ personal_data_->RecreateCreditCards(
+ true /* include_local_credit_card */,
+ true /* include_masked_server_credit_card */,
+ true /* include_full_server_credit_card */);
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating multiple submissions.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::
+ FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_WILL_SUBMIT_ONCE,
+ 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0);
@@ -1606,6 +1830,15 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) {
autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
@@ -1871,7 +2104,10 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
false);
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1892,7 +2128,10 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
AutofillDriver::FORM_DATA_ACTION_FILL,
0, form, form.fields.front(),
autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid));
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1913,7 +2152,10 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
AutofillDriver::FORM_DATA_ACTION_FILL,
0, form, form.fields.front(),
autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid));
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1928,7 +2170,17 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
false);
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1947,9 +2199,163 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
{
// Simulating submission without previous interaction.
base::HistogramTester histogram_tester;
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+}
+
+// Test that we log "will submit" (but not submitted) form events for address.
+// Mirrors AddressSubmittedFormEvents test but does not expect any "submitted"
+// metrics.
+TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) {
+ EnableWalletSync();
+ // Creating all kinds of profiles.
+ personal_data_->RecreateProfiles(true /* include_local_profile */,
+ true /* include_server_profile */);
+ // 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;
+
+ FormFieldData field;
+ std::vector<ServerFieldType> field_types;
+ test::CreateTestFormField("State", "state", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(ADDRESS_HOME_STATE);
+ test::CreateTestFormField("City", "city", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(ADDRESS_HOME_CITY);
+ test::CreateTestFormField("Street", "street", "", "text", &field);
+ form.fields.push_back(field);
+ field_types.push_back(ADDRESS_HOME_STREET_ADDRESS);
+
+ // Simulate having seen this form on page load.
+ // |form_structure| will be owned by |autofill_manager_|.
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission with no filled data.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission with filled local data.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
+ SuggestionBackendID guid("00000000-0000-0000-0000-000000000001",
+ 0); // local profile
+ autofill_manager_->FillOrPreviewForm(
+ AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
+ autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid));
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission with filled server data.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
+ SuggestionBackendID guid("00000000-0000-0000-0000-000000000002",
+ 0); // server profile
+ autofill_manager_->FillOrPreviewForm(
+ AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
+ autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid));
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating multiple submissions.
+ base::HistogramTester histogram_tester;
+ autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
+ false);
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
+ }
+
+ // Reset the autofill manager state.
+ autofill_manager_->Reset();
+ autofill_manager_->AddSeenForm(form, field_types, field_types);
+
+ {
+ // Simulating submission without previous interaction.
+ base::HistogramTester histogram_tester;
autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 0);
+ histogram_tester.ExpectBucketCount(
+ "Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
@@ -2208,7 +2614,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
// Expect no notifications when the form is submitted.
{
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectTotalCount("Autofill.UserHappiness", 0);
}
@@ -2230,7 +2636,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
// Expect a notification when the form is submitted.
{
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectUniqueSample(
"Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM,
1);
@@ -2244,7 +2650,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
// Expect a notification when the form is submitted.
{
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectUniqueSample(
"Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM,
1);
@@ -2257,7 +2663,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
// Expect notifications when the form is submitted.
{
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectUniqueSample(
"Autofill.UserHappiness",
AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_NONE, 1);
@@ -2271,7 +2677,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
// Expect notifications when the form is submitted.
{
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectUniqueSample(
"Autofill.UserHappiness",
AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_SOME, 1);
@@ -2285,7 +2691,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
// Expect notifications when the form is submitted.
{
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectUniqueSample(
"Autofill.UserHappiness",
AutofillMetrics::SUBMITTED_FILLABLE_FORM_AUTOFILLED_ALL, 1);
@@ -2298,7 +2704,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
// Expect notifications when the form is submitted.
{
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
histogram_tester.ExpectUniqueSample(
"Autofill.UserHappiness", AutofillMetrics::SUBMITTED_NON_FILLABLE_FORM,
1);
@@ -2454,7 +2860,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
{
base::HistogramTester histogram_tester;
autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
- autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17));
+ autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17));
histogram_tester.ExpectTotalCount(
"Autofill.FillDuration.FromLoad.WithAutofill", 0);
@@ -2474,7 +2880,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
TimeTicks::FromInternalValue(3));
- autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17));
+ autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17));
histogram_tester.ExpectTotalCount(
"Autofill.FillDuration.FromLoad.WithAutofill", 0);
@@ -2495,7 +2901,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
autofill_manager_->OnDidFillAutofillFormData(
TimeTicks::FromInternalValue(5));
- autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17));
+ autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17));
histogram_tester.ExpectUniqueSample(
"Autofill.FillDuration.FromLoad.WithAutofill", 16, 1);
@@ -2520,7 +2926,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
TimeTicks::FromInternalValue(5));
autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
TimeTicks::FromInternalValue(3));
- autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17));
+ autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17));
histogram_tester.ExpectUniqueSample(
"Autofill.FillDuration.FromLoad.WithAutofill", 16, 1);
@@ -2545,7 +2951,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
TimeTicks::FromInternalValue(5));
autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
TimeTicks::FromInternalValue(3));
- autofill_manager_->WillSubmitForm(form, TimeTicks::FromInternalValue(17));
+ autofill_manager_->SubmitForm(form, TimeTicks::FromInternalValue(17));
histogram_tester.ExpectUniqueSample(
"Autofill.FillDuration.FromLoad.WithAutofill", 16, 1);
@@ -2566,8 +2972,8 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1));
autofill_manager_->OnFormsSeen(second_forms,
TimeTicks::FromInternalValue(5));
- autofill_manager_->WillSubmitForm(second_form,
- TimeTicks::FromInternalValue(17));
+ autofill_manager_->SubmitForm(second_form,
+ TimeTicks::FromInternalValue(17));
histogram_tester.ExpectTotalCount(
"Autofill.FillDuration.FromLoad.WithAutofill", 0);
« 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