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

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

Issue 6068005: views: Fix shifted keyevents in textfield. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add test 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
« no previous file with comments | « views/controls/textfield/native_textfield_views.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..41e5c714568e54cc25c5c14cb17f2b64a41a36d6 100644
--- a/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/views/controls/textfield/native_textfield_views_unittest.cc
@@ -73,9 +73,11 @@ class NativeTextfieldViewsTest : public ::testing::Test,
void SendKeyEventToTextfieldViews(app::KeyboardCode key_code,
bool shift,
- bool control) {
+ bool control,
+ bool capslock = false) {
oshima 2011/01/04 20:23:41 default argument is not allowed by style guide.
sadrul 2011/01/04 20:29:27 Ah, noted. Fixed.
int flags = (shift ? KeyEvent::EF_SHIFT_DOWN : 0) |
- (control ? KeyEvent::EF_CONTROL_DOWN : 0);
+ (control ? KeyEvent::EF_CONTROL_DOWN : 0) |
+ (capslock ? KeyEvent::EF_CAPS_LOCK_DOWN : 0);
KeyEvent event(KeyEvent::ET_KEY_PRESSED, key_code, flags, 1, 0);
textfield_view_->OnKeyPressed(event);
}
@@ -140,6 +142,15 @@ TEST_F(NativeTextfieldViewsTest, KeyTest) {
SendKeyEventToTextfieldViews(app::VKEY_R, false, false);
EXPECT_STR_EQ("Cr", textfield_->text());
EXPECT_STR_EQ("Cr", last_contents_);
+
+ textfield_->SetText(ASCIIToUTF16(""));
+ SendKeyEventToTextfieldViews(app::VKEY_C, true, false, true);
+ SendKeyEventToTextfieldViews(app::VKEY_C, false, false, true);
+ SendKeyEventToTextfieldViews(app::VKEY_1, false, false, true);
+ SendKeyEventToTextfieldViews(app::VKEY_1, true, false, true);
+ SendKeyEventToTextfieldViews(app::VKEY_1, true, false, false);
+ EXPECT_STR_EQ("cC1!!", textfield_->text());
+ EXPECT_STR_EQ("cC1!!", last_contents_);
}
TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) {
« no previous file with comments | « views/controls/textfield/native_textfield_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698