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

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: Created 4 years, 10 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 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698