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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« app/l10n_util.cc ('K') | « app/l10n_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_LINUX)
8 #include <cstdlib>
9 #endif
10
7 #include "app/app_paths.h" 11 #include "app/app_paths.h"
8 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
9 #if !defined(OS_MACOSX) 13 #if !defined(OS_MACOSX)
10 #include "app/test/data/resource.h" 14 #include "app/test/data/resource.h"
11 #endif 15 #endif
12 #include "base/basictypes.h" 16 #include "base/basictypes.h"
13 #include "base/file_util.h" 17 #include "base/file_util.h"
14 #include "base/path_service.h" 18 #include "base/path_service.h"
15 #include "base/stl_util-inl.h" 19 #include "base/stl_util-inl.h"
16 #include "base/string_util.h" 20 #include "base/string_util.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 #endif 133 #endif
130 for (size_t i = 0; i < arraysize(filenames); ++i) { 134 for (size_t i = 0; i < arraysize(filenames); ++i) {
131 FilePath filename = new_locale_dir.AppendASCII( 135 FilePath filename = new_locale_dir.AppendASCII(
132 filenames[i] + kLocaleFileExtension); 136 filenames[i] + kLocaleFileExtension);
133 file_util::WriteFile(filename, "", 0); 137 file_util::WriteFile(filename, "", 0);
134 } 138 }
135 139
136 // Keep a copy of ICU's default locale before we overwrite it. 140 // Keep a copy of ICU's default locale before we overwrite it.
137 icu::Locale locale = icu::Locale::getDefault(); 141 icu::Locale locale = icu::Locale::getDefault();
138 142
143 #if defined(OS_LINUX)
144 // Test the support of LANGUAGE environment variable.
145 SetICUDefaultLocale("en-US");
146 ::setenv("LANGUAGE", "xx:fr_CA", 1);
147 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L""));
148
149 ::setenv("LANGUAGE", "xx:yy:en_gb.utf-8@quot", 1);
150 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L""));
151
152 ::setenv("LANGUAGE", "xx:zh-hk", 1);
153 EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(L""));
154
155 SetICUDefaultLocale("fr-FR");
156 ::setenv("LANGUAGE", "xx:yy", 1);
157 EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
158
159 ::setenv("LANGUAGE", "/fr:zh_CN", 1);
160 EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(L""));
161
162 // Make sure the follow tests won't be affected by LANGUAGE environment
163 // variable.
164 ::unsetenv("LANGUAGE");
tony 2009/09/28 17:38:46 Nit: We should probably cache the environment vari
165 #endif
166
139 SetICUDefaultLocale("en-US"); 167 SetICUDefaultLocale("en-US");
140 EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L"")); 168 EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(L""));
141 169
142 SetICUDefaultLocale("en-GB"); 170 SetICUDefaultLocale("en-GB");
143 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"")); 171 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L""));
144 172
145 SetICUDefaultLocale("fr-CA"); 173 SetICUDefaultLocale("fr-CA");
146 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L"")); 174 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(L""));
147 175
148 SetICUDefaultLocale("xx"); 176 SetICUDefaultLocale("xx");
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 string16 mixed(ASCIIToUTF16("Text with UPPer & lowER casE.")); 500 string16 mixed(ASCIIToUTF16("Text with UPPer & lowER casE."));
473 const string16 expected_lower(ASCIIToUTF16("text with upper & lower case.")); 501 const string16 expected_lower(ASCIIToUTF16("text with upper & lower case."));
474 const string16 expected_upper(ASCIIToUTF16("TEXT WITH UPPER & LOWER CASE.")); 502 const string16 expected_upper(ASCIIToUTF16("TEXT WITH UPPER & LOWER CASE."));
475 503
476 string16 result = l10n_util::ToLower(mixed); 504 string16 result = l10n_util::ToLower(mixed);
477 EXPECT_EQ(result, expected_lower); 505 EXPECT_EQ(result, expected_lower);
478 506
479 result = l10n_util::ToUpper(mixed); 507 result = l10n_util::ToUpper(mixed);
480 EXPECT_EQ(result, expected_upper); 508 EXPECT_EQ(result, expected_upper);
481 } 509 }
482
OLDNEW
« 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