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

Unified Diff: app/l10n_util_unittest.cc

Issue 236001: [Linux] Supports the LANGUAGE environment variable.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
« app/l10n_util.cc ('K') | « app/l10n_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/l10n_util_unittest.cc
===================================================================
--- app/l10n_util_unittest.cc (revision 27176)
+++ app/l10n_util_unittest.cc (working copy)
@@ -4,6 +4,10 @@
#include "build/build_config.h"
+#if defined(OS_LINUX)
+#include <cstdlib>
+#endif
+
#include "app/app_paths.h"
#include "app/l10n_util.h"
#if !defined(OS_MACOSX)
@@ -136,9 +140,33 @@
// Keep a copy of ICU's default locale before we overwrite it.
icu::Locale locale = icu::Locale::getDefault();
+#if defined(OS_LINUX)
+ // Test the support of LANGUAGE environment variable.
SetICUDefaultLocale("en-US");
+ ::setenv("LANGUAGE", "xx:fr_CA", 1);
+ EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L""));
+
+ ::setenv("LANGUAGE", "xx:yy:en_gb.utf-8@quot", 1);
+ EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L""));
+
+ ::setenv("LANGUAGE", "xx:zh-hk", 1);
+ EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(L""));
+
+ SetICUDefaultLocale("fr-FR");
+ ::setenv("LANGUAGE", "xx:yy", 1);
EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
+ ::setenv("LANGUAGE", "/fr:zh_CN", 1);
+ EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L""));
+
+ // Make sure the follow tests won't be affected by LANGUAGE environment
+ // variable.
+ ::unsetenv("LANGUAGE");
tony 2009/09/28 17:38:46 Nit: We should probably cache the environment vari
+#endif
+
+ SetICUDefaultLocale("en-US");
+ EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
+
SetICUDefaultLocale("en-GB");
EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L""));
@@ -479,4 +507,3 @@
result = l10n_util::ToUpper(mixed);
EXPECT_EQ(result, expected_upper);
}
-
« app/l10n_util.cc ('K') | « app/l10n_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698