#include "components/autofill/core/browser/form_structure.h"
#include <stddef.h>
#include <algorithm>
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include "base/base64.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.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/unguessable_token.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/autofill_experiments.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/field_types.h"
#include "components/autofill/core/browser/form_parsing/buildflags.h"
#include "components/autofill/core/browser/form_parsing/form_field_parser.h"
#include "components/autofill/core/browser/form_structure_test_api.h"
#include "components/autofill/core/browser/proto/api_v1.pb.h"
#include "components/autofill/core/browser/randomized_encoder.h"
#include "components/autofill/core/common/autocomplete_parsing_util.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/autofill/core/common/autofill_test_utils.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/html_field_types.h"
#include "components/autofill/core/common/signatures.h"
#include "components/version_info/version_info.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/re2/src/re2/re2.h"
#include "url/gurl.h"
namespace autofill {
namespace {
FormControlType;
CreateTestFormField;
AllOf;
Each;
ElementsAre;
IsEmpty;
Not;
Pointee;
ResultOf;
Truly;
UnorderedElementsAre;
constexpr DenseSet<PatternSource> kAllPatternSources { … };
}
class FormStructureTestImpl : public test::FormStructureTest { … };
class FormStructureTest_ForPatternSource
: public FormStructureTestImpl,
public testing::WithParamInterface<PatternSource> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(FormStructureTestImpl, FieldCount) { … }
TEST_F(FormStructureTestImpl, AutofillCount) { … }
TEST_F(FormStructureTestImpl, SourceURL) { … }
TEST_F(FormStructureTestImpl, FullSourceURLWithHashAndParam) { … }
TEST_F(FormStructureTestImpl, IsAutofillable) { … }
class FormStructureTestImpl_ShouldBeParsed_Test : public FormStructureTestImpl { … };
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test, FalseIfNoFields) { … }
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test, IgnoresCheckableFields) { … }
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test, TrueIfOneTextField) { … }
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test, FalseIfOnlySelectField) { … }
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test, FalseIfOnlySelectListField) { … }
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test, FalseIfSearchURL) { … }
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test, TrueIfOnlyPasswordFields) { … }
TEST_F(FormStructureTestImpl_ShouldBeParsed_Test,
TrueIfOneFieldHasAutocomplete) { … }
TEST_F(FormStructureTestImpl, ShouldBeParsed_BadScheme) { … }
TEST_F(FormStructureTestImpl, ShouldBeParsed_TwoFields_HasAutocomplete) { … }
TEST_F(FormStructureTestImpl, DetermineHeuristicTypes_AutocompleteFalse) { … }
TEST_F(FormStructureTestImpl, HeuristicsContactInfo) { … }
TEST_F(FormStructureTestImpl, HeuristicsAutocompleteAttribute) { … }
TEST_F(FormStructureTestImpl, StripCommonNamePrefix) { … }
TEST_F(FormStructureTestImpl, StripCommonNamePrefix_SmallPrefix) { … }
TEST_F(FormStructureTestImpl, IsCompleteCreditCardForm_Minimal) { … }
TEST_F(FormStructureTestImpl, IsCompleteCreditCardForm_Full) { … }
TEST_F(FormStructureTestImpl, IsCompleteCreditCardForm_OnlyCCNumber) { … }
TEST_F(FormStructureTestImpl, IsCompleteCreditCardForm_AddressForm) { … }
TEST_F(FormStructureTestImpl, HeuristicsAutocompleteAttributePhoneTypes) { … }
TEST_F(FormStructureTestImpl,
HeuristicsAndServerPredictions_BigForm_NoAutocompleteAttribute) { … }
TEST_F(FormStructureTestImpl,
HeuristicsAndServerPredictions_ValidAutocompleteAttribute) { … }
TEST_F(FormStructureTestImpl,
HeuristicsAndServerPredictions_UnrecognizedAutocompleteAttribute) { … }
TEST_F(FormStructureTestImpl,
HeuristicsAndServerPredictions_SmallForm_NoAutocompleteAttribute) { … }
TEST_F(FormStructureTestImpl,
HeuristicsAndServerPredictions_SmallForm_ValidAutocompleteAttribute) { … }
TEST_F(FormStructureTestImpl, PromoCodeHeuristics_SmallForm) { … }
TEST_F(FormStructureTestImpl, PasswordFormShouldBeQueried) { … }
TEST_F(FormStructureTestImpl,
HeuristicsAutocompleteAttributeWithSectionsDegenerate) { … }
TEST_F(FormStructureTestImpl,
HeuristicsAutocompleteAttributeWithSectionsRepeated) { … }
TEST_F(FormStructureTestImpl, HeuristicsSample8) { … }
TEST_F(FormStructureTestImpl, HeuristicsSample6) { … }
TEST_F(FormStructureTestImpl, HeuristicsLabelsOnly) { … }
TEST_F(FormStructureTestImpl, HeuristicsCreditCardInfo) { … }
TEST_F(FormStructureTestImpl, HeuristicsCreditCardInfoWithUnknownCardField) { … }
TEST_F(FormStructureTestImpl, ThreeAddressLines) { … }
TEST_F(FormStructureTestImpl, SurplusAddressLinesIgnored) { … }
TEST_F(FormStructureTestImpl, ThreeAddressLinesExpedia) { … }
TEST_F(FormStructureTestImpl, TwoAddressLinesEbay) { … }
TEST_F(FormStructureTestImpl, HeuristicsStateWithProvince) { … }
TEST_F(FormStructureTestImpl, HeuristicsWithBilling) { … }
TEST_F(FormStructureTestImpl, ThreePartPhoneNumber) { … }
TEST_F(FormStructureTestImpl, HeuristicsInfernoCC) { … }
TEST_F(FormStructureTestImpl, HeuristicsInferCCNames_NamesNotFirst) { … }
TEST_F(FormStructureTestImpl, HeuristicsInferCCNames_NamesFirst) { … }
TEST_F(FormStructureTestImpl, ButtonTitleType_Match) { … }
TEST_F(FormStructureTestImpl, CheckFormSignature) { … }
TEST_F(FormStructureTestImpl, CheckAlternativeFormSignatureLarge) { … }
TEST_F(FormStructureTestImpl, CheckAlternativeFormSignatureSmallPath) { … }
TEST_F(FormStructureTestImpl, CheckAlternativeFormSignatureSmallRef) { … }
TEST_F(FormStructureTestImpl, CheckAlternativeFormSignatureSmallQuery) { … }
TEST_F(FormStructureTestImpl, ToFormData) { … }
TEST_F(FormStructureTestImpl, OneFieldPasswordFormShouldNotBeUpload) { … }
TEST_F(FormStructureTestImpl, NoAutocompleteSectionNames) { … }
TEST_F(FormStructureTestImpl, NoSplitAdjacentNameFieldType) { … }
TEST_F(FormStructureTestImpl, FindFieldsEligibleForManualFilling) { … }
TEST_P(FormStructureTest_ForPatternSource, ParseFieldTypesWithPatterns) { … }
TEST_F(FormStructureTestImpl, DetermineRanks) { … }
TEST_F(FormStructureTestImpl, GetFormTypes_AutocompleteUnrecognized) { … }
TEST_F(FormStructureTestImpl, SingleFieldEmailHeuristicsDefaultBehavior) { … }
TEST_F(FormStructureTestImpl, SingleFieldEmailHeuristicsEnabled) { … }
TEST_F(FormStructureTestImpl,
SingleFieldEmailHeuristicsEnabledAutocompleteEmail) { … }
TEST_F(FormStructureTestImpl,
SingleFieldEmailHeuristicsNotSupportedOutsideFormTag) { … }
TEST_F(FormStructureTestImpl,
SingleFieldEmailHeuristicsSupportedOutsideFormTag) { … }
}