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

Side by Side 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: separate tests 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/autofill_metrics.h" 5 #include "components/autofill/core/browser/autofill_metrics.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 "Autofill.Quality.PredictedType.ByFieldType", 498 "Autofill.Quality.PredictedType.ByFieldType",
499 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, 499 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY,
500 AutofillMetrics::TYPE_MISMATCH), 500 AutofillMetrics::TYPE_MISMATCH),
501 1); 501 1);
502 histogram_tester.ExpectBucketCount( 502 histogram_tester.ExpectBucketCount(
503 "Autofill.Quality.PredictedType.ByFieldType", 503 "Autofill.Quality.PredictedType.ByFieldType",
504 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), 504 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH),
505 1); 505 1);
506 } 506 }
507 507
508 // Verify that when submitting an autofillable form, the stored profile metric
509 // is logged.
510 TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) {
511 // Construct a fillable form.
512 FormData form;
513 form.name = ASCIIToUTF16("TestForm");
514 form.origin = GURL("http://example.com/form.html");
515 form.action = GURL("http://example.com/submit.html");
516 form.user_submitted = true;
517
518 // Three fields is enough to make it an autofillable form.
519 FormFieldData field;
520 test::CreateTestFormField("Name", "name", "", "text", &field);
521 form.fields.push_back(field);
522 test::CreateTestFormField("Email", "email", "", "text", &field);
523 form.fields.push_back(field);
524 test::CreateTestFormField("Phone", "phone", "", "text", &field);
525 form.fields.push_back(field);
526
527 std::vector<FormData> forms(1, form);
528
529 {
Ilya Sherman 2015/02/02 22:37:16 nit: No need for this scope, since the test is now
Mathieu 2015/02/03 03:14:01 Done.
530 // Simulate form submission.
531 base::HistogramTester histogram_tester;
532 autofill_manager_->OnFormsSeen(forms, TimeTicks());
533 autofill_manager_->FormSubmitted(form, TimeTicks::Now());
534
535 // An autofillable form was submitted, and the number of stored profiles is
536 // logged.
537 histogram_tester.ExpectUniqueSample(
538 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 2, 1);
539 }
540 }
541
542 // Verify that when submitting a non-autofillable form, the stored profile
543 // metric is not logged.
544 TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) {
545 // Construct a non-fillable form.
546 FormData form;
547 form.name = ASCIIToUTF16("TestForm");
548 form.origin = GURL("http://example.com/form.html");
549 form.action = GURL("http://example.com/submit.html");
550 form.user_submitted = true;
551
552 // Two fields is not enough to make it an autofillable form.
553 FormFieldData field;
554 test::CreateTestFormField("Name", "name", "", "text", &field);
555 form.fields.push_back(field);
556 test::CreateTestFormField("Email", "email", "", "text", &field);
557 form.fields.push_back(field);
558
559 std::vector<FormData> forms(1, form);
560
561 {
562 // Simulate form submission.
563 base::HistogramTester histogram_tester;
564 autofill_manager_->OnFormsSeen(forms, TimeTicks());
565 autofill_manager_->FormSubmitted(form, TimeTicks::Now());
566
567 // A non-autofillable form was submitted, and number of stored profiles is
568 // NOT logged.
569 histogram_tester.ExpectTotalCount(
570 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 0);
571 }
572 }
573
508 // Verify that we correctly log metrics regarding developer engagement. 574 // Verify that we correctly log metrics regarding developer engagement.
509 TEST_F(AutofillMetricsTest, DeveloperEngagement) { 575 TEST_F(AutofillMetricsTest, DeveloperEngagement) {
510 // Start with a non-fillable form. 576 // Start with a non-fillable form.
511 FormData form; 577 FormData form;
512 form.name = ASCIIToUTF16("TestForm"); 578 form.name = ASCIIToUTF16("TestForm");
513 form.origin = GURL("http://example.com/form.html"); 579 form.origin = GURL("http://example.com/form.html");
514 form.action = GURL("http://example.com/submit.html"); 580 form.action = GURL("http://example.com/submit.html");
515 581
516 FormFieldData field; 582 FormFieldData field;
517 test::CreateTestFormField("Name", "name", "", "text", &field); 583 test::CreateTestFormField("Name", "name", "", "text", &field);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 histogram_tester.ExpectTotalCount( 1159 histogram_tester.ExpectTotalCount(
1094 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); 1160 "Autofill.FillDuration.FromInteraction.WithAutofill", 0);
1095 histogram_tester.ExpectTotalCount( 1161 histogram_tester.ExpectTotalCount(
1096 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); 1162 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0);
1097 1163
1098 autofill_manager_->Reset(); 1164 autofill_manager_->Reset();
1099 } 1165 }
1100 } 1166 }
1101 1167
1102 } // namespace autofill 1168 } // namespace autofill
OLDNEW
« 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