chromium/third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/libaddressinput/chromium/chrome_address_validator.h"

#include <stddef.h>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_problem.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.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 {

AddressData;
AddressField;
AddressProblem;
BuildCallback;
FieldProblemMap;
GetRegionCodes;
NullStorage;
Source;
Storage;
TestdataSource;

COUNTRY;
ADMIN_AREA;
LOCALITY;
DEPENDENT_LOCALITY;
SORTING_CODE;
POSTAL_CODE;
STREET_ADDRESS;
RECIPIENT;

INVALID_FORMAT;
MISMATCHING_VALUE;
MISSING_REQUIRED_FIELD;
UNEXPECTED_FIELD;
UNKNOWN_VALUE;
UNSUPPORTED_FIELD;
USES_P_O_BOX;

// This class should always succeed in getting the rules.
class AddressValidatorTest : public testing::Test, LoadRulesListener {};

// Use this test fixture if you're going to use a region with a large set of
// validation rules. All rules should be loaded in SetUpTestCase().
class LargeAddressValidatorTest : public testing::Test {};

AddressValidator* LargeAddressValidatorTest::validator_ =;

TEST_F(AddressValidatorTest, SubKeysLoaded) {}

TEST_F(AddressValidatorTest, SubKeysLoaded_DefaultLanguage) {}

TEST_F(AddressValidatorTest, SubKeysLoaded_NonDefaultLanguage) {}

TEST_F(AddressValidatorTest, SubKeysLoaded_LanguageNotAvailable) {}

TEST_F(AddressValidatorTest, SubKeysLoaded_NamesNotAvailable) {}

TEST_F(AddressValidatorTest, SubKeysNotExist) {}

TEST_F(AddressValidatorTest, RegionHasRules) {}

TEST_F(AddressValidatorTest, EmptyAddressNoFatalFailure) {}

TEST_F(AddressValidatorTest, UsStateNamesAreValidEntries) {}

TEST_F(AddressValidatorTest, USZipCode) {}

TEST_F(AddressValidatorTest, BasicValidation) {}

TEST_F(AddressValidatorTest, BasicValidationFailure) {}

TEST_F(AddressValidatorTest, NormalizeUsAdminAreaName) {}

TEST_F(AddressValidatorTest, NormalizeUsAdminAreaKey) {}

TEST_F(AddressValidatorTest, NormalizeJpAdminAreaKey) {}

TEST_F(AddressValidatorTest, NormalizeJpAdminAreaLatinName) {}

TEST_F(AddressValidatorTest, AreRulesLoadedForRegion_NotLoaded) {}

TEST_F(AddressValidatorTest, AreRulesLoadedForRegion_Loaded) {}

TEST_F(AddressValidatorTest, ValidateRequiredFieldsWithoutRules) {}

TEST_F(AddressValidatorTest,
       DoNotValidateRequiredFieldsWithoutRulesWhenErrorIsFiltered) {}

// Use this test fixture for configuring the number of failed attempts to load
// rules.
class FailingAddressValidatorTest : public testing::Test, LoadRulesListener {};

// The validator will attempt to load rules at most 8 times.
TEST_F(FailingAddressValidatorTest, RetryLoadingRulesHasLimit) {}

// The validator will load rules successfully if the source returns data
// before the maximum number of retries.
TEST_F(FailingAddressValidatorTest, RuleRetryingWillSucceed) {}

// The delayed task to retry loading rules should stop (instead of crashing) if
// the validator is destroyed before it fires.
TEST_F(FailingAddressValidatorTest, DestroyedValidatorStopsRetries) {}

// Each call to LoadRules should reset the number of retry attempts. If the
// first call to LoadRules exceeded the maximum number of retries, the second
// call to LoadRules should start counting the retries from zero.
TEST_F(FailingAddressValidatorTest, LoadingRulesSecondTimeSucceeds) {}

// Calling LoadRules("CH") and LoadRules("GB") simultaneously should attempt to
// load both rules up to the maximum number of attempts for each region.
TEST_F(FailingAddressValidatorTest, RegionsShouldRetryIndividually) {}

}  // namespace autofill