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

Unified Diff: views/controls/textfield/native_textfield_views_unittest.cc

Issue 5972008: views: Improve cursor movements on word boundaries. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: cleanups Created 9 years, 12 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
Index: views/controls/textfield/native_textfield_views_unittest.cc
diff --git a/views/controls/textfield/native_textfield_views_unittest.cc b/views/controls/textfield/native_textfield_views_unittest.cc
index ed69e54b2046d37c8d977588c79ddf2f9873512f..2d63b4f3935e777cd1b56983a01895aa5a9cbfb1 100644
--- a/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/views/controls/textfield/native_textfield_views_unittest.cc
@@ -223,4 +223,29 @@ TEST_F(NativeTextfieldViewsTest, PasswordTest) {
EXPECT_STR_EQ("my password", last_contents_);
}
+TEST_F(NativeTextfieldViewsTest, CursorMovement) {
+ InitTextfield(Textfield::STYLE_DEFAULT);
+ textfield_->SetText(ASCIIToUTF16("one two hre "));
+
+ // Send the cursor at the end.
+ SendKeyEventToTextfieldViews(app::VKEY_END);
+ // Ctrl+Left should move the cursor just before the last word.
+ SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true);
+ SendKeyEventToTextfieldViews(app::VKEY_T);
+ EXPECT_STR_EQ("one two thre ", textfield_->text());
+ EXPECT_STR_EQ("one two thre ", last_contents_);
+
+ // Ctrl+Right should move the cursor to the end of the last word.
+ SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true);
+ SendKeyEventToTextfieldViews(app::VKEY_E);
+ EXPECT_STR_EQ("one two three ", textfield_->text());
+ EXPECT_STR_EQ("one two three ", last_contents_);
+
+ // Ctrl+Right again should move the cursor to the end.
+ SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true);
+ SendKeyEventToTextfieldViews(app::VKEY_BACK);
+ EXPECT_STR_EQ("one two three", textfield_->text());
+ EXPECT_STR_EQ("one two three", last_contents_);
oshima 2011/01/04 21:53:24 can you add another test case with leading white s
sadrul 2011/01/04 23:25:44 Done.
+}
+
} // namespace views
« no previous file with comments | « views/controls/textfield/native_textfield_views.cc ('k') | views/controls/textfield/textfield_views_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698