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

Unified Diff: ui/views/controls/textfield/textfield_unittest.cc

Issue 2709633003: Fix: Cursor of Omnibox stays in LTR mode after setting to RTL mode (Closed)
Patch Set: address comments Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield_test_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..46b012831c7e9852716fcc26ff0ae2d64647834e 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -2397,6 +2397,37 @@ TEST_F(TextfieldTest, TextCursorDisplayInRTLTest) {
base::i18n::SetICUDefaultLocale(locale);
}
+TEST_F(TextfieldTest, TextCursorPositionInRTLTest) {
+ std::string locale = base::i18n::GetConfiguredLocale();
+ base::i18n::SetICUDefaultLocale("he");
+
+ 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 place after inserting new charactors in RTL mode.
+ EXPECT_EQ(text_cursor_position_prev, text_cursor_position_new);
+
+ // Reset locale.
+ base::i18n::SetICUDefaultLocale(locale);
+}
+
+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"));
« no previous file with comments | « ui/views/controls/textfield/textfield_test_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698