#include "components/autofill/core/browser/field_filling_payments_util.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <vector>
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/stl_util.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.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/credit_card.h"
#include "components/autofill/core/browser/data_model/credit_card_test_api.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_parsing/credit_card_field_parser.h"
#include "components/autofill/core/browser/form_structure_test_api.h"
#include "components/autofill/core/browser/heuristic_source.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.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/mojom/autofill_types.mojom-shared.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {
namespace {
const std::u16string kMidlineEllipsis2Dots = …;
const std::u16string kMidlineEllipsis3Dots = …;
const std::u16string kMidlineEllipsis4Dots = …;
const std::u16string kMidlineEllipsis2DotsWithoutPadding = …;
const std::u16string kMidlineEllipsis3DotsWithoutPadding = …;
const std::u16string kMidlineEllipsis4DotsWithoutPadding = …;
constexpr char kAppLocale[] = …;
const std::vector<const char*> NotNumericMonthsContentsNoPlaceholder() { … }
const std::vector<const char*> NotNumericMonthsContentsWithPlaceholder() { … }
AutofillField CreateTestSelectAutofillField(
const std::vector<const char*>& values,
FieldType heuristic_type) { … }
size_t GetIndexOfValue(const std::vector<SelectOption>& values,
const std::u16string& value) { … }
void TestFillingExpirationMonth(const std::vector<const char*>& values,
const std::vector<const char*>& contents) { … }
struct CreditCardTestCase { … };
size_t GetNumberOffset(size_t index, const CreditCardTestCase& test) { … }
class FieldFillingPaymentsUtilTest : public testing::Test { … };
TEST_F(FieldFillingPaymentsUtilTest,
FillFormField_AutocompleteOff_CreditCardField) { … }
TEST_F(FieldFillingPaymentsUtilTest,
FillFormField_MaxLength_CreditCardField_MaxLengthExceedsLength) { … }
TEST_F(FieldFillingPaymentsUtilTest,
FillFormField_MaxLength_CreditCardField_OffsetExceedsLength) { … }
TEST_F(FieldFillingPaymentsUtilTest,
FillFormField_MaxLength_CreditCardField_WithOffset) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillFormField_MaxLength_CreditCardField) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillFormField_Preview_CreditCardField) { … }
class CreditCardVerificationCodeTest
: public FieldFillingPaymentsUtilTest,
public testing::WithParamInterface<mojom::ActionPersistence> { … };
TEST_P(CreditCardVerificationCodeTest,
FillFormField_CreditCardVerificationCode) { … }
TEST_P(CreditCardVerificationCodeTest,
FillFormField_CreditCardVerificationCode_Empty) { … }
TEST_P(CreditCardVerificationCodeTest, FillFormField_StandaloneCVCField) { … }
TEST_P(CreditCardVerificationCodeTest,
FillFormField_StandaloneCVCField_AmericanExpress) { … }
INSTANTIATE_TEST_SUITE_P(…);
struct FieldFillingPaymentsUtilTestCase { … };
class ExpirationYearTest
: public FieldFillingPaymentsUtilTest,
public testing::WithParamInterface<FieldFillingPaymentsUtilTestCase> { … };
TEST_P(ExpirationYearTest, FillExpirationYearInput) { … }
INSTANTIATE_TEST_SUITE_P(…);
struct FillUtilExpirationDateTestCase { … };
class ExpirationDateTest
: public FieldFillingPaymentsUtilTest,
public testing::WithParamInterface<
std::tuple<FillUtilExpirationDateTestCase,
bool>> { … };
TEST_P(ExpirationDateTest, FillExpirationDateInput) { … }
INSTANTIATE_TEST_SUITE_P(…);
struct FillWithExpirationMonthTestCase { … };
class AutofillSelectWithExpirationMonthTest
: public FieldFillingPaymentsUtilTest,
public testing::WithParamInterface<FillWithExpirationMonthTestCase> { … };
TEST_P(AutofillSelectWithExpirationMonthTest,
FillSelectControlWithExpirationMonth) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(FieldFillingPaymentsUtilTest,
FillSelectControlWithAbbreviatedMonthName) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillSelectControlWithMonthName) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillSelectControlWithMonthNameAndDigits) { … }
TEST_F(FieldFillingPaymentsUtilTest,
FillSelectControlWithMonthNameAndDigits_French) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillSelectControlWithMonthName_French) { … }
TEST_F(FieldFillingPaymentsUtilTest,
FillSelectControlWithNumericMonthSansLeadingZero) { … }
TEST_F(FieldFillingPaymentsUtilTest,
FillSelectControlWithTwoDigitCreditCardYear) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillSelectControlWithCreditCardType) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillMonthControl) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillCreditCardNumberWithoutSplits) { … }
TEST_F(FieldFillingPaymentsUtilTest, FillCreditCardNumberWithEqualSizeSplits) { … }
TEST_F(FieldFillingPaymentsUtilTest,
PreviewCreditCardNumberWithEqualSizeSplits) { … }
TEST_F(FieldFillingPaymentsUtilTest,
FillCreditCardNumberWithUnequalSizeSplits) { … }
TEST_F(FieldFillingPaymentsUtilTest,
PreviewCreditCardNumberWithUnequalSizeSplits) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualMonth) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualMonthOneSelectOne_Empty) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualYear) { … }
TEST_F(FieldFillingPaymentsUtilTest,
PreviewVirtualFourDigitYearOnSelectOne_Empty) { … }
TEST_F(FieldFillingPaymentsUtilTest,
PreviewVirtualTwoDigitYearOnSelectOne_Empty) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualShortenedYear) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualDate) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualShortenedDate) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualCVC) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualCVCAmericanExpress) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualCardNumber) { … }
TEST_F(FieldFillingPaymentsUtilTest,
PreviewVirtualCardNumber_OffsetExceedsLength) { … }
TEST_F(FieldFillingPaymentsUtilTest, PreviewVirtualCardholderName) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_NoCCNumberField) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_CCNumberFieldNotEmpty) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_CCNumberFieldIsAutofilled) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_CCNumberFieldPresent) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_CCNumberFieldNotEmpty_NotUserTyped) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_StandaloneCvcField_CardHasCvc) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_NormalCvcFormField_CardHasCvc) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_CvcFieldNotEmpty_CardHasCvc) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_FormHasCvcAndName_CardHasCvc) { … }
TEST_F(FieldFillingPaymentsUtilTest,
WillFillCreditCardNumberOrCvc_FormHasCvcAndName_CardHasNoCvc) { … }
}
}