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

Side by Side 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: 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 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 "Autofill.Quality.PredictedType.ByFieldType", 689 "Autofill.Quality.PredictedType.ByFieldType",
690 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, 690 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY,
691 AutofillMetrics::TYPE_MISMATCH), 691 AutofillMetrics::TYPE_MISMATCH),
692 1); 692 1);
693 histogram_tester.ExpectBucketCount( 693 histogram_tester.ExpectBucketCount(
694 "Autofill.Quality.PredictedType.ByFieldType", 694 "Autofill.Quality.PredictedType.ByFieldType",
695 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), 695 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH),
696 1); 696 1);
697 } 697 }
698 698
699 // Test that we log user submitted forms appropriately.
700 TEST_F(AutofillMetricsTest, LogIsFormUserSubmitted_UserSubmitted) {
701 // Set up our form data.
702 FormData form;
703 form.name = ASCIIToUTF16("TestForm");
704 form.origin = GURL("http://example.com/form.html");
705 form.action = GURL("http://example.com/submit.html");
706 form.user_submitted = true;
707
708 std::vector<ServerFieldType> heuristic_types, server_types;
709 FormFieldData field;
710
711 test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
712 "text", &field);
713 field.is_autofilled = true;
714 form.fields.push_back(field);
715 heuristic_types.push_back(NAME_FIRST);
716 server_types.push_back(NO_SERVER_DATA);
717
718 test::CreateTestFormField("Autofill Failed", "autofillfailed",
719 "buddy@gmail.com", "text", &field);
720 field.is_autofilled = false;
721 form.fields.push_back(field);
722 heuristic_types.push_back(PHONE_HOME_WHOLE_NUMBER);
723 server_types.push_back(EMAIL_ADDRESS);
724
725 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
726 field.is_autofilled = true;
727 form.fields.push_back(field);
728 heuristic_types.push_back(PHONE_HOME_NUMBER);
729 server_types.push_back(PHONE_HOME_CITY_AND_NUMBER);
730
731 // Simulate having seen this form on page load.
732 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
733
734 // Simulate form submission.
735 base::HistogramTester histogram_tester;
736 autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
737
738 // An autofillable form was user submitted.
739 histogram_tester.ExpectUniqueSample("Autofill.IsFormUserSubmitted", true, 1);
740 }
741
742 // Test that we log non-user submitted forms appropriately.
743 TEST_F(AutofillMetricsTest, LogIsFormUserSubmitted_NotUserSubmitted) {
744 // Set up our form data.
745 FormData form;
746 form.name = ASCIIToUTF16("TestForm");
747 form.origin = GURL("http://example.com/form.html");
748 form.action = GURL("http://example.com/submit.html");
749 form.user_submitted = false;
750
751 std::vector<ServerFieldType> heuristic_types, server_types;
752 FormFieldData field;
753
754 test::CreateTestFormField("Autofilled", "autofilled", "Elvis Aaron Presley",
755 "text", &field);
756 field.is_autofilled = true;
757 form.fields.push_back(field);
758 heuristic_types.push_back(NAME_FIRST);
759 server_types.push_back(NO_SERVER_DATA);
760
761 test::CreateTestFormField("Autofill Failed", "autofillfailed",
762 "buddy@gmail.com", "text", &field);
763 field.is_autofilled = false;
764 form.fields.push_back(field);
765 heuristic_types.push_back(PHONE_HOME_WHOLE_NUMBER);
766 server_types.push_back(EMAIL_ADDRESS);
767
768 test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field);
769 field.is_autofilled = true;
770 form.fields.push_back(field);
771 heuristic_types.push_back(PHONE_HOME_NUMBER);
772 server_types.push_back(PHONE_HOME_CITY_AND_NUMBER);
773
774 // Simulate having seen this form on page load.
775 autofill_manager_->AddSeenForm(form, heuristic_types, server_types);
776
777 // Simulate form submission.
778 base::HistogramTester histogram_tester;
779 autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
780
781 // An autofillable form was NOT user submitted.
782 histogram_tester.ExpectUniqueSample("Autofill.IsFormUserSubmitted", false, 1);
783 }
784
699 // Verify that when submitting an autofillable form, the stored profile metric 785 // Verify that when submitting an autofillable form, the stored profile metric
700 // is logged. 786 // is logged.
701 TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) { 787 TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) {
702 // Construct a fillable form. 788 // Construct a fillable form.
703 FormData form; 789 FormData form;
704 form.name = ASCIIToUTF16("TestForm"); 790 form.name = ASCIIToUTF16("TestForm");
705 form.origin = GURL("http://example.com/form.html"); 791 form.origin = GURL("http://example.com/form.html");
706 form.action = GURL("http://example.com/submit.html"); 792 form.action = GURL("http://example.com/submit.html");
707 form.user_submitted = true; 793 form.user_submitted = true;
708 794
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 histogram_tester.ExpectTotalCount( 2468 histogram_tester.ExpectTotalCount(
2383 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); 2469 "Autofill.FillDuration.FromInteraction.WithAutofill", 0);
2384 histogram_tester.ExpectTotalCount( 2470 histogram_tester.ExpectTotalCount(
2385 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); 2471 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0);
2386 2472
2387 autofill_manager_->Reset(); 2473 autofill_manager_->Reset();
2388 } 2474 }
2389 } 2475 }
2390 2476
2391 } // namespace autofill 2477 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698