#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TEST_UTILS_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TEST_UTILS_H_
#include <memory>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_testing_pref_service.h"
#include "components/autofill/core/browser/data_model/autofill_offer_data.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/autofill_wallet_usage_data.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/data_model/credit_card_benefit.h"
#include "components/autofill/core/browser/data_model/credit_card_cloud_token_data.h"
#include "components/autofill/core/browser/data_model/iban.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/metrics/autofill_metrics_utils.h"
#include "components/autofill/core/browser/payments/card_unmask_challenge_option.h"
#include "components/autofill/core/browser/proto/api_v1.pb.h"
#include "components/autofill/core/browser/proto/server.pb.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/suggestion_type.h"
#include "components/autofill/core/common/autofill_test_utils.h"
#include "components/sync/protocol/autofill_specifics.pb.h"
class PrefService;
namespace user_prefs {
class PrefRegistrySyncable;
}
namespace autofill {
class AutofillExternalDelegate;
class AutofillProfile;
class BankAccount;
class FormData;
class FormFieldData;
struct FormDataPredictions;
struct FormFieldDataPredictions;
class PaymentsAutofillTable;
class TestAutofillClient;
class TestPersonalDataManager;
bool operator==(const FormFieldDataPredictions& a,
const FormFieldDataPredictions& b);
bool operator==(const FormDataPredictions& a, const FormDataPredictions& b);
namespace test {
struct FormGroupValue { … };
FormGroupValues;
void SetFormGroupValues(FormGroup& form_group,
const std::vector<FormGroupValue>& values);
void VerifyFormGroupValues(const FormGroup& form_group,
const std::vector<FormGroupValue>& values,
bool ignore_status = false);
inline constexpr char kEmptyOrigin[] = …;
std::unique_ptr<AutofillTestingPrefService> PrefServiceForTesting();
std::unique_ptr<PrefService> PrefServiceForTesting(
user_prefs::PrefRegistrySyncable* registry);
[[nodiscard]] FormData CreateTestAddressFormData(
const char* unique_id = nullptr);
AutofillProfile GetFullValidProfileForCanada();
AutofillProfile GetFullProfile(
AddressCountryCode country_code = AddressCountryCode("US"));
AutofillProfile GetFullProfile2(
AddressCountryCode country_code = AddressCountryCode("US"));
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 GetMaskedServerCard();
CreditCard GetMaskedServerCard2();
CreditCard GetMaskedServerCardWithNonLegacyId();
CreditCard GetMaskedServerCardWithLegacyId();
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 = u"123");
CreditCardCloudTokenData GetCreditCardCloudTokenData1();
CreditCardCloudTokenData GetCreditCardCloudTokenData2();
AutofillOfferData GetCardLinkedOfferData1(int64_t offer_id = 111);
AutofillOfferData GetCardLinkedOfferData2(int64_t offer_id = 222);
AutofillOfferData GetPromoCodeOfferData(
GURL origin = GURL("http://www.example.com"),
bool is_expired = false,
int64_t offer_id = 333);
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 = true,
VerificationStatus status = VerificationStatus::kObserved);
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 = true,
VerificationStatus status = VerificationStatus::kObserved);
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 = true,
VerificationStatus = VerificationStatus::kObserved);
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 = u"");
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 = u"");
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_type);
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);
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();
::autofill::AutofillQueryResponse::FormSuggestion::FieldSuggestion::
FieldPrediction
CreateFieldPrediction(FieldType type,
::autofill::AutofillQueryResponse::FormSuggestion::
FieldSuggestion::FieldPrediction::Source source);
::autofill::AutofillQueryResponse::FormSuggestion::FieldSuggestion::
FieldPrediction
CreateFieldPrediction(FieldType type, bool is_override = false);
void AddFieldPredictionToForm(
const autofill::FormFieldData& field_data,
FieldType field_type,
::autofill::AutofillQueryResponse_FormSuggestion* form_suggestion,
bool is_override = false);
void AddFieldPredictionsToForm(
const autofill::FormFieldData& field_data,
const std::vector<FieldType>& field_types,
::autofill::AutofillQueryResponse_FormSuggestion* form_suggestion);
void AddFieldPredictionsToForm(
const autofill::FormFieldData& field_data,
const std::vector<::autofill::AutofillQueryResponse::FormSuggestion::
FieldSuggestion::FieldPrediction>& field_predictions,
::autofill::AutofillQueryResponse_FormSuggestion* form_suggestion);
Suggestion CreateAutofillSuggestion(
SuggestionType type,
const std::u16string& main_text_value = std::u16string(),
const Suggestion::Payload& payload = Suggestion::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);
}
}
#endif