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

Side by Side Diff: app/l10n_util_unittest.cc

Issue 6263008: Move ResourceBundle, DataPack to ui/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « app/l10n_util.cc ('k') | app/resource_bundle.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
11 #include "app/app_paths.h"
12 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
13 #include "app/l10n_util_collator.h" 12 #include "app/l10n_util_collator.h"
14 #if !defined(OS_MACOSX) 13 #if !defined(OS_MACOSX)
15 #include "app/test/data/resource.h" 14 #include "app/test/data/resource.h"
16 #endif 15 #endif
17 #include "base/basictypes.h" 16 #include "base/basictypes.h"
18 #include "base/environment.h" 17 #include "base/environment.h"
19 #include "base/file_util.h" 18 #include "base/file_util.h"
20 #include "base/path_service.h" 19 #include "base/path_service.h"
21 #include "base/stl_util-inl.h" 20 #include "base/stl_util-inl.h"
22 #include "base/string_util.h" 21 #include "base/string_util.h"
23 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
24 #if defined(OS_WIN) 23 #if defined(OS_WIN)
25 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
26 #endif 25 #endif
27 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
28 #include "testing/platform_test.h" 27 #include "testing/platform_test.h"
28 #include "ui/base/ui_base_paths.h"
29 #include "unicode/locid.h" 29 #include "unicode/locid.h"
30 30
31 namespace { 31 namespace {
32 32
33 class StringWrapper { 33 class StringWrapper {
34 public: 34 public:
35 explicit StringWrapper(const string16& string) : string_(string) {} 35 explicit StringWrapper(const string16& string) : string_(string) {}
36 const string16& string() const { return string_; } 36 const string16& string() const { return string_; }
37 37
38 private: 38 private:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 #else 112 #else
113 SetICUDefaultLocale(tag); 113 SetICUDefaultLocale(tag);
114 #endif 114 #endif
115 } 115 }
116 116
117 TEST_F(L10nUtilTest, GetAppLocale) { 117 TEST_F(L10nUtilTest, GetAppLocale) {
118 scoped_ptr<base::Environment> env; 118 scoped_ptr<base::Environment> env;
119 // Use a temporary locale dir so we don't have to actually build the locale 119 // Use a temporary locale dir so we don't have to actually build the locale
120 // dlls for this test. 120 // dlls for this test.
121 FilePath orig_locale_dir; 121 FilePath orig_locale_dir;
122 PathService::Get(app::DIR_LOCALES, &orig_locale_dir); 122 PathService::Get(ui::DIR_LOCALES, &orig_locale_dir);
123 FilePath new_locale_dir; 123 FilePath new_locale_dir;
124 EXPECT_TRUE(file_util::CreateNewTempDirectory( 124 EXPECT_TRUE(file_util::CreateNewTempDirectory(
125 FILE_PATH_LITERAL("l10n_util_test"), 125 FILE_PATH_LITERAL("l10n_util_test"),
126 &new_locale_dir)); 126 &new_locale_dir));
127 PathService::Override(app::DIR_LOCALES, new_locale_dir); 127 PathService::Override(ui::DIR_LOCALES, new_locale_dir);
128 // Make fake locale files. 128 // Make fake locale files.
129 std::string filenames[] = { 129 std::string filenames[] = {
130 "en-US", 130 "en-US",
131 "en-GB", 131 "en-GB",
132 "fr", 132 "fr",
133 "es-419", 133 "es-419",
134 "es", 134 "es",
135 "zh-TW", 135 "zh-TW",
136 "zh-CN", 136 "zh-CN",
137 "he", 137 "he",
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale("am")); 271 EXPECT_EQ("en-GB", l10n_util::GetApplicationLocale("am"));
272 } else { 272 } else {
273 SetICUDefaultLocale("am"); 273 SetICUDefaultLocale("am");
274 EXPECT_EQ("am", l10n_util::GetApplicationLocale("")); 274 EXPECT_EQ("am", l10n_util::GetApplicationLocale(""));
275 SetICUDefaultLocale("en-GB"); 275 SetICUDefaultLocale("en-GB");
276 EXPECT_EQ("am", l10n_util::GetApplicationLocale("am")); 276 EXPECT_EQ("am", l10n_util::GetApplicationLocale("am"));
277 } 277 }
278 #endif // defined(OS_WIN) 278 #endif // defined(OS_WIN)
279 279
280 // Clean up. 280 // Clean up.
281 PathService::Override(app::DIR_LOCALES, orig_locale_dir); 281 PathService::Override(ui::DIR_LOCALES, orig_locale_dir);
282 file_util::Delete(new_locale_dir, true); 282 file_util::Delete(new_locale_dir, true);
283 UErrorCode error_code = U_ZERO_ERROR; 283 UErrorCode error_code = U_ZERO_ERROR;
284 icu::Locale::setDefault(locale, error_code); 284 icu::Locale::setDefault(locale, error_code);
285 } 285 }
286 #endif // !defined(OS_MACOSX) 286 #endif // !defined(OS_MACOSX)
287 287
288 TEST_F(L10nUtilTest, SortStringsUsingFunction) { 288 TEST_F(L10nUtilTest, SortStringsUsingFunction) {
289 std::vector<StringWrapper*> strings; 289 std::vector<StringWrapper*> strings;
290 strings.push_back(new StringWrapper(UTF8ToUTF16("C"))); 290 strings.push_back(new StringWrapper(UTF8ToUTF16("C")));
291 strings.push_back(new StringWrapper(UTF8ToUTF16("d"))); 291 strings.push_back(new StringWrapper(UTF8ToUTF16("d")));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); 388 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin"));
389 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); 389 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German"));
390 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); 390 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR"));
391 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); 391 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia"));
392 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); 392 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@"));
393 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); 393 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@"));
394 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); 394 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x"));
395 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); 395 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x="));
396 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); 396 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y"));
397 } 397 }
OLDNEW
« no previous file with comments | « app/l10n_util.cc ('k') | app/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698