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

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

Issue 1694443004: [Autofill] Add credit card first and last name heuristics predictions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 const char guid[] = "00000000-0000-0000-0000-000000000007"; 1975 const char guid[] = "00000000-0000-0000-0000-000000000007";
1976 int response_page_id = 0; 1976 int response_page_id = 0;
1977 FormData response_data; 1977 FormData response_data;
1978 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), 1978 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(),
1979 MakeFrontendID(guid, std::string()), 1979 MakeFrontendID(guid, std::string()),
1980 &response_page_id, &response_data); 1980 &response_page_id, &response_data);
1981 ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data, 1981 ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data,
1982 kDefaultPageID, false, "2012", "04"); 1982 kDefaultPageID, false, "2012", "04");
1983 } 1983 }
1984 1984
1985 // Test that we correctly fill a credit card form with first and last cardholder
1986 // name.
1987 TEST_F(AutofillManagerTest, FillCreditCardFormSplitName) {
1988 // Set up our form data.
1989 FormData form;
1990 form.name = ASCIIToUTF16("MyForm");
1991 form.origin = GURL("https://myform.com/form.html");
1992 form.action = GURL("https://myform.com/submit.html");
1993
1994 FormFieldData field;
1995 test::CreateTestFormField("Card Name", "cardname", "", "text", &field);
1996 form.fields.push_back(field);
1997 test::CreateTestFormField("Last Name", "cardlastname", "", "text", &field);
1998 form.fields.push_back(field);
1999 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field);
2000 form.fields.push_back(field);
2001 test::CreateTestFormField("CVC", "cvc", "", "text", &field);
2002 form.fields.push_back(field);
2003
2004 std::vector<FormData> forms(1, form);
2005 FormsSeen(forms);
2006
2007 const char guid[] = "00000000-0000-0000-0000-000000000004";
2008 int response_page_id = 0;
2009 FormData response_data;
2010 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(),
2011 MakeFrontendID(guid, std::string()),
2012 &response_page_id, &response_data);
2013 ExpectFilledField("Card Name", "cardname", "Elvis", "text",
2014 response_data.fields[0]);
2015 ExpectFilledField("Last Name", "cardlastname", "Presley", "text",
2016 response_data.fields[1]);
2017 ExpectFilledField("Card Number", "cardnumber", "4234567890123456", "text",
2018 response_data.fields[2]);
2019 }
2020
1985 // Test that we correctly fill a combined address and credit card form. 2021 // Test that we correctly fill a combined address and credit card form.
1986 TEST_F(AutofillManagerTest, FillAddressAndCreditCardForm) { 2022 TEST_F(AutofillManagerTest, FillAddressAndCreditCardForm) {
1987 // Set up our form data. 2023 // Set up our form data.
1988 FormData form; 2024 FormData form;
1989 test::CreateTestAddressFormData(&form); 2025 test::CreateTestAddressFormData(&form);
1990 CreateTestCreditCardFormData(&form, true, false); 2026 CreateTestCreditCardFormData(&form, true, false);
1991 std::vector<FormData> forms(1, form); 2027 std::vector<FormData> forms(1, form);
1992 FormsSeen(forms); 2028 FormsSeen(forms);
1993 2029
1994 // First fill the address data. 2030 // First fill the address data.
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3347 {"FR", ADDRESS_HOME_COUNTRY}, 3383 {"FR", ADDRESS_HOME_COUNTRY},
3348 {"France", ADDRESS_HOME_COUNTRY}, 3384 {"France", ADDRESS_HOME_COUNTRY},
3349 {"33249197070", PHONE_HOME_WHOLE_NUMBER}, 3385 {"33249197070", PHONE_HOME_WHOLE_NUMBER},
3350 {"+33 2 49 19 70 70", PHONE_HOME_WHOLE_NUMBER}, 3386 {"+33 2 49 19 70 70", PHONE_HOME_WHOLE_NUMBER},
3351 {"2 49 19 70 70", PHONE_HOME_CITY_AND_NUMBER}, 3387 {"2 49 19 70 70", PHONE_HOME_CITY_AND_NUMBER},
3352 {"249197070", PHONE_HOME_CITY_AND_NUMBER}, 3388 {"249197070", PHONE_HOME_CITY_AND_NUMBER},
3353 {"33", PHONE_HOME_COUNTRY_CODE}, 3389 {"33", PHONE_HOME_COUNTRY_CODE},
3354 {"2", PHONE_HOME_CITY_CODE}, 3390 {"2", PHONE_HOME_CITY_CODE},
3355 3391
3356 // Credit card fields matches. 3392 // Credit card fields matches.
3357 {"Elvis Presley", CREDIT_CARD_NAME}, 3393 {"Elvis Presley", CREDIT_CARD_NAME_FULL},
3358 {"4234-5678-9012-3456", CREDIT_CARD_NUMBER}, 3394 {"4234-5678-9012-3456", CREDIT_CARD_NUMBER},
3359 {"04", CREDIT_CARD_EXP_MONTH}, 3395 {"04", CREDIT_CARD_EXP_MONTH},
3360 {"April", CREDIT_CARD_EXP_MONTH}, 3396 {"April", CREDIT_CARD_EXP_MONTH},
3361 {"2012", CREDIT_CARD_EXP_4_DIGIT_YEAR}, 3397 {"2012", CREDIT_CARD_EXP_4_DIGIT_YEAR},
3362 {"12", CREDIT_CARD_EXP_2_DIGIT_YEAR}, 3398 {"12", CREDIT_CARD_EXP_2_DIGIT_YEAR},
3363 {"04/2012", CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR}, 3399 {"04/2012", CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR},
3364 3400
3365 // Make sure whitespaces and invalid characters are handled properly. 3401 // Make sure whitespaces and invalid characters are handled properly.
3366 {"", EMPTY_TYPE}, 3402 {"", EMPTY_TYPE},
3367 {" ", EMPTY_TYPE}, 3403 {" ", EMPTY_TYPE},
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4572 FormsSeen(mixed_forms); 4608 FormsSeen(mixed_forms);
4573 4609
4574 // Suggestions should always be displayed. 4610 // Suggestions should always be displayed.
4575 for (const FormFieldData& field : mixed_form.fields) { 4611 for (const FormFieldData& field : mixed_form.fields) {
4576 GetAutofillSuggestions(mixed_form, field); 4612 GetAutofillSuggestions(mixed_form, field);
4577 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 4613 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
4578 } 4614 }
4579 } 4615 }
4580 4616
4581 } // namespace autofill 4617 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/autofill_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698