#include "components/autofill/core/browser/form_structure_rationalizer.h"
#include <string_view>
#include <tuple>
#include <utility>
#include "base/base64.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_encoding.h"
#include "components/autofill/core/browser/field_types.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/form_data_test_api.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
AllOf;
ElementsAre;
ElementsAreArray;
Matcher;
Pointee;
Property;
namespace autofill {
namespace {
std::string SerializeAndEncode(const AutofillQueryResponse& response) { … }
struct FieldTemplate { … };
FieldTemplate ToNotFocusable(FieldTemplate field_template) { … }
FieldTemplate ToSelectOne(FieldTemplate field_template) { … }
FieldTemplate SetRolePresentation(FieldTemplate field_template) { … }
std::pair<FormData, std::string> CreateFormAndServerClassification(
std::vector<FieldTemplate> fields) { … }
std::unique_ptr<FormStructure> BuildFormStructure(
const std::vector<FieldTemplate>& fields,
bool run_heuristics) { … }
std::vector<FieldType> GetTypes(const FormStructure& form_structure) { … }
Matcher<AutofillField> HasType(FieldType type) { … }
Matcher<AutofillField> HasOffset(size_t offset) { … }
Matcher<AutofillField> HasTypeAndOffset(FieldType type, size_t offset) { … }
Matcher<FormStructure> AreFieldsArray(
const std::vector<Matcher<AutofillField>>& matchers) { … }
template <typename... Matchers>
Matcher<FormStructure> AreFields(Matchers... matchers) { … }
class FormStructureRationalizerTest : public testing::Test { … };
FormStructureRationalizerTest::FormStructureRationalizerTest() { … }
TEST_F(FormStructureRationalizerTest, ParseQueryResponse_RationalizeLoneField) { … }
TEST_F(FormStructureRationalizerTest, ParseQueryResponse_RationalizeCCName) { … }
TEST_F(FormStructureRationalizerTest,
ParseQueryResponse_RationalizeMultiMonth_1) { … }
TEST_F(FormStructureRationalizerTest,
ParseQueryResponse_RationalizeMultiMonth_2) { … }
TEST_F(FormStructureRationalizerTest,
RationalizePhoneNumber_RunsOncePerSection) { … }
TEST_F(FormStructureRationalizerTest, RationalizeStreetAddressAndAddressLine) { … }
TEST_F(FormStructureRationalizerTest, RationalizePhoneNumberTrunkTypes) { … }
TEST_F(FormStructureRationalizerTest, RationalizeRepeatedFields_OneAddress) { … }
TEST_F(FormStructureRationalizerTest, RationalizeRepreatedFields_TwoAddresses) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_ThreeAddresses) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_FourAddresses) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_OneAddressEachSection) { … }
TEST_F(
FormStructureRationalizerTest,
RationalizeRepreatedFields_SectionTwoAddress_SectionThreeAddress_SectionFourAddresses) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_MultipleSectionsByHeuristics_OneAddressEach) { … }
TEST_F(
FormStructureRationalizerTest,
RationalizeRepreatedFields_MultipleSectionsByHeuristics_TwoAddress_ThreeAddress) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_StateCountry_NoRationalization) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_CountryStateNoHeuristics) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_StateCountryWithHeuristics) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_FirstFieldRationalized) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeRepreatedFields_LastFieldRationalized) { … }
TEST_F(FormStructureRationalizerTest, RationalizeStandaloneCVCField) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeAndKeepCVCField_OtherCreditCardFields) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeAndKeepCVCField_EmailAddressField) { … }
TEST_F(FormStructureRationalizerTest, RationalizeContentEditables) { … }
class FormStructureRationalizerTestMultiOriginCreditCardFields
: public FormStructureRationalizerTest,
public ::testing::WithParamInterface<FieldType> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(FormStructureRationalizerTestMultiOriginCreditCardFields,
RationalizeIfSensitiveFieldsOnMainAndCrossOrigin) { … }
TEST_P(FormStructureRationalizerTestMultiOriginCreditCardFields,
DoNotRationalizeIfSensitiveFieldsOnlyOnMainOrigin) { … }
TEST_P(FormStructureRationalizerTestMultiOriginCreditCardFields,
DoNotRationalizeIfSensitiveFieldsOnlyOnCrossOrigins) { … }
TEST_F(
FormStructureRationalizerTest,
RationalizeCreditCardNumberOffsets_DoNotSplitForNonAdjacentMaxlength1Field) { … }
TEST_F(
FormStructureRationalizerTest,
RationalizeCreditCardNumberOffsets_DoNotSplitForAdjacentMaxlength1Field) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeCreditCardNumberOffsets_SplitGroupOfFours) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeCreditCardNumberOffsets_FocusabilityStartNewGroups) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeCreditCardNumberOffsets_RendererFormsStartNewGroups) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeCreditCardNumberOffsets_SplitGroupOfFoursFollodeByOverflow) { … }
TEST_F(FormStructureRationalizerTest,
RationalizeCreditCardNumberOffsets_SplitGroupOfOnes) { … }
TEST_F(FormStructureRationalizerTest, RationalizeCreditCardNumberOffsets_) { … }
TEST_F(FormStructureRationalizerTest, RationalizeAddressBetweenStreets) { … }
struct RationalizeAutocompleteTestParam { … };
class RationalizeAutocompleteTest
: public testing::Test,
public testing::WithParamInterface<RationalizeAutocompleteTestParam> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(RationalizeAutocompleteTest, RationalizeAutocompleteAttribute) { … }
struct RationalizationTypeRelationshipsTestParams { … };
class RationalizationFieldTypeFilterTest
: public testing::Test,
public testing::WithParamInterface<FieldType> { … };
class RationalizationFieldTypeRelationshipsTest
: public testing::Test,
public testing::WithParamInterface<
RationalizationTypeRelationshipsTestParams> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(RationalizationFieldTypeFilterTest, Rationalization_Rules_Filter_Out) { … }
TEST_P(RationalizationFieldTypeRelationshipsTest,
Rationalization_Rules_Relationships) { … }
}
}