Chromium Code Reviews| Index: third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc |
| diff --git a/third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc b/third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc |
| index 13b5a8b4cc32ac547bdc2ef42cc3b7bb7b602a33..a498a3b52e35fbb0a3f775b3dfb158c3e03f15eb 100644 |
| --- a/third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc |
| +++ b/third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include "third_party/libaddressinput/chromium/chrome_address_validator.h" |
| #include <stddef.h> |
| +#include <set> |
| #include <string> |
| #include <utility> |
| #include <vector> |
| @@ -67,8 +68,8 @@ class AddressValidatorTest : public testing::Test, LoadRulesListener { |
| private: |
| // LoadRulesListener implementation. |
| - virtual void OnAddressValidationRulesLoaded(const std::string& country_code, |
| - bool success) override { |
| + void OnAddressRulesLoaded(const std::string& country_code, |
| + bool success) override { |
| AddressData address_data; |
| address_data.region_code = country_code; |
| FieldProblemMap dummy; |
| @@ -110,6 +111,26 @@ class LargeAddressValidatorTest : public testing::Test { |
| AddressValidator* LargeAddressValidatorTest::validator_ = NULL; |
| +TEST_F(AddressValidatorTest, SubKeysLoaded) { |
| + std::string country_code = "US"; |
|
Mathieu
2017/03/24 17:24:33
const to both
Parastoo
2017/03/24 22:42:23
Done.
|
| + std::string first_state = "AL"; |
| + |
| + validator_->LoadRules(country_code); |
| + std::vector<std::string> sub_keys = |
| + validator_->GetRegionSubKeys(country_code); |
| + ASSERT_FALSE(sub_keys.empty()); |
| + ASSERT_EQ(sub_keys[0], first_state); |
| +} |
| + |
| +TEST_F(AddressValidatorTest, SubKeysNotLoaded) { |
| + std::string country_code = "ZZ"; |
| + |
| + validator_->LoadRules(country_code); |
| + std::vector<std::string> sub_keys = |
| + validator_->GetRegionSubKeys(country_code); |
| + ASSERT_TRUE(sub_keys.empty()); |
| +} |
| + |
| TEST_F(AddressValidatorTest, RegionHasRules) { |
| const std::vector<std::string>& region_codes = GetRegionCodes(); |
| AddressData address; |
| @@ -758,7 +779,7 @@ class FailingAddressValidatorTest : public testing::Test, LoadRulesListener { |
| virtual ~TestAddressValidator() {} |
| protected: |
| - virtual base::TimeDelta GetBaseRetryPeriod() const override { |
| + base::TimeDelta GetBaseRetryPeriod() const override { |
| return base::TimeDelta::FromSeconds(0); |
| } |
| @@ -770,7 +791,7 @@ class FailingAddressValidatorTest : public testing::Test, LoadRulesListener { |
| // data. |
| class FailingSource : public Source { |
| public: |
| - explicit FailingSource() |
| + FailingSource() |
| : failures_number_(0), attempts_number_(0), actual_source_(true) {} |
| virtual ~FailingSource() {} |
| @@ -781,8 +802,7 @@ class FailingAddressValidatorTest : public testing::Test, LoadRulesListener { |
| // Source implementation. |
| // Always fails for the first |failures_number| times. |
| - virtual void Get(const std::string& url, |
| - const Callback& callback) const override { |
| + void Get(const std::string& url, const Callback& callback) const override { |
| ++attempts_number_; |
| // |callback| takes ownership of the |new std::string|. |
| if (failures_number_-- > 0) |
| @@ -823,8 +843,7 @@ class FailingAddressValidatorTest : public testing::Test, LoadRulesListener { |
| private: |
| // LoadRulesListener implementation. |
| - virtual void OnAddressValidationRulesLoaded(const std::string&, |
| - bool success) override { |
| + void OnAddressRulesLoaded(const std::string&, bool success) override { |
| load_rules_success_ = success; |
| } |