Index: chrome/common/extensions/extension_l10n_util_unittest.cc |
=================================================================== |
--- chrome/common/extensions/extension_l10n_util_unittest.cc (revision 67716) |
+++ chrome/common/extensions/extension_l10n_util_unittest.cc (working copy) |
@@ -225,6 +225,42 @@ |
EXPECT_EQ("sr", locales[2]); |
} |
+TEST(ExtensionL10nUtil, IsValidLocaleSyntax) { |
+ // Test valid locales. |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("en")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("fr")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("de")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("pt")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("zh")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("fil")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("haw")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("en-US")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("en_US")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("en_GB")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("pt-BR")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("zh_Hans")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("zh_Hans_CN")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("zh_Hant")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("zh_Hant_TW")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("fr_CA")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("i-klingon")); |
+ EXPECT_EQ(true, extension_l10n_util::IsValidLocaleSyntax("es-021")); |
+ |
+ // Test invalid locales. |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("x")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("enUS")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("zhcn")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("en.US")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("en#US")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("-en-US")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("en-US-")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("Latin")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("German")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("pt--BR")); |
+ EXPECT_EQ(false, extension_l10n_util::IsValidLocaleSyntax("sl-macedonia")); |
+} |
+ |
// Caller owns the returned object. |
ExtensionMessageBundle* CreateManifestBundle() { |
linked_ptr<DictionaryValue> catalog(new DictionaryValue); |