| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 if (include_full_server_credit_card) { | 181 if (include_full_server_credit_card) { |
| 182 std::unique_ptr<CreditCard> credit_card = base::MakeUnique<CreditCard>( | 182 std::unique_ptr<CreditCard> credit_card = base::MakeUnique<CreditCard>( |
| 183 CreditCard::FULL_SERVER_CARD, "server_id"); | 183 CreditCard::FULL_SERVER_CARD, "server_id"); |
| 184 credit_card->set_guid("10000000-0000-0000-0000-000000000003"); | 184 credit_card->set_guid("10000000-0000-0000-0000-000000000003"); |
| 185 server_credit_cards_.push_back(std::move(credit_card)); | 185 server_credit_cards_.push_back(std::move(credit_card)); |
| 186 } | 186 } |
| 187 Refresh(); | 187 Refresh(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Removes all existing credit cards and creates 1 server card with a bank |
| 191 // name. |
| 192 void RecreateServerCreditCardsWithBankName() { |
| 193 server_credit_cards_.clear(); |
| 194 std::unique_ptr<CreditCard> credit_card = base::MakeUnique<CreditCard>( |
| 195 CreditCard::FULL_SERVER_CARD, "server_id"); |
| 196 test::SetCreditCardInfo(credit_card.get(), "name", "4111111111111111", |
| 197 "12", "24", "1"); |
| 198 credit_card->set_guid("10000000-0000-0000-0000-000000000003"); |
| 199 credit_card->set_bank_name("Chase"); |
| 200 server_credit_cards_.push_back(std::move(credit_card)); |
| 201 Refresh(); |
| 202 } |
| 203 |
| 190 bool IsAutofillEnabled() const override { return autofill_enabled_; } | 204 bool IsAutofillEnabled() const override { return autofill_enabled_; } |
| 191 | 205 |
| 192 void CreateAmbiguousProfiles() { | 206 void CreateAmbiguousProfiles() { |
| 193 web_profiles_.clear(); | 207 web_profiles_.clear(); |
| 194 CreateTestAutofillProfiles(&web_profiles_); | 208 CreateTestAutofillProfiles(&web_profiles_); |
| 195 | 209 |
| 196 auto profile = base::MakeUnique<AutofillProfile>(); | 210 auto profile = base::MakeUnique<AutofillProfile>(); |
| 197 test::SetProfileInfo(profile.get(), "John", "Decca", "Public", | 211 test::SetProfileInfo(profile.get(), "John", "Decca", "Public", |
| 198 "john@gmail.com", "Company", "123 Main St.", "unit 7", | 212 "john@gmail.com", "Company", "123 Main St.", "unit 7", |
| 199 "Springfield", "Texas", "79401", "US", "2345678901"); | 213 "Springfield", "Texas", "79401", "US", "2345678901"); |
| (...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 { | 2540 { |
| 2527 // Simulating new popup being shown. | 2541 // Simulating new popup being shown. |
| 2528 base::HistogramTester histogram_tester; | 2542 base::HistogramTester histogram_tester; |
| 2529 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); | 2543 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 2530 histogram_tester.ExpectBucketCount( | 2544 histogram_tester.ExpectBucketCount( |
| 2531 "Autofill.FormEvents.CreditCard", | 2545 "Autofill.FormEvents.CreditCard", |
| 2532 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 1); | 2546 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 1); |
| 2533 histogram_tester.ExpectBucketCount( | 2547 histogram_tester.ExpectBucketCount( |
| 2534 "Autofill.FormEvents.CreditCard", | 2548 "Autofill.FormEvents.CreditCard", |
| 2535 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); | 2549 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); |
| 2550 // Check that the bank name histogram was not recorded. ExpectBucketCount() |
| 2551 // can't be used here because it expects the histogram to exist. |
| 2552 EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( |
| 2553 "Autofill.FormEvents.CreditCard") |
| 2554 ["Autofill.FormEvents.CreditCard.BankNameDisplayed"]); |
| 2536 } | 2555 } |
| 2537 | 2556 |
| 2538 // Reset the autofill manager state. | 2557 // Reset the autofill manager state. |
| 2539 autofill_manager_->Reset(); | 2558 autofill_manager_->Reset(); |
| 2540 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2559 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2541 | 2560 |
| 2542 { | 2561 { |
| 2543 // Simulating two popups in the same page load. | 2562 // Simulating two popups in the same page load. |
| 2544 base::HistogramTester histogram_tester; | 2563 base::HistogramTester histogram_tester; |
| 2545 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); | 2564 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 2546 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); | 2565 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 2547 histogram_tester.ExpectBucketCount( | 2566 histogram_tester.ExpectBucketCount( |
| 2548 "Autofill.FormEvents.CreditCard", | 2567 "Autofill.FormEvents.CreditCard", |
| 2549 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 2); | 2568 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 2); |
| 2550 histogram_tester.ExpectBucketCount( | 2569 histogram_tester.ExpectBucketCount( |
| 2551 "Autofill.FormEvents.CreditCard", | 2570 "Autofill.FormEvents.CreditCard", |
| 2552 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); | 2571 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); |
| 2572 // Check that the bank name histogram was not recorded. ExpectBucketCount() |
| 2573 // can't be used here because it expects the histogram to exist. |
| 2574 EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( |
| 2575 "Autofill.FormEvents.CreditCard") |
| 2576 ["Autofill.FormEvents.CreditCard.BankNameDisplayed"]); |
| 2553 } | 2577 } |
| 2554 | 2578 |
| 2555 // Reset the autofill manager state. | 2579 // Reset the autofill manager state. |
| 2556 autofill_manager_->Reset(); | 2580 autofill_manager_->Reset(); |
| 2557 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2581 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2558 | 2582 |
| 2559 { | 2583 { |
| 2560 // Simulating same popup being refreshed. | 2584 // Simulating same popup being refreshed. |
| 2561 base::HistogramTester histogram_tester; | 2585 base::HistogramTester histogram_tester; |
| 2562 autofill_manager_->DidShowSuggestions(false /* is_new_popup */, form, | 2586 autofill_manager_->DidShowSuggestions(false /* is_new_popup */, form, |
| 2563 field); | 2587 field); |
| 2564 histogram_tester.ExpectBucketCount( | 2588 histogram_tester.ExpectBucketCount( |
| 2565 "Autofill.FormEvents.CreditCard", | 2589 "Autofill.FormEvents.CreditCard", |
| 2566 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); | 2590 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); |
| 2567 histogram_tester.ExpectBucketCount( | 2591 histogram_tester.ExpectBucketCount( |
| 2568 "Autofill.FormEvents.CreditCard", | 2592 "Autofill.FormEvents.CreditCard", |
| 2569 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); | 2593 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); |
| 2594 // Check that the bank name histogram was not recorded. ExpectBucketCount() |
| 2595 // can't be used here because it expects the histogram to exist. |
| 2596 EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( |
| 2597 "Autofill.FormEvents.CreditCard") |
| 2598 ["Autofill.FormEvents.CreditCard.BankNameDisplayed"]); |
| 2599 } |
| 2600 |
| 2601 // Recreate server cards with bank names. |
| 2602 personal_data_->RecreateServerCreditCardsWithBankName(); |
| 2603 |
| 2604 // Reset the autofill manager state. |
| 2605 autofill_manager_->Reset(); |
| 2606 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2607 |
| 2608 { |
| 2609 // Simulating new popup being shown. |
| 2610 base::HistogramTester histogram_tester; |
| 2611 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 2612 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 2613 histogram_tester.ExpectBucketCount( |
| 2614 "Autofill.FormEvents.CreditCard", |
| 2615 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 1); |
| 2616 histogram_tester.ExpectBucketCount( |
| 2617 "Autofill.FormEvents.CreditCard", |
| 2618 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); |
| 2619 histogram_tester.ExpectBucketCount( |
| 2620 "Autofill.FormEvents.CreditCard.BankNameDisplayed", |
| 2621 AutofillMetrics:: |
| 2622 FORM_EVENT_SUGGESTIONS_SHOWN_WITH_BANK_NAME_AVAILABLE_ONCE, |
| 2623 1); |
| 2624 } |
| 2625 |
| 2626 // Reset the autofill manager state. |
| 2627 autofill_manager_->Reset(); |
| 2628 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2629 |
| 2630 { |
| 2631 // Simulating two popups in the same page load. |
| 2632 base::HistogramTester histogram_tester; |
| 2633 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 2634 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 2635 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 2636 histogram_tester.ExpectBucketCount( |
| 2637 "Autofill.FormEvents.CreditCard", |
| 2638 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 2); |
| 2639 histogram_tester.ExpectBucketCount( |
| 2640 "Autofill.FormEvents.CreditCard", |
| 2641 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); |
| 2642 histogram_tester.ExpectBucketCount( |
| 2643 "Autofill.FormEvents.CreditCard.BankNameDisplayed", |
| 2644 AutofillMetrics:: |
| 2645 FORM_EVENT_SUGGESTIONS_SHOWN_WITH_BANK_NAME_AVAILABLE_ONCE, |
| 2646 1); |
| 2570 } | 2647 } |
| 2571 } | 2648 } |
| 2572 | 2649 |
| 2573 // Test that we log selected form event for credit cards. | 2650 // Test that we log selected form event for credit cards. |
| 2574 TEST_F(AutofillMetricsTest, CreditCardSelectedFormEvents) { | 2651 TEST_F(AutofillMetricsTest, CreditCardSelectedFormEvents) { |
| 2575 EnableWalletSync(); | 2652 EnableWalletSync(); |
| 2576 // Creating all kinds of cards. | 2653 // Creating all kinds of cards. |
| 2577 personal_data_->RecreateCreditCards( | 2654 personal_data_->RecreateCreditCards( |
| 2578 true /* include_local_credit_card */, | 2655 true /* include_local_credit_card */, |
| 2579 true /* include_masked_server_credit_card */, | 2656 true /* include_masked_server_credit_card */, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 "10000000-0000-0000-0000-000000000003"); // full server card | 2805 "10000000-0000-0000-0000-000000000003"); // full server card |
| 2729 autofill_manager_->FillOrPreviewForm( | 2806 autofill_manager_->FillOrPreviewForm( |
| 2730 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 2807 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 2731 autofill_manager_->MakeFrontendID(guid, std::string())); | 2808 autofill_manager_->MakeFrontendID(guid, std::string())); |
| 2732 histogram_tester.ExpectBucketCount( | 2809 histogram_tester.ExpectBucketCount( |
| 2733 "Autofill.FormEvents.CreditCard", | 2810 "Autofill.FormEvents.CreditCard", |
| 2734 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED, 1); | 2811 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED, 1); |
| 2735 histogram_tester.ExpectBucketCount( | 2812 histogram_tester.ExpectBucketCount( |
| 2736 "Autofill.FormEvents.CreditCard", | 2813 "Autofill.FormEvents.CreditCard", |
| 2737 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE, 1); | 2814 AutofillMetrics::FORM_EVENT_SERVER_SUGGESTION_FILLED_ONCE, 1); |
| 2815 // Check that the bank name histogram was not recorded. ExpectBucketCount() |
| 2816 // can't be used here because it expects the histogram to exist. |
| 2817 EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( |
| 2818 "Autofill.FormEvents.CreditCard") |
| 2819 ["Autofill.FormEvents.CreditCard.BankNameDisplayed"]); |
| 2738 } | 2820 } |
| 2739 | 2821 |
| 2740 // Reset the autofill manager state. | 2822 // Reset the autofill manager state. |
| 2741 autofill_manager_->Reset(); | 2823 autofill_manager_->Reset(); |
| 2742 autofill_manager_->AddSeenForm(form, field_types, field_types); | 2824 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2743 | 2825 |
| 2744 { | 2826 { |
| 2745 // Simulating filling multiple times. | 2827 // Simulating filling multiple times. |
| 2746 base::HistogramTester histogram_tester; | 2828 base::HistogramTester histogram_tester; |
| 2747 std::string guid("10000000-0000-0000-0000-000000000001"); // local card | 2829 std::string guid("10000000-0000-0000-0000-000000000001"); // local card |
| 2748 autofill_manager_->FillOrPreviewForm( | 2830 autofill_manager_->FillOrPreviewForm( |
| 2749 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 2831 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 2750 autofill_manager_->MakeFrontendID(guid, std::string())); | 2832 autofill_manager_->MakeFrontendID(guid, std::string())); |
| 2751 autofill_manager_->FillOrPreviewForm( | 2833 autofill_manager_->FillOrPreviewForm( |
| 2752 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), | 2834 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), |
| 2753 autofill_manager_->MakeFrontendID(guid, std::string())); | 2835 autofill_manager_->MakeFrontendID(guid, std::string())); |
| 2754 histogram_tester.ExpectBucketCount( | 2836 histogram_tester.ExpectBucketCount( |
| 2755 "Autofill.FormEvents.CreditCard", | 2837 "Autofill.FormEvents.CreditCard", |
| 2756 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); | 2838 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED, 2); |
| 2757 histogram_tester.ExpectBucketCount( | 2839 histogram_tester.ExpectBucketCount( |
| 2758 "Autofill.FormEvents.CreditCard", | 2840 "Autofill.FormEvents.CreditCard", |
| 2759 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); | 2841 AutofillMetrics::FORM_EVENT_LOCAL_SUGGESTION_FILLED_ONCE, 1); |
| 2760 } | 2842 } |
| 2843 |
| 2844 // Recreate server cards with bank names. |
| 2845 personal_data_->RecreateServerCreditCardsWithBankName(); |
| 2846 |
| 2847 // Reset the autofill manager state. |
| 2848 autofill_manager_->Reset(); |
| 2849 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2850 |
| 2851 { |
| 2852 // Simulating filling a full card server suggestion. |
| 2853 base::HistogramTester histogram_tester; |
| 2854 std::string guid( |
| 2855 "10000000-0000-0000-0000-000000000003"); // full server card |
| 2856 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 2857 autofill_manager_->FillOrPreviewForm( |
| 2858 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, field, |
| 2859 autofill_manager_->MakeFrontendID(guid, std::string())); |
| 2860 histogram_tester.ExpectBucketCount( |
| 2861 "Autofill.FormEvents.CreditCard.BankNameDisplayed", |
| 2862 AutofillMetrics:: |
| 2863 FORM_EVENT_SERVER_SUGGESTION_FILLED_WITH_BANK_NAME_AVAILABLE_ONCE, |
| 2864 1); |
| 2865 } |
| 2866 |
| 2867 // Reset the autofill manager state. |
| 2868 autofill_manager_->Reset(); |
| 2869 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 2870 |
| 2871 { |
| 2872 // Simulating filling multiple times. |
| 2873 base::HistogramTester histogram_tester; |
| 2874 std::string guid( |
| 2875 "10000000-0000-0000-0000-000000000003"); // full server card |
| 2876 autofill_manager_->OnQueryFormFieldAutofill(0, form, field, gfx::RectF()); |
| 2877 autofill_manager_->FillOrPreviewForm( |
| 2878 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, field, |
| 2879 autofill_manager_->MakeFrontendID(guid, std::string())); |
| 2880 autofill_manager_->FillOrPreviewForm( |
| 2881 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, field, |
| 2882 autofill_manager_->MakeFrontendID(guid, std::string())); |
| 2883 histogram_tester.ExpectBucketCount( |
| 2884 "Autofill.FormEvents.CreditCard.BankNameDisplayed", |
| 2885 AutofillMetrics:: |
| 2886 FORM_EVENT_SERVER_SUGGESTION_FILLED_WITH_BANK_NAME_AVAILABLE_ONCE, |
| 2887 1); |
| 2888 } |
| 2761 } | 2889 } |
| 2762 | 2890 |
| 2763 // Test that we log submitted form events for credit cards. | 2891 // Test that we log submitted form events for credit cards. |
| 2764 TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration) { | 2892 TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration) { |
| 2765 EnableWalletSync(); | 2893 EnableWalletSync(); |
| 2766 // Creating masked card | 2894 // Creating masked card |
| 2767 personal_data_->RecreateCreditCards( | 2895 personal_data_->RecreateCreditCards( |
| 2768 false /* include_local_credit_card */, | 2896 false /* include_local_credit_card */, |
| 2769 true /* include_masked_server_credit_card */, | 2897 true /* include_masked_server_credit_card */, |
| 2770 false /* include_full_server_credit_card */); | 2898 false /* include_full_server_credit_card */); |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3444 { | 3572 { |
| 3445 // Simulating new popup being shown. | 3573 // Simulating new popup being shown. |
| 3446 base::HistogramTester histogram_tester; | 3574 base::HistogramTester histogram_tester; |
| 3447 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); | 3575 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 3448 histogram_tester.ExpectBucketCount( | 3576 histogram_tester.ExpectBucketCount( |
| 3449 "Autofill.FormEvents.Address", | 3577 "Autofill.FormEvents.Address", |
| 3450 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 1); | 3578 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 1); |
| 3451 histogram_tester.ExpectBucketCount( | 3579 histogram_tester.ExpectBucketCount( |
| 3452 "Autofill.FormEvents.Address", | 3580 "Autofill.FormEvents.Address", |
| 3453 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); | 3581 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); |
| 3582 // Check that the bank name histogram was not recorded. ExpectBucketCount() |
| 3583 // can't be used here because it expects the histogram to exist. |
| 3584 EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( |
| 3585 "Autofill.FormEvents.CreditCard") |
| 3586 ["Autofill.FormEvents.CreditCard.BankNameDisplayed"]); |
| 3454 } | 3587 } |
| 3455 | 3588 |
| 3456 // Reset the autofill manager state. | 3589 // Reset the autofill manager state. |
| 3457 autofill_manager_->Reset(); | 3590 autofill_manager_->Reset(); |
| 3458 autofill_manager_->AddSeenForm(form, field_types, field_types); | 3591 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 3459 | 3592 |
| 3460 { | 3593 { |
| 3461 // Simulating two popups in the same page load. | 3594 // Simulating two popups in the same page load. |
| 3462 base::HistogramTester histogram_tester; | 3595 base::HistogramTester histogram_tester; |
| 3463 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); | 3596 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 3464 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); | 3597 autofill_manager_->DidShowSuggestions(true /* is_new_popup */, form, field); |
| 3465 histogram_tester.ExpectBucketCount( | 3598 histogram_tester.ExpectBucketCount( |
| 3466 "Autofill.FormEvents.Address", | 3599 "Autofill.FormEvents.Address", |
| 3467 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 2); | 3600 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 2); |
| 3468 histogram_tester.ExpectBucketCount( | 3601 histogram_tester.ExpectBucketCount( |
| 3469 "Autofill.FormEvents.Address", | 3602 "Autofill.FormEvents.Address", |
| 3470 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); | 3603 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 1); |
| 3604 // Check that the bank name histogram was not recorded. ExpectBucketCount() |
| 3605 // can't be used here because it expects the histogram to exist. |
| 3606 EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( |
| 3607 "Autofill.FormEvents.CreditCard") |
| 3608 ["Autofill.FormEvents.CreditCard.BankNameDisplayed"]); |
| 3471 } | 3609 } |
| 3472 | 3610 |
| 3473 // Reset the autofill manager state. | 3611 // Reset the autofill manager state. |
| 3474 autofill_manager_->Reset(); | 3612 autofill_manager_->Reset(); |
| 3475 autofill_manager_->AddSeenForm(form, field_types, field_types); | 3613 autofill_manager_->AddSeenForm(form, field_types, field_types); |
| 3476 | 3614 |
| 3477 { | 3615 { |
| 3478 // Simulating same popup being refreshed. | 3616 // Simulating same popup being refreshed. |
| 3479 base::HistogramTester histogram_tester; | 3617 base::HistogramTester histogram_tester; |
| 3480 autofill_manager_->DidShowSuggestions(false /* is_new_popup */, form, | 3618 autofill_manager_->DidShowSuggestions(false /* is_new_popup */, form, |
| 3481 field); | 3619 field); |
| 3482 histogram_tester.ExpectBucketCount( | 3620 histogram_tester.ExpectBucketCount( |
| 3483 "Autofill.FormEvents.Address", | 3621 "Autofill.FormEvents.Address", |
| 3484 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); | 3622 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN, 0); |
| 3485 histogram_tester.ExpectBucketCount( | 3623 histogram_tester.ExpectBucketCount( |
| 3486 "Autofill.FormEvents.Address", | 3624 "Autofill.FormEvents.Address", |
| 3487 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); | 3625 AutofillMetrics::FORM_EVENT_SUGGESTIONS_SHOWN_ONCE, 0); |
| 3626 // Check that the bank name histogram was not recorded. ExpectBucketCount() |
| 3627 // can't be used here because it expects the histogram to exist. |
| 3628 EXPECT_EQ(0, histogram_tester.GetTotalCountsForPrefix( |
| 3629 "Autofill.FormEvents.CreditCard") |
| 3630 ["Autofill.FormEvents.CreditCard.BankNameDisplayed"]); |
| 3488 } | 3631 } |
| 3489 } | 3632 } |
| 3490 | 3633 |
| 3491 // Test that we log filled form events for address. | 3634 // Test that we log filled form events for address. |
| 3492 TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { | 3635 TEST_F(AutofillMetricsTest, AddressFilledFormEvents) { |
| 3493 EnableWalletSync(); | 3636 EnableWalletSync(); |
| 3494 // Create a profile. | 3637 // Create a profile. |
| 3495 personal_data_->RecreateProfile(); | 3638 personal_data_->RecreateProfile(); |
| 3496 // Set up our form data. | 3639 // Set up our form data. |
| 3497 FormData form; | 3640 FormData form; |
| (...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5111 // Tests that no UKM is logged when the ukm service is null. | 5254 // Tests that no UKM is logged when the ukm service is null. |
| 5112 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoUkmService) { | 5255 TEST_F(AutofillMetricsTest, RecordCardUploadDecisionMetric_NoUkmService) { |
| 5113 GURL url("https://www.google.com"); | 5256 GURL url("https://www.google.com"); |
| 5114 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; | 5257 std::vector<std::pair<const char*, int>> metrics = {{"metric", 1}}; |
| 5115 | 5258 |
| 5116 EXPECT_FALSE(AutofillMetrics::LogUkm(nullptr, url, "test_ukm", metrics)); | 5259 EXPECT_FALSE(AutofillMetrics::LogUkm(nullptr, url, "test_ukm", metrics)); |
| 5117 ASSERT_EQ(0U, test_ukm_recorder_.sources_count()); | 5260 ASSERT_EQ(0U, test_ukm_recorder_.sources_count()); |
| 5118 } | 5261 } |
| 5119 | 5262 |
| 5120 } // namespace autofill | 5263 } // namespace autofill |
| OLD | NEW |