| 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/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 "Autofill.Quality.PredictedType.ByFieldType", | 679 "Autofill.Quality.PredictedType.ByFieldType", |
| 680 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, | 680 GetFieldTypeGroupMetric(ADDRESS_HOME_CITY, |
| 681 AutofillMetrics::TYPE_MISMATCH), | 681 AutofillMetrics::TYPE_MISMATCH), |
| 682 1); | 682 1); |
| 683 histogram_tester.ExpectBucketCount( | 683 histogram_tester.ExpectBucketCount( |
| 684 "Autofill.Quality.PredictedType.ByFieldType", | 684 "Autofill.Quality.PredictedType.ByFieldType", |
| 685 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), | 685 GetFieldTypeGroupMetric(EMAIL_ADDRESS, AutofillMetrics::TYPE_MISMATCH), |
| 686 1); | 686 1); |
| 687 } | 687 } |
| 688 | 688 |
| 689 // Verify that when submitting an autofillable form, the stored profile metric |
| 690 // is logged. |
| 691 TEST_F(AutofillMetricsTest, StoredProfileCountAutofillableFormSubmission) { |
| 692 // Construct a fillable form. |
| 693 FormData form; |
| 694 form.name = ASCIIToUTF16("TestForm"); |
| 695 form.origin = GURL("http://example.com/form.html"); |
| 696 form.action = GURL("http://example.com/submit.html"); |
| 697 form.user_submitted = true; |
| 698 |
| 699 // Three fields is enough to make it an autofillable form. |
| 700 FormFieldData field; |
| 701 test::CreateTestFormField("Name", "name", "", "text", &field); |
| 702 form.fields.push_back(field); |
| 703 test::CreateTestFormField("Email", "email", "", "text", &field); |
| 704 form.fields.push_back(field); |
| 705 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
| 706 form.fields.push_back(field); |
| 707 |
| 708 std::vector<FormData> forms(1, form); |
| 709 |
| 710 // Simulate form submission. |
| 711 base::HistogramTester histogram_tester; |
| 712 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 713 autofill_manager_->FormSubmitted(form, TimeTicks::Now()); |
| 714 |
| 715 // An autofillable form was submitted, and the number of stored profiles is |
| 716 // logged. |
| 717 histogram_tester.ExpectUniqueSample( |
| 718 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 2, 1); |
| 719 } |
| 720 |
| 721 // Verify that when submitting a non-autofillable form, the stored profile |
| 722 // metric is not logged. |
| 723 TEST_F(AutofillMetricsTest, StoredProfileCountNonAutofillableFormSubmission) { |
| 724 // Construct a non-fillable form. |
| 725 FormData form; |
| 726 form.name = ASCIIToUTF16("TestForm"); |
| 727 form.origin = GURL("http://example.com/form.html"); |
| 728 form.action = GURL("http://example.com/submit.html"); |
| 729 form.user_submitted = true; |
| 730 |
| 731 // Two fields is not enough to make it an autofillable form. |
| 732 FormFieldData field; |
| 733 test::CreateTestFormField("Name", "name", "", "text", &field); |
| 734 form.fields.push_back(field); |
| 735 test::CreateTestFormField("Email", "email", "", "text", &field); |
| 736 form.fields.push_back(field); |
| 737 |
| 738 std::vector<FormData> forms(1, form); |
| 739 |
| 740 // Simulate form submission. |
| 741 base::HistogramTester histogram_tester; |
| 742 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 743 autofill_manager_->FormSubmitted(form, TimeTicks::Now()); |
| 744 |
| 745 // A non-autofillable form was submitted, and number of stored profiles is NOT |
| 746 // logged. |
| 747 histogram_tester.ExpectTotalCount( |
| 748 "Autofill.StoredProfileCountAtAutofillableFormSubmission", 0); |
| 749 } |
| 750 |
| 689 // Verify that we correctly log metrics regarding developer engagement. | 751 // Verify that we correctly log metrics regarding developer engagement. |
| 690 TEST_F(AutofillMetricsTest, DeveloperEngagement) { | 752 TEST_F(AutofillMetricsTest, DeveloperEngagement) { |
| 691 // Start with a non-fillable form. | 753 // Start with a non-fillable form. |
| 692 FormData form; | 754 FormData form; |
| 693 form.name = ASCIIToUTF16("TestForm"); | 755 form.name = ASCIIToUTF16("TestForm"); |
| 694 form.origin = GURL("http://example.com/form.html"); | 756 form.origin = GURL("http://example.com/form.html"); |
| 695 form.action = GURL("http://example.com/submit.html"); | 757 form.action = GURL("http://example.com/submit.html"); |
| 696 | 758 |
| 697 FormFieldData field; | 759 FormFieldData field; |
| 698 test::CreateTestFormField("Name", "name", "", "text", &field); | 760 test::CreateTestFormField("Name", "name", "", "text", &field); |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 histogram_tester.ExpectTotalCount( | 1644 histogram_tester.ExpectTotalCount( |
| 1583 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); | 1645 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); |
| 1584 histogram_tester.ExpectTotalCount( | 1646 histogram_tester.ExpectTotalCount( |
| 1585 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 1647 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
| 1586 | 1648 |
| 1587 autofill_manager_->Reset(); | 1649 autofill_manager_->Reset(); |
| 1588 } | 1650 } |
| 1589 } | 1651 } |
| 1590 | 1652 |
| 1591 } // namespace autofill | 1653 } // namespace autofill |
| OLD | NEW |