#include "components/autofill/core/browser/field_filling_address_util.h"
#include <memory>
#include <vector>
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/test/task_environment.h"
#include "components/autofill/core/browser/address_normalizer.h"
#include "components/autofill/core/browser/address_normalizer_impl.h"
#include "components/autofill/core/browser/autofill_field.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/autofill_profile.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_parsing/regex_patterns.h"
#include "components/autofill/core/browser/geo/alternative_state_name_map_test_utils.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_test_utils.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/prefs/pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/null_storage.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
#include "third_party/libaddressinput/src/cpp/test/testdata_source.h"
namespace autofill {
namespace {
NullStorage;
Source;
Storage;
TestdataSource;
constexpr char kAppLocale[] = …;
AutofillField CreateTestSelectAutofillField(
const std::vector<const char*>& values,
FieldType heuristic_type) { … }
std::u16string GetValueForProfile(const AutofillProfile& profile,
const std::string& app_locale,
const AutofillType& field_type,
const FormFieldData& field_data,
AddressNormalizer* address_normalizer) { … }
class FieldFillingAddressUtilTest : public testing::Test { … };
TEST_F(FieldFillingAddressUtilTest,
FillFormField_AutocompleteOffNotRespected_AddressField) { … }
struct FieldFillingAddressUtilTestCase { … };
struct AutofillPhoneFieldFillerTestCase
: public FieldFillingAddressUtilTestCase { … };
class PhoneNumberTest
: public FieldFillingAddressUtilTest,
public testing::WithParamInterface<AutofillPhoneFieldFillerTestCase> { … };
TEST_P(PhoneNumberTest, FillPhoneNumber) { … }
INSTANTIATE_TEST_SUITE_P(…);
struct FillSelectTestCase { … };
class AutofillSelectWithStatesTest
: public FieldFillingAddressUtilTest,
public testing::WithParamInterface<FillSelectTestCase> { … };
TEST_P(AutofillSelectWithStatesTest, FillSelectWithStates) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(FieldFillingAddressUtilTest, FillSelectWithCountryName) { … }
TEST_F(FieldFillingAddressUtilTest, FillSelectWithCountryCode) { … }
TEST_F(FieldFillingAddressUtilTest, FillInputWithCountry) { … }
TEST_F(FieldFillingAddressUtilTest, FillStreetAddressTextArea) { … }
TEST_F(FieldFillingAddressUtilTest, FillStreetAddressTextField) { … }
struct FillStateTextTestCase { … };
class AutofillStateTextTest
: public FieldFillingAddressUtilTest,
public testing::WithParamInterface<FillStateTextTestCase> { … };
TEST_P(AutofillStateTextTest, FillStateText) { … }
INSTANTIATE_TEST_SUITE_P(…);
struct FillAugmentedPhoneCountryCodeTestCase { … };
class AutofillFillAugmentedPhoneCountryCodeTest
: public FieldFillingAddressUtilTest,
public testing::WithParamInterface<
std::tuple<bool, FillAugmentedPhoneCountryCodeTestCase>> { … };
void DoTestFillAugmentedPhoneCountryCodeField(
bool enable_filling_phone_country_codes_by_address_country_codes,
const FillAugmentedPhoneCountryCodeTestCase& test_case,
FormControlType field_type) { … }
TEST_P(AutofillFillAugmentedPhoneCountryCodeTest,
FillAugmentedPhoneCountryCodeField) { … }
TEST_P(AutofillFillAugmentedPhoneCountryCodeTest,
FillAugmentedPhoneCountryCodeSelectListField) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(FieldFillingAddressUtilTest, FillSelectAbbreviatedState) { … }
TEST_F(FieldFillingAddressUtilTest, FillSelectLocalizedState) { … }
TEST_F(FieldFillingAddressUtilTest, FillSelectLocalizedStateSubstring) { … }
TEST_F(FieldFillingAddressUtilTest, FillStateAbbreviationInTextField) { … }
TEST_F(FieldFillingAddressUtilTest, FillStateFieldWithSavedValueInProfile) { … }
TEST_F(FieldFillingAddressUtilTest, FillStateFieldWhenStateIsNotInOptions) { … }
TEST_F(FieldFillingAddressUtilTest,
FillStateFieldWhenAlternativeStateNameMapIsNotPopulated) { … }
TEST_F(FieldFillingAddressUtilTest, FillUpperCaseAbbreviationInStateTextField) { … }
TEST_F(FieldFillingAddressUtilTest,
DoNotFillStateFieldWhenAbbrStoredInProfileAndNotInOptionsList) { … }
}
}