Chromium Code Reviews| 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 #if 0 | |
| 414 // Enable these when we include the minimal locale data for Azerbaijani | |
| 415 // written in Arabic and Dhivehi. At the moment, our copy of | |
| 416 // ICU data does not have entries for them. | |
| 417 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("az_Arab")); | |
| 418 // Dhivehi that uses Thaana script. | |
| 419 EXPECT_EQ(RIGHT_TO_LEFT, GetTextDirectionForLocaleInStartUp("dv")); | |
| 420 #endif | |
|
jungshik at Google
2015/08/11 19:23:13
I don't think we need these #if-0'd lines because
danduong
2015/08/11 20:01:10
Removed the if-0 lines.
| |
| 421 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("en")); | |
| 422 // Chinese in China with '-'. | |
| 423 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("zh-CN")); | |
| 424 // Filipino : 3-letter code | |
| 425 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("fil")); | |
| 426 // Russian | |
| 427 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("ru")); | |
| 428 // Japanese that uses multiple scripts | |
| 429 EXPECT_EQ(LEFT_TO_RIGHT, GetTextDirectionForLocaleInStartUp("ja")); | |
| 430 } | |
| 431 | |
| 402 TEST_F(RTLTest, UnadjustStringForLocaleDirection) { | 432 TEST_F(RTLTest, UnadjustStringForLocaleDirection) { |
| 403 // These test strings are borrowed from WrapPathWithLTRFormatting | 433 // These test strings are borrowed from WrapPathWithLTRFormatting |
| 404 const wchar_t* cases[] = { | 434 const wchar_t* cases[] = { |
| 405 L"foo bar", | 435 L"foo bar", |
| 406 L"foo \x05d0 bar", | 436 L"foo \x05d0 bar", |
| 407 L"\x05d0 foo bar", | 437 L"\x05d0 foo bar", |
| 408 L"!foo \x05d0 bar", | 438 L"!foo \x05d0 bar", |
| 409 L",\x05d0 foo bar", | 439 L",\x05d0 foo bar", |
| 410 L"\x202a \x05d0 foo bar", | 440 L"\x202a \x05d0 foo bar", |
| 411 L"\x202d \x05d0 foo bar", | 441 L"\x202d \x05d0 foo bar", |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 432 EXPECT_EQ(test_case, adjusted_string) << " for test case [" << test_case | 462 EXPECT_EQ(test_case, adjusted_string) << " for test case [" << test_case |
| 433 << "] with IsRTL() == " << IsRTL(); | 463 << "] with IsRTL() == " << IsRTL(); |
| 434 } | 464 } |
| 435 } | 465 } |
| 436 | 466 |
| 437 EXPECT_EQ(was_rtl, IsRTL()); | 467 EXPECT_EQ(was_rtl, IsRTL()); |
| 438 } | 468 } |
| 439 | 469 |
| 440 } // namespace i18n | 470 } // namespace i18n |
| 441 } // namespace base | 471 } // namespace base |
| OLD | NEW |