#include "components/autofill/core/browser/form_parsing/credit_card_field_parser.h"
#include <algorithm>
#include <memory>
#include <vector>
#include "base/memory/ptr_util.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_parsing/autofill_scanner.h"
#include "components/autofill/core/browser/form_parsing/parsing_test_utils.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/form_field_data.h"
#include "testing/gtest/include/gtest/gtest.h"
ASCIIToUTF16;
namespace autofill {
namespace {
std::vector<SelectOption> GetMonths() { … }
std::vector<SelectOption> Get4DigitYears() { … }
std::vector<SelectOption> Get2DigitYears() { … }
std::vector<SelectOption> WithNoise(std::vector<SelectOption> options) { … }
class CreditCardFieldParserTestBase : public FormFieldParserTestBase { … };
class CreditCardFieldParserTest
: public CreditCardFieldParserTestBase,
public ::testing::TestWithParam<PatternProviderFeatureState> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CreditCardFieldParserTest, Empty) { … }
TEST_P(CreditCardFieldParserTest, NonParse) { … }
TEST_P(CreditCardFieldParserTest, ParseCreditCardNoNumber) { … }
TEST_P(CreditCardFieldParserTest, ParseCreditCardNoDate) { … }
TEST_P(CreditCardFieldParserTest, ParseMiniumCreditCard) { … }
TEST_P(CreditCardFieldParserTest, ParseMiniumCreditCardWith2DigitYearHint) { … }
TEST_P(CreditCardFieldParserTest, ParseMiniumCreditCardWithMaxLength) { … }
struct CreditCardFieldYearTestCase { … };
class CreditCardFieldYearTest
: public CreditCardFieldParserTestBase,
public testing::TestWithParam<std::tuple<PatternProviderFeatureState,
CreditCardFieldYearTestCase,
bool>> { … };
TEST_P(CreditCardFieldYearTest, ParseMinimumCreditCardWithExpiryDateOptions) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CreditCardFieldParserTest, ParseFullCreditCard) { … }
TEST_P(CreditCardFieldParserTest, ParseExpMonthYear) { … }
TEST_P(CreditCardFieldParserTest, ParseExpMonthYear2) { … }
TEST_P(CreditCardFieldParserTest, ParseGiftCard) { … }
struct ParseExpFieldTestCase { … };
class ParseExpFieldTest
: public CreditCardFieldParserTestBase,
public testing::TestWithParam<
std::tuple<PatternProviderFeatureState, ParseExpFieldTestCase>> { … };
TEST_P(ParseExpFieldTest, ParseExpField) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CreditCardFieldParserTest, ParseCreditCardHolderNameWithCCFullName) { … }
TEST_P(CreditCardFieldParserTest, ParseMonthControl) { … }
TEST_P(CreditCardFieldParserTest, ParseCreditCardExpYear_2DigitMaxLength) { … }
TEST_P(CreditCardFieldParserTest, ParseMultipleCreditCardNumbers) { … }
TEST_P(CreditCardFieldParserTest, ParseFirstAndLastNames) { … }
TEST_P(CreditCardFieldParserTest, ParseConsecutiveCvc) { … }
TEST_P(CreditCardFieldParserTest, ParseNonConsecutiveCvc) { … }
TEST_P(CreditCardFieldParserTest, ParseCreditCardContextualNameNotCard) { … }
TEST_P(CreditCardFieldParserTest,
ParseCreditCardContextualNameNotCardAcctMatch) { … }
TEST_P(CreditCardFieldParserTest, ParseCreditCardContextualNameWithExpiration) { … }
TEST_P(CreditCardFieldParserTest,
ParseCreditCardContextualNameWithVerification) { … }
struct DetermineExpirationDateFormatTestCase { … };
class DetermineExpirationDateFormat
: public testing::TestWithParam<DetermineExpirationDateFormatTestCase> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(DetermineExpirationDateFormat, TestDetermineFormat) { … }
}
}