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

Unified Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 1903183003: Look in all available CVC fields for a value for credit card upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use StringToInt instead of !empty 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 2a3d651a73bbc48689861150e72716dd34276c5a..227578f4ad74439ad191f313f9fe50b84dbae63c 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -4282,6 +4282,60 @@ TEST_F(AutofillManagerTest, UploadCreditCard_CvcUnavailable) {
AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1);
}
+TEST_F(AutofillManagerTest, UploadCreditCard_MultipleCvcFields) {
+ autofill_manager_->set_credit_card_upload_enabled(true);
+
+ // Create, fill and submit an address form in order to establish a recent
+ // profile which can be selected for the upload request.
+ FormData address_form;
+ test::CreateTestAddressFormData(&address_form);
+ FormsSeen(std::vector<FormData>(1, address_form));
+ ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form);
+ FormSubmitted(address_form);
+
+ // Set up our credit card form data.
+ FormData credit_card_form;
+ credit_card_form.name = ASCIIToUTF16("MyForm");
+ credit_card_form.origin = GURL("https://myform.com/form.html");
+ credit_card_form.action = GURL("https://myform.com/submit.html");
+
+ FormFieldData field;
+ test::CreateTestFormField("Card Name", "cardname", "", "text", &field);
+ credit_card_form.fields.push_back(field);
+ test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field);
+ credit_card_form.fields.push_back(field);
+ test::CreateTestFormField("Expiration Month", "ccmonth", "", "text", &field);
+ credit_card_form.fields.push_back(field);
+ test::CreateTestFormField("Expiration Year", "ccyear", "", "text", &field);
+ credit_card_form.fields.push_back(field);
+ test::CreateTestFormField("CVC (hidden)", "cvc1", "", "text", &field);
+ credit_card_form.fields.push_back(field);
+ test::CreateTestFormField("CVC", "cvc2", "", "text", &field);
+ credit_card_form.fields.push_back(field);
+
+ FormsSeen(std::vector<FormData>(1, credit_card_form));
+
+ // Edit the data, and submit.
+ credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master");
+ credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111");
+ credit_card_form.fields[2].value = ASCIIToUTF16("11");
+ credit_card_form.fields[3].value = ASCIIToUTF16("2017");
+ credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING
+ credit_card_form.fields[5].value = ASCIIToUTF16("123");
+
+ base::HistogramTester histogram_tester;
+
+ // A CVC value appeared in one of the two CVC fields, upload should happen.
+ EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
+ FormSubmitted(credit_card_form);
+ EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
+
+ // Verify that the correct histogram entry (and only that) was logged.
+ histogram_tester.ExpectUniqueSample(
+ "Autofill.CardUploadDecisionExpanded",
+ AutofillMetrics::UPLOAD_OFFERED, 1);
+}
+
TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) {
autofill_manager_->set_credit_card_upload_enabled(true);
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698