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

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

Issue 49034: Review request: fix 8997 -- RTL Regression: Word order separated by slash is reversed on "Bookmark M (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 std::wstring path; 302 std::wstring path;
303 std::wstring wrapped_path; 303 std::wstring wrapped_path;
304 } PathAndWrappedPath; 304 } PathAndWrappedPath;
305 305
306 TEST_F(L10nUtilTest, WrapPathWithLTRFormatting) { 306 TEST_F(L10nUtilTest, WrapPathWithLTRFormatting) {
307 std::wstring kSeparator; 307 std::wstring kSeparator;
308 kSeparator.push_back(static_cast<wchar_t>(FilePath::kSeparators[0])); 308 kSeparator.push_back(static_cast<wchar_t>(FilePath::kSeparators[0]));
309 const PathAndWrappedPath test_data[] = { 309 const PathAndWrappedPath test_data[] = {
310 // Test common path, such as "c:\foo\bar". 310 // Test common path, such as "c:\foo\bar".
311 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar", 311 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar",
312 L"\x202a"L"c:" + kSeparator + L"\x200e"L"foo" + kSeparator + 312 L"\x202a"L"c:" + kSeparator + L"foo" + kSeparator +
313 L"\x200e"L"bar\x202c" 313 L"bar\x202c"
314 }, 314 },
315 // Test path with file name, such as "c:\foo\bar\test.jpg". 315 // Test path with file name, such as "c:\foo\bar\test.jpg".
316 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar" + kSeparator + 316 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar" + kSeparator +
317 L"test.jpg", 317 L"test.jpg",
318 L"\x202a"L"c:" + kSeparator + L"\x200e"L"foo" + kSeparator + 318 L"\x202a"L"c:" + kSeparator + L"foo" + kSeparator +
319 L"\x200e"L"bar" + kSeparator + L"\x200e"L"test.jpg\x202c" 319 L"bar" + kSeparator + L"test.jpg\x202c"
320 }, 320 },
321 // Test path ending with punctuation, such as "c:\(foo)\bar.". 321 // Test path ending with punctuation, such as "c:\(foo)\bar.".
322 { L"c:" + kSeparator + L"(foo)" + kSeparator + L"bar.", 322 { L"c:" + kSeparator + L"(foo)" + kSeparator + L"bar.",
323 L"\x202a"L"c:" + kSeparator + L"\x200e"L"(foo)" + kSeparator + 323 L"\x202a"L"c:" + kSeparator + L"(foo)" + kSeparator +
324 L"\x200e"L"bar.\x202c" 324 L"bar.\x202c"
325 }, 325 },
326 // Test path ending with separator, such as "c:\foo\bar\". 326 // Test path ending with separator, such as "c:\foo\bar\".
327 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar" + kSeparator, 327 { L"c:" + kSeparator + L"foo" + kSeparator + L"bar" + kSeparator,
328 L"\x202a"L"c:" + kSeparator + L"\x200e"L"foo" + kSeparator + 328 L"\x202a"L"c:" + kSeparator + L"foo" + kSeparator +
329 L"\x200e"L"bar" + kSeparator + L"\x200e\x202c" 329 L"bar" + kSeparator + L"\x202c",
330 }, 330 },
331 // Test path with RTL character. 331 // Test path with RTL character.
332 { L"c:" + kSeparator + L"\x05d0", 332 { L"c:" + kSeparator + L"\x05d0",
333 L"\x202a"L"c:" + kSeparator + L"\x200e\x05d0\x202c", 333 L"\x202a"L"c:" + kSeparator + L"\x05d0\x202c",
334 }, 334 },
335 // Test path with 2 level RTL directory names. 335 // Test path with 2 level RTL directory names.
336 { L"c:" + kSeparator + L"\x05d0" + kSeparator + L"\x0622", 336 { L"c:" + kSeparator + L"\x05d0" + kSeparator + L"\x0622",
337 L"\x202a"L"c:" + kSeparator + L"\x200e\x05d0" + kSeparator + 337 L"\x202a"L"c:" + kSeparator + L"\x05d0" + kSeparator +
338 L"\x200e\x0622\x202c", 338 L"\x0622\x202c",
339 }, 339 },
340 // Test path with mixed RTL/LTR directory names and ending with punctuation. 340 // Test path with mixed RTL/LTR directory names and ending with punctuation.
341 { L"c:" + kSeparator + L"\x05d0" + kSeparator + L"\x0622" + kSeparator + 341 { L"c:" + kSeparator + L"\x05d0" + kSeparator + L"\x0622" + kSeparator +
342 L"(foo)" + kSeparator + L"b.a.r.", 342 L"(foo)" + kSeparator + L"b.a.r.",
343 L"\x202a"L"c:" + kSeparator + L"\x200e\x05d0" + kSeparator + 343 L"\x202a"L"c:" + kSeparator + L"\x05d0" + kSeparator +
344 L"\x200e\x0622" + kSeparator + L"\x200e"L"(foo)" + kSeparator + 344 L"\x0622" + kSeparator + L"(foo)" + kSeparator +
345 L"\x200e"L"b.a.r.\x202c", 345 L"b.a.r.\x202c",
346 }, 346 },
347 // Test path without driver name, such as "/foo/bar/test/jpg". 347 // Test path without driver name, such as "/foo/bar/test/jpg".
348 { kSeparator + L"foo" + kSeparator + L"bar" + kSeparator + L"test.jpg", 348 { kSeparator + L"foo" + kSeparator + L"bar" + kSeparator + L"test.jpg",
349 L"\x202a" + kSeparator + L"foo" + kSeparator + L"\x200e" + L"bar" + 349 L"\x202a" + kSeparator + L"foo" + kSeparator + L"bar" +
350 kSeparator + L"\x200e" + L"test.jpg" + L"\x202c" 350 kSeparator + L"test.jpg" + L"\x202c"
351 }, 351 },
352 // Test path start with current directory, such as "./foo". 352 // Test path start with current directory, such as "./foo".
353 { L"." + kSeparator + L"foo", 353 { L"." + kSeparator + L"foo",
354 L"\x202a"L"." + kSeparator + L"\x200e" + L"foo" + L"\x202c" 354 L"\x202a"L"." + kSeparator + L"foo" + L"\x202c"
355 }, 355 },
356 // Test path start with parent directory, such as "../foo/bar.jpg". 356 // Test path start with parent directory, such as "../foo/bar.jpg".
357 { L".." + kSeparator + L"foo" + kSeparator + L"bar.jpg", 357 { L".." + kSeparator + L"foo" + kSeparator + L"bar.jpg",
358 L"\x202a"L".." + kSeparator + L"\x200e" + L"foo" + kSeparator + 358 L"\x202a"L".." + kSeparator + L"foo" + kSeparator +
359 L"\x200e" + L"bar.jpg" + L"\x202c" 359 L"bar.jpg" + L"\x202c"
360 }, 360 },
361 // Test absolute path, such as "//foo/bar.jpg". 361 // Test absolute path, such as "//foo/bar.jpg".
362 { kSeparator + kSeparator + L"foo" + kSeparator + L"bar.jpg", 362 { kSeparator + kSeparator + L"foo" + kSeparator + L"bar.jpg",
363 L"\x202a" + kSeparator + kSeparator + L"\x200e"L"foo" + kSeparator + 363 L"\x202a" + kSeparator + kSeparator + L"foo" + kSeparator +
364 L"\x200e"L"bar.jpg" + L"\x202c" 364 L"bar.jpg" + L"\x202c"
365 },
366 // Test path with mixed RTL/LTR directory names.
367 { L"c:" + kSeparator + L"foo" + kSeparator + L"\x05d0" + kSeparator +
368 L"\x0622" + kSeparator + L"\x05d1.jpg",
369 L"\x202a"L"c:" + kSeparator + L"foo" + kSeparator + L"\x05d0" +
370 kSeparator + L"\x0622" + kSeparator + L"\x05d1.jpg" + L"\x202c",
365 }, 371 },
366 // Test empty path. 372 // Test empty path.
367 { L"", 373 { L"",
368 L"\x202a\x202c" 374 L"\x202a\x202c"
369 } 375 }
370 }; 376 };
371 for (unsigned int i = 0; i < arraysize(test_data); ++i) { 377 for (unsigned int i = 0; i < arraysize(test_data); ++i) {
372 string16 localized_file_path_string; 378 string16 localized_file_path_string;
373 FilePath path = FilePath::FromWStringHack(test_data[i].path); 379 FilePath path = FilePath::FromWStringHack(test_data[i].path);
374 l10n_util::WrapPathWithLTRFormatting(path, &localized_file_path_string); 380 l10n_util::WrapPathWithLTRFormatting(path, &localized_file_path_string);
375 std::wstring wrapped_path = UTF16ToWide(localized_file_path_string); 381 std::wstring wrapped_path = UTF16ToWide(localized_file_path_string);
376 EXPECT_EQ(wrapped_path, test_data[i].wrapped_path); 382 EXPECT_EQ(wrapped_path, test_data[i].wrapped_path);
377 } 383 }
378 } 384 }
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