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/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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 form.fields.push_back(field); | 1085 form.fields.push_back(field); |
1086 field_types.push_back(PHONE_HOME_NUMBER); | 1086 field_types.push_back(PHONE_HOME_NUMBER); |
1087 | 1087 |
1088 // Simulate having seen this form on page load. | 1088 // Simulate having seen this form on page load. |
1089 // |form_structure| will be owned by |autofill_manager_|. | 1089 // |form_structure| will be owned by |autofill_manager_|. |
1090 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1090 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1091 | 1091 |
1092 { | 1092 { |
1093 // Simulate activating the autofill popup for the phone field. | 1093 // Simulate activating the autofill popup for the phone field. |
1094 base::HistogramTester histogram_tester; | 1094 base::HistogramTester histogram_tester; |
1095 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1095 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1096 false); | |
1097 histogram_tester.ExpectUniqueSample("Autofill.AddressSuggestionsCount", 2, | 1096 histogram_tester.ExpectUniqueSample("Autofill.AddressSuggestionsCount", 2, |
1098 1); | 1097 1); |
1099 } | 1098 } |
1100 | 1099 |
1101 { | 1100 { |
1102 // Simulate activating the autofill popup for the email field after typing. | 1101 // Simulate activating the autofill popup for the email field after typing. |
1103 // No new metric should be logged, since we're still on the same page. | 1102 // No new metric should be logged, since we're still on the same page. |
1104 test::CreateTestFormField("Email", "email", "b", "email", &field); | 1103 test::CreateTestFormField("Email", "email", "b", "email", &field); |
1105 base::HistogramTester histogram_tester; | 1104 base::HistogramTester histogram_tester; |
1106 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1105 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1107 false); | |
1108 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); | 1106 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); |
1109 } | 1107 } |
1110 | 1108 |
1111 // Reset the autofill manager state. | 1109 // Reset the autofill manager state. |
1112 autofill_manager_->Reset(); | 1110 autofill_manager_->Reset(); |
1113 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1111 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1114 | 1112 |
1115 { | 1113 { |
1116 // Simulate activating the autofill popup for the email field after typing. | 1114 // Simulate activating the autofill popup for the email field after typing. |
1117 base::HistogramTester histogram_tester; | 1115 base::HistogramTester histogram_tester; |
1118 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1116 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1119 false); | |
1120 histogram_tester.ExpectUniqueSample("Autofill.AddressSuggestionsCount", 1, | 1117 histogram_tester.ExpectUniqueSample("Autofill.AddressSuggestionsCount", 1, |
1121 1); | 1118 1); |
1122 } | 1119 } |
1123 | 1120 |
1124 // Reset the autofill manager state again. | 1121 // Reset the autofill manager state again. |
1125 autofill_manager_->Reset(); | 1122 autofill_manager_->Reset(); |
1126 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1123 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1127 | 1124 |
1128 { | 1125 { |
1129 // Simulate activating the autofill popup for the email field after typing. | 1126 // Simulate activating the autofill popup for the email field after typing. |
1130 form.fields[0].is_autofilled = true; | 1127 form.fields[0].is_autofilled = true; |
1131 base::HistogramTester histogram_tester; | 1128 base::HistogramTester histogram_tester; |
1132 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1129 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1133 false); | |
1134 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); | 1130 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); |
1135 } | 1131 } |
1136 } | 1132 } |
1137 | 1133 |
1138 // Test that we log interacted form event for credit cards related. | 1134 // Test that we log interacted form event for credit cards related. |
1139 TEST_F(AutofillMetricsTest, CreditCardInteractedFormEvents) { | 1135 TEST_F(AutofillMetricsTest, CreditCardInteractedFormEvents) { |
1140 // Set up our form data. | 1136 // Set up our form data. |
1141 FormData form; | 1137 FormData form; |
1142 form.name = ASCIIToUTF16("TestForm"); | 1138 form.name = ASCIIToUTF16("TestForm"); |
1143 form.origin = GURL("http://example.com/form.html"); | 1139 form.origin = GURL("http://example.com/form.html"); |
(...skipping 12 matching lines...) Expand all Loading... |
1156 form.fields.push_back(field); | 1152 form.fields.push_back(field); |
1157 field_types.push_back(CREDIT_CARD_NUMBER); | 1153 field_types.push_back(CREDIT_CARD_NUMBER); |
1158 | 1154 |
1159 // Simulate having seen this form on page load. | 1155 // Simulate having seen this form on page load. |
1160 // |form_structure| will be owned by |autofill_manager_|. | 1156 // |form_structure| will be owned by |autofill_manager_|. |
1161 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1157 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1162 | 1158 |
1163 { | 1159 { |
1164 // Simulate activating the autofill popup for the credit card field. | 1160 // Simulate activating the autofill popup for the credit card field. |
1165 base::HistogramTester histogram_tester; | 1161 base::HistogramTester histogram_tester; |
1166 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1162 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1167 false); | |
1168 histogram_tester.ExpectUniqueSample( | 1163 histogram_tester.ExpectUniqueSample( |
1169 "Autofill.FormEvents.CreditCard", | 1164 "Autofill.FormEvents.CreditCard", |
1170 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 1165 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
1171 } | 1166 } |
1172 | 1167 |
1173 // Reset the autofill manager state. | 1168 // Reset the autofill manager state. |
1174 autofill_manager_->Reset(); | 1169 autofill_manager_->Reset(); |
1175 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1170 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1176 | 1171 |
1177 { | 1172 { |
1178 // Simulate activating the autofill popup for the credit card field twice. | 1173 // Simulate activating the autofill popup for the credit card field twice. |
1179 base::HistogramTester histogram_tester; | 1174 base::HistogramTester histogram_tester; |
1180 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1175 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1181 false); | 1176 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect()); |
1182 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect(), | |
1183 false); | |
1184 histogram_tester.ExpectUniqueSample( | 1177 histogram_tester.ExpectUniqueSample( |
1185 "Autofill.FormEvents.CreditCard", | 1178 "Autofill.FormEvents.CreditCard", |
1186 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 1179 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
1187 } | 1180 } |
1188 } | 1181 } |
1189 | 1182 |
1190 // Test that we log suggestion shown form events for credit cards. | 1183 // Test that we log suggestion shown form events for credit cards. |
1191 TEST_F(AutofillMetricsTest, CreditCardShownFormEvents) { | 1184 TEST_F(AutofillMetricsTest, CreditCardShownFormEvents) { |
1192 // Set up our form data. | 1185 // Set up our form data. |
1193 FormData form; | 1186 FormData form; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 form.fields.push_back(field); | 1555 form.fields.push_back(field); |
1563 field_types.push_back(CREDIT_CARD_NUMBER); | 1556 field_types.push_back(CREDIT_CARD_NUMBER); |
1564 | 1557 |
1565 // Simulate having seen this form on page load. | 1558 // Simulate having seen this form on page load. |
1566 // |form_structure| will be owned by |autofill_manager_|. | 1559 // |form_structure| will be owned by |autofill_manager_|. |
1567 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1560 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1568 | 1561 |
1569 { | 1562 { |
1570 // Simulating submission with no filled data. | 1563 // Simulating submission with no filled data. |
1571 base::HistogramTester histogram_tester; | 1564 base::HistogramTester histogram_tester; |
1572 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1565 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1573 false); | |
1574 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1566 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
1575 histogram_tester.ExpectBucketCount( | 1567 histogram_tester.ExpectBucketCount( |
1576 "Autofill.FormEvents.CreditCard", | 1568 "Autofill.FormEvents.CreditCard", |
1577 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1569 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
1578 histogram_tester.ExpectBucketCount( | 1570 histogram_tester.ExpectBucketCount( |
1579 "Autofill.FormEvents.CreditCard", | 1571 "Autofill.FormEvents.CreditCard", |
1580 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | 1572 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); |
1581 } | 1573 } |
1582 | 1574 |
1583 // Reset the autofill manager state. | 1575 // Reset the autofill manager state. |
1584 autofill_manager_->Reset(); | 1576 autofill_manager_->Reset(); |
1585 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1577 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1586 | 1578 |
1587 { | 1579 { |
1588 // Simulating submission with filled local data. | 1580 // Simulating submission with filled local data. |
1589 base::HistogramTester histogram_tester; | 1581 base::HistogramTester histogram_tester; |
1590 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1582 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1591 false); | |
1592 SuggestionBackendID guid( | 1583 SuggestionBackendID guid( |
1593 "10000000-0000-0000-0000-000000000001", 0); // local card | 1584 "10000000-0000-0000-0000-000000000001", 0); // local card |
1594 autofill_manager_->FillOrPreviewForm( | 1585 autofill_manager_->FillOrPreviewForm( |
1595 AutofillDriver::FORM_DATA_ACTION_FILL, | 1586 AutofillDriver::FORM_DATA_ACTION_FILL, |
1596 0, form, form.fields.front(), | 1587 0, form, form.fields.front(), |
1597 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); | 1588 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
1598 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1589 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
1599 histogram_tester.ExpectBucketCount( | 1590 histogram_tester.ExpectBucketCount( |
1600 "Autofill.FormEvents.CreditCard", | 1591 "Autofill.FormEvents.CreditCard", |
1601 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1592 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
1602 histogram_tester.ExpectBucketCount( | 1593 histogram_tester.ExpectBucketCount( |
1603 "Autofill.FormEvents.CreditCard", | 1594 "Autofill.FormEvents.CreditCard", |
1604 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); | 1595 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); |
1605 } | 1596 } |
1606 | 1597 |
1607 // Reset the autofill manager state. | 1598 // Reset the autofill manager state. |
1608 autofill_manager_->Reset(); | 1599 autofill_manager_->Reset(); |
1609 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1600 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1610 | 1601 |
1611 { | 1602 { |
1612 // Simulating submission with filled server data. | 1603 // Simulating submission with filled server data. |
1613 base::HistogramTester histogram_tester; | 1604 base::HistogramTester histogram_tester; |
1614 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1605 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1615 false); | |
1616 SuggestionBackendID guid( | 1606 SuggestionBackendID guid( |
1617 "10000000-0000-0000-0000-000000000003", 0); // full server card | 1607 "10000000-0000-0000-0000-000000000003", 0); // full server card |
1618 autofill_manager_->FillOrPreviewForm( | 1608 autofill_manager_->FillOrPreviewForm( |
1619 AutofillDriver::FORM_DATA_ACTION_FILL, | 1609 AutofillDriver::FORM_DATA_ACTION_FILL, |
1620 0, form, form.fields.front(), | 1610 0, form, form.fields.front(), |
1621 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); | 1611 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
1622 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1612 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
1623 histogram_tester.ExpectBucketCount( | 1613 histogram_tester.ExpectBucketCount( |
1624 "Autofill.FormEvents.CreditCard", | 1614 "Autofill.FormEvents.CreditCard", |
1625 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1615 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 true /* include_masked_server_credit_card */, | 1649 true /* include_masked_server_credit_card */, |
1660 true /* include_full_server_credit_card */); | 1650 true /* include_full_server_credit_card */); |
1661 | 1651 |
1662 // Reset the autofill manager state. | 1652 // Reset the autofill manager state. |
1663 autofill_manager_->Reset(); | 1653 autofill_manager_->Reset(); |
1664 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1654 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1665 | 1655 |
1666 { | 1656 { |
1667 // Simulating multiple submissions. | 1657 // Simulating multiple submissions. |
1668 base::HistogramTester histogram_tester; | 1658 base::HistogramTester histogram_tester; |
1669 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1659 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1670 false); | |
1671 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1660 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
1672 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1661 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
1673 histogram_tester.ExpectBucketCount( | 1662 histogram_tester.ExpectBucketCount( |
1674 "Autofill.FormEvents.CreditCard", | 1663 "Autofill.FormEvents.CreditCard", |
1675 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1664 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
1676 histogram_tester.ExpectBucketCount( | 1665 histogram_tester.ExpectBucketCount( |
1677 "Autofill.FormEvents.CreditCard", | 1666 "Autofill.FormEvents.CreditCard", |
1678 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0); | 1667 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0); |
1679 histogram_tester.ExpectBucketCount( | 1668 histogram_tester.ExpectBucketCount( |
1680 "Autofill.FormEvents.CreditCard", | 1669 "Autofill.FormEvents.CreditCard", |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 form.fields.push_back(field); | 1747 form.fields.push_back(field); |
1759 field_types.push_back(CREDIT_CARD_NUMBER); | 1748 field_types.push_back(CREDIT_CARD_NUMBER); |
1760 | 1749 |
1761 // Simulate having seen this form on page load. | 1750 // Simulate having seen this form on page load. |
1762 // |form_structure| will be owned by |autofill_manager_|. | 1751 // |form_structure| will be owned by |autofill_manager_|. |
1763 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1752 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1764 | 1753 |
1765 { | 1754 { |
1766 // Simulating submission with no filled data. | 1755 // Simulating submission with no filled data. |
1767 base::HistogramTester histogram_tester; | 1756 base::HistogramTester histogram_tester; |
1768 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1757 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1769 false); | |
1770 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1758 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1771 histogram_tester.ExpectBucketCount( | 1759 histogram_tester.ExpectBucketCount( |
1772 "Autofill.FormEvents.CreditCard", | 1760 "Autofill.FormEvents.CreditCard", |
1773 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1761 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
1774 histogram_tester.ExpectBucketCount( | 1762 histogram_tester.ExpectBucketCount( |
1775 "Autofill.FormEvents.CreditCard", | 1763 "Autofill.FormEvents.CreditCard", |
1776 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); | 1764 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
1777 } | 1765 } |
1778 | 1766 |
1779 // Reset the autofill manager state. | 1767 // Reset the autofill manager state. |
1780 autofill_manager_->Reset(); | 1768 autofill_manager_->Reset(); |
1781 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1769 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1782 | 1770 |
1783 { | 1771 { |
1784 // Simulating submission with filled local data. | 1772 // Simulating submission with filled local data. |
1785 base::HistogramTester histogram_tester; | 1773 base::HistogramTester histogram_tester; |
1786 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1774 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1787 false); | |
1788 SuggestionBackendID guid("10000000-0000-0000-0000-000000000001", | 1775 SuggestionBackendID guid("10000000-0000-0000-0000-000000000001", |
1789 0); // local card | 1776 0); // local card |
1790 autofill_manager_->FillOrPreviewForm( | 1777 autofill_manager_->FillOrPreviewForm( |
1791 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 1778 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
1792 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); | 1779 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
1793 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1780 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1794 histogram_tester.ExpectBucketCount( | 1781 histogram_tester.ExpectBucketCount( |
1795 "Autofill.FormEvents.CreditCard", | 1782 "Autofill.FormEvents.CreditCard", |
1796 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1783 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
1797 histogram_tester.ExpectBucketCount( | 1784 histogram_tester.ExpectBucketCount( |
1798 "Autofill.FormEvents.CreditCard", | 1785 "Autofill.FormEvents.CreditCard", |
1799 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); | 1786 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
1800 } | 1787 } |
1801 | 1788 |
1802 // Reset the autofill manager state. | 1789 // Reset the autofill manager state. |
1803 autofill_manager_->Reset(); | 1790 autofill_manager_->Reset(); |
1804 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1791 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1805 | 1792 |
1806 { | 1793 { |
1807 // Simulating submission with filled server data. | 1794 // Simulating submission with filled server data. |
1808 base::HistogramTester histogram_tester; | 1795 base::HistogramTester histogram_tester; |
1809 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1796 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1810 false); | |
1811 SuggestionBackendID guid("10000000-0000-0000-0000-000000000003", | 1797 SuggestionBackendID guid("10000000-0000-0000-0000-000000000003", |
1812 0); // full server card | 1798 0); // full server card |
1813 autofill_manager_->FillOrPreviewForm( | 1799 autofill_manager_->FillOrPreviewForm( |
1814 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 1800 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
1815 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); | 1801 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); |
1816 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1802 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1817 histogram_tester.ExpectBucketCount( | 1803 histogram_tester.ExpectBucketCount( |
1818 "Autofill.FormEvents.CreditCard", | 1804 "Autofill.FormEvents.CreditCard", |
1819 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1805 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
1820 histogram_tester.ExpectBucketCount( | 1806 histogram_tester.ExpectBucketCount( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 true /* include_masked_server_credit_card */, | 1838 true /* include_masked_server_credit_card */, |
1853 true /* include_full_server_credit_card */); | 1839 true /* include_full_server_credit_card */); |
1854 | 1840 |
1855 // Reset the autofill manager state. | 1841 // Reset the autofill manager state. |
1856 autofill_manager_->Reset(); | 1842 autofill_manager_->Reset(); |
1857 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1843 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1858 | 1844 |
1859 { | 1845 { |
1860 // Simulating multiple submissions. | 1846 // Simulating multiple submissions. |
1861 base::HistogramTester histogram_tester; | 1847 base::HistogramTester histogram_tester; |
1862 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1848 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1863 false); | |
1864 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1849 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1865 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 1850 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
1866 histogram_tester.ExpectBucketCount( | 1851 histogram_tester.ExpectBucketCount( |
1867 "Autofill.FormEvents.CreditCard", | 1852 "Autofill.FormEvents.CreditCard", |
1868 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 1853 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
1869 histogram_tester.ExpectBucketCount( | 1854 histogram_tester.ExpectBucketCount( |
1870 "Autofill.FormEvents.CreditCard", | 1855 "Autofill.FormEvents.CreditCard", |
1871 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0); | 1856 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0); |
1872 histogram_tester.ExpectBucketCount( | 1857 histogram_tester.ExpectBucketCount( |
1873 "Autofill.FormEvents.CreditCard", | 1858 "Autofill.FormEvents.CreditCard", |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 form.fields.push_back(field); | 1928 form.fields.push_back(field); |
1944 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); | 1929 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); |
1945 | 1930 |
1946 // Simulate having seen this form on page load. | 1931 // Simulate having seen this form on page load. |
1947 // |form_structure| will be owned by |autofill_manager_|. | 1932 // |form_structure| will be owned by |autofill_manager_|. |
1948 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1933 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1949 | 1934 |
1950 { | 1935 { |
1951 // Simulate activating the autofill popup for the street field. | 1936 // Simulate activating the autofill popup for the street field. |
1952 base::HistogramTester histogram_tester; | 1937 base::HistogramTester histogram_tester; |
1953 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1938 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1954 false); | |
1955 histogram_tester.ExpectUniqueSample( | 1939 histogram_tester.ExpectUniqueSample( |
1956 "Autofill.FormEvents.Address", | 1940 "Autofill.FormEvents.Address", |
1957 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 1941 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
1958 } | 1942 } |
1959 | 1943 |
1960 // Reset the autofill manager state. | 1944 // Reset the autofill manager state. |
1961 autofill_manager_->Reset(); | 1945 autofill_manager_->Reset(); |
1962 autofill_manager_->AddSeenForm(form, field_types, field_types); | 1946 autofill_manager_->AddSeenForm(form, field_types, field_types); |
1963 | 1947 |
1964 { | 1948 { |
1965 // Simulate activating the autofill popup for the street field twice. | 1949 // Simulate activating the autofill popup for the street field twice. |
1966 base::HistogramTester histogram_tester; | 1950 base::HistogramTester histogram_tester; |
1967 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 1951 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
1968 false); | 1952 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect()); |
1969 autofill_manager_->OnQueryFormFieldAutofill(1, form, field, gfx::Rect(), | |
1970 false); | |
1971 histogram_tester.ExpectUniqueSample( | 1953 histogram_tester.ExpectUniqueSample( |
1972 "Autofill.FormEvents.Address", | 1954 "Autofill.FormEvents.Address", |
1973 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 1955 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
1974 } | 1956 } |
1975 } | 1957 } |
1976 | 1958 |
1977 // Test that we log suggestion shown form events for address. | 1959 // Test that we log suggestion shown form events for address. |
1978 TEST_F(AutofillMetricsTest, AddressShownFormEvents) { | 1960 TEST_F(AutofillMetricsTest, AddressShownFormEvents) { |
1979 EnableWalletSync(); | 1961 EnableWalletSync(); |
1980 // Creating all kinds of profiles. | 1962 // Creating all kinds of profiles. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 form.fields.push_back(field); | 2150 form.fields.push_back(field); |
2169 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); | 2151 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); |
2170 | 2152 |
2171 // Simulate having seen this form on page load. | 2153 // Simulate having seen this form on page load. |
2172 // |form_structure| will be owned by |autofill_manager_|. | 2154 // |form_structure| will be owned by |autofill_manager_|. |
2173 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2155 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2174 | 2156 |
2175 { | 2157 { |
2176 // Simulating submission with no filled data. | 2158 // Simulating submission with no filled data. |
2177 base::HistogramTester histogram_tester; | 2159 base::HistogramTester histogram_tester; |
2178 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2160 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2179 false); | |
2180 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 2161 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2181 histogram_tester.ExpectBucketCount( | 2162 histogram_tester.ExpectBucketCount( |
2182 "Autofill.FormEvents.Address", | 2163 "Autofill.FormEvents.Address", |
2183 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2164 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2184 histogram_tester.ExpectBucketCount( | 2165 histogram_tester.ExpectBucketCount( |
2185 "Autofill.FormEvents.Address", | 2166 "Autofill.FormEvents.Address", |
2186 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); | 2167 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 1); |
2187 } | 2168 } |
2188 | 2169 |
2189 // Reset the autofill manager state. | 2170 // Reset the autofill manager state. |
2190 autofill_manager_->Reset(); | 2171 autofill_manager_->Reset(); |
2191 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2172 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2192 | 2173 |
2193 { | 2174 { |
2194 // Simulating submission with filled local data. | 2175 // Simulating submission with filled local data. |
2195 base::HistogramTester histogram_tester; | 2176 base::HistogramTester histogram_tester; |
2196 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2177 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2197 false); | |
2198 SuggestionBackendID guid( | 2178 SuggestionBackendID guid( |
2199 "00000000-0000-0000-0000-000000000001", 0); // local profile | 2179 "00000000-0000-0000-0000-000000000001", 0); // local profile |
2200 autofill_manager_->FillOrPreviewForm( | 2180 autofill_manager_->FillOrPreviewForm( |
2201 AutofillDriver::FORM_DATA_ACTION_FILL, | 2181 AutofillDriver::FORM_DATA_ACTION_FILL, |
2202 0, form, form.fields.front(), | 2182 0, form, form.fields.front(), |
2203 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); | 2183 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
2204 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 2184 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2205 histogram_tester.ExpectBucketCount( | 2185 histogram_tester.ExpectBucketCount( |
2206 "Autofill.FormEvents.Address", | 2186 "Autofill.FormEvents.Address", |
2207 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2187 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2208 histogram_tester.ExpectBucketCount( | 2188 histogram_tester.ExpectBucketCount( |
2209 "Autofill.FormEvents.Address", | 2189 "Autofill.FormEvents.Address", |
2210 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); | 2190 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 1); |
2211 } | 2191 } |
2212 | 2192 |
2213 // Reset the autofill manager state. | 2193 // Reset the autofill manager state. |
2214 autofill_manager_->Reset(); | 2194 autofill_manager_->Reset(); |
2215 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2195 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2216 | 2196 |
2217 { | 2197 { |
2218 // Simulating submission with filled server data. | 2198 // Simulating submission with filled server data. |
2219 base::HistogramTester histogram_tester; | 2199 base::HistogramTester histogram_tester; |
2220 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2200 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2221 false); | |
2222 SuggestionBackendID guid( | 2201 SuggestionBackendID guid( |
2223 "00000000-0000-0000-0000-000000000002", 0); // server profile | 2202 "00000000-0000-0000-0000-000000000002", 0); // server profile |
2224 autofill_manager_->FillOrPreviewForm( | 2203 autofill_manager_->FillOrPreviewForm( |
2225 AutofillDriver::FORM_DATA_ACTION_FILL, | 2204 AutofillDriver::FORM_DATA_ACTION_FILL, |
2226 0, form, form.fields.front(), | 2205 0, form, form.fields.front(), |
2227 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); | 2206 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
2228 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 2207 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2229 histogram_tester.ExpectBucketCount( | 2208 histogram_tester.ExpectBucketCount( |
2230 "Autofill.FormEvents.Address", | 2209 "Autofill.FormEvents.Address", |
2231 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2210 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2232 histogram_tester.ExpectBucketCount( | 2211 histogram_tester.ExpectBucketCount( |
2233 "Autofill.FormEvents.Address", | 2212 "Autofill.FormEvents.Address", |
2234 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1); | 2213 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1); |
2235 } | 2214 } |
2236 | 2215 |
2237 // Reset the autofill manager state. | 2216 // Reset the autofill manager state. |
2238 autofill_manager_->Reset(); | 2217 autofill_manager_->Reset(); |
2239 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2218 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2240 | 2219 |
2241 { | 2220 { |
2242 // Simulating multiple submissions. | 2221 // Simulating multiple submissions. |
2243 base::HistogramTester histogram_tester; | 2222 base::HistogramTester histogram_tester; |
2244 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2223 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2245 false); | |
2246 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 2224 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2247 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 2225 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
2248 histogram_tester.ExpectBucketCount( | 2226 histogram_tester.ExpectBucketCount( |
2249 "Autofill.FormEvents.Address", | 2227 "Autofill.FormEvents.Address", |
2250 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2228 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2251 histogram_tester.ExpectBucketCount( | 2229 histogram_tester.ExpectBucketCount( |
2252 "Autofill.FormEvents.Address", | 2230 "Autofill.FormEvents.Address", |
2253 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0); | 2231 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 0); |
2254 histogram_tester.ExpectBucketCount( | 2232 histogram_tester.ExpectBucketCount( |
2255 "Autofill.FormEvents.Address", | 2233 "Autofill.FormEvents.Address", |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 form.fields.push_back(field); | 2299 form.fields.push_back(field); |
2322 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); | 2300 field_types.push_back(ADDRESS_HOME_STREET_ADDRESS); |
2323 | 2301 |
2324 // Simulate having seen this form on page load. | 2302 // Simulate having seen this form on page load. |
2325 // |form_structure| will be owned by |autofill_manager_|. | 2303 // |form_structure| will be owned by |autofill_manager_|. |
2326 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2304 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2327 | 2305 |
2328 { | 2306 { |
2329 // Simulating submission with no filled data. | 2307 // Simulating submission with no filled data. |
2330 base::HistogramTester histogram_tester; | 2308 base::HistogramTester histogram_tester; |
2331 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2309 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2332 false); | |
2333 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2310 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
2334 histogram_tester.ExpectBucketCount( | 2311 histogram_tester.ExpectBucketCount( |
2335 "Autofill.FormEvents.Address", | 2312 "Autofill.FormEvents.Address", |
2336 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2313 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2337 histogram_tester.ExpectBucketCount( | 2314 histogram_tester.ExpectBucketCount( |
2338 "Autofill.FormEvents.Address", | 2315 "Autofill.FormEvents.Address", |
2339 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); | 2316 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
2340 } | 2317 } |
2341 | 2318 |
2342 // Reset the autofill manager state. | 2319 // Reset the autofill manager state. |
2343 autofill_manager_->Reset(); | 2320 autofill_manager_->Reset(); |
2344 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2321 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2345 | 2322 |
2346 { | 2323 { |
2347 // Simulating submission with filled local data. | 2324 // Simulating submission with filled local data. |
2348 base::HistogramTester histogram_tester; | 2325 base::HistogramTester histogram_tester; |
2349 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2326 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2350 false); | |
2351 SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", | 2327 SuggestionBackendID guid("00000000-0000-0000-0000-000000000001", |
2352 0); // local profile | 2328 0); // local profile |
2353 autofill_manager_->FillOrPreviewForm( | 2329 autofill_manager_->FillOrPreviewForm( |
2354 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 2330 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
2355 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); | 2331 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
2356 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2332 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
2357 histogram_tester.ExpectBucketCount( | 2333 histogram_tester.ExpectBucketCount( |
2358 "Autofill.FormEvents.Address", | 2334 "Autofill.FormEvents.Address", |
2359 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2335 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2360 histogram_tester.ExpectBucketCount( | 2336 histogram_tester.ExpectBucketCount( |
2361 "Autofill.FormEvents.Address", | 2337 "Autofill.FormEvents.Address", |
2362 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); | 2338 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_SUBMITTED_ONCE, 0); |
2363 } | 2339 } |
2364 | 2340 |
2365 // Reset the autofill manager state. | 2341 // Reset the autofill manager state. |
2366 autofill_manager_->Reset(); | 2342 autofill_manager_->Reset(); |
2367 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2343 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2368 | 2344 |
2369 { | 2345 { |
2370 // Simulating submission with filled server data. | 2346 // Simulating submission with filled server data. |
2371 base::HistogramTester histogram_tester; | 2347 base::HistogramTester histogram_tester; |
2372 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2348 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2373 false); | |
2374 SuggestionBackendID guid("00000000-0000-0000-0000-000000000002", | 2349 SuggestionBackendID guid("00000000-0000-0000-0000-000000000002", |
2375 0); // server profile | 2350 0); // server profile |
2376 autofill_manager_->FillOrPreviewForm( | 2351 autofill_manager_->FillOrPreviewForm( |
2377 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 2352 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
2378 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); | 2353 autofill_manager_->MakeFrontendID(SuggestionBackendID(), guid)); |
2379 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2354 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
2380 histogram_tester.ExpectBucketCount( | 2355 histogram_tester.ExpectBucketCount( |
2381 "Autofill.FormEvents.Address", | 2356 "Autofill.FormEvents.Address", |
2382 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2357 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2383 histogram_tester.ExpectBucketCount( | 2358 histogram_tester.ExpectBucketCount( |
2384 "Autofill.FormEvents.Address", | 2359 "Autofill.FormEvents.Address", |
2385 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); | 2360 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0); |
2386 } | 2361 } |
2387 | 2362 |
2388 // Reset the autofill manager state. | 2363 // Reset the autofill manager state. |
2389 autofill_manager_->Reset(); | 2364 autofill_manager_->Reset(); |
2390 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2365 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2391 | 2366 |
2392 { | 2367 { |
2393 // Simulating multiple submissions. | 2368 // Simulating multiple submissions. |
2394 base::HistogramTester histogram_tester; | 2369 base::HistogramTester histogram_tester; |
2395 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2370 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2396 false); | |
2397 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2371 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
2398 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); | 2372 autofill_manager_->WillSubmitForm(form, TimeTicks::Now()); |
2399 histogram_tester.ExpectBucketCount( | 2373 histogram_tester.ExpectBucketCount( |
2400 "Autofill.FormEvents.Address", | 2374 "Autofill.FormEvents.Address", |
2401 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); | 2375 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_WILL_SUBMIT_ONCE, 1); |
2402 histogram_tester.ExpectBucketCount( | 2376 histogram_tester.ExpectBucketCount( |
2403 "Autofill.FormEvents.Address", | 2377 "Autofill.FormEvents.Address", |
2404 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); | 2378 AutofillMetrics::FORM_EVENT_NO_SUGGESTION_SUBMITTED_ONCE, 0); |
2405 histogram_tester.ExpectBucketCount( | 2379 histogram_tester.ExpectBucketCount( |
2406 "Autofill.FormEvents.Address", | 2380 "Autofill.FormEvents.Address", |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 // |form_structure| will be owned by |autofill_manager_|. | 2440 // |form_structure| will be owned by |autofill_manager_|. |
2467 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2441 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2468 personal_data_->RecreateCreditCards( | 2442 personal_data_->RecreateCreditCards( |
2469 false /* include_local_credit_card */, | 2443 false /* include_local_credit_card */, |
2470 false /* include_masked_server_credit_card */, | 2444 false /* include_masked_server_credit_card */, |
2471 false /* include_full_server_credit_card */); | 2445 false /* include_full_server_credit_card */); |
2472 | 2446 |
2473 { | 2447 { |
2474 // Simulate activating the autofill popup for the credit card field. | 2448 // Simulate activating the autofill popup for the credit card field. |
2475 base::HistogramTester histogram_tester; | 2449 base::HistogramTester histogram_tester; |
2476 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2450 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2477 false); | |
2478 histogram_tester.ExpectUniqueSample( | 2451 histogram_tester.ExpectUniqueSample( |
2479 "Autofill.FormEvents.CreditCard.WithNoData", | 2452 "Autofill.FormEvents.CreditCard.WithNoData", |
2480 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2453 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2481 } | 2454 } |
2482 | 2455 |
2483 // Reset the autofill manager state. | 2456 // Reset the autofill manager state. |
2484 autofill_manager_->Reset(); | 2457 autofill_manager_->Reset(); |
2485 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2458 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2486 personal_data_->RecreateCreditCards( | 2459 personal_data_->RecreateCreditCards( |
2487 true /* include_local_credit_card */, | 2460 true /* include_local_credit_card */, |
2488 false /* include_masked_server_credit_card */, | 2461 false /* include_masked_server_credit_card */, |
2489 false /* include_full_server_credit_card */); | 2462 false /* include_full_server_credit_card */); |
2490 | 2463 |
2491 { | 2464 { |
2492 // Simulate activating the autofill popup for the credit card field. | 2465 // Simulate activating the autofill popup for the credit card field. |
2493 base::HistogramTester histogram_tester; | 2466 base::HistogramTester histogram_tester; |
2494 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2467 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2495 false); | |
2496 histogram_tester.ExpectUniqueSample( | 2468 histogram_tester.ExpectUniqueSample( |
2497 "Autofill.FormEvents.CreditCard.WithOnlyLocalData", | 2469 "Autofill.FormEvents.CreditCard.WithOnlyLocalData", |
2498 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2470 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2499 } | 2471 } |
2500 | 2472 |
2501 // Reset the autofill manager state. | 2473 // Reset the autofill manager state. |
2502 autofill_manager_->Reset(); | 2474 autofill_manager_->Reset(); |
2503 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2475 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2504 personal_data_->RecreateCreditCards( | 2476 personal_data_->RecreateCreditCards( |
2505 false /* include_local_credit_card */, | 2477 false /* include_local_credit_card */, |
2506 true /* include_masked_server_credit_card */, | 2478 true /* include_masked_server_credit_card */, |
2507 false /* include_full_server_credit_card */); | 2479 false /* include_full_server_credit_card */); |
2508 | 2480 |
2509 { | 2481 { |
2510 // Simulate activating the autofill popup for the credit card field. | 2482 // Simulate activating the autofill popup for the credit card field. |
2511 base::HistogramTester histogram_tester; | 2483 base::HistogramTester histogram_tester; |
2512 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2484 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2513 false); | |
2514 histogram_tester.ExpectUniqueSample( | 2485 histogram_tester.ExpectUniqueSample( |
2515 "Autofill.FormEvents.CreditCard.WithOnlyServerData", | 2486 "Autofill.FormEvents.CreditCard.WithOnlyServerData", |
2516 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2487 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2517 } | 2488 } |
2518 | 2489 |
2519 // Reset the autofill manager state. | 2490 // Reset the autofill manager state. |
2520 autofill_manager_->Reset(); | 2491 autofill_manager_->Reset(); |
2521 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2492 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2522 personal_data_->RecreateCreditCards( | 2493 personal_data_->RecreateCreditCards( |
2523 false /* include_local_credit_card */, | 2494 false /* include_local_credit_card */, |
2524 false /* include_masked_server_credit_card */, | 2495 false /* include_masked_server_credit_card */, |
2525 true /* include_full_server_credit_card */); | 2496 true /* include_full_server_credit_card */); |
2526 | 2497 |
2527 { | 2498 { |
2528 // Simulate activating the autofill popup for the credit card field. | 2499 // Simulate activating the autofill popup for the credit card field. |
2529 base::HistogramTester histogram_tester; | 2500 base::HistogramTester histogram_tester; |
2530 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2501 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2531 false); | |
2532 histogram_tester.ExpectUniqueSample( | 2502 histogram_tester.ExpectUniqueSample( |
2533 "Autofill.FormEvents.CreditCard.WithOnlyServerData", | 2503 "Autofill.FormEvents.CreditCard.WithOnlyServerData", |
2534 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2504 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2535 } | 2505 } |
2536 | 2506 |
2537 // Reset the autofill manager state. | 2507 // Reset the autofill manager state. |
2538 autofill_manager_->Reset(); | 2508 autofill_manager_->Reset(); |
2539 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2509 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2540 personal_data_->RecreateCreditCards( | 2510 personal_data_->RecreateCreditCards( |
2541 true /* include_local_credit_card */, | 2511 true /* include_local_credit_card */, |
2542 false /* include_masked_server_credit_card */, | 2512 false /* include_masked_server_credit_card */, |
2543 true /* include_full_server_credit_card */); | 2513 true /* include_full_server_credit_card */); |
2544 | 2514 |
2545 { | 2515 { |
2546 // Simulate activating the autofill popup for the credit card field. | 2516 // Simulate activating the autofill popup for the credit card field. |
2547 base::HistogramTester histogram_tester; | 2517 base::HistogramTester histogram_tester; |
2548 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2518 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2549 false); | |
2550 histogram_tester.ExpectUniqueSample( | 2519 histogram_tester.ExpectUniqueSample( |
2551 "Autofill.FormEvents.CreditCard.WithBothServerAndLocalData", | 2520 "Autofill.FormEvents.CreditCard.WithBothServerAndLocalData", |
2552 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2521 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2553 } | 2522 } |
2554 } | 2523 } |
2555 | 2524 |
2556 // Test that we log interacted form event for address only once. | 2525 // Test that we log interacted form event for address only once. |
2557 TEST_F(AutofillMetricsTest, AddressFormEventsAreSegmented) { | 2526 TEST_F(AutofillMetricsTest, AddressFormEventsAreSegmented) { |
2558 EnableWalletSync(); | 2527 EnableWalletSync(); |
2559 | 2528 |
(...skipping 18 matching lines...) Expand all Loading... |
2578 | 2547 |
2579 // Simulate having seen this form on page load. | 2548 // Simulate having seen this form on page load. |
2580 // |form_structure| will be owned by |autofill_manager_|. | 2549 // |form_structure| will be owned by |autofill_manager_|. |
2581 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2550 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2582 personal_data_->RecreateProfiles(false /* include_local_profile */, | 2551 personal_data_->RecreateProfiles(false /* include_local_profile */, |
2583 false /* include_server_profile */); | 2552 false /* include_server_profile */); |
2584 | 2553 |
2585 { | 2554 { |
2586 // Simulate activating the autofill popup for the street field. | 2555 // Simulate activating the autofill popup for the street field. |
2587 base::HistogramTester histogram_tester; | 2556 base::HistogramTester histogram_tester; |
2588 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2557 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2589 false); | |
2590 histogram_tester.ExpectUniqueSample( | 2558 histogram_tester.ExpectUniqueSample( |
2591 "Autofill.FormEvents.Address.WithNoData", | 2559 "Autofill.FormEvents.Address.WithNoData", |
2592 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2560 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2593 } | 2561 } |
2594 | 2562 |
2595 // Reset the autofill manager state. | 2563 // Reset the autofill manager state. |
2596 autofill_manager_->Reset(); | 2564 autofill_manager_->Reset(); |
2597 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2565 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2598 personal_data_->RecreateProfiles(true /* include_local_profile */, | 2566 personal_data_->RecreateProfiles(true /* include_local_profile */, |
2599 false /* include_server_profile */); | 2567 false /* include_server_profile */); |
2600 | 2568 |
2601 { | 2569 { |
2602 // Simulate activating the autofill popup for the street field. | 2570 // Simulate activating the autofill popup for the street field. |
2603 base::HistogramTester histogram_tester; | 2571 base::HistogramTester histogram_tester; |
2604 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2572 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2605 false); | |
2606 histogram_tester.ExpectUniqueSample( | 2573 histogram_tester.ExpectUniqueSample( |
2607 "Autofill.FormEvents.Address.WithOnlyLocalData", | 2574 "Autofill.FormEvents.Address.WithOnlyLocalData", |
2608 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2575 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2609 } | 2576 } |
2610 | 2577 |
2611 // Reset the autofill manager state. | 2578 // Reset the autofill manager state. |
2612 autofill_manager_->Reset(); | 2579 autofill_manager_->Reset(); |
2613 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2580 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2614 personal_data_->RecreateProfiles(false /* include_local_profile */, | 2581 personal_data_->RecreateProfiles(false /* include_local_profile */, |
2615 true /* include_server_profile */); | 2582 true /* include_server_profile */); |
2616 | 2583 |
2617 { | 2584 { |
2618 // Simulate activating the autofill popup for the street field. | 2585 // Simulate activating the autofill popup for the street field. |
2619 base::HistogramTester histogram_tester; | 2586 base::HistogramTester histogram_tester; |
2620 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2587 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2621 false); | |
2622 histogram_tester.ExpectUniqueSample( | 2588 histogram_tester.ExpectUniqueSample( |
2623 "Autofill.FormEvents.Address.WithOnlyServerData", | 2589 "Autofill.FormEvents.Address.WithOnlyServerData", |
2624 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2590 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2625 } | 2591 } |
2626 | 2592 |
2627 // Reset the autofill manager state. | 2593 // Reset the autofill manager state. |
2628 autofill_manager_->Reset(); | 2594 autofill_manager_->Reset(); |
2629 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2595 autofill_manager_->AddSeenForm(form, field_types, field_types); |
2630 personal_data_->RecreateProfiles(true /* include_local_profile */, | 2596 personal_data_->RecreateProfiles(true /* include_local_profile */, |
2631 true /* include_server_profile */); | 2597 true /* include_server_profile */); |
2632 | 2598 |
2633 { | 2599 { |
2634 // Simulate activating the autofill popup for the street field. | 2600 // Simulate activating the autofill popup for the street field. |
2635 base::HistogramTester histogram_tester; | 2601 base::HistogramTester histogram_tester; |
2636 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect(), | 2602 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::Rect()); |
2637 false); | |
2638 histogram_tester.ExpectUniqueSample( | 2603 histogram_tester.ExpectUniqueSample( |
2639 "Autofill.FormEvents.Address.WithBothServerAndLocalData", | 2604 "Autofill.FormEvents.Address.WithBothServerAndLocalData", |
2640 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); | 2605 AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1); |
2641 } | 2606 } |
2642 } | 2607 } |
2643 | 2608 |
2644 | 2609 |
2645 // Test that we log that Autofill is enabled when filling a form. | 2610 // Test that we log that Autofill is enabled when filling a form. |
2646 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { | 2611 TEST_F(AutofillMetricsTest, AutofillIsEnabledAtPageLoad) { |
2647 base::HistogramTester histogram_tester; | 2612 base::HistogramTester histogram_tester; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3055 histogram_tester.ExpectTotalCount( | 3020 histogram_tester.ExpectTotalCount( |
3056 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); | 3021 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); |
3057 histogram_tester.ExpectTotalCount( | 3022 histogram_tester.ExpectTotalCount( |
3058 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); | 3023 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); |
3059 | 3024 |
3060 autofill_manager_->Reset(); | 3025 autofill_manager_->Reset(); |
3061 } | 3026 } |
3062 } | 3027 } |
3063 | 3028 |
3064 } // namespace autofill | 3029 } // namespace autofill |
OLD | NEW |