Chromium Code Reviews| Index: ui/views/controls/textfield/textfield_unittest.cc |
| diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc |
| index 60fbf799ca0616fe797c0dd75bb7839dd0b33ec9..8d6fd8dce0697d9795b4c615737c35533f80b45d 100644 |
| --- a/ui/views/controls/textfield/textfield_unittest.cc |
| +++ b/ui/views/controls/textfield/textfield_unittest.cc |
| @@ -2397,6 +2397,34 @@ TEST_F(TextfieldTest, TextCursorDisplayInRTLTest) { |
| base::i18n::SetICUDefaultLocale(locale); |
| } |
| +TEST_F(TextfieldTest, TextCursorPositionInRTLTest) { |
| + std::string locale = base::i18n::GetConfiguredLocale(); |
| + base::i18n::SetICUDefaultLocale("he"); |
|
sadrul
2017/02/23 03:41:21
I think you need to restore |locale| at the end of
yiyix
2017/02/23 16:38:46
Done, i added the restoring part.
|
| + |
| + InitTextfield(); |
| + // LTR-RTL string in RTL context. |
| + int text_cursor_position_prev = test_api_->GetCursorViewOrigin().x(); |
| + SendKeyEvent('a'); |
| + SendKeyEvent('b'); |
| + EXPECT_STR_EQ("ab", textfield_->text()); |
| + int text_cursor_position_new = test_api_->GetCursorViewOrigin().x(); |
| + // Text cursor stays at same plaec after inserting new charactors in RTL mode. |
|
sadrul
2017/02/23 03:41:21
*place
yiyix
2017/02/23 16:38:46
Done.
|
| + EXPECT_EQ(text_cursor_position_prev, text_cursor_position_new); |
| +} |
| + |
| +TEST_F(TextfieldTest, TextCursorPositionInLTRTest) { |
| + InitTextfield(); |
| + |
| + // LTR-RTL string in LTR context. |
| + int text_cursor_position_prev = test_api_->GetCursorViewOrigin().x(); |
| + SendKeyEvent('a'); |
| + SendKeyEvent('b'); |
| + EXPECT_STR_EQ("ab", textfield_->text()); |
| + int text_cursor_position_new = test_api_->GetCursorViewOrigin().x(); |
| + // Text cursor moves to right after inserting new charactors in LTR mode. |
| + EXPECT_LT(text_cursor_position_prev, text_cursor_position_new); |
| +} |
| + |
| TEST_F(TextfieldTest, HitInsideTextAreaTest) { |
| InitTextfield(); |
| textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); |