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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/keyboard_codes.h" 5 #include "app/keyboard_codes.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "views/controls/textfield/native_textfield_views.h" 9 #include "views/controls/textfield/native_textfield_views.h"
10 #include "views/controls/textfield/textfield.h" 10 #include "views/controls/textfield/textfield.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 TEST_F(NativeTextfieldViewsTest, PasswordTest) { 217 TEST_F(NativeTextfieldViewsTest, PasswordTest) {
218 InitTextfield(Textfield::STYLE_PASSWORD); 218 InitTextfield(Textfield::STYLE_PASSWORD);
219 textfield_->SetText(ASCIIToUTF16("my password")); 219 textfield_->SetText(ASCIIToUTF16("my password"));
220 // Just to make sure the text() and callback returns 220 // Just to make sure the text() and callback returns
221 // the actual text instead of "*". 221 // the actual text instead of "*".
222 EXPECT_STR_EQ("my password", textfield_->text()); 222 EXPECT_STR_EQ("my password", textfield_->text());
223 EXPECT_STR_EQ("my password", last_contents_); 223 EXPECT_STR_EQ("my password", last_contents_);
224 } 224 }
225 225
226 TEST_F(NativeTextfieldViewsTest, CursorMovement) {
227 InitTextfield(Textfield::STYLE_DEFAULT);
228 textfield_->SetText(ASCIIToUTF16("one two hre "));
229
230 // Send the cursor at the end.
231 SendKeyEventToTextfieldViews(app::VKEY_END);
232 // Ctrl+Left should move the cursor just before the last word.
233 SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true);
234 SendKeyEventToTextfieldViews(app::VKEY_T);
235 EXPECT_STR_EQ("one two thre ", textfield_->text());
236 EXPECT_STR_EQ("one two thre ", last_contents_);
237
238 // Ctrl+Right should move the cursor to the end of the last word.
239 SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true);
240 SendKeyEventToTextfieldViews(app::VKEY_E);
241 EXPECT_STR_EQ("one two three ", textfield_->text());
242 EXPECT_STR_EQ("one two three ", last_contents_);
243
244 // Ctrl+Right again should move the cursor to the end.
245 SendKeyEventToTextfieldViews(app::VKEY_RIGHT, false, true);
246 SendKeyEventToTextfieldViews(app::VKEY_BACK);
247 EXPECT_STR_EQ("one two three", textfield_->text());
248 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.
249 }
250
226 } // namespace views 251 } // namespace views
OLDNEW
« 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