| 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 <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 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1972 const char guid[] = "00000000-0000-0000-0000-000000000007"; | 1972 const char guid[] = "00000000-0000-0000-0000-000000000007"; |
| 1973 int response_page_id = 0; | 1973 int response_page_id = 0; |
| 1974 FormData response_data; | 1974 FormData response_data; |
| 1975 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), | 1975 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), |
| 1976 MakeFrontendID(guid, std::string()), | 1976 MakeFrontendID(guid, std::string()), |
| 1977 &response_page_id, &response_data); | 1977 &response_page_id, &response_data); |
| 1978 ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data, | 1978 ExpectFilledCreditCardYearMonthWithYearMonth(response_page_id, response_data, |
| 1979 kDefaultPageID, false, "2012", "04"); | 1979 kDefaultPageID, false, "2012", "04"); |
| 1980 } | 1980 } |
| 1981 | 1981 |
| 1982 // Test that we correctly fill a credit card form with first and last cardholder |
| 1983 // name. |
| 1984 TEST_F(AutofillManagerTest, FillCreditCardFormSplitName) { |
| 1985 // Set up our form data. |
| 1986 FormData form; |
| 1987 form.name = ASCIIToUTF16("MyForm"); |
| 1988 form.origin = GURL("https://myform.com/form.html"); |
| 1989 form.action = GURL("https://myform.com/submit.html"); |
| 1990 |
| 1991 FormFieldData field; |
| 1992 test::CreateTestFormField("Card Name", "cardname", "", "text", &field); |
| 1993 form.fields.push_back(field); |
| 1994 test::CreateTestFormField("Last Name", "cardlastname", "", "text", &field); |
| 1995 form.fields.push_back(field); |
| 1996 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); |
| 1997 form.fields.push_back(field); |
| 1998 test::CreateTestFormField("CVC", "cvc", "", "text", &field); |
| 1999 form.fields.push_back(field); |
| 2000 |
| 2001 std::vector<FormData> forms(1, form); |
| 2002 FormsSeen(forms); |
| 2003 |
| 2004 const char guid[] = "00000000-0000-0000-0000-000000000004"; |
| 2005 int response_page_id = 0; |
| 2006 FormData response_data; |
| 2007 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, *form.fields.begin(), |
| 2008 MakeFrontendID(guid, std::string()), |
| 2009 &response_page_id, &response_data); |
| 2010 ExpectFilledField("Card Name", "cardname", "Elvis", "text", |
| 2011 response_data.fields[0]); |
| 2012 ExpectFilledField("Last Name", "cardlastname", "Presley", "text", |
| 2013 response_data.fields[1]); |
| 2014 ExpectFilledField("Card Number", "cardnumber", "4234567890123456", "text", |
| 2015 response_data.fields[2]); |
| 2016 } |
| 2017 |
| 1982 // Test that we correctly fill a combined address and credit card form. | 2018 // Test that we correctly fill a combined address and credit card form. |
| 1983 TEST_F(AutofillManagerTest, FillAddressAndCreditCardForm) { | 2019 TEST_F(AutofillManagerTest, FillAddressAndCreditCardForm) { |
| 1984 // Set up our form data. | 2020 // Set up our form data. |
| 1985 FormData form; | 2021 FormData form; |
| 1986 test::CreateTestAddressFormData(&form); | 2022 test::CreateTestAddressFormData(&form); |
| 1987 CreateTestCreditCardFormData(&form, true, false); | 2023 CreateTestCreditCardFormData(&form, true, false); |
| 1988 std::vector<FormData> forms(1, form); | 2024 std::vector<FormData> forms(1, form); |
| 1989 FormsSeen(forms); | 2025 FormsSeen(forms); |
| 1990 | 2026 |
| 1991 // First fill the address data. | 2027 // First fill the address data. |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3343 {"FR", ADDRESS_HOME_COUNTRY}, | 3379 {"FR", ADDRESS_HOME_COUNTRY}, |
| 3344 {"France", ADDRESS_HOME_COUNTRY}, | 3380 {"France", ADDRESS_HOME_COUNTRY}, |
| 3345 {"33249197070", PHONE_HOME_WHOLE_NUMBER}, | 3381 {"33249197070", PHONE_HOME_WHOLE_NUMBER}, |
| 3346 {"+33 2 49 19 70 70", PHONE_HOME_WHOLE_NUMBER}, | 3382 {"+33 2 49 19 70 70", PHONE_HOME_WHOLE_NUMBER}, |
| 3347 {"2 49 19 70 70", PHONE_HOME_CITY_AND_NUMBER}, | 3383 {"2 49 19 70 70", PHONE_HOME_CITY_AND_NUMBER}, |
| 3348 {"249197070", PHONE_HOME_CITY_AND_NUMBER}, | 3384 {"249197070", PHONE_HOME_CITY_AND_NUMBER}, |
| 3349 {"33", PHONE_HOME_COUNTRY_CODE}, | 3385 {"33", PHONE_HOME_COUNTRY_CODE}, |
| 3350 {"2", PHONE_HOME_CITY_CODE}, | 3386 {"2", PHONE_HOME_CITY_CODE}, |
| 3351 | 3387 |
| 3352 // Credit card fields matches. | 3388 // Credit card fields matches. |
| 3353 {"Elvis Presley", CREDIT_CARD_NAME}, | 3389 {"Elvis Presley", CREDIT_CARD_NAME_FULL}, |
| 3354 {"4234-5678-9012-3456", CREDIT_CARD_NUMBER}, | 3390 {"4234-5678-9012-3456", CREDIT_CARD_NUMBER}, |
| 3355 {"04", CREDIT_CARD_EXP_MONTH}, | 3391 {"04", CREDIT_CARD_EXP_MONTH}, |
| 3356 {"April", CREDIT_CARD_EXP_MONTH}, | 3392 {"April", CREDIT_CARD_EXP_MONTH}, |
| 3357 {"2012", CREDIT_CARD_EXP_4_DIGIT_YEAR}, | 3393 {"2012", CREDIT_CARD_EXP_4_DIGIT_YEAR}, |
| 3358 {"12", CREDIT_CARD_EXP_2_DIGIT_YEAR}, | 3394 {"12", CREDIT_CARD_EXP_2_DIGIT_YEAR}, |
| 3359 {"04/2012", CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR}, | 3395 {"04/2012", CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR}, |
| 3360 | 3396 |
| 3361 // Make sure whitespaces are trimmed properly. | 3397 // Make sure whitespaces are trimmed properly. |
| 3362 {"", EMPTY_TYPE}, | 3398 {"", EMPTY_TYPE}, |
| 3363 {" ", EMPTY_TYPE}, | 3399 {" ", EMPTY_TYPE}, |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4321 FormsSeen(mixed_forms); | 4357 FormsSeen(mixed_forms); |
| 4322 | 4358 |
| 4323 // Suggestions should always be displayed. | 4359 // Suggestions should always be displayed. |
| 4324 for (const FormFieldData& field : mixed_form.fields) { | 4360 for (const FormFieldData& field : mixed_form.fields) { |
| 4325 GetAutofillSuggestions(mixed_form, field); | 4361 GetAutofillSuggestions(mixed_form, field); |
| 4326 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4362 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4327 } | 4363 } |
| 4328 } | 4364 } |
| 4329 | 4365 |
| 4330 } // namespace autofill | 4366 } // namespace autofill |
| OLD | NEW |