OLD | NEW |
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 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #if defined(OS_WIN) |
| 12 #include "base/win_util.h" |
| 13 #endif |
11 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/common/l10n_util.h" | 15 #include "chrome/common/l10n_util.h" |
13 #include "chrome/common/stl_util-inl.h" | 16 #include "chrome/common/stl_util-inl.h" |
14 #if !defined(OS_MACOSX) | 17 #if !defined(OS_MACOSX) |
15 #include "chrome/test/data/resource.h" | 18 #include "chrome/test/data/resource.h" |
16 #endif | 19 #endif |
17 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
19 #include "unicode/locid.h" | 22 #include "unicode/locid.h" |
20 | 23 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 L"en-US", | 110 L"en-US", |
108 L"en-GB", | 111 L"en-GB", |
109 L"fr", | 112 L"fr", |
110 L"es-419", | 113 L"es-419", |
111 L"es", | 114 L"es", |
112 L"zh-TW", | 115 L"zh-TW", |
113 L"zh-CN", | 116 L"zh-CN", |
114 L"he", | 117 L"he", |
115 L"fil", | 118 L"fil", |
116 L"nb", | 119 L"nb", |
| 120 L"or", |
117 }; | 121 }; |
118 | 122 |
119 #if defined(OS_WIN) | 123 #if defined(OS_WIN) |
120 static const wchar_t kLocaleFileExtension[] = L".dll"; | 124 static const wchar_t kLocaleFileExtension[] = L".dll"; |
121 #elif defined(OS_POSIX) | 125 #elif defined(OS_POSIX) |
122 static const wchar_t kLocaleFileExtension[] = L".pak"; | 126 static const wchar_t kLocaleFileExtension[] = L".pak"; |
123 #endif | 127 #endif |
124 for (size_t i = 0; i < arraysize(filenames); ++i) { | 128 for (size_t i = 0; i < arraysize(filenames); ++i) { |
125 std::wstring filename = new_locale_dir; | 129 std::wstring filename = new_locale_dir; |
126 file_util::AppendToPath(&filename, filenames[i]); | 130 file_util::AppendToPath(&filename, filenames[i]); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 181 |
178 SetICUDefaultLocale(L"zh-MK"); | 182 SetICUDefaultLocale(L"zh-MK"); |
179 EXPECT_EQ(L"zh-TW", l10n_util::GetApplicationLocale(L"")); | 183 EXPECT_EQ(L"zh-TW", l10n_util::GetApplicationLocale(L"")); |
180 | 184 |
181 SetICUDefaultLocale(L"zh-SG"); | 185 SetICUDefaultLocale(L"zh-SG"); |
182 EXPECT_EQ(L"zh-CN", l10n_util::GetApplicationLocale(L"")); | 186 EXPECT_EQ(L"zh-CN", l10n_util::GetApplicationLocale(L"")); |
183 | 187 |
184 SetICUDefaultLocale(L"he"); | 188 SetICUDefaultLocale(L"he"); |
185 EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en")); | 189 EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en")); |
186 | 190 |
| 191 #if defined(OS_WIN) |
| 192 // Oriya should be blocked unless OS is Vista or newer. |
| 193 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { |
| 194 SetICUDefaultLocale(L"or"); |
| 195 EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"")); |
| 196 SetICUDefaultLocale(L"en-GB"); |
| 197 EXPECT_EQ(L"en-GB", l10n_util::GetApplicationLocale(L"or")); |
| 198 } else { |
| 199 SetICUDefaultLocale(L"or"); |
| 200 EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L"")); |
| 201 SetICUDefaultLocale(L"en-GB"); |
| 202 EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L"or")); |
| 203 } |
| 204 #endif |
| 205 |
187 // Clean up. | 206 // Clean up. |
188 PathService::Override(chrome::DIR_LOCALES, orig_locale_dir); | 207 PathService::Override(chrome::DIR_LOCALES, orig_locale_dir); |
189 file_util::Delete(new_locale_dir, true); | 208 file_util::Delete(new_locale_dir, true); |
190 UErrorCode error_code = U_ZERO_ERROR; | 209 UErrorCode error_code = U_ZERO_ERROR; |
191 Locale::setDefault(locale, error_code); | 210 Locale::setDefault(locale, error_code); |
192 } | 211 } |
193 #endif | 212 #endif |
194 | 213 |
195 TEST_F(L10nUtilTest, SortStringsUsingFunction) { | 214 TEST_F(L10nUtilTest, SortStringsUsingFunction) { |
196 std::vector<StringWrapper*> strings; | 215 std::vector<StringWrapper*> strings; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("en")); | 420 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("en")); |
402 // Chinese in China with '-'. | 421 // Chinese in China with '-'. |
403 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("zh-CN")); | 422 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("zh-CN")); |
404 // Filipino : 3-letter code | 423 // Filipino : 3-letter code |
405 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("fil")); | 424 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("fil")); |
406 // Russian | 425 // Russian |
407 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ru")); | 426 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ru")); |
408 // Japanese that uses multiple scripts | 427 // Japanese that uses multiple scripts |
409 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ja")); | 428 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ja")); |
410 } | 429 } |
OLD | NEW |