Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1248)

Unified Diff: third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc

Issue 2966103002: [Payments] Show admin area complete names on PR form. (Closed)
Patch Set: Small Changes. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libaddressinput/chromium/chrome_address_validator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 54c37e49383e1c1d44a18206ade19db6a66c763f..4116f5da91e5755787a9af337f67e3eb8683904a 100644
--- a/third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc
+++ b/third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc
@@ -120,23 +120,83 @@ AddressValidator* LargeAddressValidatorTest::validator_ = NULL;
TEST_F(AddressValidatorTest, SubKeysLoaded) {
const std::string country_code = "US";
- const std::string first_state = "AL";
+ const std::string state_code = "AL";
+ const std::string state_name = "Alabama";
+ const std::string language = "en";
validator_->LoadRules(country_code);
- std::vector<std::string> sub_keys =
- validator_->GetRegionSubKeys(country_code);
+ std::vector<std::pair<std::string, std::string>> sub_keys =
+ validator_->GetRegionSubKeys(country_code, language);
ASSERT_FALSE(sub_keys.empty());
- ASSERT_EQ(sub_keys[0], first_state);
+ ASSERT_EQ(state_code, sub_keys[0].first);
+ ASSERT_EQ(state_name, sub_keys[0].second);
+}
+
+TEST_F(AddressValidatorTest, SubKeysLoaded_DefaultLanguage) {
+ const std::string country_code = "CA";
+ const std::string province_code = "BC";
+ const std::string province_name = "British Columbia";
+ const std::string language = "en";
+
+ validator_->LoadRules(country_code);
+ std::vector<std::pair<std::string, std::string>> sub_keys =
+ validator_->GetRegionSubKeys(country_code, language);
+ ASSERT_FALSE(sub_keys.empty());
+ ASSERT_EQ(province_code, sub_keys[1].first);
+ ASSERT_EQ(province_name, sub_keys[1].second);
+}
+
+TEST_F(AddressValidatorTest, SubKeysLoaded_NonDefaultLanguage) {
+ const std::string country_code = "CA";
+ const std::string province_code = "BC";
+ const std::string province_name = "Colombie-Britannique";
+ const std::string language = "fr";
+
+ validator_->LoadRules(country_code);
+ std::vector<std::pair<std::string, std::string>> sub_keys =
+ validator_->GetRegionSubKeys(country_code, language);
+ ASSERT_FALSE(sub_keys.empty());
+ ASSERT_EQ(province_code, sub_keys[1].first);
+ ASSERT_EQ(province_name, sub_keys[1].second);
+}
+
+TEST_F(AddressValidatorTest, SubKeysLoaded_LanguageNotAvailable) {
+ const std::string country_code = "CA";
+ const std::string province_code = "BC";
+ const std::string province_name = "British Columbia";
+ const std::string language = "es";
+
+ validator_->LoadRules(country_code);
+ std::vector<std::pair<std::string, std::string>> sub_keys =
+ validator_->GetRegionSubKeys(country_code, language);
+ ASSERT_FALSE(sub_keys.empty());
+ ASSERT_EQ(province_code, sub_keys[1].first);
+ ASSERT_EQ(province_name, sub_keys[1].second);
+}
+
+TEST_F(AddressValidatorTest, SubKeysLoaded_NamesNotAvailable) {
+ const std::string country_code = "ES";
+ const std::string province_code = "A Coruña";
+ const std::string province_name = "A Coruña";
+ const std::string language = "es";
+
+ validator_->LoadRules(country_code);
+ std::vector<std::pair<std::string, std::string>> sub_keys =
+ validator_->GetRegionSubKeys(country_code, language);
+ ASSERT_FALSE(sub_keys.empty());
+ ASSERT_EQ(province_code, sub_keys[0].first);
+ ASSERT_EQ(province_name, sub_keys[0].second);
}
TEST_F(AddressValidatorTest, SubKeysNotExist) {
const std::string country_code = "OZ";
+ const std::string language = "en";
set_expected_status(AddressValidator::RULES_UNAVAILABLE);
validator_->LoadRules(country_code);
- std::vector<std::string> sub_keys =
- validator_->GetRegionSubKeys(country_code);
+ std::vector<std::pair<std::string, std::string>> sub_keys =
+ validator_->GetRegionSubKeys(country_code, language);
ASSERT_TRUE(sub_keys.empty());
}
« no previous file with comments | « third_party/libaddressinput/chromium/chrome_address_validator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698