OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 #else | 83 #else |
84 base::i18n::SetICUDefaultLocale(tag); | 84 base::i18n::SetICUDefaultLocale(tag); |
85 #endif | 85 #endif |
86 } | 86 } |
87 | 87 |
88 TEST_F(L10nUtilTest, GetAppLocale) { | 88 TEST_F(L10nUtilTest, GetAppLocale) { |
89 scoped_ptr<base::Environment> env; | 89 scoped_ptr<base::Environment> env; |
90 // Use a temporary locale dir so we don't have to actually build the locale | 90 // Use a temporary locale dir so we don't have to actually build the locale |
91 // pak files for this test. | 91 // pak files for this test. |
92 base::ScopedPathOverride locale_dir_override(ui::DIR_LOCALES); | 92 base::ScopedPathOverride locale_dir_override(ui::DIR_LOCALES); |
93 FilePath new_locale_dir; | 93 base::FilePath new_locale_dir; |
94 ASSERT_TRUE(PathService::Get(ui::DIR_LOCALES, &new_locale_dir)); | 94 ASSERT_TRUE(PathService::Get(ui::DIR_LOCALES, &new_locale_dir)); |
95 // Make fake locale files. | 95 // Make fake locale files. |
96 std::string filenames[] = { | 96 std::string filenames[] = { |
97 "en-US", | 97 "en-US", |
98 "en-GB", | 98 "en-GB", |
99 "fr", | 99 "fr", |
100 "es-419", | 100 "es-419", |
101 "es", | 101 "es", |
102 "zh-TW", | 102 "zh-TW", |
103 "zh-CN", | 103 "zh-CN", |
104 "he", | 104 "he", |
105 "fil", | 105 "fil", |
106 "nb", | 106 "nb", |
107 "am", | 107 "am", |
108 "ca", | 108 "ca", |
109 "ca@valencia", | 109 "ca@valencia", |
110 }; | 110 }; |
111 | 111 |
112 for (size_t i = 0; i < arraysize(filenames); ++i) { | 112 for (size_t i = 0; i < arraysize(filenames); ++i) { |
113 FilePath filename = new_locale_dir.AppendASCII( | 113 base::FilePath filename = new_locale_dir.AppendASCII( |
114 filenames[i] + ".pak"); | 114 filenames[i] + ".pak"); |
115 file_util::WriteFile(filename, "", 0); | 115 file_util::WriteFile(filename, "", 0); |
116 } | 116 } |
117 | 117 |
118 // Keep a copy of ICU's default locale before we overwrite it. | 118 // Keep a copy of ICU's default locale before we overwrite it. |
119 icu::Locale locale = icu::Locale::getDefault(); | 119 icu::Locale locale = icu::Locale::getDefault(); |
120 | 120 |
121 #if defined(OS_POSIX) && !defined(OS_CHROMEOS) | 121 #if defined(OS_POSIX) && !defined(OS_CHROMEOS) |
122 env.reset(base::Environment::Create()); | 122 env.reset(base::Environment::Create()); |
123 | 123 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); | 455 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); |
456 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); | 456 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); |
457 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); | 457 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); |
458 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); | 458 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); |
459 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); | 459 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); |
460 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); | 460 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); |
461 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); | 461 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); |
462 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); | 462 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); |
463 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); | 463 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); |
464 } | 464 } |
OLD | NEW |