#include "components/autofill/core/browser/form_data_importer.h"
#include <stddef.h>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/address_data_manager_test_api.h"
#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_form_test_utils.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address_utils.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_data_importer_test_api.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/form_structure_test_api.h"
#include "components/autofill/core/browser/metrics/autofill_metrics_utils.h"
#include "components/autofill/core/browser/mock_autofill_plus_address_delegate.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/test_credit_card_save_manager.h"
#include "components/autofill/core/browser/payments/test_virtual_card_enrollment_manager.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/strike_databases/payments/iban_save_strike_database.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_clock.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/common/autocomplete_parsing_util.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/autofill/core/common/autofill_test_utils.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/credit_card_network_identifiers.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/html_field_types.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h"
#include "components/prefs/pref_service.h"
#include "components/sync/test/test_sync_service.h"
namespace autofill {
namespace {
UTF8ToUTF16;
CreateTestFormField;
CreateTestIbanFormData;
_;
NiceMock;
constexpr char kLocale[] = …;
constexpr char kDefaultFullName[] = …;
constexpr char kDefaultFirstName[] = …;
constexpr char kDefaultLastName[] = …;
constexpr char kDefaultMail[] = …;
constexpr char kDefaultAddressLine1[] = …;
constexpr char kDefaultStreetAddress[] = …;
constexpr char kDefaultZip[] = …;
constexpr char kDefaultCity[] = …;
constexpr char kDefaultState[] = …;
constexpr char kDefaultCountry[] = …;
constexpr char kDefaultPhone[] = …;
constexpr char kDefaultPhoneDomesticFormatting[] = …;
constexpr char kDefaultPhoneAreaCode[] = …;
constexpr char kDefaultPhonePrefix[] = …;
constexpr char kDefaultPhoneSuffix[] = …;
constexpr char kSecondFirstName[] = …;
constexpr char kSecondLastName[] = …;
constexpr char kSecondMail[] = …;
constexpr char kSecondAddressLine1[] = …;
constexpr char kSecondZip[] = …;
constexpr char kSecondCity[] = …;
constexpr char kSecondState[] = …;
constexpr char kSecondPhone[] = …;
constexpr char kSecondPhoneAreaCode[] = …;
constexpr char kSecondPhonePrefix[] = …;
constexpr char kSecondPhoneSuffix[] = …;
constexpr char kThirdFirstName[] = …;
constexpr char kThirdLastName[] = …;
constexpr char kThirdMail[] = …;
constexpr char kThirdAddressLine1[] = …;
constexpr char kThirdZip[] = …;
constexpr char kThirdCity[] = …;
constexpr char kThirdState[] = …;
constexpr char kThirdPhone[] = …;
constexpr char kDefaultCreditCardName[] = …;
constexpr char kDefaultCreditCardNumber[] = …;
constexpr char kDefaultCreditCardExpMonth[] = …;
constexpr char kDefaultCreditCardExpYear[] = …;
constexpr char kDefaultPhoneGermany[] = …;
constexpr char kDefaultPhoneMexico[] = …;
constexpr char kDefaultPhoneArmenia[] = …;
std::pair<std::string, std::string> GetLabelAndNameForType(FieldType type) { … }
TypeValuePairs;
FormData ConstructFormDateFromTypeValuePairs(
TypeValuePairs type_value_pairs,
std::string url = "https://www.foo.com") { … }
std::unique_ptr<FormStructure> ConstructFormStructureFromFormData(
const FormData& form,
GeoIpCountryCode geo_country = GeoIpCountryCode("")) { … }
std::unique_ptr<FormStructure> ConstructFormStructureFromTypeValuePairs(
TypeValuePairs type_value_pairs,
std::string url = "https://www.foo.com") { … }
AutofillProfile ConstructProfileFromTypeValuePairs(
TypeValuePairs type_value_pairs) { … }
TypeValuePairs GetDefaultProfileTypeValuePairs() { … }
void SetValueForType(TypeValuePairs& pairs,
FieldType type,
const std::string& value) { … }
TypeValuePairs GetDefaultProfileTypeValuePairsWithOverriddenCountry(
const std::string& country) { … }
TypeValuePairs GetSplitDefaultProfileTypeValuePairs(int part) { … }
TypeValuePairs GetSecondProfileTypeValuePairs() { … }
TypeValuePairs GetThirdProfileTypeValuePairs() { … }
TypeValuePairs GetDefaultCreditCardTypeValuePairs() { … }
AutofillProfile ConstructDefaultProfile() { … }
AutofillProfile ConstructDefaultProfileWithOverriddenCountry(
const std::string& country) { … }
AutofillProfile ConstructSecondProfile() { … }
AutofillProfile ConstructThirdProfile() { … }
std::unique_ptr<FormStructure> ConstructDefaultProfileFormStructure() { … }
std::unique_ptr<FormStructure> ConstructDefaultEmailFormStructure() { … }
std::unique_ptr<FormStructure> ConstructSplitDefaultProfileFormStructure(
int part) { … }
std::unique_ptr<FormStructure> ConstructSecondProfileFormStructure() { … }
std::unique_ptr<FormStructure> ConstructThirdProfileFormStructure() { … }
std::unique_ptr<FormStructure> ConstructShippingAndBillingFormStructure() { … }
std::unique_ptr<FormStructure> ConstructDefaultCreditCardFormStructure() { … }
FormData ConstructDefaultFormData() { … }
FormData ConstructDefaultFormDataWithTwoAddresses() { … }
FormData ConstructSplitDefaultFormData(int part) { … }
template <typename T>
auto ComparesEqual(T expected) { … }
template <typename T>
auto UnorderedElementsCompareEqualArray(const std::vector<T>& expected_values) { … }
template <typename... Matchers>
auto UnorderedElementsCompareEqual(Matchers... matchers) { … }
}
class MockVirtualCardEnrollmentManager
: public TestVirtualCardEnrollmentManager { … };
class MockCreditCardSaveManager : public TestCreditCardSaveManager { … };
class FormDataImporterTest : public testing::Test { … };
TEST_F(FormDataImporterTest, ComplementCountry_PartOfForm) { … }
TEST_F(FormDataImporterTest, ComplementCountry_VariationCountryCode) { … }
TEST_F(FormDataImporterTest, ComplementCountry_VariationConfigCountryCode) { … }
TEST_F(FormDataImporterTest, ComplementCountry_PhoneNumberParsing) { … }
TEST_F(FormDataImporterTest, ParseI18nPhoneNumberInCityAndNumberField) { … }
TEST_F(FormDataImporterTest, InvalidCountry) { … }
TEST_F(FormDataImporterTest, InvalidPhoneNumber) { … }
TEST_F(FormDataImporterTest, PlusAddressesExcluded) { … }
TEST_F(FormDataImporterTest, ImportStructuredNameProfile) { … }
TEST_F(FormDataImporterTest,
ImportStructuredAddressProfile_StreetNameAndHouseNumber) { … }
TEST_F(
FormDataImporterTest,
ImportStructuredAddressProfile_StreetNameAndHouseNumberAndApartmentNumber) { … }
TEST_F(FormDataImporterTest,
ImportStructuredAddressProfile_GermanStreetNameAndHouseNumber) { … }
TEST_F(FormDataImporterTest, ImportStructuredAddressProfile_I18nAddressFormMX) { … }
TEST_F(FormDataImporterTest, ImportStructuredAddressProfile_I18nAddressFormBR) { … }
TEST_F(FormDataImporterTest, ImportStructuredNameAddressProfile) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles) { … }
TEST_F(FormDataImporterTest, ImportSecondAddressProfiles) { … }
TEST_F(FormDataImporterTest, ImportThirdAddressProfiles) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_DependentLocality) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_DontAllowPrompt) { … }
TEST_F(FormDataImporterTest, ImportAddressProfileFromUnifiedSection) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_BadEmail) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_TwoEmails) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_TwoDifferentEmails) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_MultiplePhoneNumbers) { … }
TEST_F(FormDataImporterTest,
ImportAddressProfiles_MultiplePhoneNumbersSplitAcrossMultipleFields) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_NotEnoughFilledFields) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_MinimumAddressUSA) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_MinimumAddressGB) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_MinimumAddressGI) { … }
TEST_F(FormDataImporterTest,
ImportAddressProfiles_PhoneNumberSplitAcrossMultipleFields) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_UnfocusableFields) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_MultilineAddress) { … }
TEST_F(FormDataImporterTest,
ImportAddressProfiles_TwoValidProfilesDifferentForms) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_TwoValidProfilesSameForm) { … }
TEST_F(FormDataImporterTest,
ImportAddressProfiles_OneValidProfileSameForm_PartsHidden) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_MissingInfoInOld) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_MissingInfoInNew) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_InsufficientAddress) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_NoSynthesizedTypes) { … }
TEST_F(FormDataImporterTest, ImportAddressProfiles_ContainsSynthesizedTypes) { … }
TEST_F(FormDataImporterTest,
ImportAddressProfiles_CompleteComposedCountryName) { … }
TEST_F(FormDataImporterTest,
ImportAddressProfiles_IncompleteComposedCountryName) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_Valid) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_InvalidCardNumber) { … }
TEST_F(FormDataImporterTest,
ExtractCreditCard_PreferUserInputForCreditCardNumber) { … }
TEST_F(FormDataImporterTest,
ExtractCreditCard_InvalidExpiryDate_EditableExpirationExpOn) { … }
TEST_F(FormDataImporterTest,
ExtractCreditCard_ExpiredExpiryDate_EditableExpirationExpOn) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_MonthSelectInvalidText) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_TwoValidCards) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_Month2DigitYearCombination) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_Month4DigitYearCombination) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_1DigitMonth4DigitYear) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_2DigitYear) { … }
TEST_F(FormDataImporterTest,
ExtractCreditCard_DuplicateServerCards_ExtractMaskedCard) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_SameCreditCardWithConflict) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_ShouldReturnLocalCard) { … }
TEST_F(FormDataImporterTest,
ExtractCreditCard_ShouldReturnLocalCard_WithExtractedCvc) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_EmptyCardWithConflict) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_MissingInfoInNew) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_MissingInfoInOld) { … }
TEST_F(FormDataImporterTest, ExtractCreditCard_SameCardWithSeparators) { … }
TEST_F(FormDataImporterTest,
ExtractCreditCard_ExistingVerifiedCardWithConflict) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_SecondImportResetsCreditCardRecordType) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_NewCard) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_LocalCard) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_MaskedServerCard) { … }
TEST_F(
FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_DuplicateLocalAndMaskedServerCard) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_NoCard_InvalidCardNumber) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_NoCard_VirtualCard) { … }
TEST_F(
FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_NewCard_ExpiredCard_WithExpDateFixFlow) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_NoCard_NoCardOnForm) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_ServerCardWithCvc) { … }
TEST_F(
FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_MaskedServerCardWithSameLastFour) { … }
TEST_F(
FormDataImporterTest,
ExtractFormData_ExtractCreditCardRecordType_TwoMaskedServerCardWithSameLastFour) { … }
TEST_F(FormDataImporterTest, ExtractFormData_OneAddressOneCreditCard) { … }
TEST_F(FormDataImporterTest, ExtractFormData_TwoAddressesOneCreditCard) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(FormDataImporterTest, ExtractFormData_ImportIbanRecordType_NoIban) { … }
TEST_F(FormDataImporterTest, ExtractFormData_SubmittingIbanFormUpdatesPref) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_SubmittingCreditCardFormDoesNotUpdateIbanPref) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ImportIbanRecordType_IbanAutofill_NewInvalidIban) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ImportIbanRecordType_IbanAutofill_NewIban) { … }
TEST_F(FormDataImporterTest, ExtractFormData_ImportIbanRecordType_LocalIban) { … }
#endif
TEST_F(FormDataImporterTest, ExtractFormData_AddressesDisabledOneCreditCard) { … }
TEST_F(FormDataImporterTest, ExtractFormData_OneAddressCreditCardDisabled) { … }
TEST_F(FormDataImporterTest, ExtractFormData_AddressCreditCardDisabled) { … }
TEST_F(FormDataImporterTest, DuplicateMaskedServerCard) { … }
TEST_F(FormDataImporterTest, ExtractFormData_HiddenCreditCardFormAfterEntered) { … }
TEST_F(FormDataImporterTest,
Metrics_SubmittedServerCardExpirationStatus_EmptyExpirationMonth) { … }
TEST_F(FormDataImporterTest,
Metrics_SubmittedServerCardExpirationStatus_EmptyExpirationYear) { … }
TEST_F(
FormDataImporterTest,
Metrics_SubmittedDifferentServerCardExpirationStatus_EmptyExpirationYear) { … }
TEST_F(FormDataImporterTest,
Metrics_SubmittedServerCardExpirationStatus_MaskedServerCardMatch) { … }
TEST_F(FormDataImporterTest,
Metrics_SubmittedServerCardExpirationStatus_MaskedServerCardMismatch) { … }
TEST_F(FormDataImporterTest, SilentlyUpdateExistingProfileByIncompleteProfile) { … }
TEST_F(
FormDataImporterTest,
SilentlyUpdateExistingProfileByIncompleteProfile_DespiteDisallowedPrompts) { … }
TEST_F(FormDataImporterTest, UnusableIncompleteProfile) { … }
TEST_F(FormDataImporterTest, RemoveInaccessibleProfileValuesMetrics) { … }
TEST_F(FormDataImporterTest, MultiStepImport) { … }
TEST_F(FormDataImporterTest, MultiStepImport_Complement) { … }
TEST_F(FormDataImporterTest, MultiStepImport_Complement_ExternalUpdate) { … }
TEST_F(FormDataImporterTest, MultiStepImport_Complement_ExternalRemove) { … }
TEST_F(FormDataImporterTest, MultiStepImport_DifferentOrigin) { … }
TEST_F(FormDataImporterTest, MultiStepImport_TTL) { … }
TEST_F(FormDataImporterTest, MultiStepImport_DeleteOnBrowsingHistoryCleared) { … }
TEST_F(FormDataImporterTest, FormAssociator) { … }
TEST_F(FormDataImporterTest, SkipAutocompleteUnrecognizedFields) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(FormDataImporterTest,
ProcessIbanImportCandidate_ShouldOfferLocalSave_NewIban) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ProcessIbanImportCandidate_NoIban) { … }
TEST_F(
FormDataImporterTest,
ExtractFormData_ProcessIbanImportCandidate_PaymentMethodsSettingDisabled) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ProcessIbanImportCandidate_NewIban) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ProcessIbanImportCandidate_LocalIban) { … }
TEST_F(FormDataImporterTest,
ExtractFormData_ProcessIbanImportCandidate_MaxStrikes) { … }
#endif
TEST_F(FormDataImporterTest, ProcessExtractedCreditCard_EmptyCreditCard) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(FormDataImporterTest, ProcessExtractedCreditCard_VirtualCardEligible) { … }
#endif
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID)
TEST_F(FormDataImporterTest,
ProcessExtractedCreditCard_MandatoryReauthNotOffered) {
CreditCard extracted_credit_card = test::GetVirtualCard();
std::unique_ptr<FormStructure> form_structure =
ConstructDefaultCreditCardFormStructure();
form_data_importer()
.SetPaymentMethodTypeIfNonInteractiveAuthenticationFlowCompleted(
NonInteractivePaymentMethodType::kVirtualCard);
test_api(form_data_importer())
.set_credit_card_import_type(
FormDataImporter::CreditCardImportType::kVirtualCard);
EXPECT_CALL(
*static_cast<::testing::NiceMock<payments::MockMandatoryReauthManager>*>(
autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager()),
ShouldOfferOptin)
.Times(1)
.WillOnce(testing::Return(false));
EXPECT_CALL(
*static_cast<::testing::NiceMock<payments::MockMandatoryReauthManager>*>(
autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager()),
StartOptInFlow)
.Times(0);
test_api(form_data_importer())
.ProcessExtractedCreditCard(*form_structure, extracted_credit_card,
true);
}
TEST_F(FormDataImporterTest,
ProcessExtractedCreditCard_MandatoryReauthNotOffered_NewCard) {
std::unique_ptr<FormStructure> form_structure =
ConstructDefaultCreditCardFormStructure();
form_data_importer()
.SetPaymentMethodTypeIfNonInteractiveAuthenticationFlowCompleted(
NonInteractivePaymentMethodType::kLocalCard);
test_api(form_data_importer())
.set_credit_card_import_type(
FormDataImporter::CreditCardImportType::kNewCard);
EXPECT_CALL(
*static_cast<::testing::NiceMock<payments::MockMandatoryReauthManager>*>(
autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager()),
ShouldOfferOptin)
.Times(0);
EXPECT_CALL(
*static_cast<::testing::NiceMock<payments::MockMandatoryReauthManager>*>(
autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager()),
StartOptInFlow)
.Times(0);
test_api(form_data_importer())
.ProcessExtractedCreditCard(*form_structure, test::GetCreditCard2(),
true);
}
TEST_F(FormDataImporterTest,
ProcessExtractedCreditCard_MandatoryReauthOffered) {
CreditCard extracted_credit_card = test::GetCreditCard2();
std::unique_ptr<FormStructure> form_structure =
ConstructDefaultCreditCardFormStructure();
form_data_importer()
.SetPaymentMethodTypeIfNonInteractiveAuthenticationFlowCompleted(
NonInteractivePaymentMethodType::kLocalCard);
test_api(form_data_importer())
.set_credit_card_import_type(
FormDataImporter::CreditCardImportType::kLocalCard);
EXPECT_CALL(
*static_cast<::testing::NiceMock<payments::MockMandatoryReauthManager>*>(
autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager()),
ShouldOfferOptin)
.Times(1)
.WillOnce(testing::Return(true));
EXPECT_CALL(
*static_cast<::testing::NiceMock<payments::MockMandatoryReauthManager>*>(
autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager()),
StartOptInFlow)
.Times(1);
EXPECT_TRUE(test_api(form_data_importer())
.ProcessExtractedCreditCard(
*form_structure, extracted_credit_card,
true));
EXPECT_FALSE(
test_api(form_data_importer())
.payment_method_type_if_non_interactive_authentication_flow_completed()
.has_value());
}
TEST_F(FormDataImporterTest, ProcessExtractedIban_MandatoryReauthOffered) {
FormStructure form_structure(CreateTestIbanFormData());
form_structure.DetermineHeuristicTypes(GeoIpCountryCode(""), nullptr,
nullptr);
form_data_importer()
.SetPaymentMethodTypeIfNonInteractiveAuthenticationFlowCompleted(
NonInteractivePaymentMethodType::kLocalIban);
EXPECT_CALL(*autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager(),
ShouldOfferOptin)
.WillOnce(testing::Return(true));
EXPECT_CALL(*autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager(),
StartOptInFlow);
EXPECT_TRUE(ExtractFormDataAndProcessIbanCandidates(
form_structure, true,
true));
EXPECT_FALSE(
test_api(form_data_importer())
.payment_method_type_if_non_interactive_authentication_flow_completed()
.has_value());
}
TEST_F(FormDataImporterTest, ProcessExtractedIban_MandatoryReauthNotOffered) {
FormStructure form_structure(CreateTestIbanFormData());
form_structure.DetermineHeuristicTypes(GeoIpCountryCode(""), nullptr,
nullptr);
EXPECT_CALL(*autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager(),
ShouldOfferOptin)
.WillOnce(testing::Return(false));
EXPECT_CALL(*autofill_client_->GetPaymentsAutofillClient()
->GetOrCreatePaymentsMandatoryReauthManager(),
StartOptInFlow)
.Times(0);
EXPECT_TRUE(ExtractFormDataAndProcessIbanCandidates(
form_structure, true,
true));
EXPECT_FALSE(
test_api(form_data_importer())
.payment_method_type_if_non_interactive_authentication_flow_completed()
.has_value());
}
#endif
TEST_F(FormDataImporterTest,
ProcessExtractedCreditCard_ProceedWithSavingIfApplicable_Server) { … }
TEST_F(FormDataImporterTest,
ProcessExtractedCreditCard_ProceedWithSavingIfApplicable_Local) { … }
TEST_F(FormDataImporterTest,
GetObservedFieldValues_SkipFieldsFilledWithFallback) { … }
TEST_F(FormDataImporterTest,
GetObservedFieldValues_ImportFromAutocompleteUnrecognized) { … }
class FormDataImporterTest_ExtractCreditCardFromForm
: public FormDataImporterTest { … };
TEST_F(FormDataImporterTest_ExtractCreditCardFromForm,
IgnoreInconsistentValuesFromDifferentPriorityClasses) { … }
TEST_F(FormDataImporterTest_ExtractCreditCardFromForm, MergeDerivedValues) { … }
TEST_F(FormDataImporterTest_ExtractCreditCardFromForm,
BlockImportForInconsistentValues) { … }
TEST_F(FormDataImporterTest_ExtractCreditCardFromForm, PartialFirstLastNames) { … }
}