#include "chrome/browser/sync/test/integration/wallet_helper.h"
#include <stddef.h>
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/webdata_services/web_data_service_factory.h"
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/data_model/payments_metadata.h"
#include "components/autofill/core/browser/payments/payments_customer_data.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/webdata/autofill_sync_metadata_table.h"
#include "components/autofill/core/browser/webdata/payments/payments_autofill_table.h"
#include "components/autofill/core/common/credit_card_network_identifiers.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/sync/model/metadata_batch.h"
#include "components/sync/protocol/autofill_wallet_credential_specifics.pb.h"
#include "components/sync/protocol/data_type_progress_marker.pb.h"
#include "components/sync/protocol/data_type_state.pb.h"
AutofillWebDataService;
CreditCard;
CreditCardCloudTokenData;
PaymentsAutofillTable;
PaymentsCustomerData;
PaymentsMetadata;
PersonalDataManager;
ServerCvc;
TruncateUTF8;
test;
namespace {
const int kDefaultCardExpMonth = …;
const int kDefaultCardExpYear = …;
const std::u16string kDefaultCardCvc = …;
const int kDefaultCardInstrumentId = …;
const char kDefaultCardLastFour[] = …;
const char16_t kDefaultCardLastFour16[] = …;
const char kDefaultCardName[] = …;
const char16_t kDefaultCardName16[] = …;
const sync_pb::WalletMaskedCreditCard_WalletCardType kDefaultCardType = …;
template <class Item>
bool ListsMatch(int profile_a,
const std::vector<Item*>& list_a,
int profile_b,
const std::vector<Item*>& list_b) { … }
template <class Item>
void LogLists(const std::vector<Item*>& list_a,
const std::vector<Item*>& list_b) { … }
template <class Item, base::RawPtrTraits Traits = base::RawPtrTraits::kEmpty>
void LogLists(const std::vector<raw_ptr<Item, Traits>>& list_a,
const std::vector<raw_ptr<Item, Traits>>& list_b) { … }
template <class Item, base::RawPtrTraits Traits = base::RawPtrTraits::kEmpty>
bool ListsMatch(int profile_a,
const std::vector<raw_ptr<Item, Traits>>& list_a,
int profile_b,
const std::vector<raw_ptr<Item, Traits>>& list_b) { … }
bool WalletDataAndMetadataMatch(
int profile_a,
const std::vector<CreditCard*>& server_cards_a,
int profile_b,
const std::vector<CreditCard*>& server_cards_b) { … }
void WaitForCurrentTasksToComplete(
scoped_refptr<base::SequencedTaskRunner> task_runner) { … }
void WaitForPDMToRefresh(int profile) { … }
void SetServerCardsOnDBSequence(AutofillWebDataService* wds,
const std::vector<CreditCard>& credit_cards) { … }
void SetPaymentsCustomerDataOnDBSequence(
AutofillWebDataService* wds,
const PaymentsCustomerData& customer_data) { … }
void SetCreditCardCloudTokenDataOnDBSequence(
AutofillWebDataService* wds,
const std::vector<CreditCardCloudTokenData>& cloud_token_data) { … }
void GetServerCardsMetadataOnDBSequence(
AutofillWebDataService* wds,
std::vector<PaymentsMetadata>* cards_metadata) { … }
void GetDataTypeStateOnDBSequence(syncer::DataType data_type,
AutofillWebDataService* wds,
sync_pb::DataTypeState* data_type_state) { … }
}
namespace wallet_helper {
PersonalDataManager* GetPersonalDataManager(int index) { … }
scoped_refptr<AutofillWebDataService> GetProfileWebDataService(int index) { … }
scoped_refptr<AutofillWebDataService> GetAccountWebDataService(int index) { … }
void SetServerCreditCards(
int profile,
const std::vector<autofill::CreditCard>& credit_cards) { … }
void SetPaymentsCustomerData(
int profile,
const autofill::PaymentsCustomerData& customer_data) { … }
void SetCreditCardCloudTokenData(
int profile,
const std::vector<autofill::CreditCardCloudTokenData>& cloud_token_data) { … }
void SetServerCardCredentialData(int profile, const CreditCard& credit_card) { … }
void RemoveServerCardCredentialData(int profile,
const CreditCard& credit_card) { … }
void UpdateServerCardCredentialData(int profile,
const CreditCard& credit_card) { … }
void UpdateServerCardMetadata(int profile, const CreditCard& credit_card) { … }
std::vector<PaymentsMetadata> GetServerCardsMetadata(int profile) { … }
sync_pb::DataTypeState GetWalletDataTypeState(syncer::DataType data_type,
int profile) { … }
sync_pb::SyncEntity CreateDefaultSyncWalletCard() { … }
sync_pb::SyncEntity CreateSyncWalletCard(const std::string& name,
const std::string& last_four,
const std::string& billing_address_id,
const std::string& nickname,
int64_t instrument_id) { … }
sync_pb::SyncEntity CreateSyncPaymentsCustomerData(
const std::string& customer_id) { … }
sync_pb::SyncEntity CreateDefaultSyncPaymentsCustomerData() { … }
CreditCard GetDefaultCreditCard() { … }
sync_pb::SyncEntity CreateSyncCreditCardCloudTokenData(
const std::string& cloud_token_data_id) { … }
sync_pb::SyncEntity CreateDefaultSyncCreditCardCloudTokenData() { … }
sync_pb::SyncEntity CreateDefaultSyncWalletCredential() { … }
sync_pb::SyncEntity CreateSyncWalletCredential(const ServerCvc& server_cvc) { … }
void ExpectDefaultCreditCardValues(const CreditCard& card) { … }
void ExpectDefaultWalletCredentialValues(const CreditCard& card) { … }
std::vector<CreditCard*> GetServerCreditCards(int profile) { … }
}
AutofillWalletChecker::AutofillWalletChecker(int profile_a, int profile_b)
: … { … }
AutofillWalletChecker::~AutofillWalletChecker() { … }
bool AutofillWalletChecker::Wait() { … }
bool AutofillWalletChecker::IsExitConditionSatisfied(std::ostream* os) { … }
void AutofillWalletChecker::OnPaymentsDataChanged() { … }
AutofillWalletMetadataSizeChecker::AutofillWalletMetadataSizeChecker(
int profile_a,
int profile_b)
: … { … }
AutofillWalletMetadataSizeChecker::~AutofillWalletMetadataSizeChecker() { … }
bool AutofillWalletMetadataSizeChecker::IsExitConditionSatisfied(
std::ostream* os) { … }
void AutofillWalletMetadataSizeChecker::OnPaymentsDataChanged() { … }
bool AutofillWalletMetadataSizeChecker::IsExitConditionSatisfiedImpl() { … }
FullUpdateTypeProgressMarkerChecker::FullUpdateTypeProgressMarkerChecker(
base::Time min_required_progress_marker_timestamp,
syncer::SyncService* service,
syncer::DataType data_type)
: … { … }
FullUpdateTypeProgressMarkerChecker::~FullUpdateTypeProgressMarkerChecker() =
default;
bool FullUpdateTypeProgressMarkerChecker::IsExitConditionSatisfied(
std::ostream* os) { … }
void FullUpdateTypeProgressMarkerChecker::OnSyncCycleCompleted(
syncer::SyncService* sync) { … }