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

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 884843002: Recording in UMA when a user interacted with an address form or a credit card form. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Recording in UMA when a user interacted with an address form or a credit card form. 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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 { 673 {
674 // Simulate activating the autofill popup for the email field after typing. 674 // Simulate activating the autofill popup for the email field after typing.
675 form.fields[0].is_autofilled = true; 675 form.fields[0].is_autofilled = true;
676 base::HistogramTester histogram_tester; 676 base::HistogramTester histogram_tester;
677 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), 677 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
678 false); 678 false);
679 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); 679 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0);
680 } 680 }
681 } 681 }
682 682
683 // Test that we log interacted form event for credit cards only once.
684 TEST_F(AutofillMetricsTest, CreditCardInteractedOnce) {
685 // Set up our form data.
686 FormData form;
687 form.name = ASCIIToUTF16("TestForm");
688 form.origin = GURL("http://example.com/form.html");
689 form.action = GURL("http://example.com/submit.html");
690 form.user_submitted = true;
691
692 FormFieldData field;
693 std::vector<ServerFieldType> field_types;
694 test::CreateTestFormField("Month", "card_month", "", "text", &field);
695 form.fields.push_back(field);
696 field_types.push_back(CREDIT_CARD_EXP_MONTH);
697 test::CreateTestFormField("Year", "card_year", "", "text", &field);
698 form.fields.push_back(field);
699 field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR);
700 test::CreateTestFormField("Credit card", "card", "", "text", &field);
701 form.fields.push_back(field);
702 field_types.push_back(CREDIT_CARD_NUMBER);
703
704 // Simulate having seen this form on page load.
705 // |form_structure| will be owned by |autofill_manager_|.
706 autofill_manager_->AddSeenForm(form, field_types, field_types);
707
708 {
709 // Simulate activating the autofill popup for the credit card field.
710 base::HistogramTester histogram_tester;
711 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
712 false);
713 histogram_tester.ExpectUniqueSample(
714 "Autofill.FormEvents.CreditCard", AutofillMetrics::INTERACTED_ONCE, 1);
715 }
716
717 // Reset the autofill manager state.
718 autofill_manager_->Reset();
719 autofill_manager_->AddSeenForm(form, field_types, field_types);
720
721 {
722 // Simulate activating the autofill popup for the credit card field twice.
723 base::HistogramTester histogram_tester;
724 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
725 false);
726 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect(),
727 false);
728 histogram_tester.ExpectUniqueSample(
729 "Autofill.FormEvents.CreditCard", AutofillMetrics::INTERACTED_ONCE, 1);
730 }
731 }
732
733 // Test that we log interacted form event for address only once.
734 TEST_F(AutofillMetricsTest, AddressInteractedOnce) {
735 // Set up our form data.
736 FormData form;
737 form.name = ASCIIToUTF16("TestForm");
738 form.origin = GURL("http://example.com/form.html");
739 form.action = GURL("http://example.com/submit.html");
740 form.user_submitted = true;
741
742 FormFieldData field;
743 std::vector<ServerFieldType> field_types;
744 test::CreateTestFormField("State", "state", "", "text", &field);
745 form.fields.push_back(field);
746 field_types.push_back(ADDRESS_HOME_STATE);
747 test::CreateTestFormField("City", "city", "", "text", &field);
748 form.fields.push_back(field);
749 field_types.push_back(ADDRESS_HOME_CITY);
750 test::CreateTestFormField("Street", "street", "", "text", &field);
751 form.fields.push_back(field);
752 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS);
753
754 // Simulate having seen this form on page load.
755 // |form_structure| will be owned by |autofill_manager_|.
756 autofill_manager_->AddSeenForm(form, field_types, field_types);
757
758 {
759 // Simulate activating the autofill popup for the street field.
760 base::HistogramTester histogram_tester;
761 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
762 false);
763 histogram_tester.ExpectUniqueSample(
764 "Autofill.FormEvents.Address", AutofillMetrics::INTERACTED_ONCE, 1);
765 }
766
767 // Reset the autofill manager state.
768 autofill_manager_->Reset();
769 autofill_manager_->AddSeenForm(form, field_types, field_types);
770
771 {
772 // Simulate activating the autofill popup for the street field twice.
773 base::HistogramTester histogram_tester;
774 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(),
775 false);
776 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect(),
777 false);
778 histogram_tester.ExpectUniqueSample(
779 "Autofill.FormEvents.Address", AutofillMetrics::INTERACTED_ONCE, 1);
780 }
781 }
782
683 // Test that we log that Autofill is enabled when filling a form. 783 // Test that we log that Autofill is enabled when filling a form.
684 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { 784 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) {
685 base::HistogramTester histogram_tester; 785 base::HistogramTester histogram_tester;
686 autofill_manager_->set_autofill_enabled(true); 786 autofill_manager_->set_autofill_enabled(true);
687 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); 787 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks());
688 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.PageLoad", true, 1); 788 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.PageLoad", true, 1);
689 } 789 }
690 790
691 // Test that we log that Autofill is disabled when filling a form. 791 // Test that we log that Autofill is disabled when filling a form.
692 TEST_F(AutofillMetricsTest, AutofillIsDisabledAtPageLoad) { 792 TEST_F(AutofillMetricsTest, AutofillIsDisabledAtPageLoad) {
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 histogram_tester.ExpectTotalCount( 1193 histogram_tester.ExpectTotalCount(
1094 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); 1194 "Autofill.FillDuration.FromInteraction.WithAutofill", 0);
1095 histogram_tester.ExpectTotalCount( 1195 histogram_tester.ExpectTotalCount(
1096 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); 1196 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0);
1097 1197
1098 autofill_manager_->Reset(); 1198 autofill_manager_->Reset();
1099 } 1199 }
1100 } 1200 }
1101 1201
1102 } // namespace autofill 1202 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698