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

Side by Side Diff: base/i18n/rtl_unittest.cc

Issue 1281343003: Optimize RTL check in ICU to avoid mmap access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fixes Created 5 years, 4 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
« base/i18n/rtl.cc ('K') | « base/i18n/rtl.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) 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 "base/i18n/rtl.h" 5 #include "base/i18n/rtl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // Chinese in China with '-'. 392 // Chinese in China with '-'.
393 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("zh-CN")); 393 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("zh-CN"));
394 // Filipino : 3-letter code 394 // Filipino : 3-letter code
395 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("fil")); 395 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("fil"));
396 // Russian 396 // Russian
397 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("ru")); 397 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("ru"));
398 // Japanese that uses multiple scripts 398 // Japanese that uses multiple scripts
399 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("ja")); 399 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocale("ja"));
400 } 400 }
401 401
402 TEST_F(RTLTest, GetTextDirectionForLocaleInStartUp) {
403 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("ar"));
404 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("ar_EG"));
405 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("he"));
406 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("he_IL"));
407 // iw is an obsolete code for Hebrew.
408 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("iw"));
409 // Although we're not yet localized to Farsi and Urdu, we
410 // do have the text layout direction information for them.
411 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("fa"));
412 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("ur"));
413 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("en"));
414 // Chinese in China with '-'.
415 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("zh-CN"));
416 // Filipino : 3-letter code
417 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("fil"));
418 // Russian
419 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("ru"));
420 // Japanese that uses multiple scripts
421 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("ja"));
422 }
423
402 TEST_F(RTLTest, UnadjustStringForLocaleDirection) { 424 TEST_F(RTLTest, UnadjustStringForLocaleDirection) {
403 // These test strings are borrowed from WrapPathWithLTRFormatting 425 // These test strings are borrowed from WrapPathWithLTRFormatting
404 const wchar_t* cases[] = { 426 const wchar_t* cases[] = {
405 L"foo bar", 427 L"foo bar",
406 L"foo \x05d0 bar", 428 L"foo \x05d0 bar",
407 L"\x05d0 foo bar", 429 L"\x05d0 foo bar",
408 L"!foo \x05d0 bar", 430 L"!foo \x05d0 bar",
409 L",\x05d0 foo bar", 431 L",\x05d0 foo bar",
410 L"\x202a \x05d0 foo bar", 432 L"\x202a \x05d0 foo bar",
411 L"\x202d \x05d0 foo bar", 433 L"\x202d \x05d0 foo bar",
(...skipping 20 matching lines...) Expand all
432 EXPECT_EQ(test_case, adjusted_string) << " for test case [" << test_case 454 EXPECT_EQ(test_case, adjusted_string) << " for test case [" << test_case
433 << "] with IsRTL() == " << IsRTL(); 455 << "] with IsRTL() == " << IsRTL();
434 } 456 }
435 } 457 }
436 458
437 EXPECT_EQ(was_rtl, IsRTL()); 459 EXPECT_EQ(was_rtl, IsRTL());
438 } 460 }
439 461
440 } // namespace i18n 462 } // namespace i18n
441 } // namespace base 463 } // namespace base
OLDNEW
« base/i18n/rtl.cc ('K') | « base/i18n/rtl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698