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

Side by Side Diff: chrome/common/l10n_util_unittest.cc

Issue 28236: fix GetAppLocale that is failing on posix (Closed)
Patch Set: proper fix Created 11 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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) 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"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Use a temporary locale dir so we don't have to actually build the locale 87 // Use a temporary locale dir so we don't have to actually build the locale
88 // dlls for this test. 88 // dlls for this test.
89 std::wstring orig_locale_dir; 89 std::wstring orig_locale_dir;
90 PathService::Get(chrome::DIR_LOCALES, &orig_locale_dir); 90 PathService::Get(chrome::DIR_LOCALES, &orig_locale_dir);
91 std::wstring new_locale_dir; 91 std::wstring new_locale_dir;
92 EXPECT_TRUE(file_util::CreateNewTempDirectory(L"l10n_util_test", 92 EXPECT_TRUE(file_util::CreateNewTempDirectory(L"l10n_util_test",
93 &new_locale_dir)); 93 &new_locale_dir));
94 PathService::Override(chrome::DIR_LOCALES, new_locale_dir); 94 PathService::Override(chrome::DIR_LOCALES, new_locale_dir);
95 // Make fake locale files. 95 // Make fake locale files.
96 const wchar_t* filenames[] = { 96 const wchar_t* filenames[] = {
97 L"en-US.dll", 97 L"en-US",
98 L"en-GB.dll", 98 L"en-GB",
99 L"fr.dll", 99 L"fr",
100 L"es-419.dll", 100 L"es-419",
101 L"es.dll", 101 L"es",
102 L"zh-TW.dll", 102 L"zh-TW",
103 L"zh-CN.dll", 103 L"zh-CN",
104 L"he.dll", 104 L"he",
105 L"fil.dll", 105 L"fil",
106 L"nb.dll", 106 L"nb",
107 }; 107 };
108
109 #if defined(OS_WIN)
110 static const wchar_t kLocaleFileExtension[] = L".dll";
111 #elif defined(OS_POSIX)
112 static const wchar_t kLocaleFileExtension[] = L".pak";
113 #endif
108 for (size_t i = 0; i < arraysize(filenames); ++i) { 114 for (size_t i = 0; i < arraysize(filenames); ++i) {
109 std::wstring filename = new_locale_dir; 115 std::wstring filename = new_locale_dir;
110 file_util::AppendToPath(&filename, filenames[i]); 116 file_util::AppendToPath(&filename, filenames[i]);
117 filename += kLocaleFileExtension;
111 file_util::WriteFile(filename, "", 0); 118 file_util::WriteFile(filename, "", 0);
112 } 119 }
113 120
114 // Keep a copy of ICU's default locale before we overwrite it. 121 // Keep a copy of ICU's default locale before we overwrite it.
115 Locale locale = Locale::getDefault(); 122 Locale locale = Locale::getDefault();
116 123
117 SetICUDefaultLocale(L"en-US"); 124 SetICUDefaultLocale(L"en-US");
118 EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"")); 125 EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L""));
119 126
120 SetICUDefaultLocale(L"en-GB"); 127 SetICUDefaultLocale(L"en-GB");
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 362 }
356 }; 363 };
357 for (unsigned int i = 0; i < arraysize(test_data); ++i) { 364 for (unsigned int i = 0; i < arraysize(test_data); ++i) {
358 string16 localized_file_path_string; 365 string16 localized_file_path_string;
359 FilePath path = FilePath::FromWStringHack(test_data[i].path); 366 FilePath path = FilePath::FromWStringHack(test_data[i].path);
360 l10n_util::WrapPathWithLTRFormatting(path, &localized_file_path_string); 367 l10n_util::WrapPathWithLTRFormatting(path, &localized_file_path_string);
361 std::wstring wrapped_path = UTF16ToWide(localized_file_path_string); 368 std::wstring wrapped_path = UTF16ToWide(localized_file_path_string);
362 EXPECT_EQ(wrapped_path, test_data[i].wrapped_path); 369 EXPECT_EQ(wrapped_path, test_data[i].wrapped_path);
363 } 370 }
364 } 371 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698