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

Unified Diff: third_party/libaddressinput/chromium/cpp/test/address_ui_test.cc

Issue 208243005: Determine language code and type of format for address. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add ctime include. Created 6 years, 9 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
Index: third_party/libaddressinput/chromium/cpp/test/address_ui_test.cc
diff --git a/third_party/libaddressinput/chromium/cpp/test/address_ui_test.cc b/third_party/libaddressinput/chromium/cpp/test/address_ui_test.cc
index 8fa508a81418fa972d3415baa00d5dc47821dfb8..dadd8e76ef7a32aecb7b8441f0568a76b168e3ae 100644
--- a/third_party/libaddressinput/chromium/cpp/test/address_ui_test.cc
+++ b/third_party/libaddressinput/chromium/cpp/test/address_ui_test.cc
@@ -75,7 +75,8 @@ TEST(AddressUiTest, RegionsAndComponentsAreValid) {
for (size_t i = 0; i < region_codes.size(); ++i) {
SCOPED_TRACE("Region code: " + region_codes[i]);
EXPECT_EQ(2U, region_codes[i].size());
- EXPECT_TRUE(ComponentsAreValid(BuildComponents(region_codes[i])));
+ EXPECT_TRUE(ComponentsAreValid(
+ BuildComponents(region_codes[i], std::string(), NULL)));
EXPECT_FALSE(GetRequiredFields(region_codes[i]).empty());
}
}
@@ -83,7 +84,8 @@ TEST(AddressUiTest, RegionsAndComponentsAreValid) {
// Verifies that BuildComponents() and GetRequiredFields() return an empty
// vector for an invalid region code.
TEST(AddressUiTest, InvalidRegionCodeReturnsEmptyVector) {
- EXPECT_TRUE(BuildComponents("INVALID-REGION-CODE").empty());
+ EXPECT_TRUE(
+ BuildComponents("INVALID-REGION-CODE", std::string(), NULL).empty());
EXPECT_TRUE(GetRequiredFields("INVALID-REGION-CODE").empty());
}
@@ -119,6 +121,53 @@ INSTANTIATE_TEST_CASE_P(
SeparatorData("th", " "),
SeparatorData("en", ", ")));
+TEST(AddressUiTest, ComponentLanguageCodeTest) {
+ static const struct LanguageCodeData {
+ const char* region_code;
+ const char* ui_language_code;
+ const char* components_language_code;
+ } kLangugeCodes[] = {
+ {"AM", "", "hy"},
+ {"AM", "hy", "hy"},
+ {"AM", "en", "hy-latn"},
+ {"CN", "zh-hans", "zh-hans"},
+ {"CN", "zh-hant", "zh-hant"},
+ {"CN", "zh", "zh"},
+ {"CN", "zh-latn", "zh-latn"},
+ {"CN", "en", "zh-latn"},
+ {"CN", "ja", "zh-latn"},
+ {"CN", "ko", "zh-latn"},
+ {"HK", "zh", "zh"},
+ {"HK", "zh-hans", "zh-hans"},
+ {"HK", "zh-hant", "zh-hant"},
+ {"HK", "zh-latn", "zh-latn"},
+ {"HK", "en", "en"},
+ {"HK", "fr", "zh-latn"},
+ {"HK", "ja", "zh-latn"},
+ {"HK", "ko", "zh-latn"},
+ {"MO", "zh", "zh"},
+ {"MO", "pt", "pt"},
+ {"MO", "en", "zh-latn"},
+ {"AQ", "en", "en"},
+ {"AQ", "fr", "fr"},
+ {"AQ", "es", "es"},
+ {"AQ", "zh", "zh"}
+ };
+ static const size_t kArraySize =
+ sizeof kLangugeCodes / sizeof (LanguageCodeData);
+ for (size_t i = 0; i < kArraySize; ++i) {
+ SCOPED_TRACE(std::string("region code = ") +
+ kLangugeCodes[i].region_code + ", ui language code = " +
+ kLangugeCodes[i].ui_language_code + ", components language code = " +
+ kLangugeCodes[i].components_language_code);
+ std::string components_language_code;
+ EXPECT_FALSE(BuildComponents(kLangugeCodes[i].region_code,
+ kLangugeCodes[i].ui_language_code,
+ &components_language_code).empty());
+ EXPECT_EQ(
+ kLangugeCodes[i].components_language_code, components_language_code);
+ }
+}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698