OLD | NEW |
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/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/test/histogram_tester.h" | 15 #include "base/test/histogram_tester.h" |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "components/autofill/core/browser/autofill_external_delegate.h" | 17 #include "components/autofill/core/browser/autofill_external_delegate.h" |
17 #include "components/autofill/core/browser/autofill_manager.h" | 18 #include "components/autofill/core/browser/autofill_manager.h" |
18 #include "components/autofill/core/browser/autofill_test_utils.h" | 19 #include "components/autofill/core/browser/autofill_test_utils.h" |
19 #include "components/autofill/core/browser/personal_data_manager.h" | 20 #include "components/autofill/core/browser/personal_data_manager.h" |
20 #include "components/autofill/core/browser/test_autofill_client.h" | 21 #include "components/autofill/core/browser/test_autofill_client.h" |
21 #include "components/autofill/core/browser/test_autofill_driver.h" | 22 #include "components/autofill/core/browser/test_autofill_driver.h" |
22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 23 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 24 #include "components/autofill/core/common/autofill_pref_names.h" |
| 25 #include "components/autofill/core/common/autofill_switches.h" |
23 #include "components/autofill/core/common/form_data.h" | 26 #include "components/autofill/core/common/form_data.h" |
24 #include "components/autofill/core/common/form_field_data.h" | 27 #include "components/autofill/core/common/form_field_data.h" |
25 #include "components/webdata/common/web_data_results.h" | 28 #include "components/webdata/common/web_data_results.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
28 #include "url/gurl.h" | 31 #include "url/gurl.h" |
29 | 32 |
30 using base::ASCIIToUTF16; | 33 using base::ASCIIToUTF16; |
31 using base::TimeTicks; | 34 using base::TimeTicks; |
32 | 35 |
33 namespace autofill { | 36 namespace autofill { |
34 namespace { | 37 namespace { |
35 | 38 |
36 class TestPersonalDataManager : public PersonalDataManager { | 39 class TestPersonalDataManager : public PersonalDataManager { |
37 public: | 40 public: |
38 TestPersonalDataManager() | 41 TestPersonalDataManager() |
39 : PersonalDataManager("en-US"), autofill_enabled_(true) { | 42 : PersonalDataManager("en-US"), |
| 43 autofill_enabled_(true) { |
40 CreateTestAutofillProfiles(&web_profiles_); | 44 CreateTestAutofillProfiles(&web_profiles_); |
41 } | 45 } |
42 | 46 |
43 using PersonalDataManager::set_database; | 47 using PersonalDataManager::set_database; |
44 using PersonalDataManager::SetPrefService; | 48 using PersonalDataManager::SetPrefService; |
45 | 49 |
46 // Overridden to avoid a trip to the database. This should be a no-op except | 50 // Overridden to avoid a trip to the database. This should be a no-op except |
47 // for the side-effect of logging the profile count. | 51 // for the side-effect of logging the profile count. |
48 void LoadProfiles() override { | 52 void LoadProfiles() override { |
49 std::vector<AutofillProfile*> profiles; | 53 { |
50 web_profiles_.release(&profiles); | 54 std::vector<AutofillProfile*> profiles; |
51 WDResult<std::vector<AutofillProfile*> > result(AUTOFILL_PROFILES_RESULT, | 55 web_profiles_.release(&profiles); |
52 profiles); | 56 WDResult<std::vector<AutofillProfile*> > result(AUTOFILL_PROFILES_RESULT, |
53 pending_profiles_query_ = 123; | 57 profiles); |
54 OnWebDataServiceRequestDone(pending_profiles_query_, &result); | 58 pending_profiles_query_ = 123; |
| 59 OnWebDataServiceRequestDone(pending_profiles_query_, &result); |
| 60 } |
| 61 { |
| 62 std::vector<AutofillProfile*> profiles; |
| 63 server_profiles_.release(&profiles); |
| 64 WDResult<std::vector<AutofillProfile*> > result(AUTOFILL_PROFILES_RESULT, |
| 65 profiles); |
| 66 pending_server_profiles_query_ = 124; |
| 67 OnWebDataServiceRequestDone(pending_server_profiles_query_, &result); |
| 68 } |
55 } | 69 } |
56 | 70 |
57 // Overridden to avoid a trip to the database. | 71 // Overridden to avoid a trip to the database. |
58 void LoadCreditCards() override {} | 72 void LoadCreditCards() override { |
| 73 { |
| 74 std::vector<CreditCard*> credit_cards; |
| 75 local_credit_cards_.release(&credit_cards); |
| 76 WDResult<std::vector<CreditCard*> > result( |
| 77 AUTOFILL_CREDITCARDS_RESULT, credit_cards); |
| 78 pending_creditcards_query_ = 125; |
| 79 OnWebDataServiceRequestDone(pending_creditcards_query_, &result); |
| 80 } |
| 81 { |
| 82 std::vector<CreditCard*> credit_cards; |
| 83 server_credit_cards_.release(&credit_cards); |
| 84 WDResult<std::vector<CreditCard*> > result( |
| 85 AUTOFILL_CREDITCARDS_RESULT, credit_cards); |
| 86 pending_server_creditcards_query_ = 126; |
| 87 OnWebDataServiceRequestDone(pending_server_creditcards_query_, &result); |
| 88 } |
| 89 } |
59 | 90 |
60 void set_autofill_enabled(bool autofill_enabled) { | 91 void set_autofill_enabled(bool autofill_enabled) { |
61 autofill_enabled_ = autofill_enabled; | 92 autofill_enabled_ = autofill_enabled; |
62 } | 93 } |
63 | 94 |
| 95 // Removes all existing profiles and creates 0 or 1 local profiles and 0 or 1 |
| 96 // server profile according to the paramters. |
| 97 void RecreateProfiles(bool include_local_profile, |
| 98 bool include_server_profile) { |
| 99 web_profiles_.clear(); |
| 100 server_profiles_.clear(); |
| 101 if (include_local_profile) { |
| 102 AutofillProfile* profile = new AutofillProfile; |
| 103 test::SetProfileInfo(profile, "Elvis", "Aaron", |
| 104 "Presley", "theking@gmail.com", "RCA", |
| 105 "3734 Elvis Presley Blvd.", "Apt. 10", |
| 106 "Memphis", "Tennessee", "38116", "US", |
| 107 "12345678901"); |
| 108 profile->set_guid("00000000-0000-0000-0000-000000000001"); |
| 109 web_profiles_.push_back(profile); |
| 110 } |
| 111 if (include_server_profile) { |
| 112 AutofillProfile* profile = new AutofillProfile( |
| 113 AutofillProfile::SERVER_PROFILE, "server_id"); |
| 114 test::SetProfileInfo(profile, "Charles", "Hardin", |
| 115 "Holley", "buddy@gmail.com", "Decca", |
| 116 "123 Apple St.", "unit 6", "Lubbock", |
| 117 "Texas", "79401", "US", "2345678901"); |
| 118 profile->set_guid("00000000-0000-0000-0000-000000000002"); |
| 119 server_profiles_.push_back(profile); |
| 120 } |
| 121 Refresh(); |
| 122 } |
| 123 |
| 124 // Removes all existing credit cards and creates 0 or 1 local profiles and |
| 125 // 0 or 1 server profile according to the paramters. |
| 126 void RecreateCreditCards(bool include_local_credit_card, |
| 127 bool include_masked_server_credit_card, |
| 128 bool include_full_server_credit_card) { |
| 129 local_credit_cards_.clear(); |
| 130 server_credit_cards_.clear(); |
| 131 if (include_local_credit_card) { |
| 132 CreditCard* credit_card = new CreditCard; |
| 133 credit_card->set_guid("10000000-0000-0000-0000-000000000001"); |
| 134 local_credit_cards_.push_back(credit_card); |
| 135 } |
| 136 if (include_masked_server_credit_card) { |
| 137 CreditCard* credit_card = new CreditCard( |
| 138 CreditCard::MASKED_SERVER_CARD, "server_id"); |
| 139 credit_card->set_guid("10000000-0000-0000-0000-000000000002"); |
| 140 server_credit_cards_.push_back(credit_card); |
| 141 } |
| 142 if (include_full_server_credit_card) { |
| 143 CreditCard* credit_card = new CreditCard( |
| 144 CreditCard::FULL_SERVER_CARD, "server_id"); |
| 145 credit_card->set_guid("10000000-0000-0000-0000-000000000003"); |
| 146 server_credit_cards_.push_back(credit_card); |
| 147 } |
| 148 Refresh(); |
| 149 } |
| 150 |
64 bool IsAutofillEnabled() const override { return autofill_enabled_; } | 151 bool IsAutofillEnabled() const override { return autofill_enabled_; } |
65 | 152 |
66 private: | 153 private: |
67 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { | 154 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { |
68 AutofillProfile* profile = new AutofillProfile; | 155 AutofillProfile* profile = new AutofillProfile; |
69 test::SetProfileInfo(profile, "Elvis", "Aaron", | 156 test::SetProfileInfo(profile, "Elvis", "Aaron", |
70 "Presley", "theking@gmail.com", "RCA", | 157 "Presley", "theking@gmail.com", "RCA", |
71 "3734 Elvis Presley Blvd.", "Apt. 10", | 158 "3734 Elvis Presley Blvd.", "Apt. 10", |
72 "Memphis", "Tennessee", "38116", "US", | 159 "Memphis", "Tennessee", "38116", "US", |
73 "12345678901"); | 160 "12345678901"); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 { | 760 { |
674 // Simulate activating the autofill popup for the email field after typing. | 761 // Simulate activating the autofill popup for the email field after typing. |
675 form.fields[0].is_autofilled = true; | 762 form.fields[0].is_autofilled = true; |
676 base::HistogramTester histogram_tester; | 763 base::HistogramTester histogram_tester; |
677 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 764 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
678 false); | 765 false); |
679 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); | 766 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); |
680 } | 767 } |
681 } | 768 } |
682 | 769 |
| 770 // Test that we log interacted form event for credit cards only once. |
| 771 TEST_F(AutofillMetricsTest, CreditCardInteractedOnce) { |
| 772 // Set up our form data. |
| 773 FormData form; |
| 774 form.name = ASCIIToUTF16("TestForm"); |
| 775 form.origin = GURL("http://example.com/form.html"); |
| 776 form.action = GURL("http://example.com/submit.html"); |
| 777 form.user_submitted = true; |
| 778 |
| 779 FormFieldData field; |
| 780 std::vector<ServerFieldType> field_types; |
| 781 test::CreateTestFormField("Month", "card_month", "", "text", &field); |
| 782 form.fields.push_back(field); |
| 783 field_types.push_back(CREDIT_CARD_EXP_MONTH); |
| 784 test::CreateTestFormField("Year", "card_year", "", "text", &field); |
| 785 form.fields.push_back(field); |
| 786 field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 787 test::CreateTestFormField("Credit card", "card", "", "text", &field); |
| 788 form.fields.push_back(field); |
| 789 field_types.push_back(CREDIT_CARD_NUMBER); |
| 790 |
| 791 // Simulate having seen this form on page load. |
| 792 // |form_structure| will be owned by |autofill_manager_|. |
| 793 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 794 |
| 795 { |
| 796 // Simulate activating the autofill popup for the credit card field. |
| 797 base::HistogramTester histogram_tester; |
| 798 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 799 false); |
| 800 histogram_tester.ExpectUniqueSample( |
| 801 "Autofill.FormEvents.CreditCard", |
| 802 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 803 } |
| 804 |
| 805 // Reset the autofill manager state. |
| 806 autofill_manager_->Reset(); |
| 807 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 808 |
| 809 { |
| 810 // Simulate activating the autofill popup for the credit card field twice. |
| 811 base::HistogramTester histogram_tester; |
| 812 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 813 false); |
| 814 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect(), |
| 815 false); |
| 816 histogram_tester.ExpectUniqueSample( |
| 817 "Autofill.FormEvents.CreditCard", |
| 818 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 819 } |
| 820 } |
| 821 |
| 822 // Test that we log interacted form event for address only once. |
| 823 TEST_F(AutofillMetricsTest, AddressInteractedOnce) { |
| 824 // Set up our form data. |
| 825 FormData form; |
| 826 form.name = ASCIIToUTF16("TestForm"); |
| 827 form.origin = GURL("http://example.com/form.html"); |
| 828 form.action = GURL("http://example.com/submit.html"); |
| 829 form.user_submitted = true; |
| 830 |
| 831 FormFieldData field; |
| 832 std::vector<ServerFieldType> field_types; |
| 833 test::CreateTestFormField("State", "state", "", "text", &field); |
| 834 form.fields.push_back(field); |
| 835 field_types.push_back(ADDRESS_HOME_STATE); |
| 836 test::CreateTestFormField("City", "city", "", "text", &field); |
| 837 form.fields.push_back(field); |
| 838 field_types.push_back(ADDRESS_HOME_CITY); |
| 839 test::CreateTestFormField("Street", "street", "", "text", &field); |
| 840 form.fields.push_back(field); |
| 841 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); |
| 842 |
| 843 // Simulate having seen this form on page load. |
| 844 // |form_structure| will be owned by |autofill_manager_|. |
| 845 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 846 |
| 847 { |
| 848 // Simulate activating the autofill popup for the street field. |
| 849 base::HistogramTester histogram_tester; |
| 850 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 851 false); |
| 852 histogram_tester.ExpectUniqueSample( |
| 853 "Autofill.FormEvents.Address", |
| 854 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 855 } |
| 856 |
| 857 // Reset the autofill manager state. |
| 858 autofill_manager_->Reset(); |
| 859 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 860 |
| 861 { |
| 862 // Simulate activating the autofill popup for the street field twice. |
| 863 base::HistogramTester histogram_tester; |
| 864 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 865 false); |
| 866 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect(), |
| 867 false); |
| 868 histogram_tester.ExpectUniqueSample( |
| 869 "Autofill.FormEvents.Address", |
| 870 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 871 } |
| 872 } |
| 873 |
| 874 // Test that we log interacted form event for credit cards only once. |
| 875 TEST_F(AutofillMetricsTest, CreditCardFormEventsAreSegmented) { |
| 876 // Enabling server card. |
| 877 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 878 ::autofill::switches::kEnableWalletCardImport); |
| 879 autofill_client_.GetPrefs()->SetBoolean( |
| 880 ::autofill::prefs::kAutofillWalletImportEnabled, true); |
| 881 // Set up our form data. |
| 882 FormData form; |
| 883 form.name = ASCIIToUTF16("TestForm"); |
| 884 form.origin = GURL("http://example.com/form.html"); |
| 885 form.action = GURL("http://example.com/submit.html"); |
| 886 form.user_submitted = true; |
| 887 |
| 888 FormFieldData field; |
| 889 std::vector<ServerFieldType> field_types; |
| 890 test::CreateTestFormField("Month", "card_month", "", "text", &field); |
| 891 form.fields.push_back(field); |
| 892 field_types.push_back(CREDIT_CARD_EXP_MONTH); |
| 893 test::CreateTestFormField("Year", "card_year", "", "text", &field); |
| 894 form.fields.push_back(field); |
| 895 field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 896 test::CreateTestFormField("Credit card", "card", "", "text", &field); |
| 897 form.fields.push_back(field); |
| 898 field_types.push_back(CREDIT_CARD_NUMBER); |
| 899 |
| 900 // Simulate having seen this form on page load. |
| 901 // |form_structure| will be owned by |autofill_manager_|. |
| 902 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 903 personal_data_->RecreateCreditCards( |
| 904 false /* include_local_credit_card */, |
| 905 false /* include_masked_server_credit_card */, |
| 906 false /* include_full_server_credit_card */); |
| 907 |
| 908 { |
| 909 // Simulate activating the autofill popup for the credit card field. |
| 910 base::HistogramTester histogram_tester; |
| 911 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 912 false); |
| 913 histogram_tester.ExpectUniqueSample( |
| 914 "Autofill.FormEvents.CreditCard.WithNoData", |
| 915 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 916 } |
| 917 |
| 918 // Reset the autofill manager state. |
| 919 autofill_manager_->Reset(); |
| 920 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 921 personal_data_->RecreateCreditCards( |
| 922 true /* include_local_credit_card */, |
| 923 false /* include_masked_server_credit_card */, |
| 924 false /* include_full_server_credit_card */); |
| 925 |
| 926 { |
| 927 // Simulate activating the autofill popup for the credit card field. |
| 928 base::HistogramTester histogram_tester; |
| 929 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 930 false); |
| 931 histogram_tester.ExpectUniqueSample( |
| 932 "Autofill.FormEvents.CreditCard.WithOnlyLocalData", |
| 933 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 934 } |
| 935 |
| 936 // Reset the autofill manager state. |
| 937 autofill_manager_->Reset(); |
| 938 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 939 personal_data_->RecreateCreditCards( |
| 940 false /* include_local_credit_card */, |
| 941 true /* include_masked_server_credit_card */, |
| 942 false /* include_full_server_credit_card */); |
| 943 |
| 944 { |
| 945 // Simulate activating the autofill popup for the credit card field. |
| 946 base::HistogramTester histogram_tester; |
| 947 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 948 false); |
| 949 histogram_tester.ExpectUniqueSample( |
| 950 "Autofill.FormEvents.CreditCard.WithOnlyServerData", |
| 951 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 952 } |
| 953 |
| 954 // Reset the autofill manager state. |
| 955 autofill_manager_->Reset(); |
| 956 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 957 personal_data_->RecreateCreditCards( |
| 958 false /* include_local_credit_card */, |
| 959 false /* include_masked_server_credit_card */, |
| 960 true /* include_full_server_credit_card */); |
| 961 |
| 962 { |
| 963 // Simulate activating the autofill popup for the credit card field. |
| 964 base::HistogramTester histogram_tester; |
| 965 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 966 false); |
| 967 histogram_tester.ExpectUniqueSample( |
| 968 "Autofill.FormEvents.CreditCard.WithOnlyServerData", |
| 969 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 970 } |
| 971 |
| 972 // Reset the autofill manager state. |
| 973 autofill_manager_->Reset(); |
| 974 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 975 personal_data_->RecreateCreditCards( |
| 976 true /* include_local_credit_card */, |
| 977 false /* include_masked_server_credit_card */, |
| 978 true /* include_full_server_credit_card */); |
| 979 |
| 980 { |
| 981 // Simulate activating the autofill popup for the credit card field. |
| 982 base::HistogramTester histogram_tester; |
| 983 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 984 false); |
| 985 histogram_tester.ExpectUniqueSample( |
| 986 "Autofill.FormEvents.CreditCard.WithBothServerAndLocalData", |
| 987 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 988 } |
| 989 } |
| 990 |
| 991 // Test that we log interacted form event for address only once. |
| 992 TEST_F(AutofillMetricsTest, AddressFormEventsAreSegmented) { |
| 993 // Set up our form data. |
| 994 FormData form; |
| 995 form.name = ASCIIToUTF16("TestForm"); |
| 996 form.origin = GURL("http://example.com/form.html"); |
| 997 form.action = GURL("http://example.com/submit.html"); |
| 998 form.user_submitted = true; |
| 999 |
| 1000 FormFieldData field; |
| 1001 std::vector<ServerFieldType> field_types; |
| 1002 test::CreateTestFormField("State", "state", "", "text", &field); |
| 1003 form.fields.push_back(field); |
| 1004 field_types.push_back(ADDRESS_HOME_STATE); |
| 1005 test::CreateTestFormField("City", "city", "", "text", &field); |
| 1006 form.fields.push_back(field); |
| 1007 field_types.push_back(ADDRESS_HOME_CITY); |
| 1008 test::CreateTestFormField("Street", "street", "", "text", &field); |
| 1009 form.fields.push_back(field); |
| 1010 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); |
| 1011 |
| 1012 // Simulate having seen this form on page load. |
| 1013 // |form_structure| will be owned by |autofill_manager_|. |
| 1014 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1015 personal_data_->RecreateProfiles(false /* include_local_profile */, |
| 1016 false /* include_server_profile */); |
| 1017 |
| 1018 { |
| 1019 // Simulate activating the autofill popup for the street field. |
| 1020 base::HistogramTester histogram_tester; |
| 1021 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1022 false); |
| 1023 histogram_tester.ExpectUniqueSample( |
| 1024 "Autofill.FormEvents.Address.WithNoData", |
| 1025 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 1026 } |
| 1027 |
| 1028 // Reset the autofill manager state. |
| 1029 autofill_manager_->Reset(); |
| 1030 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1031 personal_data_->RecreateProfiles(true /* include_local_profile */, |
| 1032 false /* include_server_profile */); |
| 1033 |
| 1034 { |
| 1035 // Simulate activating the autofill popup for the street field. |
| 1036 base::HistogramTester histogram_tester; |
| 1037 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1038 false); |
| 1039 histogram_tester.ExpectUniqueSample( |
| 1040 "Autofill.FormEvents.Address.WithOnlyLocalData", |
| 1041 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 1042 } |
| 1043 |
| 1044 // Reset the autofill manager state. |
| 1045 autofill_manager_->Reset(); |
| 1046 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1047 personal_data_->RecreateProfiles(false /* include_local_profile */, |
| 1048 true /* include_server_profile */); |
| 1049 |
| 1050 { |
| 1051 // Simulate activating the autofill popup for the street field. |
| 1052 base::HistogramTester histogram_tester; |
| 1053 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1054 false); |
| 1055 histogram_tester.ExpectUniqueSample( |
| 1056 "Autofill.FormEvents.Address.WithOnlyServerData", |
| 1057 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 1058 } |
| 1059 |
| 1060 // Reset the autofill manager state. |
| 1061 autofill_manager_->Reset(); |
| 1062 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 1063 personal_data_->RecreateProfiles(true /* include_local_profile */, |
| 1064 true /* include_server_profile */); |
| 1065 |
| 1066 { |
| 1067 // Simulate activating the autofill popup for the street field. |
| 1068 base::HistogramTester histogram_tester; |
| 1069 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), |
| 1070 false); |
| 1071 histogram_tester.ExpectUniqueSample( |
| 1072 "Autofill.FormEvents.Address.WithBothServerAndLocalData", |
| 1073 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 1074 } |
| 1075 } |
| 1076 |
| 1077 |
683 // Test that we log that Autofill is enabled when filling a form. | 1078 // Test that we log that Autofill is enabled when filling a form. |
684 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { | 1079 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { |
685 base::HistogramTester histogram_tester; | 1080 base::HistogramTester histogram_tester; |
686 autofill_manager_->set_autofill_enabled(true); | 1081 autofill_manager_->set_autofill_enabled(true); |
687 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); | 1082 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); |
688 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.PageLoad", true, 1); | 1083 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.PageLoad", true, 1); |
689 } | 1084 } |
690 | 1085 |
691 // Test that we log that Autofill is disabled when filling a form. | 1086 // Test that we log that Autofill is disabled when filling a form. |
692 TEST_F(AutofillMetricsTest, AutofillIsDisabledAtPageLoad) { | 1087 TEST_F(AutofillMetricsTest, AutofillIsDisabledAtPageLoad) { |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 histogram_tester.ExpectTotalCount( | 1488 histogram_tester.ExpectTotalCount( |
1094 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); | 1489 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); |
1095 histogram_tester.ExpectTotalCount( | 1490 histogram_tester.ExpectTotalCount( |
1096 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 1491 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
1097 | 1492 |
1098 autofill_manager_->Reset(); | 1493 autofill_manager_->Reset(); |
1099 } | 1494 } |
1100 } | 1495 } |
1101 | 1496 |
1102 } // namespace autofill | 1497 } // namespace autofill |
OLD | NEW |