chromium/components/autofill/core/browser/autofill_test_utils.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/autofill_test_utils.h"

#include <cstdint>
#include <iterator>
#include <string>

#include "base/functional/overloaded.h"
#include "base/memory/raw_ptr.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/autofill_external_delegate.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/autofill_profile_test_api.h"
#include "components/autofill/core/browser/data_model/bank_account.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/data_model/credit_card_test_api.h"
#include "components/autofill/core/browser/data_model/iban.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/metrics/suggestions_list_metrics.h"
#include "components/autofill/core/browser/payments/card_unmask_challenge_option.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/randomized_encoder.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_personal_data_manager.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/suggestion_type.h"
#include "components/autofill/core/browser/webdata/payments/payments_autofill_table.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_prefs.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_predictions.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/form_field_data_predictions.h"
#include "components/autofill/core/common/unique_ids.h"
#include "components/os_crypt/sync/os_crypt_mocker.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_service_factory.h"
#include "components/prefs/testing_pref_store.h"
#include "components/security_interstitials/core/pref_names.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"

ASCIIToUTF16;
FieldPrediction;

namespace autofill {

bool operator==(const FormFieldDataPredictions& a,
                const FormFieldDataPredictions& b) = default;

bool operator==(const FormDataPredictions& a, const FormDataPredictions& b) {}

namespace test {

namespace {

std::string GetRandomCardNumber() {}

base::Time GetArbitraryPastTime() {}

base::Time GetArbitraryFutureTime() {}

}  // namespace

void SetFormGroupValues(FormGroup& form_group,
                        const std::vector<FormGroupValue>& values) {}

void VerifyFormGroupValues(const FormGroup& form_group,
                           const std::vector<FormGroupValue>& values,
                           bool ignore_status) {}

std::unique_ptr<AutofillTestingPrefService> PrefServiceForTesting() {}

std::unique_ptr<PrefService> PrefServiceForTesting(
    user_prefs::PrefRegistrySyncable* registry) {}

[[nodiscard]] FormData CreateTestAddressFormData(const char* unique_id) {}

inline void check_and_set(
    FormGroup* profile,
    FieldType type,
    const char* value,
    VerificationStatus status = VerificationStatus::kObserved) {}

AutofillProfile GetFullValidProfileForCanada() {}

AutofillProfile GetFullProfile(AddressCountryCode country_code) {}

AutofillProfile GetFullProfile2(AddressCountryCode country_code) {}

AutofillProfile GetFullCanadianProfile() {}

AutofillProfile GetIncompleteProfile1() {}

AutofillProfile GetIncompleteProfile2() {}

void SetProfileCategory(
    AutofillProfile& profile,
    autofill_metrics::AutofillProfileRecordTypeCategory category) {}

std::string GetStrippedValue(const char* value) {}

Iban GetLocalIban() {}

Iban GetLocalIban2() {}

Iban GetServerIban() {}

Iban GetServerIban2() {}

Iban GetServerIban3() {}

CreditCard GetCreditCard() {}

CreditCard GetCreditCard2() {}

CreditCard GetExpiredCreditCard() {}

CreditCard GetIncompleteCreditCard() {}

CreditCard GetVerifiedCreditCard() {}

CreditCard GetVerifiedCreditCard2() {}

CreditCard GetMaskedServerCard() {}

CreditCard GetMaskedServerCard2() {}

CreditCard GetMaskedServerCardWithLegacyId() {}

CreditCard GetMaskedServerCardWithNonLegacyId() {}

CreditCard GetMaskedServerCardVisa() {}

CreditCard GetMaskedServerCardAmex() {}

CreditCard GetMaskedServerCardWithNickname() {}

CreditCard GetMaskedServerCardEnrolledIntoVirtualCardNumber() {}

CreditCard GetFullServerCard() {}

CreditCard GetVirtualCard() {}

CreditCard GetRandomCreditCard(CreditCard::RecordType record_type) {}

CreditCard WithCvc(CreditCard credit_card, std::u16string cvc) {}

CreditCardCloudTokenData GetCreditCardCloudTokenData1() {}

CreditCardCloudTokenData GetCreditCardCloudTokenData2() {}

AutofillOfferData GetCardLinkedOfferData1(int64_t offer_id) {}

AutofillOfferData GetCardLinkedOfferData2(int64_t offer_id) {}

AutofillOfferData GetPromoCodeOfferData(GURL origin,
                                        bool is_expired,
                                        int64_t offer_id) {}

VirtualCardUsageData GetVirtualCardUsageData1() {}

VirtualCardUsageData GetVirtualCardUsageData2() {}

std::vector<CardUnmaskChallengeOption> GetCardUnmaskChallengeOptions(
    const std::vector<CardUnmaskChallengeOptionType>& types) {}

CreditCardFlatRateBenefit GetActiveCreditCardFlatRateBenefit() {}

CreditCardCategoryBenefit GetActiveCreditCardCategoryBenefit() {}

CreditCardMerchantBenefit GetActiveCreditCardMerchantBenefit() {}

base::flat_set<url::Origin> GetOriginsForMerchantBenefit() {}

void SetUpCreditCardAndBenefitData(
    CreditCard& card,
    const CreditCardBenefit& benefit,
    const std::string& issuer_id,
    TestPersonalDataManager& personal_data,
    AutofillOptimizationGuide* optimization_guide) {}

void SetProfileInfo(AutofillProfile* profile,
                    const char* first_name,
                    const char* middle_name,
                    const char* last_name,
                    const char* email,
                    const char* company,
                    const char* address1,
                    const char* address2,
                    const char* dependent_locality,
                    const char* city,
                    const char* state,
                    const char* zipcode,
                    const char* country,
                    const char* phone,
                    bool finalize,
                    VerificationStatus status) {}

void SetProfileInfo(AutofillProfile* profile,
                    const char* first_name,
                    const char* middle_name,
                    const char* last_name,
                    const char* email,
                    const char* company,
                    const char* address1,
                    const char* address2,
                    const char* city,
                    const char* state,
                    const char* zipcode,
                    const char* country,
                    const char* phone,
                    bool finalize,
                    VerificationStatus status) {}

void SetProfileInfoWithGuid(AutofillProfile* profile,
                            const char* guid,
                            const char* first_name,
                            const char* middle_name,
                            const char* last_name,
                            const char* email,
                            const char* company,
                            const char* address1,
                            const char* address2,
                            const char* city,
                            const char* state,
                            const char* zipcode,
                            const char* country,
                            const char* phone,
                            bool finalize,
                            VerificationStatus status) {}

void SetCreditCardInfo(CreditCard* credit_card,
                       const char* name_on_card,
                       const char* card_number,
                       const char* expiration_month,
                       const char* expiration_year,
                       const std::string& billing_address_id,
                       const std::u16string& cvc) {}

CreditCard CreateCreditCardWithInfo(const char* name_on_card,
                                    const char* card_number,
                                    const char* expiration_month,
                                    const char* expiration_year,
                                    const std::string& billing_address_id,
                                    const std::u16string& cvc) {}

void DisableSystemServices(PrefService* prefs) {}

void ReenableSystemServices() {}

void SetServerCreditCards(PaymentsAutofillTable* table,
                          const std::vector<CreditCard>& cards) {}

void InitializePossibleTypes(std::vector<FieldTypeSet>& possible_field_types,
                             const std::vector<FieldType>& possible_types) {}

void FillUploadField(AutofillUploadContents::Field* field,
                     unsigned signature,
                     unsigned autofill_type) {}

void FillUploadField(AutofillUploadContents::Field* field,
                     unsigned signature,
                     const std::vector<unsigned>& autofill_types) {}

void GenerateTestAutofillPopup(
    AutofillExternalDelegate* autofill_external_delegate) {}

std::string ObfuscatedCardDigitsAsUTF8(const std::string& str,
                                       int obfuscation_length) {}

std::string NextMonth() {}
std::string LastYear() {}
std::string NextYear() {}
std::string TenYearsFromNow() {}

std::vector<FormSignature> GetEncodedSignatures(const FormStructure& form) {}

std::vector<FormSignature> GetEncodedSignatures(
    const std::vector<raw_ptr<FormStructure, VectorExperimental>>& forms) {}

std::vector<FormSignature> GetEncodedAlternativeSignatures(
    const FormStructure& form) {}

std::vector<FormSignature> GetEncodedAlternativeSignatures(
    const std::vector<raw_ptr<FormStructure, VectorExperimental>>& forms) {}

FieldPrediction CreateFieldPrediction(FieldType type,
                                      FieldPrediction::Source source) {}

FieldPrediction CreateFieldPrediction(FieldType type, bool is_override) {}

void AddFieldPredictionToForm(
    const FormFieldData& field_data,
    FieldType field_type,
    AutofillQueryResponse_FormSuggestion* form_suggestion,
    bool is_override) {}

void AddFieldPredictionsToForm(
    const FormFieldData& field_data,
    const std::vector<FieldType>& field_types,
    AutofillQueryResponse_FormSuggestion* form_suggestion) {}

void AddFieldPredictionsToForm(
    const FormFieldData& field_data,
    const std::vector<FieldPrediction>& field_predictions,
    AutofillQueryResponse_FormSuggestion* form_suggestion) {}

Suggestion CreateAutofillSuggestion(SuggestionType type,
                                    const std::u16string& main_text_value,
                                    const Suggestion::Payload& payload) {}

Suggestion CreateAutofillSuggestion(const std::u16string& main_text_value,
                                    const std::u16string& minor_text_value,
                                    bool apply_deactivated_style) {}

BankAccount CreatePixBankAccount(int64_t instrument_id) {}

sync_pb::PaymentInstrument CreatePaymentInstrumentWithBankAccount(
    int64_t instrument_id) {}

sync_pb::PaymentInstrument CreatePaymentInstrumentWithIban(
    int64_t instrument_id) {}

}  // namespace test
}  // namespace autofill