| Index: components/autofill/core/browser/autofill_metrics_unittest.cc
|
| diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc
|
| index 83fd0624d16a65da25cc6a973e481971d3c4faab..74e6a64db32d86b9530927e12e6b391b2bf68a4e 100644
|
| --- a/components/autofill/core/browser/autofill_metrics_unittest.cc
|
| +++ b/components/autofill/core/browser/autofill_metrics_unittest.cc
|
| @@ -124,33 +124,25 @@ class TestPersonalDataManager : public PersonalDataManager {
|
| autofill_enabled_ = autofill_enabled;
|
| }
|
|
|
| - // Removes all existing profiles and creates 0 or 1 local profiles and 0 or 1
|
| - // server profile according to the parameters.
|
| - void RecreateProfiles(bool include_local_profile,
|
| - bool include_server_profile) {
|
| + // Removes all existing profiles
|
| + void ClearProfiles() {
|
| web_profiles_.clear();
|
| - server_profiles_.clear();
|
| - if (include_local_profile) {
|
| - std::unique_ptr<AutofillProfile> profile =
|
| - base::MakeUnique<AutofillProfile>();
|
| - test::SetProfileInfo(profile.get(), "Elvis", "Aaron", "Presley",
|
| - "theking@gmail.com", "RCA",
|
| - "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis",
|
| - "Tennessee", "38116", "US", "12345678901");
|
| - profile->set_guid("00000000-0000-0000-0000-000000000001");
|
| - web_profiles_.push_back(std::move(profile));
|
| - }
|
| - if (include_server_profile) {
|
| - std::unique_ptr<AutofillProfile> profile =
|
| - base::MakeUnique<AutofillProfile>(AutofillProfile::SERVER_PROFILE,
|
| - "server_id");
|
| - test::SetProfileInfo(profile.get(), "Charles", "Hardin", "Holley",
|
| - "buddy@gmail.com", "Decca", "123 Apple St.",
|
| - "unit 6", "Lubbock", "Texas", "79401", "US",
|
| - "2345678901");
|
| - profile->set_guid("00000000-0000-0000-0000-000000000002");
|
| - server_profiles_.push_back(std::move(profile));
|
| - }
|
| + Refresh();
|
| + }
|
| +
|
| + // Removes all existing profiles and creates one profile.
|
| + void RecreateProfile() {
|
| + web_profiles_.clear();
|
| +
|
| + std::unique_ptr<AutofillProfile> profile =
|
| + base::MakeUnique<AutofillProfile>();
|
| + test::SetProfileInfo(profile.get(), "Elvis", "Aaron", "Presley",
|
| + "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.",
|
| + "Apt. 10", "Memphis", "Tennessee", "38116", "US",
|
| + "12345678901");
|
| + profile->set_guid("00000000-0000-0000-0000-000000000001");
|
| + web_profiles_.push_back(std::move(profile));
|
| +
|
| Refresh();
|
| }
|
|
|
| @@ -1740,9 +1732,8 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) {
|
|
|
| // Test that the profile checkout flow user actions are correctly logged.
|
| TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) {
|
| - // Create profiles.
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - false /* include_server_profile */);
|
| + // Create a profile.
|
| + personal_data_->RecreateProfile();
|
|
|
| // Set up our form data.
|
| FormData form;
|
| @@ -1932,8 +1923,7 @@ TEST_F(AutofillMetricsTest, QueriedCreditCardFormIsSecure) {
|
| // Tests that the Autofill_PolledProfileSuggestions user action is only logged
|
| // once if the field is queried repeatedly.
|
| TEST_F(AutofillMetricsTest, PolledProfileSuggestions_DebounceLogs) {
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - false /* include_server_profile */);
|
| + personal_data_->RecreateProfile();
|
|
|
| // Set up the form data.
|
| FormData form;
|
| @@ -2872,9 +2862,8 @@ TEST_F(AutofillMetricsTest, AddressInteractedFormEvents) {
|
| // Test that we log suggestion shown form events for address.
|
| TEST_F(AutofillMetricsTest, AddressShownFormEvents) {
|
| EnableWalletSync();
|
| - // Creating all kinds of profiles.
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - true /* include_server_profile */);
|
| + // Create a profile.
|
| + personal_data_->RecreateProfile();
|
| // Set up our form data.
|
| FormData form;
|
| form.name = ASCIIToUTF16("TestForm");
|
| @@ -2947,9 +2936,8 @@ TEST_F(AutofillMetricsTest, AddressShownFormEvents) {
|
| // Test that we log filled form events for address.
|
| TEST_F(AutofillMetricsTest, AddressFilledFormEvents) {
|
| EnableWalletSync();
|
| - // Creating all kinds of profiles.
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - true /* include_server_profile */);
|
| + // Create a profile.
|
| + personal_data_->RecreateProfile();
|
| // Set up our form data.
|
| FormData form;
|
| form.name = ASCIIToUTF16("TestForm");
|
| @@ -2992,25 +2980,6 @@ TEST_F(AutofillMetricsTest, AddressFilledFormEvents) {
|
| autofill_manager_->AddSeenForm(form, field_types, field_types);
|
|
|
| {
|
| - // Simulating selecting/filling a server profile suggestion.
|
| - base::HistogramTester histogram_tester;
|
| - std::string guid("00000000-0000-0000-0000-000000000002"); // server profile
|
| - autofill_manager_->FillOrPreviewForm(
|
| - AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
|
| - autofill_manager_->MakeFrontendID(std::string(), guid));
|
| - histogram_tester.ExpectBucketCount(
|
| - "Autofill.FormEvents.Address",
|
| - AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED, 1);
|
| - histogram_tester.ExpectBucketCount(
|
| - "Autofill.FormEvents.Address",
|
| - AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE, 1);
|
| - }
|
| -
|
| - // Reset the autofill manager state.
|
| - autofill_manager_->Reset();
|
| - autofill_manager_->AddSeenForm(form, field_types, field_types);
|
| -
|
| - {
|
| // Simulating selecting/filling a local profile suggestion.
|
| base::HistogramTester histogram_tester;
|
| std::string guid("00000000-0000-0000-0000-000000000001"); // local profile
|
| @@ -3032,9 +3001,8 @@ TEST_F(AutofillMetricsTest, AddressFilledFormEvents) {
|
| // Test that we log submitted form events for address.
|
| TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
|
| EnableWalletSync();
|
| - // Creating all kinds of profiles.
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - true /* include_server_profile */);
|
| + // Create a profile.
|
| + personal_data_->RecreateProfile();
|
| // Set up our form data.
|
| FormData form;
|
| form.name = ASCIIToUTF16("TestForm");
|
| @@ -3114,27 +3082,6 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
|
| autofill_manager_->AddSeenForm(form, field_types, field_types);
|
|
|
| {
|
| - // Simulating submission with filled server data.
|
| - base::HistogramTester histogram_tester;
|
| - autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF());
|
| - std::string guid("00000000-0000-0000-0000-000000000002"); // server profile
|
| - autofill_manager_->FillOrPreviewForm(
|
| - AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
|
| - autofill_manager_->MakeFrontendID(std::string(), guid));
|
| - autofill_manager_->SubmitForm(form, TimeTicks::Now());
|
| - histogram_tester.ExpectBucketCount(
|
| - "Autofill.FormEvents.Address",
|
| - AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1);
|
| - histogram_tester.ExpectBucketCount(
|
| - "Autofill.FormEvents.Address",
|
| - AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 1);
|
| - }
|
| -
|
| - // Reset the autofill manager state.
|
| - autofill_manager_->Reset();
|
| - autofill_manager_->AddSeenForm(form, field_types, field_types);
|
| -
|
| - {
|
| // Simulating multiple submissions.
|
| base::HistogramTester histogram_tester;
|
| autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF());
|
| @@ -3218,9 +3165,8 @@ TEST_F(AutofillMetricsTest, AddressSubmittedFormEvents) {
|
| // metrics.
|
| TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) {
|
| EnableWalletSync();
|
| - // Creating all kinds of profiles.
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - true /* include_server_profile */);
|
| + // Create a profile.
|
| + personal_data_->RecreateProfile();
|
| // Set up our form data.
|
| FormData form;
|
| form.name = ASCIIToUTF16("TestForm");
|
| @@ -3300,27 +3246,6 @@ TEST_F(AutofillMetricsTest, AddressWillSubmitFormEvents) {
|
| autofill_manager_->AddSeenForm(form, field_types, field_types);
|
|
|
| {
|
| - // Simulating submission with filled server data.
|
| - base::HistogramTester histogram_tester;
|
| - autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF());
|
| - std::string guid("00000000-0000-0000-0000-000000000002"); // server profile
|
| - autofill_manager_->FillOrPreviewForm(
|
| - AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(),
|
| - autofill_manager_->MakeFrontendID(std::string(), guid));
|
| - autofill_manager_->WillSubmitForm(form, TimeTicks::Now());
|
| - histogram_tester.ExpectBucketCount(
|
| - "Autofill.FormEvents.Address",
|
| - AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_WILL_SUBMIT_ONCE, 1);
|
| - histogram_tester.ExpectBucketCount(
|
| - "Autofill.FormEvents.Address",
|
| - AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_SUBMITTED_ONCE, 0);
|
| - }
|
| -
|
| - // Reset the autofill manager state.
|
| - autofill_manager_->Reset();
|
| - autofill_manager_->AddSeenForm(form, field_types, field_types);
|
| -
|
| - {
|
| // Simulating multiple submissions.
|
| base::HistogramTester histogram_tester;
|
| autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF());
|
| @@ -3542,8 +3467,7 @@ TEST_F(AutofillMetricsTest, AddressFormEventsAreSegmented) {
|
| // Simulate having seen this form on page load.
|
| // |form_structure| will be owned by |autofill_manager_|.
|
| autofill_manager_->AddSeenForm(form, field_types, field_types);
|
| - personal_data_->RecreateProfiles(false /* include_local_profile */,
|
| - false /* include_server_profile */);
|
| + personal_data_->ClearProfiles();
|
|
|
| {
|
| // Simulate activating the autofill popup for the street field.
|
| @@ -3557,8 +3481,7 @@ TEST_F(AutofillMetricsTest, AddressFormEventsAreSegmented) {
|
| // Reset the autofill manager state.
|
| autofill_manager_->Reset();
|
| autofill_manager_->AddSeenForm(form, field_types, field_types);
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - false /* include_server_profile */);
|
| + personal_data_->RecreateProfile();
|
|
|
| {
|
| // Simulate activating the autofill popup for the street field.
|
| @@ -3568,36 +3491,6 @@ TEST_F(AutofillMetricsTest, AddressFormEventsAreSegmented) {
|
| "Autofill.FormEvents.Address.WithOnlyLocalData",
|
| AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1);
|
| }
|
| -
|
| - // Reset the autofill manager state.
|
| - autofill_manager_->Reset();
|
| - autofill_manager_->AddSeenForm(form, field_types, field_types);
|
| - personal_data_->RecreateProfiles(false /* include_local_profile */,
|
| - true /* include_server_profile */);
|
| -
|
| - {
|
| - // Simulate activating the autofill popup for the street field.
|
| - base::HistogramTester histogram_tester;
|
| - autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF());
|
| - histogram_tester.ExpectUniqueSample(
|
| - "Autofill.FormEvents.Address.WithOnlyServerData",
|
| - AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1);
|
| - }
|
| -
|
| - // Reset the autofill manager state.
|
| - autofill_manager_->Reset();
|
| - autofill_manager_->AddSeenForm(form, field_types, field_types);
|
| - personal_data_->RecreateProfiles(true /* include_local_profile */,
|
| - true /* include_server_profile */);
|
| -
|
| - {
|
| - // Simulate activating the autofill popup for the street field.
|
| - base::HistogramTester histogram_tester;
|
| - autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF());
|
| - histogram_tester.ExpectUniqueSample(
|
| - "Autofill.FormEvents.Address.WithBothServerAndLocalData",
|
| - AutofillMetrics::FORM_EVENT_INTERACTED_ONCE, 1);
|
| - }
|
| }
|
|
|
|
|
|
|