| 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 "app/app_paths.h" | 7 #include "app/app_paths.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #if !defined(OS_MACOSX) | 9 #if !defined(OS_MACOSX) |
| 10 #include "app/test/data/resource.h" | 10 #include "app/test/data/resource.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Cocoa. | 99 // Cocoa. |
| 100 TEST_F(L10nUtilTest, GetAppLocale) { | 100 TEST_F(L10nUtilTest, GetAppLocale) { |
| 101 // Use a temporary locale dir so we don't have to actually build the locale | 101 // Use a temporary locale dir so we don't have to actually build the locale |
| 102 // dlls for this test. | 102 // dlls for this test. |
| 103 FilePath orig_locale_dir; | 103 FilePath orig_locale_dir; |
| 104 PathService::Get(app::DIR_LOCALES, &orig_locale_dir); | 104 PathService::Get(app::DIR_LOCALES, &orig_locale_dir); |
| 105 FilePath new_locale_dir; | 105 FilePath new_locale_dir; |
| 106 EXPECT_TRUE(file_util::CreateNewTempDirectory( | 106 EXPECT_TRUE(file_util::CreateNewTempDirectory( |
| 107 FILE_PATH_LITERAL("l10n_util_test"), | 107 FILE_PATH_LITERAL("l10n_util_test"), |
| 108 &new_locale_dir)); | 108 &new_locale_dir)); |
| 109 PathService::Override(app::DIR_LOCALES, new_locale_dir.ToWStringHack()); | 109 PathService::Override(app::DIR_LOCALES, new_locale_dir); |
| 110 // Make fake locale files. | 110 // Make fake locale files. |
| 111 std::string filenames[] = { | 111 std::string filenames[] = { |
| 112 "en-US", | 112 "en-US", |
| 113 "en-GB", | 113 "en-GB", |
| 114 "fr", | 114 "fr", |
| 115 "es-419", | 115 "es-419", |
| 116 "es", | 116 "es", |
| 117 "zh-TW", | 117 "zh-TW", |
| 118 "zh-CN", | 118 "zh-CN", |
| 119 "he", | 119 "he", |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"or")); | 203 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale(L"or")); |
| 204 } else { | 204 } else { |
| 205 SetICUDefaultLocale("or"); | 205 SetICUDefaultLocale("or"); |
| 206 EXPECT_EQ("or", l10n_util::GetApplicationLocale(L"")); | 206 EXPECT_EQ("or", l10n_util::GetApplicationLocale(L"")); |
| 207 SetICUDefaultLocale("en-GB"); | 207 SetICUDefaultLocale("en-GB"); |
| 208 EXPECT_EQ("or", l10n_util::GetApplicationLocale(L"or")); | 208 EXPECT_EQ("or", l10n_util::GetApplicationLocale(L"or")); |
| 209 } | 209 } |
| 210 #endif // defined(OS_WIN) | 210 #endif // defined(OS_WIN) |
| 211 | 211 |
| 212 // Clean up. | 212 // Clean up. |
| 213 PathService::Override(app::DIR_LOCALES, orig_locale_dir.ToWStringHack()); | 213 PathService::Override(app::DIR_LOCALES, orig_locale_dir); |
| 214 file_util::Delete(new_locale_dir, true); | 214 file_util::Delete(new_locale_dir, true); |
| 215 UErrorCode error_code = U_ZERO_ERROR; | 215 UErrorCode error_code = U_ZERO_ERROR; |
| 216 icu::Locale::setDefault(locale, error_code); | 216 icu::Locale::setDefault(locale, error_code); |
| 217 } | 217 } |
| 218 #endif // defined(OS_WIN) || defined(OS_LINUX) | 218 #endif // defined(OS_WIN) || defined(OS_LINUX) |
| 219 | 219 |
| 220 TEST_F(L10nUtilTest, SortStringsUsingFunction) { | 220 TEST_F(L10nUtilTest, SortStringsUsingFunction) { |
| 221 std::vector<StringWrapper*> strings; | 221 std::vector<StringWrapper*> strings; |
| 222 strings.push_back(new StringWrapper(L"C")); | 222 strings.push_back(new StringWrapper(L"C")); |
| 223 strings.push_back(new StringWrapper(L"d")); | 223 strings.push_back(new StringWrapper(L"d")); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("en")); | 432 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("en")); |
| 433 // Chinese in China with '-'. | 433 // Chinese in China with '-'. |
| 434 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("zh-CN")); | 434 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("zh-CN")); |
| 435 // Filipino : 3-letter code | 435 // Filipino : 3-letter code |
| 436 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("fil")); | 436 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("fil")); |
| 437 // Russian | 437 // Russian |
| 438 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ru")); | 438 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ru")); |
| 439 // Japanese that uses multiple scripts | 439 // Japanese that uses multiple scripts |
| 440 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ja")); | 440 EXPECT_EQ(l10n_util::LEFT_TO_RIGHT, GetTextDirection("ja")); |
| 441 } | 441 } |
| OLD | NEW |