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

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

Issue 2864483005: Uses AutofillProfileComparator to compare profile names. (Closed)
Patch Set: Reorder method definitions to match declaration order. Created 3 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 c9da4f2c188d01e21f5bac2ea579b944a633b59e..b5190ff74c8274c3cfa8039a7308fc79d5555ff0 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -5507,13 +5507,14 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoZipCodeAvailable) {
// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
#if defined(OS_ANDROID)
-#define MAYBE_UploadCreditCard_NamesMatchLoosely \
- DISABLED_UploadCreditCard_NamesMatchLoosely
+#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleInitial \
+ DISABLED_UploadCreditCard_CreditCardFormHasMiddleInitial
#else
-#define MAYBE_UploadCreditCard_NamesMatchLoosely \
- UploadCreditCard_NamesMatchLoosely
+#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleInitial \
+ UploadCreditCard_CreditCardFormHasMiddleInitial
#endif
-TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesMatchLoosely) {
+TEST_F(AutofillManagerTest,
+ MAYBE_UploadCreditCard_CreditCardFormHasMiddleInitial) {
EnableUkmLogging();
personal_data_.ClearAutofillProfiles();
autofill_manager_->set_credit_card_upload_enabled(true);
@@ -5522,11 +5523,7 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesMatchLoosely) {
FormData address_form1, address_form2;
test::CreateTestAddressFormData(&address_form1);
test::CreateTestAddressFormData(&address_form2);
-
- std::vector<FormData> address_forms;
- address_forms.push_back(address_form1);
- address_forms.push_back(address_form2);
- FormsSeen(address_forms);
+ FormsSeen({address_form1, address_form2});
// Names can be different case.
ManuallyFillAddressForm("flo", "master", "77401", "US", &address_form1);
@@ -5539,7 +5536,7 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesMatchLoosely) {
// Set up our credit card form data.
FormData credit_card_form;
CreateTestCreditCardFormData(&credit_card_form, true, false);
- FormsSeen(std::vector<FormData>(1, credit_card_form));
+ FormsSeen({credit_card_form});
// Edit the data, but use the name with a middle initial *and* period, and
// submit.
@@ -5565,6 +5562,152 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesMatchLoosely) {
// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
#if defined(OS_ANDROID)
+#define MAYBE_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial \
+ DISABLED_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial
+#else
+#define MAYBE_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial \
+ UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial
+#endif
+TEST_F(AutofillManagerTest,
+ MAYBE_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial) {
+ EnableUkmLogging();
+ personal_data_.ClearAutofillProfiles();
+ autofill_manager_->set_credit_card_upload_enabled(true);
+
+ // Create, fill and submit two address forms with different names.
+ FormData address_form1, address_form2;
+ test::CreateTestAddressFormData(&address_form1);
+ test::CreateTestAddressFormData(&address_form2);
+ FormsSeen({address_form1, address_form2});
+
+ // Names can have different variations of middle initials.
+ ManuallyFillAddressForm("flo w.", "master", "77401", "US", &address_form1);
+ FormSubmitted(address_form1);
+ ManuallyFillAddressForm("Flo W", "Master", "77401", "US", &address_form2);
+ FormSubmitted(address_form2);
+
+ // Set up our credit card form data.
+ FormData credit_card_form;
+ CreateTestCreditCardFormData(&credit_card_form, true, false);
+ FormsSeen({credit_card_form});
+
+ // Edit the data, but do not use middle initial.
+ 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("123");
+
+ base::HistogramTester histogram_tester;
+
+ // Names match loosely, 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.
+ ExpectUniqueCardUploadDecision(histogram_tester,
+ AutofillMetrics::UPLOAD_OFFERED);
+ // Verify that the correct UKM was logged.
+ ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
+}
+
+// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
+#if defined(OS_ANDROID)
+#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleName \
+ DISABLED_UploadCreditCard_CreditCardFormHasMiddleName
+#else
+#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleName \
+ UploadCreditCard_CreditCardFormHasMiddleName
+#endif
+TEST_F(AutofillManagerTest,
+ MAYBE_UploadCreditCard_CreditCardFormHasMiddleName) {
+ EnableUkmLogging();
+ personal_data_.ClearAutofillProfiles();
+ autofill_manager_->set_credit_card_upload_enabled(true);
+
+ // Create, fill and submit address form without middle name.
+ FormData address_form;
+ test::CreateTestAddressFormData(&address_form);
+ FormsSeen({address_form});
+ ManuallyFillAddressForm("John", "Adams", "77401", "US", &address_form);
+ FormSubmitted(address_form);
+
+ // Set up our credit card form data.
+ FormData credit_card_form;
+ CreateTestCreditCardFormData(&credit_card_form, true, false);
+ FormsSeen({credit_card_form});
+
+ // Edit the name by adding a middle name.
+ credit_card_form.fields[0].value = ASCIIToUTF16("John Quincy Adams");
+ 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("123");
+
+ base::HistogramTester histogram_tester;
+
+ // Names match loosely, 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.
+ ExpectUniqueCardUploadDecision(histogram_tester,
+ AutofillMetrics::UPLOAD_OFFERED);
+ // Verify that the correct UKM was logged.
+ ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
+}
+
+// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
+#if defined(OS_ANDROID)
+#define MAYBE_UploadCreditCard_CreditCardFormRemovesMiddleName \
+ DISABLED_UploadCreditCard_CreditCardFormRemovesMiddleName
+#else
+#define MAYBE_UploadCreditCard_CreditCardFormRemovesMiddleName \
+ UploadCreditCard_CreditCardFormRemovesMiddleName
+#endif
+TEST_F(AutofillManagerTest,
+ MAYBE_UploadCreditCard_CreditCardFormRemovesMiddleName) {
+ EnableUkmLogging();
+ personal_data_.ClearAutofillProfiles();
+ autofill_manager_->set_credit_card_upload_enabled(true);
+
+ // Create, fill and submit address form with middle name.
+ FormData address_form;
+ test::CreateTestAddressFormData(&address_form);
+ FormsSeen({address_form});
+ ManuallyFillAddressForm("John Quincy", "Adams", "77401", "US", &address_form);
+ FormSubmitted(address_form);
+
+ // Set up our credit card form data.
+ FormData credit_card_form;
+ CreateTestCreditCardFormData(&credit_card_form, true, false);
+ FormsSeen({credit_card_form});
+
+ // Edit the name by removing middle name.
+ credit_card_form.fields[0].value = ASCIIToUTF16("John Adams");
+ 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("123");
+
+ base::HistogramTester histogram_tester;
+
+ // Names match loosely, 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.
+ ExpectUniqueCardUploadDecision(histogram_tester,
+ AutofillMetrics::UPLOAD_OFFERED);
+ // Verify that the correct UKM was logged.
+ ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
+}
+
+// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
+#if defined(OS_ANDROID)
#define MAYBE_UploadCreditCard_NamesHaveToMatch \
DISABLED_UploadCreditCard_NamesHaveToMatch
#else
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/autofill_profile_comparator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698