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

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

Issue 20038: Review request: fix 7324 and 7326: missing icon and wrong path in "download location" (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/l10n_util.cc ('k') | 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/file_util.h" 8 #include "base/file_util.h"
8 #include "base/path_service.h" 9 #include "base/path_service.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
11 #include "chrome/common/l10n_util.h" 12 #include "chrome/common/l10n_util.h"
12 #if !defined(OS_MACOSX) 13 #if !defined(OS_MACOSX)
13 #include "chrome/test/data/resource.h" 14 #include "chrome/test/data/resource.h"
14 #endif 15 #endif
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/platform_test.h" 17 #include "testing/platform_test.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 SetICUDefaultLocale(L"he"); 153 SetICUDefaultLocale(L"he");
153 EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en")); 154 EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en"));
154 155
155 // Clean up. 156 // Clean up.
156 PathService::Override(chrome::DIR_LOCALES, orig_locale_dir); 157 PathService::Override(chrome::DIR_LOCALES, orig_locale_dir);
157 file_util::Delete(new_locale_dir, true); 158 file_util::Delete(new_locale_dir, true);
158 UErrorCode error_code = U_ZERO_ERROR; 159 UErrorCode error_code = U_ZERO_ERROR;
159 Locale::setDefault(locale, error_code); 160 Locale::setDefault(locale, error_code);
160 } 161 }
161 162
163 typedef struct {
164 std::wstring path;
165 std::wstring wrapped_path;
166 } PathAndWrappedPath;
167
168 TEST_F(L10nUtilTest, WrapPathWithLTRFormatting) {
169 std::wstring kSeparator;
170 kSeparator.push_back(static_cast<wchar_t>(FilePath::kSeparators[0]));
171 const PathAndWrappedPath test_data[] = {
172 // Test common path, such as "c:\foo\bar".
173 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar",
174 L"\x202a"L"c:" + kSeparator + L"\x200e"L"foo" + kSeparator +
175 L"\x200e"L"bar\x202c"
176 },
177 // Test path with file name, such as "c:\foo\bar\test.jpg".
178 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar" + kSeparator +
179 L"test.jpg",
180 L"\x202a"L"c:" + kSeparator + L"\x200e"L"foo" + kSeparator +
181 L"\x200e"L"bar" + kSeparator + L"\x200e"L"test.jpg\x202c"
182 },
183 // Test path ending with punctuation, such as "c:\(foo)\bar.".
184 { L"c:" + kSeparator + L"(foo)" + kSeparator + L"bar.",
185 L"\x202a"L"c:" + kSeparator + L"\x200e"L"(foo)" + kSeparator +
186 L"\x200e"L"bar.\x202c"
187 },
188 // Test path ending with separator, such as "c:\foo\bar\".
189 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar" + kSeparator,
190 L"\x202a"L"c:" + kSeparator + L"\x200e"L"foo" + kSeparator +
191 L"\x200e"L"bar" + kSeparator + L"\x200e\x202c"
192 },
193 // Test path with RTL character.
194 { L"c:" + kSeparator + L"\x05d0",
195 L"\x202a"L"c:" + kSeparator + L"\x200e\x05d0\x202c",
196 },
197 // Test path with 2 level RTL directory names.
198 { L"c:" + kSeparator + L"\x05d0" + kSeparator + L"\x0622",
199 L"\x202a"L"c:" + kSeparator + L"\x200e\x05d0" + kSeparator +
200 L"\x200e\x0622\x202c",
201 },
202 // Test path with mixed RTL/LTR directory names and ending with punctuation.
203 { L"c:" + kSeparator + L"\x05d0" + kSeparator + L"\x0622" + kSeparator +
204 L"(foo)" + kSeparator + L"b.a.r.",
205 L"\x202a"L"c:" + kSeparator + L"\x200e\x05d0" + kSeparator +
206 L"\x200e\x0622" + kSeparator + L"\x200e"L"(foo)" + kSeparator +
207 L"\x200e"L"b.a.r.\x202c",
208 },
209 // Test path without driver name, such as "/foo/bar/test/jpg".
210 { kSeparator + L"foo" + kSeparator + L"bar" + kSeparator + L"test.jpg",
211 L"\x202a" + kSeparator + L"foo" + kSeparator + L"\x200e" + L"bar" +
212 kSeparator + L"\x200e" + L"test.jpg" + L"\x202c"
213 },
214 // Test path start with current directory, such as "./foo".
215 { L"." + kSeparator + L"foo",
216 L"\x202a"L"." + kSeparator + L"\x200e" + L"foo" + L"\x202c"
217 },
218 // Test path start with parent directory, such as "../foo/bar.jpg".
219 { L".." + kSeparator + L"foo" + kSeparator + L"bar.jpg",
220 L"\x202a"L".." + kSeparator + L"\x200e" + L"foo" + kSeparator +
221 L"\x200e" + L"bar.jpg" + L"\x202c"
222 },
223 // Test absolute path, such as "//foo/bar.jpg".
224 { kSeparator + kSeparator + L"foo" + kSeparator + L"bar.jpg",
225 L"\x202a" + kSeparator + kSeparator + L"\x200e"L"foo" + kSeparator +
226 L"\x200e"L"bar.jpg" + L"\x202c"
227 },
228 // Test empty path.
229 { L"",
230 L"\x202a\x202c"
231 }
232 };
233 for (unsigned int i = 0; i < arraysize(test_data); ++i) {
234 string16 localized_file_path_string;
235 FilePath path = FilePath::FromWStringHack(test_data[i].path);
236 l10n_util::WrapPathWithLTRFormatting(path, &localized_file_path_string);
237 std::wstring wrapped_path = UTF16ToWide(localized_file_path_string);
238 EXPECT_EQ(wrapped_path, test_data[i].wrapped_path);
239 }
240 }
162 } 241 }
163 242
OLDNEW
« no previous file with comments | « chrome/common/l10n_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698