| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |