Commit ba345648 authored by Jared Saul's avatar Jared Saul Committed by Commit Bot

Remove AutofillUpstreamUseAutofillProfileComparator experiment

Bug: 
Change-Id: Iec0429a3149ee17ca53b60224684e4dc3e6bbf26
Reviewed-on: https://chromium-review.googlesource.com/828442
Commit-Queue: Jared Saul <jsaul@google.com>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524435}
parent 7e9579c8
...@@ -69,9 +69,6 @@ const base::Feature kAutofillUpstreamSendDetectedValues{ ...@@ -69,9 +69,6 @@ const base::Feature kAutofillUpstreamSendDetectedValues{
"AutofillUpstreamSendDetectedValues", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillUpstreamSendDetectedValues", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAutofillUpstreamSendPanFirstSix{ const base::Feature kAutofillUpstreamSendPanFirstSix{
"AutofillUpstreamSendPanFirstSix", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillUpstreamSendPanFirstSix", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAutofillUpstreamUseAutofillProfileComparator{
"AutofillUpstreamUseAutofillProfileComparator",
base::FEATURE_DISABLED_BY_DEFAULT};
const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit"; const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit";
const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color"; const char kAutofillCreditCardPopupBackgroundColorKey[] = "background_color";
const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color"; const char kAutofillCreditCardPopupDividerColorKey[] = "dropdown_divider_color";
......
...@@ -46,7 +46,6 @@ extern const base::Feature kAutofillUpstreamAllowAllEmailDomains; ...@@ -46,7 +46,6 @@ extern const base::Feature kAutofillUpstreamAllowAllEmailDomains;
extern const base::Feature kAutofillUpstreamRequestCvcIfMissing; extern const base::Feature kAutofillUpstreamRequestCvcIfMissing;
extern const base::Feature kAutofillUpstreamSendDetectedValues; extern const base::Feature kAutofillUpstreamSendDetectedValues;
extern const base::Feature kAutofillUpstreamSendPanFirstSix; extern const base::Feature kAutofillUpstreamSendPanFirstSix;
extern const base::Feature kAutofillUpstreamUseAutofillProfileComparator;
extern const char kCreditCardSigninPromoImpressionLimitParamKey[]; extern const char kCreditCardSigninPromoImpressionLimitParamKey[];
extern const char kAutofillCreditCardLastUsedDateShowExpirationDateKey[]; extern const char kAutofillCreditCardLastUsedDateShowExpirationDateKey[];
extern const char kAutofillUpstreamMaxMinutesSinceAutofillProfileUseKey[]; extern const char kAutofillUpstreamMaxMinutesSinceAutofillProfileUseKey[];
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "components/autofill/core/browser/autofill_experiments.h" #include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/autofill_profile.h" #include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_profile_comparator.h"
#include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/credit_card.h" #include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/browser/form_structure.h"
...@@ -330,12 +329,6 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload( ...@@ -330,12 +329,6 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload(
: AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS_PROFILE; : AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS_PROFILE;
} }
std::unique_ptr<AutofillProfileComparator> comparator;
if (!candidate_profiles.empty() &&
(base::FeatureList::IsEnabled(
kAutofillUpstreamUseAutofillProfileComparator)))
comparator = std::make_unique<AutofillProfileComparator>(app_locale_);
// If any of the names on the card or the addresses don't match the // If any of the names on the card or the addresses don't match the
// candidate set is invalid. This matches the rules for name matching applied // candidate set is invalid. This matches the rules for name matching applied
// server-side by Google Payments and ensures that we don't send upload // server-side by Google Payments and ensures that we don't send upload
...@@ -347,37 +340,18 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload( ...@@ -347,37 +340,18 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload(
verified_name = card_name; verified_name = card_name;
} else { } else {
bool found_conflicting_names = false; bool found_conflicting_names = false;
if (comparator) { verified_name = RemoveMiddleInitial(card_name);
upload_request->active_experiments.push_back( for (const AutofillProfile& profile : candidate_profiles) {
kAutofillUpstreamUseAutofillProfileComparator.name); const base::string16 address_name =
verified_name = comparator->NormalizeForComparison(card_name); RemoveMiddleInitial(profile.GetInfo(NAME_FULL, app_locale_));
for (const AutofillProfile& profile : candidate_profiles) { if (address_name.empty())
const base::string16 address_name = comparator->NormalizeForComparison( continue;
profile.GetInfo(NAME_FULL, app_locale_)); if (verified_name.empty()) {
if (address_name.empty()) verified_name = address_name;
continue; } else if (!base::EqualsCaseInsensitiveASCII(verified_name,
if (verified_name.empty() || address_name)) {
comparator->IsNameVariantOf(address_name, verified_name)) { found_conflicting_names = true;
verified_name = address_name; break;
} else if (!comparator->IsNameVariantOf(verified_name, address_name)) {
found_conflicting_names = true;
break;
}
}
} else {
verified_name = RemoveMiddleInitial(card_name);
for (const AutofillProfile& profile : candidate_profiles) {
const base::string16 address_name =
RemoveMiddleInitial(profile.GetInfo(NAME_FULL, app_locale_));
if (address_name.empty())
continue;
if (verified_name.empty()) {
verified_name = address_name;
} else if (!base::EqualsCaseInsensitiveASCII(verified_name,
address_name)) {
found_conflicting_names = true;
break;
}
} }
} }
if (found_conflicting_names) { if (found_conflicting_names) {
...@@ -395,29 +369,12 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload( ...@@ -395,29 +369,12 @@ void CreditCardSaveManager::SetProfilesForCreditCardUpload(
// If any of the candidate addresses have a non-empty zip that doesn't match // If any of the candidate addresses have a non-empty zip that doesn't match
// any other non-empty zip, then the candidate set is invalid. // any other non-empty zip, then the candidate set is invalid.
base::string16 verified_zip; base::string16 verified_zip;
base::string16 normalized_verified_zip;
const AutofillType kZipCode(ADDRESS_HOME_ZIP); const AutofillType kZipCode(ADDRESS_HOME_ZIP);
for (const AutofillProfile& profile : candidate_profiles) { for (const AutofillProfile& profile : candidate_profiles) {
const base::string16 zip = comparator const base::string16 zip = profile.GetRawInfo(ADDRESS_HOME_ZIP);
? profile.GetInfo(kZipCode, app_locale_)
: profile.GetRawInfo(ADDRESS_HOME_ZIP);
const base::string16 normalized_zip =
comparator ? comparator->NormalizeForComparison(
zip, AutofillProfileComparator::DISCARD_WHITESPACE)
: base::string16();
if (!zip.empty()) { if (!zip.empty()) {
if (verified_zip.empty()) { if (verified_zip.empty()) {
verified_zip = zip; verified_zip = zip;
normalized_verified_zip = normalized_zip;
} else if (comparator) {
if (normalized_zip.find(normalized_verified_zip) ==
base::string16::npos &&
normalized_verified_zip.find(normalized_zip) ==
base::string16::npos) {
upload_decision_metrics_ |=
AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS;
break;
}
} else { } else {
// To compare two zips, we check to see if either is a prefix of the // To compare two zips, we check to see if either is a prefix of the
// other. This allows us to consider a 5-digit zip and a zip+4 to be a // other. This allows us to consider a 5-digit zip and a zip+4 to be a
......
...@@ -367,11 +367,6 @@ class CreditCardSaveManagerTest : public testing::Test { ...@@ -367,11 +367,6 @@ class CreditCardSaveManagerTest : public testing::Test {
scoped_feature_list_.InitAndEnableFeature(kAutofillUpstreamSendPanFirstSix); scoped_feature_list_.InitAndEnableFeature(kAutofillUpstreamSendPanFirstSix);
} }
void EnableAutofillUpstreamUseAutofillProfileComparator() {
scoped_feature_list_.InitAndEnableFeature(
kAutofillUpstreamUseAutofillProfileComparator);
}
void FormsSeen(const std::vector<FormData>& forms) { void FormsSeen(const std::vector<FormData>& forms) {
autofill_manager_->OnFormsSeen(forms, base::TimeTicks()); autofill_manager_->OnFormsSeen(forms, base::TimeTicks());
} }
...@@ -1539,7 +1534,8 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesConflict) { ...@@ -1539,7 +1534,8 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesConflict) {
AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
} }
TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesDiscardWhitespace) { TEST_F(CreditCardSaveManagerTest,
UploadCreditCard_ZipCodesDoNotDiscardWhitespace) {
personal_data_.ClearProfiles(); personal_data_.ClearProfiles();
credit_card_save_manager_->set_credit_card_upload_enabled(true); credit_card_save_manager_->set_credit_card_upload_enabled(true);
...@@ -1581,52 +1577,6 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesDiscardWhitespace) { ...@@ -1581,52 +1577,6 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesDiscardWhitespace) {
histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
} }
TEST_F(CreditCardSaveManagerTest,
UploadCreditCard_ZipCodesDiscardWhitespace_ComparatorEnabled) {
EnableAutofillUpstreamUseAutofillProfileComparator();
personal_data_.ClearProfiles();
credit_card_save_manager_->set_credit_card_upload_enabled(true);
// Create, fill and submit two address forms with different zip codes.
FormData address_form1, address_form2;
test::CreateTestAddressFormData(&address_form1);
test::CreateTestAddressFormData(&address_form2);
FormsSeen({address_form1, address_form2});
ManuallyFillAddressForm("Flo", "Master", "H3B2Y5", "CA", &address_form1);
FormSubmitted(address_form1);
ManuallyFillAddressForm("Flo", "Master", "h3b 2y5", "CA", &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 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(NextYear());
credit_card_form.fields[4].value = ASCIIToUTF16("123");
base::HistogramTester histogram_tester;
// Zips match because we discard whitespace before comparison.
EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
FormSubmitted(credit_card_form);
EXPECT_TRUE(credit_card_save_manager_->credit_card_was_uploaded());
EXPECT_THAT(
credit_card_save_manager_->GetActiveExperiments(),
UnorderedElementsAre(kAutofillUpstreamUseAutofillProfileComparator.name));
// Verify that the correct histogram entry (and only that) was logged.
ExpectUniqueCardUploadDecision(histogram_tester,
AutofillMetrics::UPLOAD_OFFERED);
}
TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) { TEST_F(CreditCardSaveManagerTest, UploadCreditCard_ZipCodesHavePrefixMatch) {
personal_data_.ClearProfiles(); personal_data_.ClearProfiles();
credit_card_save_manager_->set_credit_card_upload_enabled(true); credit_card_save_manager_->set_credit_card_upload_enabled(true);
...@@ -1764,56 +1714,6 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleInitial) { ...@@ -1764,56 +1714,6 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleInitial) {
ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED);
} }
TEST_F(CreditCardSaveManagerTest,
UploadCreditCard_CCFormHasMiddleInitial_ComparatorEnabled) {
EnableAutofillUpstreamUseAutofillProfileComparator();
personal_data_.ClearProfiles();
credit_card_save_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(NextYear());
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(credit_card_save_manager_->credit_card_was_uploaded());
EXPECT_THAT(
credit_card_save_manager_->GetActiveExperiments(),
UnorderedElementsAre(kAutofillUpstreamUseAutofillProfileComparator.name));
// 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);
}
TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) {
personal_data_.ClearProfiles(); personal_data_.ClearProfiles();
credit_card_save_manager_->set_credit_card_upload_enabled(true); credit_card_save_manager_->set_credit_card_upload_enabled(true);
...@@ -1857,50 +1757,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { ...@@ -1857,50 +1757,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) {
} }
TEST_F(CreditCardSaveManagerTest, TEST_F(CreditCardSaveManagerTest,
UploadCreditCard_NoMiddleInitialInCCForm_ComparatorEnabled) { UploadCreditCard_CCFormHasCardholderMiddleName) {
EnableAutofillUpstreamUseAutofillProfileComparator();
personal_data_.ClearProfiles();
credit_card_save_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(NextYear());
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(credit_card_save_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);
}
TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleName) {
personal_data_.ClearProfiles(); personal_data_.ClearProfiles();
credit_card_save_manager_->set_credit_card_upload_enabled(true); credit_card_save_manager_->set_credit_card_upload_enabled(true);
...@@ -1925,8 +1782,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleName) { ...@@ -1925,8 +1782,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleName) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
// Names match loosely but we have disabled comparator. Upload should not // Names match loosely but middle name mismatches. Upload should not happen.
// happen.
EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
FormSubmitted(credit_card_form); FormSubmitted(credit_card_form);
EXPECT_FALSE(credit_card_save_manager_->credit_card_was_uploaded()); EXPECT_FALSE(credit_card_save_manager_->credit_card_was_uploaded());
...@@ -1937,49 +1793,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleName) { ...@@ -1937,49 +1793,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasMiddleName) {
histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
} }
TEST_F(CreditCardSaveManagerTest, TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormHasAddressMiddleName) {
UploadCreditCard_CCFormHasMiddleName_ComparatorEnabled) {
EnableAutofillUpstreamUseAutofillProfileComparator();
personal_data_.ClearProfiles();
credit_card_save_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(NextYear());
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(credit_card_save_manager_->credit_card_was_uploaded());
EXPECT_THAT(
credit_card_save_manager_->GetActiveExperiments(),
UnorderedElementsAre(kAutofillUpstreamUseAutofillProfileComparator.name));
// 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);
}
TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormRemovesMiddleName) {
personal_data_.ClearProfiles(); personal_data_.ClearProfiles();
credit_card_save_manager_->set_credit_card_upload_enabled(true); credit_card_save_manager_->set_credit_card_upload_enabled(true);
...@@ -2004,7 +1818,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormRemovesMiddleName) { ...@@ -2004,7 +1818,7 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormRemovesMiddleName) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
// With the comparator disabled, names do not match; upload should not happen. // Names match loosely but middle name mismatches. Upload should not happen.
EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
FormSubmitted(credit_card_form); FormSubmitted(credit_card_form);
EXPECT_FALSE(credit_card_save_manager_->credit_card_was_uploaded()); EXPECT_FALSE(credit_card_save_manager_->credit_card_was_uploaded());
...@@ -2018,48 +1832,6 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormRemovesMiddleName) { ...@@ -2018,48 +1832,6 @@ TEST_F(CreditCardSaveManagerTest, UploadCreditCard_CCFormRemovesMiddleName) {
AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
} }
TEST_F(CreditCardSaveManagerTest,
UploadCreditCard_CCFormRemovesMiddleName_ComparatorEnabled) {
EnableAutofillUpstreamUseAutofillProfileComparator();
personal_data_.ClearProfiles();
credit_card_save_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(NextYear());
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(credit_card_save_manager_->credit_card_was_uploaded());
EXPECT_THAT(
credit_card_save_manager_->GetActiveExperiments(),
UnorderedElementsAre(kAutofillUpstreamUseAutofillProfileComparator.name));
// 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);
}
TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NamesHaveToMatch) { TEST_F(CreditCardSaveManagerTest, UploadCreditCard_NamesHaveToMatch) {
personal_data_.ClearProfiles(); personal_data_.ClearProfiles();
credit_card_save_manager_->set_credit_card_upload_enabled(true); credit_card_save_manager_->set_credit_card_upload_enabled(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment