#include "components/autofill/core/browser/payments/credit_card_otp_authenticator.h"
#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/metrics/payments/card_unmask_authentication_metrics.h"
#include "components/autofill/core/browser/payments/autofill_error_dialog_context.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/test_authentication_requester.h"
#include "components/autofill/core/browser/payments/test_payments_autofill_client.h"
#include "components/autofill/core/browser/payments/test_payments_network_interface.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_driver.h"
#include "components/autofill/core/browser/test_personal_data_manager.h"
#include "components/prefs/pref_service.h"
#include "components/sync/test/test_sync_service.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {
namespace {
const char kTestChallengeId[] = …;
const char kTestNumber[] = …;
const char16_t kTestNumber16[] = …;
const char16_t kMaskedPhoneNumber[] = …;
const char16_t kMaskedEmailAddress[] = …;
const int64_t kTestBillingCustomerNumber = …;
}
class CreditCardOtpAuthenticatorTestBase : public testing::Test { … };
class CreditCardOtpAuthenticatorTest
: public CreditCardOtpAuthenticatorTestBase,
public testing::WithParamInterface<CardUnmaskChallengeOptionType> { … };
TEST_P(CreditCardOtpAuthenticatorTest, AuthenticateServerCardSuccess) { … }
TEST_P(CreditCardOtpAuthenticatorTest, SelectChallengeOptionFailsWithVcnError) { … }
TEST_P(CreditCardOtpAuthenticatorTest,
SelectChallengeOptionFailsWithOtherErrors) { … }
TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthServerVcnError) { … }
TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthServerNonVcnError) { … }
TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthMismatchThenRetry) { … }
TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthExpiredThenResendOtp) { … }
TEST_P(CreditCardOtpAuthenticatorTest, OtpAuthCancelled) { … }
INSTANTIATE_TEST_SUITE_P(…);
class CreditCardOtpAuthenticatorCardMetadataTest
: public CreditCardOtpAuthenticatorTestBase,
public testing::WithParamInterface<std::tuple<bool, bool, bool>> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CreditCardOtpAuthenticatorCardMetadataTest, MetadataSignal) { … }
class CreditCardOtpAuthenticatorCardBenefitsTest
: public CreditCardOtpAuthenticatorTestBase,
public ::testing::WithParamInterface<
std::tuple<base::FunctionRef<CreditCardBenefit()>,
bool,
std::string>> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CreditCardOtpAuthenticatorCardBenefitsTest,
Benefits_ClientsBehaviorConstant) { … }
}