summaryrefslogtreecommitdiffstats
path: root/extensions/common/extension_l10n_util_unittest.cc
diff options
context:
space:
mode:
authorsydli <sydli@google.com>2015-08-17 22:12:31 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-18 05:13:09 +0000
commit0db5da63004e13f458c5a76391da1b309222d71e (patch)
tree97b7fd7fa1ed4f54202ed5719fade4626bc343cd /extensions/common/extension_l10n_util_unittest.cc
parent7a694fe11fb4602ddd56edfa34a1b48f26049f63 (diff)
downloadchromium_src-0db5da63004e13f458c5a76391da1b309222d71e.zip
chromium_src-0db5da63004e13f458c5a76391da1b309222d71e.tar.gz
chromium_src-0db5da63004e13f458c5a76391da1b309222d71e.tar.bz2
Remove extraneous GetValidLocales calls.
GetValidLocales is already called on first extension install. There's no need to check the locales again (i.e. on extension loading) until a new install. GetValidLocales can be costly since it stats all subdirectories and messages.json of an extension's _locales subfolder. BUG=516745 Review URL: https://codereview.chromium.org/1281523005 Cr-Commit-Position: refs/heads/master@{#343805}
Diffstat (limited to 'extensions/common/extension_l10n_util_unittest.cc')
-rw-r--r--extensions/common/extension_l10n_util_unittest.cc26
1 files changed, 7 insertions, 19 deletions
diff --git a/extensions/common/extension_l10n_util_unittest.cc b/extensions/common/extension_l10n_util_unittest.cc
index 03feeab..d269501 100644
--- a/extensions/common/extension_l10n_util_unittest.cc
+++ b/extensions/common/extension_l10n_util_unittest.cc
@@ -128,12 +128,8 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsValidFallback) {
install_dir.AppendASCII("extension_with_locales").Append(kLocaleFolder);
std::string error;
- std::set<std::string> locales;
- EXPECT_TRUE(
- extension_l10n_util::GetValidLocales(install_dir, &locales, &error));
-
scoped_ptr<MessageBundle> bundle(extension_l10n_util::LoadMessageCatalogs(
- install_dir, "sr", "en_US", locales, &error));
+ install_dir, "sr", "en_US", &error));
ASSERT_FALSE(NULL == bundle.get());
EXPECT_TRUE(error.empty());
EXPECT_EQ("Color", bundle->GetL10nMessage("color"));
@@ -146,13 +142,12 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsMissingFiles) {
base::FilePath src_path = temp.path().Append(kLocaleFolder);
ASSERT_TRUE(base::CreateDirectory(src_path));
+ ASSERT_TRUE(base::CreateDirectory(src_path.AppendASCII("en")));
+ ASSERT_TRUE(base::CreateDirectory(src_path.AppendASCII("sr")));
- std::set<std::string> valid_locales;
- valid_locales.insert("sr");
- valid_locales.insert("en");
std::string error;
- EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(
- src_path, "en", "sr", valid_locales, &error));
+ EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(src_path, "en",
+ "sr", &error));
EXPECT_FALSE(error.empty());
}
@@ -170,12 +165,9 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsBadJSONFormat) {
base::FilePath messages_file = locale.Append(kMessagesFilename);
ASSERT_TRUE(base::WriteFile(messages_file, data.c_str(), data.length()));
- std::set<std::string> valid_locales;
- valid_locales.insert("sr");
- valid_locales.insert("en_US");
std::string error;
EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs(
- src_path, "en_US", "sr", valid_locales, &error));
+ src_path, "en_US", "sr", &error));
EXPECT_EQ(ErrorUtils::FormatErrorMessage(
errors::kLocalesInvalidLocale,
base::UTF16ToUTF8(messages_file.LossyDisplayName()),
@@ -205,15 +197,11 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) {
ASSERT_TRUE(base::WriteFile(
locale_2.Append(kMessagesFilename), data.c_str(), data.length()));
- std::set<std::string> valid_locales;
- valid_locales.insert("sr");
- valid_locales.insert("en");
std::string error;
// JSON parser hides duplicates. We are going to get only one key/value
// pair at the end.
scoped_ptr<MessageBundle> message_bundle(
- extension_l10n_util::LoadMessageCatalogs(
- src_path, "en", "sr", valid_locales, &error));
+ extension_l10n_util::LoadMessageCatalogs(src_path, "en", "sr", &error));
EXPECT_TRUE(NULL != message_bundle.get());
EXPECT_TRUE(error.empty());
}