diff options
author | msramek <msramek@chromium.org> | 2015-08-18 00:01:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-18 07:02:11 +0000 |
commit | c17ed8c0967143aac1b3dbe656215eb245f721cc (patch) | |
tree | 31265d820bb963b8baafdf9480a499744e46a69c /extensions/common/extension_l10n_util_unittest.cc | |
parent | 118d8e025b9d81226a5c3cfaf9be74d635b0a6a9 (diff) | |
download | chromium_src-c17ed8c0967143aac1b3dbe656215eb245f721cc.zip chromium_src-c17ed8c0967143aac1b3dbe656215eb245f721cc.tar.gz chromium_src-c17ed8c0967143aac1b3dbe656215eb245f721cc.tar.bz2 |
Revert of Remove extraneous GetValidLocales calls. (patchset #6 id:100001 of https://codereview.chromium.org/1281523005/ )
Reason for revert:
Test breakage in build http://build.chromium.org/p/chromium.linux/builders/Linux%20Tests%20%28dbg%29%281%29/builds/46007 .
Stack traces point to extension_l10n_util.
Original issue's description:
> 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}
TBR=asargent@chromium.org,erikchen@chromium.org,robliao@chromium.org,sydli@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=516745
Review URL: https://codereview.chromium.org/1298093005
Cr-Commit-Position: refs/heads/master@{#343844}
Diffstat (limited to 'extensions/common/extension_l10n_util_unittest.cc')
-rw-r--r-- | extensions/common/extension_l10n_util_unittest.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/extensions/common/extension_l10n_util_unittest.cc b/extensions/common/extension_l10n_util_unittest.cc index d269501..03feeab 100644 --- a/extensions/common/extension_l10n_util_unittest.cc +++ b/extensions/common/extension_l10n_util_unittest.cc @@ -128,8 +128,12 @@ 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", &error)); + install_dir, "sr", "en_US", locales, &error)); ASSERT_FALSE(NULL == bundle.get()); EXPECT_TRUE(error.empty()); EXPECT_EQ("Color", bundle->GetL10nMessage("color")); @@ -142,12 +146,13 @@ 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", &error)); + EXPECT_TRUE(NULL == extension_l10n_util::LoadMessageCatalogs( + src_path, "en", "sr", valid_locales, &error)); EXPECT_FALSE(error.empty()); } @@ -165,9 +170,12 @@ 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", &error)); + src_path, "en_US", "sr", valid_locales, &error)); EXPECT_EQ(ErrorUtils::FormatErrorMessage( errors::kLocalesInvalidLocale, base::UTF16ToUTF8(messages_file.LossyDisplayName()), @@ -197,11 +205,15 @@ 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", &error)); + extension_l10n_util::LoadMessageCatalogs( + src_path, "en", "sr", valid_locales, &error)); EXPECT_TRUE(NULL != message_bundle.get()); EXPECT_TRUE(error.empty()); } |