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

Unified Diff: components/autofill/core/browser/autofill_manager_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 side-by-side diff with in-line comments
Download patch
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 b8466a9a9363d47ff56568b24cdd22f037bbeac3..d29549f78d1ffeaa6e5dd98dca38711661640a79 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -1513,15 +1513,26 @@ TEST_F(AutofillManagerTest, WillFillCreditCardNumber) {
month_field = &form.fields[i];
}
- // Empty form - whole form is Autofilled.
+ // Empty form - whole form is Autofilled (except on iOS).
EXPECT_TRUE(WillFillCreditCardNumber(form, *number_field));
+#if defined(OS_IOS)
+ EXPECT_FALSE(WillFillCreditCardNumber(form, *name_field));
+#else
EXPECT_TRUE(WillFillCreditCardNumber(form, *name_field));
+#endif // defined(OS_IOS)
+
// If the user has entered a value, it won't be overridden.
number_field->value = ASCIIToUTF16("gibberish");
EXPECT_TRUE(WillFillCreditCardNumber(form, *number_field));
EXPECT_FALSE(WillFillCreditCardNumber(form, *name_field));
+
+ // But if that value is removed, it will be Autofilled (except on iOS).
number_field->value.clear();
+#if defined(OS_IOS)
+ EXPECT_FALSE(WillFillCreditCardNumber(form, *name_field));
+#else
EXPECT_TRUE(WillFillCreditCardNumber(form, *name_field));
+#endif // defined(OS_IOS)
// When part of the section is Autofilled, only fill the initiating field.
month_field->is_autofilled = true;
@@ -3197,7 +3208,13 @@ TEST_F(AutofillManagerTest, DontOfferToSaveWalletCard) {
AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, form,
form.fields[0], card, 0);
- // Manually fill out |form| so we can use it in OnFormSubmitted.
+ // Manually fill out |form| so we can use it in OnFormSubmitted. On iOS, only
+ // the selected field (the first one as specified in the call to
+ // FillOrPreviewCreditCardForm below) is filled out because the actual
+ // implementation only fills one field out at a time.
+#if defined(OS_IOS)
+ form.fields[0].value = ASCIIToUTF16("some data");
+#else
for (size_t i = 0; i < form.fields.size(); ++i) {
if (form.fields[i].name == ASCIIToUTF16("cardnumber"))
form.fields[i].value = ASCIIToUTF16("4012888888881881");
@@ -3208,6 +3225,7 @@ TEST_F(AutofillManagerTest, DontOfferToSaveWalletCard) {
else if (form.fields[i].name == ASCIIToUTF16("ccyear"))
form.fields[i].value = ASCIIToUTF16("2017");
}
+#endif // defined(OS_IOS)
AutofillManager::UnmaskResponse response;
response.should_store_pan = false;

Powered by Google App Engine
This is Rietveld 408576698