| 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 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 "Autofill_FilledCreditCardSuggestion")); | 1664 "Autofill_FilledCreditCardSuggestion")); |
| 1665 } | 1665 } |
| 1666 | 1666 |
| 1667 // Simulate submitting the credit card form. | 1667 // Simulate submitting the credit card form. |
| 1668 { | 1668 { |
| 1669 base::UserActionTester user_action_tester; | 1669 base::UserActionTester user_action_tester; |
| 1670 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | 1670 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 1671 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1671 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1672 EXPECT_EQ(1, | 1672 EXPECT_EQ(1, |
| 1673 user_action_tester.GetActionCount("Autofill_OnWillSubmitForm")); | 1673 user_action_tester.GetActionCount("Autofill_OnWillSubmitForm")); |
| 1674 EXPECT_EQ(1, user_action_tester.GetActionCount("Autofill_FormSubmitted")); | 1674 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 1675 "Autofill_FormSubmitted_NonFillable")); |
| 1675 } | 1676 } |
| 1676 } | 1677 } |
| 1677 | 1678 |
| 1678 // Test that the profile checkout flow user actions are correctly logged. | 1679 // Test that the profile checkout flow user actions are correctly logged. |
| 1679 TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { | 1680 TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { |
| 1680 // Create profiles. | 1681 // Create profiles. |
| 1681 personal_data_->RecreateProfiles(true /* include_local_profile */, | 1682 personal_data_->RecreateProfiles(true /* include_local_profile */, |
| 1682 false /* include_server_profile */); | 1683 false /* include_server_profile */); |
| 1683 | 1684 |
| 1684 // Set up our form data. | 1685 // Set up our form data. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1741 "Autofill_FilledProfileSuggestion")); | 1742 "Autofill_FilledProfileSuggestion")); |
| 1742 } | 1743 } |
| 1743 | 1744 |
| 1744 // Simulate submitting the profile form. | 1745 // Simulate submitting the profile form. |
| 1745 { | 1746 { |
| 1746 base::UserActionTester user_action_tester; | 1747 base::UserActionTester user_action_tester; |
| 1747 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | 1748 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 1748 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1749 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1749 EXPECT_EQ(1, | 1750 EXPECT_EQ(1, |
| 1750 user_action_tester.GetActionCount("Autofill_OnWillSubmitForm")); | 1751 user_action_tester.GetActionCount("Autofill_OnWillSubmitForm")); |
| 1751 EXPECT_EQ(1, user_action_tester.GetActionCount("Autofill_FormSubmitted")); | 1752 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 1753 "Autofill_FormSubmitted_NonFillable")); |
| 1752 } | 1754 } |
| 1753 } | 1755 } |
| 1754 | 1756 |
| 1755 // Test that we log interacted form event for credit cards related. | 1757 // Test that we log interacted form event for credit cards related. |
| 1756 TEST_F(AutofillMetricsTest, CreditCardInteractedFormEvents) { | 1758 TEST_F(AutofillMetricsTest, CreditCardInteractedFormEvents) { |
| 1757 // Set up our form data. | 1759 // Set up our form data. |
| 1758 FormData form; | 1760 FormData form; |
| 1759 form.name = ASCIIToUTF16("TestForm"); | 1761 form.name = ASCIIToUTF16("TestForm"); |
| 1760 form.origin = GURL("http://example.com/form.html"); | 1762 form.origin = GURL("http://example.com/form.html"); |
| 1761 form.action = GURL("http://example.com/submit.html"); | 1763 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3242 // Expect no notifications when the form is first seen. | 3244 // Expect no notifications when the form is first seen. |
| 3243 { | 3245 { |
| 3244 base::HistogramTester histogram_tester; | 3246 base::HistogramTester histogram_tester; |
| 3245 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 3247 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 3246 histogram_tester.ExpectTotalCount("Autofill.FormSubmittedState", 0); | 3248 histogram_tester.ExpectTotalCount("Autofill.FormSubmittedState", 0); |
| 3247 } | 3249 } |
| 3248 | 3250 |
| 3249 // No data entered in the form. | 3251 // No data entered in the form. |
| 3250 { | 3252 { |
| 3251 base::HistogramTester histogram_tester; | 3253 base::HistogramTester histogram_tester; |
| 3254 base::UserActionTester user_action_tester; |
| 3252 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3255 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3253 histogram_tester.ExpectUniqueSample( | 3256 histogram_tester.ExpectUniqueSample( |
| 3254 "Autofill.FormSubmittedState", | 3257 "Autofill.FormSubmittedState", |
| 3255 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA, 1); | 3258 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA, 1); |
| 3259 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 3260 "Autofill_FormSubmitted_NonFillable")); |
| 3256 } | 3261 } |
| 3257 | 3262 |
| 3258 // Non fillable form. | 3263 // Non fillable form. |
| 3259 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); | 3264 form.fields[0].value = ASCIIToUTF16("Elvis Aaron Presley"); |
| 3260 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); | 3265 form.fields[1].value = ASCIIToUTF16("theking@gmail.com"); |
| 3261 forms.front() = form; | 3266 forms.front() = form; |
| 3262 | 3267 |
| 3263 { | 3268 { |
| 3264 base::HistogramTester histogram_tester; | 3269 base::HistogramTester histogram_tester; |
| 3270 base::UserActionTester user_action_tester; |
| 3265 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3271 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3266 histogram_tester.ExpectUniqueSample( | 3272 histogram_tester.ExpectUniqueSample( |
| 3267 "Autofill.FormSubmittedState", | 3273 "Autofill.FormSubmittedState", |
| 3268 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA, 1); | 3274 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA, 1); |
| 3275 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 3276 "Autofill_FormSubmitted_NonFillable")); |
| 3269 } | 3277 } |
| 3270 | 3278 |
| 3271 // Fill in the third field. | 3279 // Fill in the third field. |
| 3272 form.fields[2].value = ASCIIToUTF16("12345678901"); | 3280 form.fields[2].value = ASCIIToUTF16("12345678901"); |
| 3273 forms.front() = form; | 3281 forms.front() = form; |
| 3274 | 3282 |
| 3275 // Autofilled none with no suggestions shown. | 3283 // Autofilled none with no suggestions shown. |
| 3276 { | 3284 { |
| 3277 base::HistogramTester histogram_tester; | 3285 base::HistogramTester histogram_tester; |
| 3286 base::UserActionTester user_action_tester; |
| 3278 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3287 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3279 histogram_tester.ExpectUniqueSample( | 3288 histogram_tester.ExpectUniqueSample( |
| 3280 "Autofill.FormSubmittedState", | 3289 "Autofill.FormSubmittedState", |
| 3281 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_NONE_DID_NOT_SHOW_SUGGESTIONS, | 3290 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_NONE_DID_NOT_SHOW_SUGGESTIONS, |
| 3282 1); | 3291 1); |
| 3292 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 3293 "Autofill_FormSubmitted_FilledNone_SuggestionsNotShown")); |
| 3283 } | 3294 } |
| 3284 | 3295 |
| 3285 // Autofilled none with suggestions shown. | 3296 // Autofilled none with suggestions shown. |
| 3286 autofill_manager_->DidShowSuggestions(true, form, form.fields[2]); | 3297 autofill_manager_->DidShowSuggestions(true, form, form.fields[2]); |
| 3287 { | 3298 { |
| 3288 base::HistogramTester histogram_tester; | 3299 base::HistogramTester histogram_tester; |
| 3300 base::UserActionTester user_action_tester; |
| 3289 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3301 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3290 histogram_tester.ExpectUniqueSample( | 3302 histogram_tester.ExpectUniqueSample( |
| 3291 "Autofill.FormSubmittedState", | 3303 "Autofill.FormSubmittedState", |
| 3292 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_NONE_DID_SHOW_SUGGESTIONS, 1); | 3304 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_NONE_DID_SHOW_SUGGESTIONS, 1); |
| 3305 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 3306 "Autofill_FormSubmitted_FilledNone_SuggestionsShown")); |
| 3293 } | 3307 } |
| 3294 | 3308 |
| 3295 // Mark one of the fields as autofilled. | 3309 // Mark one of the fields as autofilled. |
| 3296 form.fields[1].is_autofilled = true; | 3310 form.fields[1].is_autofilled = true; |
| 3297 forms.front() = form; | 3311 forms.front() = form; |
| 3298 | 3312 |
| 3299 // Autofilled some of the fields. | 3313 // Autofilled some of the fields. |
| 3300 { | 3314 { |
| 3301 base::HistogramTester histogram_tester; | 3315 base::HistogramTester histogram_tester; |
| 3316 base::UserActionTester user_action_tester; |
| 3302 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3317 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3303 histogram_tester.ExpectUniqueSample( | 3318 histogram_tester.ExpectUniqueSample( |
| 3304 "Autofill.FormSubmittedState", | 3319 "Autofill.FormSubmittedState", |
| 3305 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_SOME, 1); | 3320 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_SOME, 1); |
| 3321 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 3322 "Autofill_FormSubmitted_FilledSome")); |
| 3306 } | 3323 } |
| 3307 | 3324 |
| 3308 // Mark all of the fillable fields as autofilled. | 3325 // Mark all of the fillable fields as autofilled. |
| 3309 form.fields[0].is_autofilled = true; | 3326 form.fields[0].is_autofilled = true; |
| 3310 form.fields[2].is_autofilled = true; | 3327 form.fields[2].is_autofilled = true; |
| 3311 forms.front() = form; | 3328 forms.front() = form; |
| 3312 | 3329 |
| 3313 // Autofilled all the fields. | 3330 // Autofilled all the fields. |
| 3314 { | 3331 { |
| 3315 base::HistogramTester histogram_tester; | 3332 base::HistogramTester histogram_tester; |
| 3333 base::UserActionTester user_action_tester; |
| 3316 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3334 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3317 histogram_tester.ExpectUniqueSample( | 3335 histogram_tester.ExpectUniqueSample( |
| 3318 "Autofill.FormSubmittedState", | 3336 "Autofill.FormSubmittedState", |
| 3319 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_ALL, 1); | 3337 AutofillMetrics::FILLABLE_FORM_AUTOFILLED_ALL, 1); |
| 3338 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 3339 "Autofill_FormSubmitted_FilledAll")); |
| 3320 } | 3340 } |
| 3321 | 3341 |
| 3322 // Clear out the third field's value. | 3342 // Clear out the third field's value. |
| 3323 form.fields[2].value = base::string16(); | 3343 form.fields[2].value = base::string16(); |
| 3324 forms.front() = form; | 3344 forms.front() = form; |
| 3325 | 3345 |
| 3326 // Non fillable form. | 3346 // Non fillable form. |
| 3327 { | 3347 { |
| 3328 base::HistogramTester histogram_tester; | 3348 base::HistogramTester histogram_tester; |
| 3349 base::UserActionTester user_action_tester; |
| 3329 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 3350 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 3330 histogram_tester.ExpectUniqueSample( | 3351 histogram_tester.ExpectUniqueSample( |
| 3331 "Autofill.FormSubmittedState", | 3352 "Autofill.FormSubmittedState", |
| 3332 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA, 1); | 3353 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA, 1); |
| 3354 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 3355 "Autofill_FormSubmitted_NonFillable")); |
| 3333 } | 3356 } |
| 3334 } | 3357 } |
| 3335 | 3358 |
| 3336 // Verify that we correctly log user happiness metrics dealing with form | 3359 // Verify that we correctly log user happiness metrics dealing with form |
| 3337 // interaction. | 3360 // interaction. |
| 3338 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { | 3361 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { |
| 3339 // Load a fillable form. | 3362 // Load a fillable form. |
| 3340 FormData form; | 3363 FormData form; |
| 3341 form.name = ASCIIToUTF16("TestForm"); | 3364 form.name = ASCIIToUTF16("TestForm"); |
| 3342 form.origin = GURL("http://example.com/form.html"); | 3365 form.origin = GURL("http://example.com/form.html"); |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 EXPECT_THAT( | 3903 EXPECT_THAT( |
| 3881 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), | 3904 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), |
| 3882 ElementsAre(Bucket(true, 2))); | 3905 ElementsAre(Bucket(true, 2))); |
| 3883 | 3906 |
| 3884 // No RAPPOR metrics are logged in the case there is at least some server data | 3907 // No RAPPOR metrics are logged in the case there is at least some server data |
| 3885 // available for all forms. | 3908 // available for all forms. |
| 3886 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 3909 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
| 3887 } | 3910 } |
| 3888 | 3911 |
| 3889 } // namespace autofill | 3912 } // namespace autofill |
| OLD | NEW |