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

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: git cl format 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
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..881161f6f60702fe993de218fd42572fd5fd77c0 100644
--- a/components/autofill/core/browser/autofill_metrics_unittest.cc
+++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
@@ -229,13 +229,16 @@ class TestAutofillManager : public AutofillManager {
form_structures()->push_back(form_structure);
}
- void WillSubmitForm(const FormData& form, const TimeTicks& timestamp) {
+ // Calls both OnWillSubmitForm and OnFormSubmitted.
Ilya Sherman 2015/03/18 22:42:10 Please add test coverage for OnWillSubmitForm bein
Mathieu 2015/03/23 15:24:02 Done.
+ void SubmitForm(const FormData& form, const TimeTicks& timestamp) {
run_loop_.reset(new base::RunLoop());
if (!OnWillSubmitForm(form, timestamp))
return;
// Wait for the asynchronous OnWillSubmitForm() call to complete.
run_loop_->Run();
+
+ OnFormSubmitted(form);
}
void UploadFormDataAsyncCallback(
@@ -377,7 +380,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 +502,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 +545,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 +588,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 +641,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 +694,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 +807,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 +917,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 +947,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 +1493,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_WILL_SUBMIT,
+ 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1511,7 +1517,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_WILL_SUBMIT,
+ 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1532,7 +1541,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_WILL_SUBMIT,
+ 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1578,8 +1590,11 @@ 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_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_WILL_SUBMIT,
+ 2);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1603,7 +1618,10 @@ TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) {
{
// Simulating submission without previous interaction.
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount("Autofill.FormEvents.CreditCard",
+ AutofillMetrics::FORM_EVENT_WILL_SUBMIT,
+ 0);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.CreditCard",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
@@ -1871,7 +1889,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_WILL_SUBMIT,
+ 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1892,7 +1913,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_WILL_SUBMIT,
+ 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1913,7 +1937,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_WILL_SUBMIT,
+ 1);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1928,7 +1955,11 @@ 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_WILL_SUBMIT,
+ 2);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1);
@@ -1947,7 +1978,10 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
{
// Simulating submission without previous interaction.
base::HistogramTester histogram_tester;
- autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
+ autofill_manager_->SubmitForm(form, TimeTicks::Now());
+ histogram_tester.ExpectBucketCount("Autofill.FormEvents.Address",
+ AutofillMetrics::FORM_EVENT_WILL_SUBMIT,
+ 0);
histogram_tester.ExpectBucketCount(
"Autofill.FormEvents.Address",
AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0);
@@ -2208,7 +2242,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 +2264,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 +2278,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 +2291,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 +2305,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 +2319,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 +2332,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 +2488,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 +2508,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 +2529,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 +2554,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 +2579,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 +2600,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);

Powered by Google App Engine
This is Rietveld 408576698