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

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

Issue 1137403002: Add upstream bits necessary for iOS card unmask prompt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix autofill tests on iOS Created 5 years, 7 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 <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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 test::CreateTestFormField("Month", "card_month", "", "text", &field); 1292 test::CreateTestFormField("Month", "card_month", "", "text", &field);
1293 form.fields.push_back(field); 1293 form.fields.push_back(field);
1294 field_types.push_back(CREDIT_CARD_EXP_MONTH); 1294 field_types.push_back(CREDIT_CARD_EXP_MONTH);
1295 test::CreateTestFormField("Year", "card_year", "", "text", &field); 1295 test::CreateTestFormField("Year", "card_year", "", "text", &field);
1296 form.fields.push_back(field); 1296 form.fields.push_back(field);
1297 field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR); 1297 field_types.push_back(CREDIT_CARD_EXP_2_DIGIT_YEAR);
1298 test::CreateTestFormField("Credit card", "card", "", "text", &field); 1298 test::CreateTestFormField("Credit card", "card", "", "text", &field);
1299 form.fields.push_back(field); 1299 form.fields.push_back(field);
1300 field_types.push_back(CREDIT_CARD_NUMBER); 1300 field_types.push_back(CREDIT_CARD_NUMBER);
1301 1301
1302 // On iOS, the credit card field will only be filled out if that's the one
1303 // selected, since we only fill out one field at a time. On other platforms,
1304 // it doesn't matter which field is selected.
1305 FormFieldData selected_field;
Evan Stade 2015/05/14 22:41:38 why not just makes this form.fields[2] for all pla
Justin Donnelly 2015/05/14 22:43:45 I figured it would be better to continue to test t
Evan Stade 2015/05/14 22:45:34 that's not really what this test is testing. The o
Justin Donnelly 2015/05/15 19:26:58 Understood that we're testing the logging here. I
1306 #if defined(OS_IOS)
1307 selected_field = form.fields[2]; // credit card field
1308 #else
1309 selected_field = form.fields[0];
1310 #endif // defined(OS_IOS)
1311
1302 // Simulate having seen this form on page load. 1312 // Simulate having seen this form on page load.
1303 // |form_structure| will be owned by |autofill_manager_|. 1313 // |form_structure| will be owned by |autofill_manager_|.
1304 autofill_manager_->AddSeenForm(form, field_types, field_types); 1314 autofill_manager_->AddSeenForm(form, field_types, field_types);
1305 1315
1306 { 1316 {
1307 // Simulating selecting a masked card server suggestion. 1317 // Simulating selecting a masked card server suggestion.
1308 base::HistogramTester histogram_tester; 1318 base::HistogramTester histogram_tester;
1309 SuggestionBackendID guid( 1319 SuggestionBackendID guid(
1310 "10000000-0000-0000-0000-000000000002", 0); // masked server card 1320 "10000000-0000-0000-0000-000000000002", 0); // masked server card
1311 autofill_manager_->FillOrPreviewForm( 1321 autofill_manager_->FillOrPreviewForm(
1312 AutofillDriver::FORM_DATA_ACTION_FILL, 1322 AutofillDriver::FORM_DATA_ACTION_FILL,
1313 0, form, form.fields.front(), 1323 0, form, selected_field,
1314 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); 1324 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
1315 histogram_tester.ExpectBucketCount( 1325 histogram_tester.ExpectBucketCount(
1316 "Autofill.FormEvents.CreditCard", 1326 "Autofill.FormEvents.CreditCard",
1317 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 1); 1327 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 1);
1318 histogram_tester.ExpectBucketCount( 1328 histogram_tester.ExpectBucketCount(
1319 "Autofill.FormEvents.CreditCard", 1329 "Autofill.FormEvents.CreditCard",
1320 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, 1330 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE,
1321 1); 1331 1);
1322 } 1332 }
1323 1333
1324 // Reset the autofill manager state. 1334 // Reset the autofill manager state.
1325 autofill_manager_->Reset(); 1335 autofill_manager_->Reset();
1326 autofill_manager_->AddSeenForm(form, field_types, field_types); 1336 autofill_manager_->AddSeenForm(form, field_types, field_types);
1327 1337
1328 { 1338 {
1329 // Simulating selecting multiple times a masked card server. 1339 // Simulating selecting multiple times a masked card server.
1330 base::HistogramTester histogram_tester; 1340 base::HistogramTester histogram_tester;
1331 SuggestionBackendID guid( 1341 SuggestionBackendID guid(
1332 "10000000-0000-0000-0000-000000000002", 0); // masked server card 1342 "10000000-0000-0000-0000-000000000002", 0); // masked server card
1333 autofill_manager_->FillOrPreviewForm( 1343 autofill_manager_->FillOrPreviewForm(
1334 AutofillDriver::FORM_DATA_ACTION_FILL, 1344 AutofillDriver::FORM_DATA_ACTION_FILL,
1335 0, form, form.fields.front(), 1345 0, form, selected_field,
1336 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); 1346 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
1337 autofill_manager_->FillOrPreviewForm( 1347 autofill_manager_->FillOrPreviewForm(
1338 AutofillDriver::FORM_DATA_ACTION_FILL, 1348 AutofillDriver::FORM_DATA_ACTION_FILL,
1339 0, form, form.fields.front(), 1349 0, form, selected_field,
1340 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID())); 1350 autofill_manager_->MakeFrontendID(guid, SuggestionBackendID()));
1341 histogram_tester.ExpectBucketCount( 1351 histogram_tester.ExpectBucketCount(
1342 "Autofill.FormEvents.CreditCard", 1352 "Autofill.FormEvents.CreditCard",
1343 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 2); 1353 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED, 2);
1344 histogram_tester.ExpectBucketCount( 1354 histogram_tester.ExpectBucketCount(
1345 "Autofill.FormEvents.CreditCard", 1355 "Autofill.FormEvents.CreditCard",
1346 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE, 1356 AutofillMetrics::FORM_EVENT_MASKED_SERVER_CARD_SUGGESTION_SELECTED_ONCE,
1347 1); 1357 1);
1348 } 1358 }
1349 } 1359 }
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
3040 histogram_tester.ExpectTotalCount( 3050 histogram_tester.ExpectTotalCount(
3041 "Autofill.FillDuration.FromInteraction.WithAutofill", 0); 3051 "Autofill.FillDuration.FromInteraction.WithAutofill", 0);
3042 histogram_tester.ExpectTotalCount( 3052 histogram_tester.ExpectTotalCount(
3043 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0); 3053 "Autofill.FillDuration.FromInteraction.WithoutAutofill", 0);
3044 3054
3045 autofill_manager_->Reset(); 3055 autofill_manager_->Reset();
3046 } 3056 }
3047 } 3057 }
3048 3058
3049 } // namespace autofill 3059 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager_unittest.cc ('k') | components/autofill/ios/browser/js_autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698