diff options
author | sydli <sydli@google.com> | 2015-08-19 10:57:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-19 17:58:01 +0000 |
commit | 5cc762fb20839736bfc9ed61202cb7daf9bab654 (patch) | |
tree | 78f72932c4a9c3718089c2d4c70304ce4ae9332b /extensions/common/extension_l10n_util_unittest.cc | |
parent | e8eb9894ccb9b48af52b533397212f158244df91 (diff) | |
download | chromium_src-5cc762fb20839736bfc9ed61202cb7daf9bab654.zip chromium_src-5cc762fb20839736bfc9ed61202cb7daf9bab654.tar.gz chromium_src-5cc762fb20839736bfc9ed61202cb7daf9bab654.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
Committed: https://crrev.com/0db5da63004e13f458c5a76391da1b309222d71e
Cr-Commit-Position: refs/heads/master@{#343805}
Review URL: https://codereview.chromium.org/1281523005
Cr-Commit-Position: refs/heads/master@{#344269}
Diffstat (limited to 'extensions/common/extension_l10n_util_unittest.cc')
-rw-r--r-- | extensions/common/extension_l10n_util_unittest.cc | 26 |
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()); } |