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

Unified Diff: chrome/browser/extensions/extension_l10n_util_unittest.cc

Issue 316013: Loading local resources uses improved fallback algorithm.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « chrome/browser/extensions/extension_l10n_util.cc ('k') | chrome/common/extensions/extension_resource.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_l10n_util_unittest.cc
===================================================================
--- chrome/browser/extensions/extension_l10n_util_unittest.cc (revision 29776)
+++ chrome/browser/extensions/extension_l10n_util_unittest.cc (working copy)
@@ -183,6 +183,17 @@
EXPECT_TRUE(error.empty());
}
+TEST(ExtensionL10nUtil, GetParentLocales) {
+ std::vector<std::string> locales;
+ const std::string top_locale("sr_Cyrl_RS");
+ extension_l10n_util::GetParentLocales(top_locale, &locales);
+
+ ASSERT_EQ(3U, locales.size());
+ EXPECT_EQ("sr_Cyrl_RS", locales[0]);
+ EXPECT_EQ("sr_Cyrl", locales[1]);
+ EXPECT_EQ("sr", locales[2]);
+}
+
bool PathsAreEqual(const FilePath& path1, const FilePath& path2) {
FilePath::StringType path1_str = path1.value();
std::replace(path1_str.begin(), path1_str.end(), '\\', '/');
@@ -198,19 +209,24 @@
}
TEST(ExtensionL10nUtil, GetL10nRelativePath) {
- static std::string current_locale = l10n_util::GetApplicationLocale(L"");
- std::replace(current_locale.begin(), current_locale.end(), '-', '_');
+ static std::string current_locale =
+ extension_l10n_util::NormalizeLocale(l10n_util::GetApplicationLocale(L""));
- FilePath locale_path;
- locale_path = locale_path
- .AppendASCII(Extension::kLocaleFolder)
- .AppendASCII(current_locale)
- .AppendASCII("foo")
- .AppendASCII("bar.js");
+ std::vector<FilePath> l10n_paths;
+ extension_l10n_util::GetL10nRelativePaths(
+ FilePath(FILE_PATH_LITERAL("foo/bar.js")), &l10n_paths);
+ ASSERT_FALSE(l10n_paths.empty());
- FilePath result = extension_l10n_util::GetL10nRelativePath(
- FilePath(FILE_PATH_LITERAL("foo/bar.js")));
- EXPECT_TRUE(PathsAreEqual(locale_path, result));
+ std::vector<std::string> locales;
+ extension_l10n_util::GetParentLocales(current_locale, &locales);
+ ASSERT_EQ(locales.size(), l10n_paths.size());
+
+ for (size_t i = 0; i < locales.size(); ++i) {
+ FilePath tmp;
+ tmp = tmp.AppendASCII(Extension::kLocaleFolder)
+ .AppendASCII(locales[i]).AppendASCII("foo/bar.js");
+ EXPECT_TRUE(PathsAreEqual(tmp, l10n_paths[i]));
+ }
}
} // namespace
« no previous file with comments | « chrome/browser/extensions/extension_l10n_util.cc ('k') | chrome/common/extensions/extension_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698