| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // form submission. | 117 // form submission. |
| 118 web_profiles_.clear(); | 118 web_profiles_.clear(); |
| 119 for (const auto& profile : *profiles) | 119 for (const auto& profile : *profiles) |
| 120 web_profiles_.push_back(base::MakeUnique<AutofillProfile>(profile)); | 120 web_profiles_.push_back(base::MakeUnique<AutofillProfile>(profile)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void set_autofill_enabled(bool autofill_enabled) { | 123 void set_autofill_enabled(bool autofill_enabled) { |
| 124 autofill_enabled_ = autofill_enabled; | 124 autofill_enabled_ = autofill_enabled; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Removes all existing profiles and creates 0 or 1 local profiles and 0 or 1 | 127 // Removes all existing profiles |
| 128 // server profile according to the parameters. | 128 void ClearProfiles() { |
| 129 void RecreateProfiles(bool include_local_profile, | |
| 130 bool include_server_profile) { | |
| 131 web_profiles_.clear(); | 129 web_profiles_.clear(); |
| 132 server_profiles_.clear(); | |
| 133 if (include_local_profile) { | |
| 134 std::unique_ptr<AutofillProfile> profile = | |
| 135 base::MakeUnique<AutofillProfile>(); | |
| 136 test::SetProfileInfo(profile.get(), "Elvis", "Aaron", "Presley", | |
| 137 "theking@gmail.com", "RCA", | |
| 138 "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", | |
| 139 "Tennessee", "38116", "US", "12345678901"); | |
| 140 profile->set_guid("00000000-0000-0000-0000-000000000001"); | |
| 141 web_profiles_.push_back(std::move(profile)); | |
| 142 } | |
| 143 if (include_server_profile) { | |
| 144 std::unique_ptr<AutofillProfile> profile = | |
| 145 base::MakeUnique<AutofillProfile>(AutofillProfile::SERVER_PROFILE, | |
| 146 "server_id"); | |
| 147 test::SetProfileInfo(profile.get(), "Charles", "Hardin", "Holley", | |
| 148 "buddy@gmail.com", "Decca", "123 Apple St.", | |
| 149 "unit 6", "Lubbock", "Texas", "79401", "US", | |
| 150 "2345678901"); | |
| 151 profile->set_guid("00000000-0000-0000-0000-000000000002"); | |
| 152 server_profiles_.push_back(std::move(profile)); | |
| 153 } | |
| 154 Refresh(); | 130 Refresh(); |
| 155 } | 131 } |
| 156 | 132 |
| 133 // Removes all existing profiles and creates one profile. |
| 134 void RecreateProfile() { |
| 135 web_profiles_.clear(); |
| 136 |
| 137 std::unique_ptr<AutofillProfile> profile = |
| 138 base::MakeUnique<AutofillProfile>(); |
| 139 test::SetProfileInfo(profile.get(), "Elvis", "Aaron", "Presley", |
| 140 "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.", |
| 141 "Apt. 10", "Memphis", "Tennessee", "38116", "US", |
| 142 "12345678901"); |
| 143 profile->set_guid("00000000-0000-0000-0000-000000000001"); |
| 144 web_profiles_.push_back(std::move(profile)); |
| 145 |
| 146 Refresh(); |
| 147 } |
| 148 |
| 157 // Removes all existing credit cards and creates 0 or 1 local profiles and | 149 // Removes all existing credit cards and creates 0 or 1 local profiles and |
| 158 // 0 or 1 server profile according to the parameters. | 150 // 0 or 1 server profile according to the parameters. |
| 159 void RecreateCreditCards(bool include_local_credit_card, | 151 void RecreateCreditCards(bool include_local_credit_card, |
| 160 bool include_masked_server_credit_card, | 152 bool include_masked_server_credit_card, |
| 161 bool include_full_server_credit_card) { | 153 bool include_full_server_credit_card) { |
| 162 local_credit_cards_.clear(); | 154 local_credit_cards_.clear(); |
| 163 server_credit_cards_.clear(); | 155 server_credit_cards_.clear(); |
| 164 if (include_local_credit_card) { | 156 if (include_local_credit_card) { |
| 165 std::unique_ptr<CreditCard> credit_card = base::MakeUnique<CreditCard>( | 157 std::unique_ptr<CreditCard> credit_card = base::MakeUnique<CreditCard>( |
| 166 "10000000-0000-0000-0000-000000000001", std::string()); | 158 "10000000-0000-0000-0000-000000000001", std::string()); |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1725 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1734 EXPECT_EQ(1, | 1726 EXPECT_EQ(1, |
| 1735 user_action_tester.GetActionCount("Autofill_OnWillSubmitForm")); | 1727 user_action_tester.GetActionCount("Autofill_OnWillSubmitForm")); |
| 1736 EXPECT_EQ(1, user_action_tester.GetActionCount( | 1728 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 1737 "Autofill_FormSubmitted_NonFillable")); | 1729 "Autofill_FormSubmitted_NonFillable")); |
| 1738 } | 1730 } |
| 1739 } | 1731 } |
| 1740 | 1732 |
| 1741 // Test that the profile checkout flow user actions are correctly logged. | 1733 // Test that the profile checkout flow user actions are correctly logged. |
| 1742 TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { | 1734 TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { |
| 1743 // Create profiles. | 1735 // Create a profile. |
| 1744 personal_data_->RecreateProfiles(true /* include_local_profile */, | 1736 personal_data_->RecreateProfile(); |
| 1745 false /* include_server_profile */); | |
| 1746 | 1737 |
| 1747 // Set up our form data. | 1738 // Set up our form data. |
| 1748 FormData form; | 1739 FormData form; |
| 1749 form.name = ASCIIToUTF16("TestForm"); | 1740 form.name = ASCIIToUTF16("TestForm"); |
| 1750 form.origin = GURL("http://example.com/form.html"); | 1741 form.origin = GURL("http://example.com/form.html"); |
| 1751 form.action = GURL("http://example.com/submit.html"); | 1742 form.action = GURL("http://example.com/submit.html"); |
| 1752 | 1743 |
| 1753 FormFieldData field; | 1744 FormFieldData field; |
| 1754 std::vector<ServerFieldType> field_types; | 1745 std::vector<ServerFieldType> field_types; |
| 1755 test::CreateTestFormField("State", "state", "", "text", &field); | 1746 test::CreateTestFormField("State", "state", "", "text", &field); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 autofill_manager_->OnQueryFormFieldAutofill(0, form, form.fields[1], | 1916 autofill_manager_->OnQueryFormFieldAutofill(0, form, form.fields[1], |
| 1926 gfx::RectF()); | 1917 gfx::RectF()); |
| 1927 histogram_tester.ExpectUniqueSample( | 1918 histogram_tester.ExpectUniqueSample( |
| 1928 "Autofill.QueriedCreditCardFormIsSecure", true, 1); | 1919 "Autofill.QueriedCreditCardFormIsSecure", true, 1); |
| 1929 } | 1920 } |
| 1930 } | 1921 } |
| 1931 | 1922 |
| 1932 // Tests that the Autofill_PolledProfileSuggestions user action is only logged | 1923 // Tests that the Autofill_PolledProfileSuggestions user action is only logged |
| 1933 // once if the field is queried repeatedly. | 1924 // once if the field is queried repeatedly. |
| 1934 TEST_F(AutofillMetricsTest, PolledProfileSuggestions_DebounceLogs) { | 1925 TEST_F(AutofillMetricsTest, PolledProfileSuggestions_DebounceLogs) { |
| 1935 personal_data_->RecreateProfiles(true /* include_local_profile */, | 1926 personal_data_->RecreateProfile(); |
| 1936 false /* include_server_profile */); | |
| 1937 | 1927 |
| 1938 // Set up the form data. | 1928 // Set up the form data. |
| 1939 FormData form; | 1929 FormData form; |
| 1940 form.name = ASCIIToUTF16("TestForm"); | 1930 form.name = ASCIIToUTF16("TestForm"); |
| 1941 form.origin = GURL("http://example.com/form.html"); | 1931 form.origin = GURL("http://example.com/form.html"); |
| 1942 form.action = GURL("http://example.com/submit.html"); | 1932 form.action = GURL("http://example.com/submit.html"); |
| 1943 | 1933 |
| 1944 FormFieldData field; | 1934 FormFieldData field; |
| 1945 std::vector<ServerFieldType> field_types; | 1935 std::vector<ServerFieldType> field_types; |
| 1946 test::CreateTestFormField("State", "state", "", "text", &field); | 1936 test::CreateTestFormField("State", "state", "", "text", &field); |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::RectF()); | 2855 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::RectF()); |
| 2866 histogram_tester.ExpectUniqueSample( | 2856 histogram_tester.ExpectUniqueSample( |
| 2867 "Autofill.FormEvents.Address", | 2857 "Autofill.FormEvents.Address", |
| 2868 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2858 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 2869 } | 2859 } |
| 2870 } | 2860 } |
| 2871 | 2861 |
| 2872 // Test that we log suggestion shown form events for address. | 2862 // Test that we log suggestion shown form events for address. |
| 2873 TEST_F(AutofillMetricsTest, AddressShownFormEvents) { | 2863 TEST_F(AutofillMetricsTest, AddressShownFormEvents) { |
| 2874 EnableWalletSync(); | 2864 EnableWalletSync(); |
| 2875 // Creating all kinds of profiles. | 2865 // Create a profile. |
| 2876 personal_data_->RecreateProfiles(true /* include_local_profile */, | 2866 personal_data_->RecreateProfile(); |
| 2877 true /* include_server_profile */); | |
| 2878 // Set up our form data. | 2867 // Set up our form data. |
| 2879 FormData form; | 2868 FormData form; |
| 2880 form.name = ASCIIToUTF16("TestForm"); | 2869 form.name = ASCIIToUTF16("TestForm"); |
| 2881 form.origin = GURL("http://example.com/form.html"); | 2870 form.origin = GURL("http://example.com/form.html"); |
| 2882 form.action = GURL("http://example.com/submit.html"); | 2871 form.action = GURL("http://example.com/submit.html"); |
| 2883 | 2872 |
| 2884 FormFieldData field; | 2873 FormFieldData field; |
| 2885 std::vector<ServerFieldType> field_types; | 2874 std::vector<ServerFieldType> field_types; |
| 2886 test::CreateTestFormField("State", "state", "", "text", &field); | 2875 test::CreateTestFormField("State", "state", "", "text", &field); |
| 2887 form.fields.push_back(field); | 2876 form.fields.push_back(field); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2940 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); | 2929 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); |
| 2941 histogram_tester.ExpectBucketCount( | 2930 histogram_tester.ExpectBucketCount( |
| 2942 "Autofill.FormEvents.Address", | 2931 "Autofill.FormEvents.Address", |
| 2943 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); | 2932 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); |
| 2944 } | 2933 } |
| 2945 } | 2934 } |
| 2946 | 2935 |
| 2947 // Test that we log filled form events for address. | 2936 // Test that we log filled form events for address. |
| 2948 TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { | 2937 TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { |
| 2949 EnableWalletSync(); | 2938 EnableWalletSync(); |
| 2950 // Creating all kinds of profiles. | 2939 // Create a profile. |
| 2951 personal_data_->RecreateProfiles(true /* include_local_profile */, | 2940 personal_data_->RecreateProfile(); |
| 2952 true /* include_server_profile */); | |
| 2953 // Set up our form data. | 2941 // Set up our form data. |
| 2954 FormData form; | 2942 FormData form; |
| 2955 form.name = ASCIIToUTF16("TestForm"); | 2943 form.name = ASCIIToUTF16("TestForm"); |
| 2956 form.origin = GURL("http://example.com/form.html"); | 2944 form.origin = GURL("http://example.com/form.html"); |
| 2957 form.action = GURL("http://example.com/submit.html"); | 2945 form.action = GURL("http://example.com/submit.html"); |
| 2958 | 2946 |
| 2959 FormFieldData field; | 2947 FormFieldData field; |
| 2960 std::vector<ServerFieldType> field_types; | 2948 std::vector<ServerFieldType> field_types; |
| 2961 test::CreateTestFormField("State", "state", "", "text", &field); | 2949 test::CreateTestFormField("State", "state", "", "text", &field); |
| 2962 form.fields.push_back(field); | 2950 form.fields.push_back(field); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2985 histogram_tester.ExpectBucketCount( | 2973 histogram_tester.ExpectBucketCount( |
| 2986 "Autofill.FormEvents.Address", | 2974 "Autofill.FormEvents.Address", |
| 2987 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); | 2975 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); |
| 2988 } | 2976 } |
| 2989 | 2977 |
| 2990 // Reset the autofill manager state. | 2978 // Reset the autofill manager state. |
| 2991 autofill_manager_->Reset(); | 2979 autofill_manager_->Reset(); |
| 2992 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2980 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2993 | 2981 |
| 2994 { | 2982 { |
| 2995 // Simulating selecting/filling a server profile suggestion. | |
| 2996 base::HistogramTester histogram_tester; | |
| 2997 std::string guid("00000000-0000-0000-0000-000000000002"); // server profile | |
| 2998 autofill_manager_->FillOrPreviewForm( | |
| 2999 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | |
| 3000 autofill_manager_->MakeFrontendID(std::string(), guid)); | |
| 3001 histogram_tester.ExpectBucketCount( | |
| 3002 "Autofill.FormEvents.Address", | |
| 3003 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED, 1); | |
| 3004 histogram_tester.ExpectBucketCount( | |
| 3005 "Autofill.FormEvents.Address", | |
| 3006 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE, 1); | |
| 3007 } | |
| 3008 | |
| 3009 // Reset the autofill manager state. | |
| 3010 autofill_manager_->Reset(); | |
| 3011 autofill_manager_->AddSeenForm(form, field_types, field_types); | |
| 3012 | |
| 3013 { | |
| 3014 // Simulating selecting/filling a local profile suggestion. | 2983 // Simulating selecting/filling a local profile suggestion. |
| 3015 base::HistogramTester histogram_tester; | 2984 base::HistogramTester histogram_tester; |
| 3016 std::string guid("00000000-0000-0000-0000-000000000001"); // local profile | 2985 std::string guid("00000000-0000-0000-0000-000000000001"); // local profile |
| 3017 autofill_manager_->FillOrPreviewForm( | 2986 autofill_manager_->FillOrPreviewForm( |
| 3018 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 2987 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 3019 autofill_manager_->MakeFrontendID(std::string(), guid)); | 2988 autofill_manager_->MakeFrontendID(std::string(), guid)); |
| 3020 autofill_manager_->FillOrPreviewForm( | 2989 autofill_manager_->FillOrPreviewForm( |
| 3021 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 2990 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 3022 autofill_manager_->MakeFrontendID(std::string(), guid)); | 2991 autofill_manager_->MakeFrontendID(std::string(), guid)); |
| 3023 histogram_tester.ExpectBucketCount( | 2992 histogram_tester.ExpectBucketCount( |
| 3024 "Autofill.FormEvents.Address", | 2993 "Autofill.FormEvents.Address", |
| 3025 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); | 2994 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); |
| 3026 histogram_tester.ExpectBucketCount( | 2995 histogram_tester.ExpectBucketCount( |
| 3027 "Autofill.FormEvents.Address", | 2996 "Autofill.FormEvents.Address", |
| 3028 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); | 2997 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); |
| 3029 } | 2998 } |
| 3030 } | 2999 } |
| 3031 | 3000 |
| 3032 // Test that we log submitted form events for address. | 3001 // Test that we log submitted form events for address. |
| 3033 TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) { | 3002 TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) { |
| 3034 EnableWalletSync(); | 3003 EnableWalletSync(); |
| 3035 // Creating all kinds of profiles. | 3004 // Create a profile. |
| 3036 personal_data_->RecreateProfiles(true /* include_local_profile */, | 3005 personal_data_->RecreateProfile(); |
| 3037 true /* include_server_profile */); | |
| 3038 // Set up our form data. | 3006 // Set up our form data. |
| 3039 FormData form; | 3007 FormData form; |
| 3040 form.name = ASCIIToUTF16("TestForm"); | 3008 form.name = ASCIIToUTF16("TestForm"); |
| 3041 form.origin = GURL("http://example.com/form.html"); | 3009 form.origin = GURL("http://example.com/form.html"); |
| 3042 form.action = GURL("http://example.com/submit.html"); | 3010 form.action = GURL("http://example.com/submit.html"); |
| 3043 | 3011 |
| 3044 FormFieldData field; | 3012 FormFieldData field; |
| 3045 std::vector<ServerFieldType> field_types; | 3013 std::vector<ServerFieldType> field_types; |
| 3046 test::CreateTestFormField("State", "state", "", "text", &field); | 3014 test::CreateTestFormField("State", "state", "", "text", &field); |
| 3047 form.fields.push_back(field); | 3015 form.fields.push_back(field); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3107 histogram_tester.ExpectBucketCount( | 3075 histogram_tester.ExpectBucketCount( |
| 3108 "Autofill.FormEvents.Address", | 3076 "Autofill.FormEvents.Address", |
| 3109 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); | 3077 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); |
| 3110 } | 3078 } |
| 3111 | 3079 |
| 3112 // Reset the autofill manager state. | 3080 // Reset the autofill manager state. |
| 3113 autofill_manager_->Reset(); | 3081 autofill_manager_->Reset(); |
| 3114 autofill_manager_->AddSeenForm(form, field_types, field_types); | 3082 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 3115 | 3083 |
| 3116 { | 3084 { |
| 3117 // Simulating submission with filled server data. | |
| 3118 base::HistogramTester histogram_tester; | |
| 3119 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | |
| 3120 std::string guid("00000000-0000-0000-0000-000000000002"); // server profile | |
| 3121 autofill_manager_->FillOrPreviewForm( | |
| 3122 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | |
| 3123 autofill_manager_->MakeFrontendID(std::string(), guid)); | |
| 3124 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | |
| 3125 histogram_tester.ExpectBucketCount( | |
| 3126 "Autofill.FormEvents.Address", | |
| 3127 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); | |
| 3128 histogram_tester.ExpectBucketCount( | |
| 3129 "Autofill.FormEvents.Address", | |
| 3130 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1); | |
| 3131 } | |
| 3132 | |
| 3133 // Reset the autofill manager state. | |
| 3134 autofill_manager_->Reset(); | |
| 3135 autofill_manager_->AddSeenForm(form, field_types, field_types); | |
| 3136 | |
| 3137 { | |
| 3138 // Simulating multiple submissions. | 3085 // Simulating multiple submissions. |
| 3139 base::HistogramTester histogram_tester; | 3086 base::HistogramTester histogram_tester; |
| 3140 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | 3087 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 3141 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3088 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3142 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3089 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3143 histogram_tester.ExpectBucketCount( | 3090 histogram_tester.ExpectBucketCount( |
| 3144 "Autofill.FormEvents.Address", | 3091 "Autofill.FormEvents.Address", |
| 3145 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 3092 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
| 3146 histogram_tester.ExpectBucketCount( | 3093 histogram_tester.ExpectBucketCount( |
| 3147 "Autofill.FormEvents.Address", | 3094 "Autofill.FormEvents.Address", |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3211 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, | 3158 FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SUBMITTED_ONCE, |
| 3212 0); | 3159 0); |
| 3213 } | 3160 } |
| 3214 } | 3161 } |
| 3215 | 3162 |
| 3216 // Test that we log "will submit" (but not submitted) form events for address. | 3163 // Test that we log "will submit" (but not submitted) form events for address. |
| 3217 // Mirrors AddressSubmittedFormEvents test but does not expect any "submitted" | 3164 // Mirrors AddressSubmittedFormEvents test but does not expect any "submitted" |
| 3218 // metrics. | 3165 // metrics. |
| 3219 TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) { | 3166 TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) { |
| 3220 EnableWalletSync(); | 3167 EnableWalletSync(); |
| 3221 // Creating all kinds of profiles. | 3168 // Create a profile. |
| 3222 personal_data_->RecreateProfiles(true /* include_local_profile */, | 3169 personal_data_->RecreateProfile(); |
| 3223 true /* include_server_profile */); | |
| 3224 // Set up our form data. | 3170 // Set up our form data. |
| 3225 FormData form; | 3171 FormData form; |
| 3226 form.name = ASCIIToUTF16("TestForm"); | 3172 form.name = ASCIIToUTF16("TestForm"); |
| 3227 form.origin = GURL("http://example.com/form.html"); | 3173 form.origin = GURL("http://example.com/form.html"); |
| 3228 form.action = GURL("http://example.com/submit.html"); | 3174 form.action = GURL("http://example.com/submit.html"); |
| 3229 | 3175 |
| 3230 FormFieldData field; | 3176 FormFieldData field; |
| 3231 std::vector<ServerFieldType> field_types; | 3177 std::vector<ServerFieldType> field_types; |
| 3232 test::CreateTestFormField("State", "state", "", "text", &field); | 3178 test::CreateTestFormField("State", "state", "", "text", &field); |
| 3233 form.fields.push_back(field); | 3179 form.fields.push_back(field); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3293 histogram_tester.ExpectBucketCount( | 3239 histogram_tester.ExpectBucketCount( |
| 3294 "Autofill.FormEvents.Address", | 3240 "Autofill.FormEvents.Address", |
| 3295 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); | 3241 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
| 3296 } | 3242 } |
| 3297 | 3243 |
| 3298 // Reset the autofill manager state. | 3244 // Reset the autofill manager state. |
| 3299 autofill_manager_->Reset(); | 3245 autofill_manager_->Reset(); |
| 3300 autofill_manager_->AddSeenForm(form, field_types, field_types); | 3246 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 3301 | 3247 |
| 3302 { | 3248 { |
| 3303 // Simulating submission with filled server data. | |
| 3304 base::HistogramTester histogram_tester; | |
| 3305 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | |
| 3306 std::string guid("00000000-0000-0000-0000-000000000002"); // server profile | |
| 3307 autofill_manager_->FillOrPreviewForm( | |
| 3308 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | |
| 3309 autofill_manager_->MakeFrontendID(std::string(), guid)); | |
| 3310 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | |
| 3311 histogram_tester.ExpectBucketCount( | |
| 3312 "Autofill.FormEvents.Address", | |
| 3313 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); | |
| 3314 histogram_tester.ExpectBucketCount( | |
| 3315 "Autofill.FormEvents.Address", | |
| 3316 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); | |
| 3317 } | |
| 3318 | |
| 3319 // Reset the autofill manager state. | |
| 3320 autofill_manager_->Reset(); | |
| 3321 autofill_manager_->AddSeenForm(form, field_types, field_types); | |
| 3322 | |
| 3323 { | |
| 3324 // Simulating multiple submissions. | 3249 // Simulating multiple submissions. |
| 3325 base::HistogramTester histogram_tester; | 3250 base::HistogramTester histogram_tester; |
| 3326 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | 3251 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 3327 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 3252 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 3328 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 3253 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
| 3329 histogram_tester.ExpectBucketCount( | 3254 histogram_tester.ExpectBucketCount( |
| 3330 "Autofill.FormEvents.Address", | 3255 "Autofill.FormEvents.Address", |
| 3331 AutofillMetrics::FORM_EVENT_SUGGESTION_SHOWN_WILL_SUBMIT_ONCE, 0); | 3256 AutofillMetrics::FORM_EVENT_SUGGESTION_SHOWN_WILL_SUBMIT_ONCE, 0); |
| 3332 histogram_tester.ExpectBucketCount( | 3257 histogram_tester.ExpectBucketCount( |
| 3333 "Autofill.FormEvents.Address", | 3258 "Autofill.FormEvents.Address", |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3535 test::CreateTestFormField("City", "city", "", "text", &field); | 3460 test::CreateTestFormField("City", "city", "", "text", &field); |
| 3536 form.fields.push_back(field); | 3461 form.fields.push_back(field); |
| 3537 field_types.push_back(ADDRESS_HOME_CITY); | 3462 field_types.push_back(ADDRESS_HOME_CITY); |
| 3538 test::CreateTestFormField("Street", "street", "", "text", &field); | 3463 test::CreateTestFormField("Street", "street", "", "text", &field); |
| 3539 form.fields.push_back(field); | 3464 form.fields.push_back(field); |
| 3540 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); | 3465 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); |
| 3541 | 3466 |
| 3542 // Simulate having seen this form on page load. | 3467 // Simulate having seen this form on page load. |
| 3543 // |form_structure| will be owned by |autofill_manager_|. | 3468 // |form_structure| will be owned by |autofill_manager_|. |
| 3544 autofill_manager_->AddSeenForm(form, field_types, field_types); | 3469 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 3545 personal_data_->RecreateProfiles(false /* include_local_profile */, | 3470 personal_data_->ClearProfiles(); |
| 3546 false /* include_server_profile */); | |
| 3547 | 3471 |
| 3548 { | 3472 { |
| 3549 // Simulate activating the autofill popup for the street field. | 3473 // Simulate activating the autofill popup for the street field. |
| 3550 base::HistogramTester histogram_tester; | 3474 base::HistogramTester histogram_tester; |
| 3551 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | 3475 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 3552 histogram_tester.ExpectUniqueSample( | 3476 histogram_tester.ExpectUniqueSample( |
| 3553 "Autofill.FormEvents.Address.WithNoData", | 3477 "Autofill.FormEvents.Address.WithNoData", |
| 3554 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 3478 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 3555 } | 3479 } |
| 3556 | 3480 |
| 3557 // Reset the autofill manager state. | 3481 // Reset the autofill manager state. |
| 3558 autofill_manager_->Reset(); | 3482 autofill_manager_->Reset(); |
| 3559 autofill_manager_->AddSeenForm(form, field_types, field_types); | 3483 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 3560 personal_data_->RecreateProfiles(true /* include_local_profile */, | 3484 personal_data_->RecreateProfile(); |
| 3561 false /* include_server_profile */); | |
| 3562 | 3485 |
| 3563 { | 3486 { |
| 3564 // Simulate activating the autofill popup for the street field. | 3487 // Simulate activating the autofill popup for the street field. |
| 3565 base::HistogramTester histogram_tester; | 3488 base::HistogramTester histogram_tester; |
| 3566 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | 3489 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 3567 histogram_tester.ExpectUniqueSample( | 3490 histogram_tester.ExpectUniqueSample( |
| 3568 "Autofill.FormEvents.Address.WithOnlyLocalData", | 3491 "Autofill.FormEvents.Address.WithOnlyLocalData", |
| 3569 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 3492 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
| 3570 } | 3493 } |
| 3571 | |
| 3572 // Reset the autofill manager state. | |
| 3573 autofill_manager_->Reset(); | |
| 3574 autofill_manager_->AddSeenForm(form, field_types, field_types); | |
| 3575 personal_data_->RecreateProfiles(false /* include_local_profile */, | |
| 3576 true /* include_server_profile */); | |
| 3577 | |
| 3578 { | |
| 3579 // Simulate activating the autofill popup for the street field. | |
| 3580 base::HistogramTester histogram_tester; | |
| 3581 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | |
| 3582 histogram_tester.ExpectUniqueSample( | |
| 3583 "Autofill.FormEvents.Address.WithOnlyServerData", | |
| 3584 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | |
| 3585 } | |
| 3586 | |
| 3587 // Reset the autofill manager state. | |
| 3588 autofill_manager_->Reset(); | |
| 3589 autofill_manager_->AddSeenForm(form, field_types, field_types); | |
| 3590 personal_data_->RecreateProfiles(true /* include_local_profile */, | |
| 3591 true /* include_server_profile */); | |
| 3592 | |
| 3593 { | |
| 3594 // Simulate activating the autofill popup for the street field. | |
| 3595 base::HistogramTester histogram_tester; | |
| 3596 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | |
| 3597 histogram_tester.ExpectUniqueSample( | |
| 3598 "Autofill.FormEvents.Address.WithBothServerAndLocalData", | |
| 3599 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | |
| 3600 } | |
| 3601 } | 3494 } |
| 3602 | 3495 |
| 3603 | 3496 |
| 3604 // Test that we log that Autofill is enabled when filling a form. | 3497 // Test that we log that Autofill is enabled when filling a form. |
| 3605 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { | 3498 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { |
| 3606 base::HistogramTester histogram_tester; | 3499 base::HistogramTester histogram_tester; |
| 3607 autofill_manager_->set_autofill_enabled(true); | 3500 autofill_manager_->set_autofill_enabled(true); |
| 3608 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); | 3501 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); |
| 3609 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.PageLoad", true, 1); | 3502 histogram_tester.ExpectUniqueSample("Autofill.IsEnabled.PageLoad", true, 1); |
| 3610 } | 3503 } |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4317 EXPECT_THAT( | 4210 EXPECT_THAT( |
| 4318 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), | 4211 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), |
| 4319 ElementsAre(Bucket(true, 2))); | 4212 ElementsAre(Bucket(true, 2))); |
| 4320 | 4213 |
| 4321 // No RAPPOR metrics are logged in the case there is at least some server data | 4214 // No RAPPOR metrics are logged in the case there is at least some server data |
| 4322 // available for all forms. | 4215 // available for all forms. |
| 4323 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 4216 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
| 4324 } | 4217 } |
| 4325 | 4218 |
| 4326 } // namespace autofill | 4219 } // namespace autofill |
| OLD | NEW |