Chromium Code Reviews| 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 ac2db777ad53ad7e48fbe4ddbc0bf0559c8d83bf..9231569151b107138e95b63e8dd2cf174a78d83c 100644 |
| --- a/components/autofill/core/browser/autofill_manager_unittest.cc |
| +++ b/components/autofill/core/browser/autofill_manager_unittest.cc |
| @@ -1077,6 +1077,11 @@ class AutofillManagerTest : public testing::Test { |
| {kAutofillUpstreamRequestCvcIfMissing, kAutofillUkmLogging}, {}); |
| } |
| + void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { |
| + scoped_feature_list_.InitAndDisableFeature( |
| + kAutofillUpstreamUseAutofillProfileComparatorForName); |
| + } |
| + |
| void ExpectUniqueFillableFormParsedUkm() { |
| ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| @@ -5559,14 +5564,13 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoZipCodeAvailable) { |
| // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| #if defined(OS_ANDROID) |
| -#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleInitial \ |
| - DISABLED_UploadCreditCard_CreditCardFormHasMiddleInitial |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleInitial \ |
| + DISABLED_UploadCreditCard_CCFormHasMiddleInitial |
| #else |
| -#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleInitial \ |
| - UploadCreditCard_CreditCardFormHasMiddleInitial |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleInitial \ |
| + UploadCreditCard_CCFormHasMiddleInitial |
| #endif |
| -TEST_F(AutofillManagerTest, |
| - MAYBE_UploadCreditCard_CreditCardFormHasMiddleInitial) { |
| +TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CCFormHasMiddleInitial) { |
| EnableUkmLogging(); |
| personal_data_.ClearAutofillProfiles(); |
| autofill_manager_->set_credit_card_upload_enabled(true); |
| @@ -5614,14 +5618,66 @@ TEST_F(AutofillManagerTest, |
| // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| #if defined(OS_ANDROID) |
| -#define MAYBE_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial \ |
| - DISABLED_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleInitial_DisableComparator \ |
| + DISABLED_UploadCreditCard_CCFormHasMiddleInitial_DisableComparator |
| #else |
| -#define MAYBE_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial \ |
| - UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleInitial_DisableComparator \ |
| + UploadCreditCard_CCFormHasMiddleInitial_DisableComparator |
| #endif |
| TEST_F(AutofillManagerTest, |
| - MAYBE_UploadCreditCard_CreditCardFormDoesNotHaveMiddleInitial) { |
| + MAYBE_UploadCreditCard_CCFormHasMiddleInitial_DisableComparator) { |
|
Roger McFarlane (Chromium)
2017/05/08 15:38:16
Do we need to start out with the added tests disab
csashi
2017/05/08 16:17:14
Just following the pattern. I can try removing it.
|
| + DisableAutofillUpstreamUseAutofillProfileComparatorForName(); |
| + 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 be different case. |
| + ManuallyFillAddressForm("flo", "master", "77401", "US", &address_form1); |
| + FormSubmitted(address_form1); |
| + |
| + // And they can have a middle initial even if the other names don't. |
| + 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 use the name with a middle initial *and* period, and |
| + // submit. |
| + credit_card_form.fields[0].value = ASCIIToUTF16("Flo W. 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); |
| +} |
| + |
| +// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| +#if defined(OS_ANDROID) |
| +#define MAYBE_UploadCreditCard_NoMiddleInitialInCCForm \ |
| + DISABLED_UploadCreditCard_NoMiddleInitialInCCForm |
| +#else |
| +#define MAYBE_UploadCreditCard_NoMiddleInitialInCCForm \ |
| + UploadCreditCard_NoMiddleInitialInCCForm |
| +#endif |
| +TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoMiddleInitialInCCForm) { |
| EnableUkmLogging(); |
| personal_data_.ClearAutofillProfiles(); |
| autofill_manager_->set_credit_card_upload_enabled(true); |
| @@ -5666,14 +5722,63 @@ TEST_F(AutofillManagerTest, |
| // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| #if defined(OS_ANDROID) |
| -#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleName \ |
| - DISABLED_UploadCreditCard_CreditCardFormHasMiddleName |
| +#define MAYBE_UploadCreditCard_NoMiddleInitialInCCForm_DisableComparator \ |
| + DISABLED_UploadCreditCard_NoMiddleInitialInCCForm_DisableComparator |
| #else |
| -#define MAYBE_UploadCreditCard_CreditCardFormHasMiddleName \ |
| - UploadCreditCard_CreditCardFormHasMiddleName |
| +#define MAYBE_UploadCreditCard_NoMiddleInitialInCCForm_DisableComparator \ |
| + UploadCreditCard_NoMiddleInitialInCCForm_DisableComparator |
| #endif |
| TEST_F(AutofillManagerTest, |
| - MAYBE_UploadCreditCard_CreditCardFormHasMiddleName) { |
| + MAYBE_UploadCreditCard_NoMiddleInitialInCCForm_DisableComparator) { |
| + DisableAutofillUpstreamUseAutofillProfileComparatorForName(); |
| + 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); |
| +} |
| + |
| +// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| +#if defined(OS_ANDROID) |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleName \ |
| + DISABLED_UploadCreditCard_CCFormHasMiddleName |
| +#else |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleName \ |
| + UploadCreditCard_CCFormHasMiddleName |
| +#endif |
| +TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CCFormHasMiddleName) { |
| EnableUkmLogging(); |
| personal_data_.ClearAutofillProfiles(); |
| autofill_manager_->set_credit_card_upload_enabled(true); |
| @@ -5713,14 +5818,59 @@ TEST_F(AutofillManagerTest, |
| // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| #if defined(OS_ANDROID) |
| -#define MAYBE_UploadCreditCard_CreditCardFormRemovesMiddleName \ |
| - DISABLED_UploadCreditCard_CreditCardFormRemovesMiddleName |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleName_DisableComparator \ |
| + DISABLED_UploadCreditCard_CCFormHasMiddleName_DisableComparator |
| #else |
| -#define MAYBE_UploadCreditCard_CreditCardFormRemovesMiddleName \ |
| - UploadCreditCard_CreditCardFormRemovesMiddleName |
| +#define MAYBE_UploadCreditCard_CCFormHasMiddleName_DisableComparator \ |
| + UploadCreditCard_CCFormHasMiddleName_DisableComparator |
| #endif |
| TEST_F(AutofillManagerTest, |
| - MAYBE_UploadCreditCard_CreditCardFormRemovesMiddleName) { |
| + MAYBE_UploadCreditCard_CCFormHasMiddleName_DisableComparator) { |
| + DisableAutofillUpstreamUseAutofillProfileComparatorForName(); |
| + 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 but we have disabled comparator. Upload should not |
| + // happen. |
| + EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| + FormSubmitted(credit_card_form); |
| + EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| + |
| + // Verify that the correct histogram entry (and only that) was logged. |
| + ExpectUniqueCardUploadDecision( |
| + histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
| +} |
| + |
| +// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| +#if defined(OS_ANDROID) |
| +#define MAYBE_UploadCreditCard_CCFormRemovesMiddleName \ |
| + DISABLED_UploadCreditCard_CCFormRemovesMiddleName |
| +#else |
| +#define MAYBE_UploadCreditCard_CCFormRemovesMiddleName \ |
| + UploadCreditCard_CCFormRemovesMiddleName |
| +#endif |
| +TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CCFormRemovesMiddleName) { |
| EnableUkmLogging(); |
| personal_data_.ClearAutofillProfiles(); |
| autofill_manager_->set_credit_card_upload_enabled(true); |
| @@ -5826,6 +5976,60 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesHaveToMatch) { |
| // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| #if defined(OS_ANDROID) |
| +#define MAYBE_UploadCreditCard_NamesHaveToMatch_DisableComparator \ |
| + DISABLED_UploadCreditCard_NamesHaveToMatch_DisableComparator |
| +#else |
| +#define MAYBE_UploadCreditCard_NamesHaveToMatch_DisableComparator \ |
| + UploadCreditCard_NamesHaveToMatch_DisableComparator |
| +#endif |
| +TEST_F(AutofillManagerTest, |
| + MAYBE_UploadCreditCard_NamesHaveToMatch_DisableComparator) { |
| + DisableAutofillUpstreamUseAutofillProfileComparatorForName(); |
| + 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); |
| + |
| + std::vector<FormData> address_forms; |
| + address_forms.push_back(address_form1); |
| + address_forms.push_back(address_form2); |
| + FormsSeen(address_forms); |
| + |
| + ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form1); |
| + FormSubmitted(address_form1); |
| + |
| + ManuallyFillAddressForm("Master", "Blaster", "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(std::vector<FormData>(1, credit_card_form)); |
| + |
| + // Edit the data, but use yet another name, and submit. |
| + credit_card_form.fields[0].value = ASCIIToUTF16("Bob 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 are required to match, upload should not happen. |
| + EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| + FormSubmitted(credit_card_form); |
| + EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| + |
| + // Verify that the correct histogram entry (and only that) was logged. |
| + ExpectUniqueCardUploadDecision( |
| + histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
| +} |
| + |
| +// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| +#if defined(OS_ANDROID) |
| #define MAYBE_UploadCreditCard_UploadDetailsFails \ |
| DISABLED_UploadCreditCard_UploadDetailsFails |
| #else |