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

Side by Side Diff: ui/base/l10n/l10n_util_unittest.cc

Issue 7744053: Revert 98103 - Switch to using .pak files for locale data on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | « ui/base/l10n/l10n_util.cc ('k') | ui/base/resource/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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
83 #if defined(OS_POSIX) && !defined(OS_CHROMEOS) 83 #if defined(OS_POSIX) && !defined(OS_CHROMEOS)
84 env->SetVar("LANGUAGE", tag); 84 env->SetVar("LANGUAGE", tag);
85 #else 85 #else
86 SetICUDefaultLocale(tag); 86 SetICUDefaultLocale(tag);
87 #endif 87 #endif
88 } 88 }
89 89
90 TEST_F(L10nUtilTest, GetAppLocale) { 90 TEST_F(L10nUtilTest, GetAppLocale) {
91 scoped_ptr<base::Environment> env; 91 scoped_ptr<base::Environment> env;
92 // Use a temporary locale dir so we don't have to actually build the locale 92 // Use a temporary locale dir so we don't have to actually build the locale
93 // pak files for this test. 93 // dlls for this test.
94 FilePath orig_locale_dir; 94 FilePath orig_locale_dir;
95 PathService::Get(ui::DIR_LOCALES, &orig_locale_dir); 95 PathService::Get(ui::DIR_LOCALES, &orig_locale_dir);
96 FilePath new_locale_dir; 96 FilePath new_locale_dir;
97 EXPECT_TRUE(file_util::CreateNewTempDirectory( 97 EXPECT_TRUE(file_util::CreateNewTempDirectory(
98 FILE_PATH_LITERAL("l10n_util_test"), 98 FILE_PATH_LITERAL("l10n_util_test"),
99 &new_locale_dir)); 99 &new_locale_dir));
100 PathService::Override(ui::DIR_LOCALES, new_locale_dir); 100 PathService::Override(ui::DIR_LOCALES, new_locale_dir);
101 // Make fake locale files. 101 // Make fake locale files.
102 std::string filenames[] = { 102 std::string filenames[] = {
103 "en-US", 103 "en-US",
104 "en-GB", 104 "en-GB",
105 "fr", 105 "fr",
106 "es-419", 106 "es-419",
107 "es", 107 "es",
108 "zh-TW", 108 "zh-TW",
109 "zh-CN", 109 "zh-CN",
110 "he", 110 "he",
111 "fil", 111 "fil",
112 "nb", 112 "nb",
113 "am", 113 "am",
114 "ca", 114 "ca",
115 "ca@valencia", 115 "ca@valencia",
116 }; 116 };
117 117
118 #if defined(OS_WIN)
119 static const char kLocaleFileExtension[] = ".dll";
120 #elif defined(OS_POSIX)
121 static const char kLocaleFileExtension[] = ".pak";
122 #endif
118 for (size_t i = 0; i < arraysize(filenames); ++i) { 123 for (size_t i = 0; i < arraysize(filenames); ++i) {
119 FilePath filename = new_locale_dir.AppendASCII( 124 FilePath filename = new_locale_dir.AppendASCII(
120 filenames[i] + ".pak"); 125 filenames[i] + kLocaleFileExtension);
121 file_util::WriteFile(filename, "", 0); 126 file_util::WriteFile(filename, "", 0);
122 } 127 }
123 128
124 // Keep a copy of ICU's default locale before we overwrite it. 129 // Keep a copy of ICU's default locale before we overwrite it.
125 icu::Locale locale = icu::Locale::getDefault(); 130 icu::Locale locale = icu::Locale::getDefault();
126 131
127 #if defined(OS_POSIX) && !defined(OS_CHROMEOS) 132 #if defined(OS_POSIX) && !defined(OS_CHROMEOS)
128 env.reset(base::Environment::Create()); 133 env.reset(base::Environment::Create());
129 134
130 // Test the support of LANGUAGE environment variable. 135 // Test the support of LANGUAGE environment variable.
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); 380 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin"));
376 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); 381 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German"));
377 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); 382 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR"));
378 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); 383 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia"));
379 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); 384 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@"));
380 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); 385 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@"));
381 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); 386 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x"));
382 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); 387 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x="));
383 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); 388 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y"));
384 } 389 }
OLDNEW
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698