| 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 <utility> | 10 #include <utility> |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 408 |
| 409 class AutofillMetricsTest : public testing::Test { | 409 class AutofillMetricsTest : public testing::Test { |
| 410 public: | 410 public: |
| 411 ~AutofillMetricsTest() override; | 411 ~AutofillMetricsTest() override; |
| 412 | 412 |
| 413 void SetUp() override; | 413 void SetUp() override; |
| 414 void TearDown() override; | 414 void TearDown() override; |
| 415 | 415 |
| 416 protected: | 416 protected: |
| 417 void EnableWalletSync(); | 417 void EnableWalletSync(); |
| 418 void EnableUkmLogging(); | |
| 419 | 418 |
| 420 base::test::ScopedTaskEnvironment scoped_task_environment_; | 419 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 421 TestAutofillClient autofill_client_; | 420 TestAutofillClient autofill_client_; |
| 422 std::unique_ptr<AccountTrackerService> account_tracker_; | 421 std::unique_ptr<AccountTrackerService> account_tracker_; |
| 423 std::unique_ptr<FakeSigninManagerBase> signin_manager_; | 422 std::unique_ptr<FakeSigninManagerBase> signin_manager_; |
| 424 std::unique_ptr<TestSigninClient> signin_client_; | 423 std::unique_ptr<TestSigninClient> signin_client_; |
| 425 std::unique_ptr<TestAutofillDriver> autofill_driver_; | 424 std::unique_ptr<TestAutofillDriver> autofill_driver_; |
| 426 std::unique_ptr<TestAutofillManager> autofill_manager_; | 425 std::unique_ptr<TestAutofillManager> autofill_manager_; |
| 427 std::unique_ptr<TestPersonalDataManager> personal_data_; | 426 std::unique_ptr<TestPersonalDataManager> personal_data_; |
| 428 std::unique_ptr<AutofillExternalDelegate> external_delegate_; | 427 std::unique_ptr<AutofillExternalDelegate> external_delegate_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 account_tracker_.reset(); | 476 account_tracker_.reset(); |
| 478 signin_client_.reset(); | 477 signin_client_.reset(); |
| 479 test::ReenableSystemServices(); | 478 test::ReenableSystemServices(); |
| 480 autofill_client_.GetTestUkmService()->Purge(); | 479 autofill_client_.GetTestUkmService()->Purge(); |
| 481 } | 480 } |
| 482 | 481 |
| 483 void AutofillMetricsTest::EnableWalletSync() { | 482 void AutofillMetricsTest::EnableWalletSync() { |
| 484 signin_manager_->SetAuthenticatedAccountInfo("12345", "syncuser@example.com"); | 483 signin_manager_->SetAuthenticatedAccountInfo("12345", "syncuser@example.com"); |
| 485 } | 484 } |
| 486 | 485 |
| 487 void AutofillMetricsTest::EnableUkmLogging() { | |
| 488 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging); | |
| 489 } | |
| 490 | |
| 491 // Test that we log quality metrics appropriately. | 486 // Test that we log quality metrics appropriately. |
| 492 TEST_F(AutofillMetricsTest, QualityMetrics) { | 487 TEST_F(AutofillMetricsTest, QualityMetrics) { |
| 493 // Set up our form data. | 488 // Set up our form data. |
| 494 FormData form; | 489 FormData form; |
| 495 form.name = ASCIIToUTF16("TestForm"); | 490 form.name = ASCIIToUTF16("TestForm"); |
| 496 form.origin = GURL("http://example.com/form.html"); | 491 form.origin = GURL("http://example.com/form.html"); |
| 497 form.action = GURL("http://example.com/submit.html"); | 492 form.action = GURL("http://example.com/submit.html"); |
| 498 | 493 |
| 499 std::vector<ServerFieldType> heuristic_types, server_types; | 494 std::vector<ServerFieldType> heuristic_types, server_types; |
| 500 FormFieldData field; | 495 FormFieldData field; |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 autofill_manager_->OnTextFieldDidChange(form, form.fields[0], TimeTicks()); | 1617 autofill_manager_->OnTextFieldDidChange(form, form.fields[0], TimeTicks()); |
| 1623 autofill_manager_->OnTextFieldDidChange(form, form.fields[1], TimeTicks()); | 1618 autofill_manager_->OnTextFieldDidChange(form, form.fields[1], TimeTicks()); |
| 1624 | 1619 |
| 1625 // Simulate form submission. | 1620 // Simulate form submission. |
| 1626 autofill_manager_->SubmitForm(form, TimeTicks::Now()); | 1621 autofill_manager_->SubmitForm(form, TimeTicks::Now()); |
| 1627 | 1622 |
| 1628 // An autofillable form was submitted, and the number of edited autofilled | 1623 // An autofillable form was submitted, and the number of edited autofilled |
| 1629 // fields is logged. | 1624 // fields is logged. |
| 1630 histogram_tester.ExpectUniqueSample( | 1625 histogram_tester.ExpectUniqueSample( |
| 1631 "Autofill.NumberOfEditedAutofilledFieldsAtSubmission", 2, 1); | 1626 "Autofill.NumberOfEditedAutofilledFieldsAtSubmission", 2, 1); |
| 1632 | |
| 1633 // UKM must not be logged unless enabled. | |
| 1634 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | |
| 1635 EXPECT_EQ(0U, ukm_service->sources_count()); | |
| 1636 EXPECT_EQ(0U, ukm_service->entries_count()); | |
| 1637 } | 1627 } |
| 1638 | 1628 |
| 1639 // Verify that when resetting the autofill manager (such as during a | 1629 // Verify that when resetting the autofill manager (such as during a |
| 1640 // navigation), the proper number of edited fields is logged. | 1630 // navigation), the proper number of edited fields is logged. |
| 1641 TEST_F(AutofillMetricsTest, NumberOfEditedAutofilledFields_NoSubmission) { | 1631 TEST_F(AutofillMetricsTest, NumberOfEditedAutofilledFields_NoSubmission) { |
| 1642 // Construct a fillable form. | 1632 // Construct a fillable form. |
| 1643 FormData form; | 1633 FormData form; |
| 1644 form.name = ASCIIToUTF16("TestForm"); | 1634 form.name = ASCIIToUTF16("TestForm"); |
| 1645 form.origin = GURL("http://example.com/form.html"); | 1635 form.origin = GURL("http://example.com/form.html"); |
| 1646 form.action = GURL("http://example.com/submit.html"); | 1636 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 autofill_manager_->RunRunLoop(); | 1671 autofill_manager_->RunRunLoop(); |
| 1682 | 1672 |
| 1683 // An autofillable form was uploaded, and the number of edited autofilled | 1673 // An autofillable form was uploaded, and the number of edited autofilled |
| 1684 // fields is logged. | 1674 // fields is logged. |
| 1685 histogram_tester.ExpectUniqueSample( | 1675 histogram_tester.ExpectUniqueSample( |
| 1686 "Autofill.NumberOfEditedAutofilledFieldsAtSubmission.NoSubmission", 1, 1); | 1676 "Autofill.NumberOfEditedAutofilledFieldsAtSubmission.NoSubmission", 1, 1); |
| 1687 } | 1677 } |
| 1688 | 1678 |
| 1689 // Verify that we correctly log metrics regarding developer engagement. | 1679 // Verify that we correctly log metrics regarding developer engagement. |
| 1690 TEST_F(AutofillMetricsTest, DeveloperEngagement) { | 1680 TEST_F(AutofillMetricsTest, DeveloperEngagement) { |
| 1691 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | |
| 1692 | |
| 1693 // Start with a non-fillable form. | 1681 // Start with a non-fillable form. |
| 1694 FormData form; | 1682 FormData form; |
| 1695 form.name = ASCIIToUTF16("TestForm"); | 1683 form.name = ASCIIToUTF16("TestForm"); |
| 1696 form.origin = GURL("http://example.com/form.html"); | 1684 form.origin = GURL("http://example.com/form.html"); |
| 1697 form.action = GURL("http://example.com/submit.html"); | 1685 form.action = GURL("http://example.com/submit.html"); |
| 1698 | 1686 |
| 1699 FormFieldData field; | 1687 FormFieldData field; |
| 1700 test::CreateTestFormField("Name", "name", "", "text", &field); | 1688 test::CreateTestFormField("Name", "name", "", "text", &field); |
| 1701 form.fields.push_back(field); | 1689 form.fields.push_back(field); |
| 1702 test::CreateTestFormField("Email", "email", "", "text", &field); | 1690 test::CreateTestFormField("Email", "email", "", "text", &field); |
| 1703 form.fields.push_back(field); | 1691 form.fields.push_back(field); |
| 1704 | 1692 |
| 1705 std::vector<FormData> forms(1, form); | 1693 std::vector<FormData> forms(1, form); |
| 1706 | 1694 |
| 1707 // Ensure no metrics are logged when loading a non-fillable form. | 1695 // Ensure no metrics are logged when loading a non-fillable form. |
| 1708 { | 1696 { |
| 1709 base::HistogramTester histogram_tester; | 1697 base::HistogramTester histogram_tester; |
| 1710 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 1698 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 1711 autofill_manager_->Reset(); | 1699 autofill_manager_->Reset(); |
| 1712 histogram_tester.ExpectTotalCount("Autofill.DeveloperEngagement", 0); | 1700 histogram_tester.ExpectTotalCount("Autofill.DeveloperEngagement", 0); |
| 1713 | |
| 1714 // UKM must not be logged unless enabled. | |
| 1715 EXPECT_EQ(0U, ukm_service->sources_count()); | |
| 1716 EXPECT_EQ(0U, ukm_service->entries_count()); | |
| 1717 } | 1701 } |
| 1718 | 1702 |
| 1719 // Add another field to the form, so that it becomes fillable. | 1703 // Add another field to the form, so that it becomes fillable. |
| 1720 test::CreateTestFormField("Phone", "phone", "", "text", &field); | 1704 test::CreateTestFormField("Phone", "phone", "", "text", &field); |
| 1721 forms.back().fields.push_back(field); | 1705 forms.back().fields.push_back(field); |
| 1722 | 1706 |
| 1723 // Expect the "form parsed without hints" metric to be logged. | 1707 // Expect the "form parsed without hints" metric to be logged. |
| 1724 { | 1708 { |
| 1725 base::HistogramTester histogram_tester; | 1709 base::HistogramTester histogram_tester; |
| 1726 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 1710 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 1727 autofill_manager_->Reset(); | 1711 autofill_manager_->Reset(); |
| 1728 histogram_tester.ExpectUniqueSample( | 1712 histogram_tester.ExpectUniqueSample( |
| 1729 "Autofill.DeveloperEngagement", | 1713 "Autofill.DeveloperEngagement", |
| 1730 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, 1); | 1714 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, 1); |
| 1731 | |
| 1732 // UKM must not be logged unless enabled. | |
| 1733 EXPECT_EQ(0U, ukm_service->sources_count()); | |
| 1734 EXPECT_EQ(0U, ukm_service->entries_count()); | |
| 1735 } | 1715 } |
| 1736 | 1716 |
| 1737 // Add some fields with an author-specified field type to the form. | 1717 // Add some fields with an author-specified field type to the form. |
| 1738 // We need to add at least three fields, because a form must have at least | 1718 // We need to add at least three fields, because a form must have at least |
| 1739 // three fillable fields to be considered to be autofillable; and if at least | 1719 // three fillable fields to be considered to be autofillable; and if at least |
| 1740 // one field specifies an explicit type hint, we don't apply any of our usual | 1720 // one field specifies an explicit type hint, we don't apply any of our usual |
| 1741 // local heuristics to detect field types in the rest of the form. | 1721 // local heuristics to detect field types in the rest of the form. |
| 1742 test::CreateTestFormField("", "", "", "text", &field); | 1722 test::CreateTestFormField("", "", "", "text", &field); |
| 1743 field.autocomplete_attribute = "given-name"; | 1723 field.autocomplete_attribute = "given-name"; |
| 1744 forms.back().fields.push_back(field); | 1724 forms.back().fields.push_back(field); |
| 1745 test::CreateTestFormField("", "", "", "text", &field); | 1725 test::CreateTestFormField("", "", "", "text", &field); |
| 1746 field.autocomplete_attribute = "email"; | 1726 field.autocomplete_attribute = "email"; |
| 1747 forms.back().fields.push_back(field); | 1727 forms.back().fields.push_back(field); |
| 1748 test::CreateTestFormField("", "", "", "text", &field); | 1728 test::CreateTestFormField("", "", "", "text", &field); |
| 1749 field.autocomplete_attribute = "address-line1"; | 1729 field.autocomplete_attribute = "address-line1"; |
| 1750 forms.back().fields.push_back(field); | 1730 forms.back().fields.push_back(field); |
| 1751 | 1731 |
| 1752 // Expect the "form parsed with field type hints" metric to be logged. | 1732 // Expect the "form parsed with field type hints" metric to be logged. |
| 1753 { | 1733 { |
| 1754 base::HistogramTester histogram_tester; | 1734 base::HistogramTester histogram_tester; |
| 1755 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 1735 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 1756 autofill_manager_->Reset(); | 1736 autofill_manager_->Reset(); |
| 1757 histogram_tester.ExpectBucketCount( | 1737 histogram_tester.ExpectBucketCount( |
| 1758 "Autofill.DeveloperEngagement", | 1738 "Autofill.DeveloperEngagement", |
| 1759 AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, 1); | 1739 AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, 1); |
| 1760 | 1740 |
| 1761 // UKM must not be logged unless enabled. | |
| 1762 EXPECT_EQ(0U, ukm_service->sources_count()); | |
| 1763 EXPECT_EQ(0U, ukm_service->entries_count()); | |
| 1764 | |
| 1765 histogram_tester.ExpectBucketCount( | 1741 histogram_tester.ExpectBucketCount( |
| 1766 "Autofill.DeveloperEngagement", | 1742 "Autofill.DeveloperEngagement", |
| 1767 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT, 0); | 1743 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT, 0); |
| 1768 } | 1744 } |
| 1769 | 1745 |
| 1770 // Add a field with an author-specified UPI-VPA field type in the form. | 1746 // Add a field with an author-specified UPI-VPA field type in the form. |
| 1771 test::CreateTestFormField("", "", "", "text", &field); | 1747 test::CreateTestFormField("", "", "", "text", &field); |
| 1772 field.autocomplete_attribute = "upi-vpa"; | 1748 field.autocomplete_attribute = "upi-vpa"; |
| 1773 forms.back().fields.push_back(field); | 1749 forms.back().fields.push_back(field); |
| 1774 | 1750 |
| 1775 // Expect the "form parsed with type hints" metric, and the | 1751 // Expect the "form parsed with type hints" metric, and the |
| 1776 // "author-specified upi-vpa type" metric to be logged. | 1752 // "author-specified upi-vpa type" metric to be logged. |
| 1777 { | 1753 { |
| 1778 base::HistogramTester histogram_tester; | 1754 base::HistogramTester histogram_tester; |
| 1779 autofill_manager_->OnFormsSeen(forms, TimeTicks()); | 1755 autofill_manager_->OnFormsSeen(forms, TimeTicks()); |
| 1780 autofill_manager_->Reset(); | 1756 autofill_manager_->Reset(); |
| 1781 histogram_tester.ExpectBucketCount( | 1757 histogram_tester.ExpectBucketCount( |
| 1782 "Autofill.DeveloperEngagement", | 1758 "Autofill.DeveloperEngagement", |
| 1783 AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, 1); | 1759 AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS, 1); |
| 1784 histogram_tester.ExpectBucketCount( | 1760 histogram_tester.ExpectBucketCount( |
| 1785 "Autofill.DeveloperEngagement", | 1761 "Autofill.DeveloperEngagement", |
| 1786 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT, 1); | 1762 AutofillMetrics::FORM_CONTAINS_UPI_VPA_HINT, 1); |
| 1787 } | 1763 } |
| 1788 } | 1764 } |
| 1789 | 1765 |
| 1790 // Verify that we correctly log UKM for form parsed without type hints regarding | 1766 // Verify that we correctly log UKM for form parsed without type hints regarding |
| 1791 // developer engagement. | 1767 // developer engagement. |
| 1792 TEST_F(AutofillMetricsTest, | 1768 TEST_F(AutofillMetricsTest, |
| 1793 UkmDeveloperEngagement_LogFillableFormParsedWithoutTypeHints) { | 1769 UkmDeveloperEngagement_LogFillableFormParsedWithoutTypeHints) { |
| 1794 EnableUkmLogging(); | |
| 1795 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1770 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 1796 | 1771 |
| 1797 // Start with a non-fillable form. | 1772 // Start with a non-fillable form. |
| 1798 FormData form; | 1773 FormData form; |
| 1799 form.name = ASCIIToUTF16("TestForm"); | 1774 form.name = ASCIIToUTF16("TestForm"); |
| 1800 form.origin = GURL("http://example.com/form.html"); | 1775 form.origin = GURL("http://example.com/form.html"); |
| 1801 form.action = GURL("http://example.com/submit.html"); | 1776 form.action = GURL("http://example.com/submit.html"); |
| 1802 | 1777 |
| 1803 FormFieldData field; | 1778 FormFieldData field; |
| 1804 test::CreateTestFormField("Name", "name", "", "text", &field); | 1779 test::CreateTestFormField("Name", "name", "", "text", &field); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1832 VerifyDeveloperEngagementUkm( | 1807 VerifyDeveloperEngagementUkm( |
| 1833 form, ukm_service, | 1808 form, ukm_service, |
| 1834 {AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS}); | 1809 {AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS}); |
| 1835 } | 1810 } |
| 1836 } | 1811 } |
| 1837 | 1812 |
| 1838 // Verify that we correctly log UKM for form parsed with type hints regarding | 1813 // Verify that we correctly log UKM for form parsed with type hints regarding |
| 1839 // developer engagement. | 1814 // developer engagement. |
| 1840 TEST_F(AutofillMetricsTest, | 1815 TEST_F(AutofillMetricsTest, |
| 1841 UkmDeveloperEngagement_LogFillableFormParsedWithTypeHints) { | 1816 UkmDeveloperEngagement_LogFillableFormParsedWithTypeHints) { |
| 1842 EnableUkmLogging(); | |
| 1843 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1817 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 1844 | 1818 |
| 1845 FormData form; | 1819 FormData form; |
| 1846 form.name = ASCIIToUTF16("TestForm"); | 1820 form.name = ASCIIToUTF16("TestForm"); |
| 1847 form.origin = GURL("http://example.com/form.html"); | 1821 form.origin = GURL("http://example.com/form.html"); |
| 1848 form.action = GURL("http://example.com/submit.html"); | 1822 form.action = GURL("http://example.com/submit.html"); |
| 1849 | 1823 |
| 1850 FormFieldData field; | 1824 FormFieldData field; |
| 1851 test::CreateTestFormField("Name", "name", "", "text", &field); | 1825 test::CreateTestFormField("Name", "name", "", "text", &field); |
| 1852 form.fields.push_back(field); | 1826 form.fields.push_back(field); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 ASSERT_EQ(1U, ukm_service->sources_count()); | 1858 ASSERT_EQ(1U, ukm_service->sources_count()); |
| 1885 VerifyDeveloperEngagementUkm( | 1859 VerifyDeveloperEngagementUkm( |
| 1886 form, ukm_service, | 1860 form, ukm_service, |
| 1887 {AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS}); | 1861 {AutofillMetrics::FILLABLE_FORM_PARSED_WITH_TYPE_HINTS}); |
| 1888 } | 1862 } |
| 1889 } | 1863 } |
| 1890 | 1864 |
| 1891 // Verify that we correctly log UKM for form parsed with type hints regarding | 1865 // Verify that we correctly log UKM for form parsed with type hints regarding |
| 1892 // developer engagement. | 1866 // developer engagement. |
| 1893 TEST_F(AutofillMetricsTest, UkmDeveloperEngagement_LogUpiVpaTypeHint) { | 1867 TEST_F(AutofillMetricsTest, UkmDeveloperEngagement_LogUpiVpaTypeHint) { |
| 1894 EnableUkmLogging(); | |
| 1895 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1868 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 1896 | 1869 |
| 1897 FormData form; | 1870 FormData form; |
| 1898 form.name = ASCIIToUTF16("TestForm"); | 1871 form.name = ASCIIToUTF16("TestForm"); |
| 1899 form.origin = GURL("http://example.com/form.html"); | 1872 form.origin = GURL("http://example.com/form.html"); |
| 1900 form.action = GURL("http://example.com/submit.html"); | 1873 form.action = GURL("http://example.com/submit.html"); |
| 1901 | 1874 |
| 1902 FormFieldData field; | 1875 FormFieldData field; |
| 1903 test::CreateTestFormField("Name", "name", "", "text", &field); | 1876 test::CreateTestFormField("Name", "name", "", "text", &field); |
| 1904 form.fields.push_back(field); | 1877 form.fields.push_back(field); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 // Simulate activating the autofill popup for the email field after typing. | 2084 // Simulate activating the autofill popup for the email field after typing. |
| 2112 form.fields[0].is_autofilled = true; | 2085 form.fields[0].is_autofilled = true; |
| 2113 base::HistogramTester histogram_tester; | 2086 base::HistogramTester histogram_tester; |
| 2114 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); | 2087 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 2115 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); | 2088 histogram_tester.ExpectTotalCount("Autofill.AddressSuggestionsCount", 0); |
| 2116 } | 2089 } |
| 2117 } | 2090 } |
| 2118 | 2091 |
| 2119 // Test that the credit card checkout flow user actions are correctly logged. | 2092 // Test that the credit card checkout flow user actions are correctly logged. |
| 2120 TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) { | 2093 TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) { |
| 2121 EnableUkmLogging(); | |
| 2122 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 2094 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 2123 | 2095 |
| 2124 personal_data_->RecreateCreditCards( | 2096 personal_data_->RecreateCreditCards( |
| 2125 true /* include_local_credit_card */, | 2097 true /* include_local_credit_card */, |
| 2126 false /* include_masked_server_credit_card */, | 2098 false /* include_masked_server_credit_card */, |
| 2127 false /* include_full_server_credit_card */); | 2099 false /* include_full_server_credit_card */); |
| 2128 | 2100 |
| 2129 // Set up our form data. | 2101 // Set up our form data. |
| 2130 FormData form; | 2102 FormData form; |
| 2131 form.name = ASCIIToUTF16("TestForm"); | 2103 form.name = ASCIIToUTF16("TestForm"); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 {{internal::kUKMRecordTypeMetricName, CreditCard::LOCAL_CARD}, | 2182 {{internal::kUKMRecordTypeMetricName, CreditCard::LOCAL_CARD}, |
| 2211 {internal::kUKMMillisecondsSinceFormLoadedMetricName, 0}}}); | 2183 {internal::kUKMMillisecondsSinceFormLoadedMetricName, 0}}}); |
| 2212 // Expect |NON_FILLABLE_FORM_OR_NEW_DATA| in |AutofillFormSubmittedState| | 2184 // Expect |NON_FILLABLE_FORM_OR_NEW_DATA| in |AutofillFormSubmittedState| |
| 2213 // because |field.value| is empty in |DeterminePossibleFieldTypesForUpload|. | 2185 // because |field.value| is empty in |DeterminePossibleFieldTypesForUpload|. |
| 2214 VerifySubmitFormUkm(form, ukm_service, | 2186 VerifySubmitFormUkm(form, ukm_service, |
| 2215 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA); | 2187 AutofillMetrics::NON_FILLABLE_FORM_OR_NEW_DATA); |
| 2216 } | 2188 } |
| 2217 | 2189 |
| 2218 // Test that the profile checkout flow user actions are correctly logged. | 2190 // Test that the profile checkout flow user actions are correctly logged. |
| 2219 TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { | 2191 TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) { |
| 2220 EnableUkmLogging(); | |
| 2221 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 2192 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 2222 | 2193 |
| 2223 // Create a profile. | 2194 // Create a profile. |
| 2224 personal_data_->RecreateProfile(); | 2195 personal_data_->RecreateProfile(); |
| 2225 | 2196 |
| 2226 // Set up our form data. | 2197 // Set up our form data. |
| 2227 FormData form; | 2198 FormData form; |
| 2228 form.name = ASCIIToUTF16("TestForm"); | 2199 form.name = ASCIIToUTF16("TestForm"); |
| 2229 form.origin = GURL("http://example.com/form.html"); | 2200 form.origin = GURL("http://example.com/form.html"); |
| 2230 form.action = GURL("http://example.com/submit.html"); | 2201 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 base::HistogramTester histogram_tester; | 2563 base::HistogramTester histogram_tester; |
| 2593 autofill_manager_->DidShowSuggestions(false /* is_new_popup */, form, | 2564 autofill_manager_->DidShowSuggestions(false /* is_new_popup */, form, |
| 2594 field); | 2565 field); |
| 2595 histogram_tester.ExpectBucketCount( | 2566 histogram_tester.ExpectBucketCount( |
| 2596 "Autofill.FormEvents.CreditCard", | 2567 "Autofill.FormEvents.CreditCard", |
| 2597 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); | 2568 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); |
| 2598 histogram_tester.ExpectBucketCount( | 2569 histogram_tester.ExpectBucketCount( |
| 2599 "Autofill.FormEvents.CreditCard", | 2570 "Autofill.FormEvents.CreditCard", |
| 2600 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); | 2571 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); |
| 2601 } | 2572 } |
| 2602 | |
| 2603 // UKM must not be logged unless enabled. | |
| 2604 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | |
| 2605 EXPECT_EQ(0U, ukm_service->sources_count()); | |
| 2606 EXPECT_EQ(0U, ukm_service->entries_count()); | |
| 2607 } | 2573 } |
| 2608 | 2574 |
| 2609 // Test that we log selected form event for credit cards. | 2575 // Test that we log selected form event for credit cards. |
| 2610 TEST_F(AutofillMetricsTest, CreditCardSelectedFormEvents) { | 2576 TEST_F(AutofillMetricsTest, CreditCardSelectedFormEvents) { |
| 2611 EnableWalletSync(); | 2577 EnableWalletSync(); |
| 2612 // Creating all kinds of cards. | 2578 // Creating all kinds of cards. |
| 2613 personal_data_->RecreateCreditCards( | 2579 personal_data_->RecreateCreditCards( |
| 2614 true /* include_local_credit_card */, | 2580 true /* include_local_credit_card */, |
| 2615 true /* include_masked_server_credit_card */, | 2581 true /* include_masked_server_credit_card */, |
| 2616 true /* include_full_server_credit_card */); | 2582 true /* include_full_server_credit_card */); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2863 std::string()); | 2829 std::string()); |
| 2864 histogram_tester.ExpectTotalCount( | 2830 histogram_tester.ExpectTotalCount( |
| 2865 "Autofill.UnmaskPrompt.GetRealPanDuration", 1); | 2831 "Autofill.UnmaskPrompt.GetRealPanDuration", 1); |
| 2866 histogram_tester.ExpectTotalCount( | 2832 histogram_tester.ExpectTotalCount( |
| 2867 "Autofill.UnmaskPrompt.GetRealPanDuration.Failure", 1); | 2833 "Autofill.UnmaskPrompt.GetRealPanDuration.Failure", 1); |
| 2868 } | 2834 } |
| 2869 } | 2835 } |
| 2870 | 2836 |
| 2871 // Test that we log submitted form events for credit cards. | 2837 // Test that we log submitted form events for credit cards. |
| 2872 TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) { | 2838 TEST_F(AutofillMetricsTest, CreditCardSubmittedFormEvents) { |
| 2873 EnableUkmLogging(); | |
| 2874 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 2839 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 2875 | 2840 |
| 2876 EnableWalletSync(); | 2841 EnableWalletSync(); |
| 2877 // Creating all kinds of cards. | 2842 // Creating all kinds of cards. |
| 2878 personal_data_->RecreateCreditCards( | 2843 personal_data_->RecreateCreditCards( |
| 2879 true /* include_local_credit_card */, | 2844 true /* include_local_credit_card */, |
| 2880 true /* include_masked_server_credit_card */, | 2845 true /* include_masked_server_credit_card */, |
| 2881 true /* include_full_server_credit_card */); | 2846 true /* include_full_server_credit_card */); |
| 2882 // Set up our form data. | 2847 // Set up our form data. |
| 2883 FormData form; | 2848 FormData form; |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3580 "Autofill.FormEvents.Address", | 3545 "Autofill.FormEvents.Address", |
| 3581 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); | 3546 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); |
| 3582 histogram_tester.ExpectBucketCount( | 3547 histogram_tester.ExpectBucketCount( |
| 3583 "Autofill.FormEvents.Address", | 3548 "Autofill.FormEvents.Address", |
| 3584 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); | 3549 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); |
| 3585 } | 3550 } |
| 3586 } | 3551 } |
| 3587 | 3552 |
| 3588 // Test that we log submitted form events for address. | 3553 // Test that we log submitted form events for address. |
| 3589 TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) { | 3554 TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) { |
| 3590 EnableUkmLogging(); | |
| 3591 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 3555 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 3592 | 3556 |
| 3593 EnableWalletSync(); | 3557 EnableWalletSync(); |
| 3594 // Create a profile. | 3558 // Create a profile. |
| 3595 personal_data_->RecreateProfile(); | 3559 personal_data_->RecreateProfile(); |
| 3596 // Set up our form data. | 3560 // Set up our form data. |
| 3597 FormData form; | 3561 FormData form; |
| 3598 form.name = ASCIIToUTF16("TestForm"); | 3562 form.name = ASCIIToUTF16("TestForm"); |
| 3599 form.origin = GURL("http://example.com/form.html"); | 3563 form.origin = GURL("http://example.com/form.html"); |
| 3600 form.action = GURL("http://example.com/submit.html"); | 3564 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4121 base::HistogramTester histogram_tester; | 4085 base::HistogramTester histogram_tester; |
| 4122 AutofillProfile profile; | 4086 AutofillProfile profile; |
| 4123 profile.set_use_date(base::Time::Now() - base::TimeDelta::FromDays(13)); | 4087 profile.set_use_date(base::Time::Now() - base::TimeDelta::FromDays(13)); |
| 4124 profile.RecordAndLogUse(); | 4088 profile.RecordAndLogUse(); |
| 4125 histogram_tester.ExpectBucketCount("Autofill.DaysSinceLastUse.Profile", 13, | 4089 histogram_tester.ExpectBucketCount("Autofill.DaysSinceLastUse.Profile", 13, |
| 4126 1); | 4090 1); |
| 4127 } | 4091 } |
| 4128 | 4092 |
| 4129 // Verify that we correctly log the submitted form's state. | 4093 // Verify that we correctly log the submitted form's state. |
| 4130 TEST_F(AutofillMetricsTest, AutofillFormSubmittedState) { | 4094 TEST_F(AutofillMetricsTest, AutofillFormSubmittedState) { |
| 4131 EnableUkmLogging(); | |
| 4132 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 4095 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 4133 | 4096 |
| 4134 // Start with a form with insufficiently many fields. | 4097 // Start with a form with insufficiently many fields. |
| 4135 FormData form; | 4098 FormData form; |
| 4136 form.name = ASCIIToUTF16("TestForm"); | 4099 form.name = ASCIIToUTF16("TestForm"); |
| 4137 form.origin = GURL("http://example.com/form.html"); | 4100 form.origin = GURL("http://example.com/form.html"); |
| 4138 form.action = GURL("http://example.com/submit.html"); | 4101 form.action = GURL("http://example.com/submit.html"); |
| 4139 | 4102 |
| 4140 FormFieldData field; | 4103 FormFieldData field; |
| 4141 test::CreateTestFormField("Name", "name", "", "text", &field); | 4104 test::CreateTestFormField("Name", "name", "", "text", &field); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4328 {internal::kUKMMillisecondsSinceFormLoadedMetricName, 0}}); | 4291 {internal::kUKMMillisecondsSinceFormLoadedMetricName, 0}}); |
| 4329 VerifyFormInteractionUkm(form, ukm_service, | 4292 VerifyFormInteractionUkm(form, ukm_service, |
| 4330 internal::kUKMFormSubmittedEntryName, | 4293 internal::kUKMFormSubmittedEntryName, |
| 4331 expected_form_submission_ukm_metrics); | 4294 expected_form_submission_ukm_metrics); |
| 4332 } | 4295 } |
| 4333 } | 4296 } |
| 4334 | 4297 |
| 4335 // Verify that we correctly log user happiness metrics dealing with form | 4298 // Verify that we correctly log user happiness metrics dealing with form |
| 4336 // interaction. | 4299 // interaction. |
| 4337 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { | 4300 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { |
| 4338 EnableUkmLogging(); | |
| 4339 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 4301 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 4340 | 4302 |
| 4341 // Load a fillable form. | 4303 // Load a fillable form. |
| 4342 FormData form; | 4304 FormData form; |
| 4343 form.name = ASCIIToUTF16("TestForm"); | 4305 form.name = ASCIIToUTF16("TestForm"); |
| 4344 form.origin = GURL("http://example.com/form.html"); | 4306 form.origin = GURL("http://example.com/form.html"); |
| 4345 form.action = GURL("http://example.com/submit.html"); | 4307 form.action = GURL("http://example.com/submit.html"); |
| 4346 | 4308 |
| 4347 FormFieldData field; | 4309 FormFieldData field; |
| 4348 test::CreateTestFormField("Name", "name", "", "text", &field); | 4310 test::CreateTestFormField("Name", "name", "", "text", &field); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5047 // Check that the nonsecure histogram was not recorded. ExpectBucketCount() | 5009 // Check that the nonsecure histogram was not recorded. ExpectBucketCount() |
| 5048 // can't be used here because it expects the histogram to exist. | 5010 // can't be used here because it expects the histogram to exist. |
| 5049 EXPECT_EQ( | 5011 EXPECT_EQ( |
| 5050 0, histograms.GetTotalCountsForPrefix("Autofill.FormEvents.CreditCard") | 5012 0, histograms.GetTotalCountsForPrefix("Autofill.FormEvents.CreditCard") |
| 5051 ["Autofill.FormEvents.CreditCard.OnNonsecurePage"]); | 5013 ["Autofill.FormEvents.CreditCard.OnNonsecurePage"]); |
| 5052 } | 5014 } |
| 5053 } | 5015 } |
| 5054 | 5016 |
| 5055 // Tests that logging CardUploadDecision UKM works as expected. | 5017 // Tests that logging CardUploadDecision UKM works as expected. |
| 5056 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) { | 5018 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric) { |
| 5057 EnableUkmLogging(); | |
| 5058 ukm::UkmServiceTestingHarness ukm_service_test_harness; | 5019 ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| 5059 GURL url("https://www.google.com"); | 5020 GURL url("https://www.google.com"); |
| 5060 int upload_decision = 1; | 5021 int upload_decision = 1; |
| 5061 std::vector<std::pair<const char*, int>> metrics = { | 5022 std::vector<std::pair<const char*, int>> metrics = { |
| 5062 {internal::kUKMCardUploadDecisionMetricName, upload_decision}}; | 5023 {internal::kUKMCardUploadDecisionMetricName, upload_decision}}; |
| 5063 | 5024 |
| 5064 EXPECT_TRUE(AutofillMetrics::LogUkm( | 5025 EXPECT_TRUE(AutofillMetrics::LogUkm( |
| 5065 ukm_service_test_harness.test_ukm_service(), url, | 5026 ukm_service_test_harness.test_ukm_service(), url, |
| 5066 internal::kUKMCardUploadDecisionEntryName, metrics)); | 5027 internal::kUKMCardUploadDecisionEntryName, metrics)); |
| 5067 | 5028 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5088 | 5049 |
| 5089 // Make sure that the correct upload decision was logged. | 5050 // Make sure that the correct upload decision was logged. |
| 5090 const ukm::Entry_Metric* metric = FindMetric( | 5051 const ukm::Entry_Metric* metric = FindMetric( |
| 5091 internal::kUKMCardUploadDecisionMetricName, entry_proto.metrics()); | 5052 internal::kUKMCardUploadDecisionMetricName, entry_proto.metrics()); |
| 5092 ASSERT_NE(nullptr, metric); | 5053 ASSERT_NE(nullptr, metric); |
| 5093 EXPECT_EQ(upload_decision, metric->value()); | 5054 EXPECT_EQ(upload_decision, metric->value()); |
| 5094 } | 5055 } |
| 5095 | 5056 |
| 5096 // Tests that logging DeveloperEngagement UKM works as expected. | 5057 // Tests that logging DeveloperEngagement UKM works as expected. |
| 5097 TEST_F(AutofillMetricsTest, RecordDeveloperEngagementMetric) { | 5058 TEST_F(AutofillMetricsTest, RecordDeveloperEngagementMetric) { |
| 5098 EnableUkmLogging(); | |
| 5099 ukm::UkmServiceTestingHarness ukm_service_test_harness; | 5059 ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| 5100 GURL url("https://www.google.com"); | 5060 GURL url("https://www.google.com"); |
| 5101 int form_structure_metric = 1; | 5061 int form_structure_metric = 1; |
| 5102 std::vector<std::pair<const char*, int>> metrics = { | 5062 std::vector<std::pair<const char*, int>> metrics = { |
| 5103 {internal::kUKMDeveloperEngagementMetricName, form_structure_metric}}; | 5063 {internal::kUKMDeveloperEngagementMetricName, form_structure_metric}}; |
| 5104 | 5064 |
| 5105 EXPECT_TRUE(AutofillMetrics::LogUkm( | 5065 EXPECT_TRUE(AutofillMetrics::LogUkm( |
| 5106 ukm_service_test_harness.test_ukm_service(), url, | 5066 ukm_service_test_harness.test_ukm_service(), url, |
| 5107 internal::kUKMDeveloperEngagementEntryName, metrics)); | 5067 internal::kUKMDeveloperEngagementEntryName, metrics)); |
| 5108 | 5068 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5129 | 5089 |
| 5130 // Make sure that the correct developer engagement metric was logged. | 5090 // Make sure that the correct developer engagement metric was logged. |
| 5131 const ukm::Entry_Metric* metric = FindMetric( | 5091 const ukm::Entry_Metric* metric = FindMetric( |
| 5132 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); | 5092 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); |
| 5133 ASSERT_NE(nullptr, metric); | 5093 ASSERT_NE(nullptr, metric); |
| 5134 EXPECT_EQ(form_structure_metric, metric->value()); | 5094 EXPECT_EQ(form_structure_metric, metric->value()); |
| 5135 } | 5095 } |
| 5136 | 5096 |
| 5137 // Tests that no UKM is logged when the URL is not valid. | 5097 // Tests that no UKM is logged when the URL is not valid. |
| 5138 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_InvalidUrl) { | 5098 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_InvalidUrl) { |
| 5139 EnableUkmLogging(); | |
| 5140 ukm::UkmServiceTestingHarness ukm_service_test_harness; | 5099 ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| 5141 GURL url(""); | 5100 GURL url(""); |
| 5142 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; | 5101 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; |
| 5143 | 5102 |
| 5144 EXPECT_FALSE(AutofillMetrics::LogUkm( | 5103 EXPECT_FALSE(AutofillMetrics::LogUkm( |
| 5145 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); | 5104 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); |
| 5146 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); | 5105 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); |
| 5147 } | 5106 } |
| 5148 | 5107 |
| 5149 // Tests that no UKM is logged when the metrics map is empty. | 5108 // Tests that no UKM is logged when the metrics map is empty. |
| 5150 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoMetrics) { | 5109 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoMetrics) { |
| 5151 EnableUkmLogging(); | |
| 5152 ukm::UkmServiceTestingHarness ukm_service_test_harness; | 5110 ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| 5153 GURL url("https://www.google.com"); | 5111 GURL url("https://www.google.com"); |
| 5154 std::vector<std::pair<const char*, int>> metrics; | 5112 std::vector<std::pair<const char*, int>> metrics; |
| 5155 | 5113 |
| 5156 EXPECT_FALSE(AutofillMetrics::LogUkm( | 5114 EXPECT_FALSE(AutofillMetrics::LogUkm( |
| 5157 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); | 5115 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); |
| 5158 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); | 5116 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); |
| 5159 } | 5117 } |
| 5160 | 5118 |
| 5161 // Tests that no UKM is logged when the ukm service is null. | 5119 // Tests that no UKM is logged when the ukm service is null. |
| 5162 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoUkmService) { | 5120 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoUkmService) { |
| 5163 EnableUkmLogging(); | |
| 5164 ukm::UkmServiceTestingHarness ukm_service_test_harness; | 5121 ukm::UkmServiceTestingHarness ukm_service_test_harness; |
| 5165 GURL url("https://www.google.com"); | 5122 GURL url("https://www.google.com"); |
| 5166 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; | 5123 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; |
| 5167 | 5124 |
| 5168 EXPECT_FALSE(AutofillMetrics::LogUkm(nullptr, url, "test_ukm", metrics)); | 5125 EXPECT_FALSE(AutofillMetrics::LogUkm(nullptr, url, "test_ukm", metrics)); |
| 5169 ASSERT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); | 5126 ASSERT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); |
| 5170 } | 5127 } |
| 5171 | 5128 |
| 5172 // Tests that no UKM is logged when the ukm logging feature is disabled. | |
| 5173 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_FeatureDisabled) { | |
| 5174 ukm::UkmServiceTestingHarness ukm_service_test_harness; | |
| 5175 GURL url("https://www.google.com"); | |
| 5176 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; | |
| 5177 | |
| 5178 EXPECT_FALSE(AutofillMetrics::LogUkm( | |
| 5179 ukm_service_test_harness.test_ukm_service(), url, "test_ukm", metrics)); | |
| 5180 EXPECT_EQ(0U, ukm_service_test_harness.test_ukm_service()->sources_count()); | |
| 5181 } | |
| 5182 | |
| 5183 } // namespace autofill | 5129 } // namespace autofill |
| OLD | NEW |