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

Side by Side Diff: app/l10n_util_unittest.cc

Issue 2836088: base: rename Environment::SetEnv to Environment::SetVar. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | base/environment.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_POSIX) && !defined(OS_MACOSX) 7 #if defined(OS_POSIX) && !defined(OS_MACOSX)
8 #include <cstdlib> 8 #include <cstdlib>
9 #endif 9 #endif
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 // Keep a copy of ICU's default locale before we overwrite it. 139 // Keep a copy of ICU's default locale before we overwrite it.
140 icu::Locale locale = icu::Locale::getDefault(); 140 icu::Locale locale = icu::Locale::getDefault();
141 141
142 #if defined(OS_POSIX) && !defined(OS_CHROMEOS) 142 #if defined(OS_POSIX) && !defined(OS_CHROMEOS)
143 scoped_ptr<base::Environment> env(base::Environment::Create()); 143 scoped_ptr<base::Environment> env(base::Environment::Create());
144 144
145 // Test the support of LANGUAGE environment variable. 145 // Test the support of LANGUAGE environment variable.
146 SetICUDefaultLocale("en-US"); 146 SetICUDefaultLocale("en-US");
147 env->SetEnv("LANGUAGE", "xx:fr_CA"); 147 env->SetVar("LANGUAGE", "xx:fr_CA");
148 EXPECT_EQ("fr", l10n_util::GetApplicationLocale("")); 148 EXPECT_EQ("fr", l10n_util::GetApplicationLocale(""));
149 149
150 env->SetEnv("LANGUAGE", "xx:yy:en_gb.utf-8@quot"); 150 env->SetVar("LANGUAGE", "xx:yy:en_gb.utf-8@quot");
151 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale("")); 151 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(""));
152 152
153 env->SetEnv("LANGUAGE", "xx:zh-hk"); 153 env->SetVar("LANGUAGE", "xx:zh-hk");
154 EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale("")); 154 EXPECT_EQ("zh-TW", l10n_util::GetApplicationLocale(""));
155 155
156 // We emulate gettext's behavior here, which ignores LANG/LC_MESSAGES/LC_ALL 156 // We emulate gettext's behavior here, which ignores LANG/LC_MESSAGES/LC_ALL
157 // when LANGUAGE is specified. If no language specified in LANGUAGE is valid, 157 // when LANGUAGE is specified. If no language specified in LANGUAGE is valid,
158 // then just fallback to the default language, which is en-US for us. 158 // then just fallback to the default language, which is en-US for us.
159 SetICUDefaultLocale("fr-FR"); 159 SetICUDefaultLocale("fr-FR");
160 env->SetEnv("LANGUAGE", "xx:yy"); 160 env->SetVar("LANGUAGE", "xx:yy");
161 EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); 161 EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(""));
162 162
163 env->SetEnv("LANGUAGE", "/fr:zh_CN"); 163 env->SetVar("LANGUAGE", "/fr:zh_CN");
164 EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale("")); 164 EXPECT_EQ("zh-CN", l10n_util::GetApplicationLocale(""));
165 165
166 // Make sure the follow tests won't be affected by LANGUAGE environment 166 // Make sure the follow tests won't be affected by LANGUAGE environment
167 // variable. 167 // variable.
168 env->UnSetVar("LANGUAGE"); 168 env->UnSetVar("LANGUAGE");
169 #endif // defined(OS_POSIX) && !defined(OS_CHROMEOS) 169 #endif // defined(OS_POSIX) && !defined(OS_CHROMEOS)
170 170
171 SetICUDefaultLocale("en-US"); 171 SetICUDefaultLocale("en-US");
172 EXPECT_EQ("en-US", l10n_util::GetApplicationLocale("")); 172 EXPECT_EQ("en-US", l10n_util::GetApplicationLocale(""));
173 173
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 result = l10n_util::GetDisplayNameForLocale("zh-TW", "en", false); 296 result = l10n_util::GetDisplayNameForLocale("zh-TW", "en", false);
297 EXPECT_EQ(result, ASCIIToUTF16("Chinese (Traditional Han)")); 297 EXPECT_EQ(result, ASCIIToUTF16("Chinese (Traditional Han)"));
298 298
299 result = l10n_util::GetDisplayNameForLocale("pt-BR", "en", false); 299 result = l10n_util::GetDisplayNameForLocale("pt-BR", "en", false);
300 EXPECT_EQ(result, ASCIIToUTF16("Portuguese (Brazil)")); 300 EXPECT_EQ(result, ASCIIToUTF16("Portuguese (Brazil)"));
301 301
302 result = l10n_util::GetDisplayNameForLocale("es-419", "en", false); 302 result = l10n_util::GetDisplayNameForLocale("es-419", "en", false);
303 EXPECT_EQ(result, ASCIIToUTF16("Spanish (Latin America and the Caribbean)")); 303 EXPECT_EQ(result, ASCIIToUTF16("Spanish (Latin America and the Caribbean)"));
304 } 304 }
OLDNEW
« no previous file with comments | « no previous file | base/environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698