Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 1899893002: Card unmasking without form filling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use the credit card number field in metrics tests, because ios single-field form fill will not requ… Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 10 #include <vector>
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 // Reset the autofill manager state. 1875 // Reset the autofill manager state.
1876 autofill_manager_->Reset(); 1876 autofill_manager_->Reset();
1877 autofill_manager_->AddSeenForm(form, field_types, field_types); 1877 autofill_manager_->AddSeenForm(form, field_types, field_types);
1878 1878
1879 { 1879 {
1880 // Simulating filling a masked card server suggestion. 1880 // Simulating filling a masked card server suggestion.
1881 base::HistogramTester histogram_tester; 1881 base::HistogramTester histogram_tester;
1882 std::string guid( 1882 std::string guid(
1883 "10000000-0000-0000-0000-000000000002"); // masked server card 1883 "10000000-0000-0000-0000-000000000002"); // masked server card
1884 autofill_manager_->FillOrPreviewForm( 1884 autofill_manager_->FillOrPreviewForm(
1885 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), 1885 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
1886 autofill_manager_->MakeFrontendID(guid, std::string())); 1886 autofill_manager_->MakeFrontendID(guid, std::string()));
1887 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, 1887 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
1888 "6011000990139424"); 1888 "6011000990139424");
1889 histogram_tester.ExpectBucketCount( 1889 histogram_tester.ExpectBucketCount(
1890 "Autofill.FormEvents.CreditCard", 1890 "Autofill.FormEvents.CreditCard",
1891 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1); 1891 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1);
1892 histogram_tester.ExpectBucketCount( 1892 histogram_tester.ExpectBucketCount(
1893 "Autofill.FormEvents.CreditCard", 1893 "Autofill.FormEvents.CreditCard",
1894 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, 1894 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE,
1895 1); 1895 1);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 // Simulate having seen this form on page load. 1974 // Simulate having seen this form on page load.
1975 // |form_structure| will be owned by |autofill_manager_|. 1975 // |form_structure| will be owned by |autofill_manager_|.
1976 autofill_manager_->AddSeenForm(form, field_types, field_types); 1976 autofill_manager_->AddSeenForm(form, field_types, field_types);
1977 1977
1978 { 1978 {
1979 // Simulating filling a masked card server suggestion. 1979 // Simulating filling a masked card server suggestion.
1980 base::HistogramTester histogram_tester; 1980 base::HistogramTester histogram_tester;
1981 // Masked server card. 1981 // Masked server card.
1982 std::string guid("10000000-0000-0000-0000-000000000002"); 1982 std::string guid("10000000-0000-0000-0000-000000000002");
1983 autofill_manager_->FillOrPreviewForm( 1983 autofill_manager_->FillOrPreviewForm(
1984 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), 1984 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
1985 autofill_manager_->MakeFrontendID(guid, std::string())); 1985 autofill_manager_->MakeFrontendID(guid, std::string()));
1986 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, 1986 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
1987 "6011000990139424"); 1987 "6011000990139424");
1988 histogram_tester.ExpectTotalCount( 1988 histogram_tester.ExpectTotalCount(
1989 "Autofill.UnmaskPrompt.GetRealPanDuration", 1); 1989 "Autofill.UnmaskPrompt.GetRealPanDuration", 1);
1990 histogram_tester.ExpectTotalCount( 1990 histogram_tester.ExpectTotalCount(
1991 "Autofill.UnmaskPrompt.GetRealPanDuration.Success", 1); 1991 "Autofill.UnmaskPrompt.GetRealPanDuration.Success", 1);
1992 } 1992 }
1993 1993
1994 // Reset the autofill manager state. 1994 // Reset the autofill manager state.
1995 autofill_manager_->Reset(); 1995 autofill_manager_->Reset();
1996 autofill_manager_->AddSeenForm(form, field_types, field_types); 1996 autofill_manager_->AddSeenForm(form, field_types, field_types);
1997 // Creating masked card 1997 // Creating masked card
1998 personal_data_->RecreateCreditCards( 1998 personal_data_->RecreateCreditCards(
1999 false /* include_local_credit_card */, 1999 false /* include_local_credit_card */,
2000 true /* include_masked_server_credit_card */, 2000 true /* include_masked_server_credit_card */,
2001 false /* include_full_server_credit_card */); 2001 false /* include_full_server_credit_card */);
2002 2002
2003 { 2003 {
2004 // Simulating filling a masked card server suggestion. 2004 // Simulating filling a masked card server suggestion.
2005 base::HistogramTester histogram_tester; 2005 base::HistogramTester histogram_tester;
2006 // Masked server card. 2006 // Masked server card.
2007 std::string guid("10000000-0000-0000-0000-000000000002"); 2007 std::string guid("10000000-0000-0000-0000-000000000002");
2008 autofill_manager_->FillOrPreviewForm( 2008 autofill_manager_->FillOrPreviewForm(
2009 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), 2009 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
2010 autofill_manager_->MakeFrontendID(guid, std::string())); 2010 autofill_manager_->MakeFrontendID(guid, std::string()));
2011 autofill_manager_->OnDidGetRealPan(AutofillClient::PERMANENT_FAILURE, 2011 autofill_manager_->OnDidGetRealPan(AutofillClient::PERMANENT_FAILURE,
2012 std::string()); 2012 std::string());
2013 histogram_tester.ExpectTotalCount( 2013 histogram_tester.ExpectTotalCount(
2014 "Autofill.UnmaskPrompt.GetRealPanDuration", 1); 2014 "Autofill.UnmaskPrompt.GetRealPanDuration", 1);
2015 histogram_tester.ExpectTotalCount( 2015 histogram_tester.ExpectTotalCount(
2016 "Autofill.UnmaskPrompt.GetRealPanDuration.Failure", 1); 2016 "Autofill.UnmaskPrompt.GetRealPanDuration.Failure", 1);
2017 } 2017 }
2018 } 2018 }
2019 2019
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 // Reset the autofill manager state. 2106 // Reset the autofill manager state.
2107 autofill_manager_->Reset(); 2107 autofill_manager_->Reset();
2108 autofill_manager_->AddSeenForm(form, field_types, field_types); 2108 autofill_manager_->AddSeenForm(form, field_types, field_types);
2109 2109
2110 { 2110 {
2111 // Simulating submission with a masked card server suggestion. 2111 // Simulating submission with a masked card server suggestion.
2112 base::HistogramTester histogram_tester; 2112 base::HistogramTester histogram_tester;
2113 std::string guid( 2113 std::string guid(
2114 "10000000-0000-0000-0000-000000000002"); // masked server card 2114 "10000000-0000-0000-0000-000000000002"); // masked server card
2115 autofill_manager_->FillOrPreviewForm( 2115 autofill_manager_->FillOrPreviewForm(
2116 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), 2116 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
2117 autofill_manager_->MakeFrontendID(guid, std::string())); 2117 autofill_manager_->MakeFrontendID(guid, std::string()));
2118 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, 2118 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
2119 "6011000990139424"); 2119 "6011000990139424");
2120 histogram_tester.ExpectBucketCount( 2120 histogram_tester.ExpectBucketCount(
2121 "Autofill.FormEvents.CreditCard", 2121 "Autofill.FormEvents.CreditCard",
2122 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1); 2122 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1);
2123 histogram_tester.ExpectBucketCount( 2123 histogram_tester.ExpectBucketCount(
2124 "Autofill.FormEvents.CreditCard", 2124 "Autofill.FormEvents.CreditCard",
2125 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, 2125 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE,
2126 1); 2126 1);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 // Reset the autofill manager state. 2293 // Reset the autofill manager state.
2294 autofill_manager_->Reset(); 2294 autofill_manager_->Reset();
2295 autofill_manager_->AddSeenForm(form, field_types, field_types); 2295 autofill_manager_->AddSeenForm(form, field_types, field_types);
2296 2296
2297 { 2297 {
2298 // Simulating submission with a masked card server suggestion. 2298 // Simulating submission with a masked card server suggestion.
2299 base::HistogramTester histogram_tester; 2299 base::HistogramTester histogram_tester;
2300 // Masked server card. 2300 // Masked server card.
2301 std::string guid("10000000-0000-0000-0000-000000000002"); 2301 std::string guid("10000000-0000-0000-0000-000000000002");
2302 autofill_manager_->FillOrPreviewForm( 2302 autofill_manager_->FillOrPreviewForm(
2303 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.front(), 2303 AutofillDriver::FORM_DATA_ACTION_FILL, 0, form, form.fields.back(),
2304 autofill_manager_->MakeFrontendID(guid, std::string())); 2304 autofill_manager_->MakeFrontendID(guid, std::string()));
2305 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, 2305 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
2306 "6011000990139424"); 2306 "6011000990139424");
2307 histogram_tester.ExpectBucketCount( 2307 histogram_tester.ExpectBucketCount(
2308 "Autofill.FormEvents.CreditCard", 2308 "Autofill.FormEvents.CreditCard",
2309 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1); 2309 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED, 1);
2310 histogram_tester.ExpectBucketCount( 2310 histogram_tester.ExpectBucketCount(
2311 "Autofill.FormEvents.CreditCard", 2311 "Autofill.FormEvents.CreditCard",
2312 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE, 2312 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_FILLED_ONCE,
2313 1); 2313 1);
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 EXPECT_THAT( 3765 EXPECT_THAT(
3766 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), 3766 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"),
3767 ElementsAre(Bucket(true, 2))); 3767 ElementsAre(Bucket(true, 2)));
3768 3768
3769 // No RAPPOR metrics are logged in the case there is at least some server data 3769 // No RAPPOR metrics are logged in the case there is at least some server data
3770 // available for all forms. 3770 // available for all forms.
3771 EXPECT_EQ(0, rappor_service_.GetReportsCount()); 3771 EXPECT_EQ(0, rappor_service_.GetReportsCount());
3772 } 3772 }
3773 3773
3774 } // namespace autofill 3774 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698