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

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

Issue 12238002: Views Textfield: Copy on Ctrl+Insert, fix and disable overtype. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Expand unit tests. Created 7 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/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: ui/views/controls/textfield/native_textfield_views_unittest.cc
diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc
index dbd875cd47bffcddd1aca9655cc8b85b278479a3..92c34aafce882e556c0e0765a0df4382c6071451 100644
--- a/ui/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc
@@ -1306,19 +1306,42 @@ TEST_F(NativeTextfieldViewsTest, UndoRedoTest) {
EXPECT_STR_EQ("", textfield_->text());
SendKeyEvent(ui::VKEY_Y, false, true);
EXPECT_STR_EQ("", textfield_->text());
+}
+
+TEST_F(NativeTextfieldViewsTest, CopyPasteShortcuts) {
+ InitTextfield(Textfield::STYLE_DEFAULT);
+ // Ensure [Ctrl]+[c] copies and [Ctrl]+[v] pastes.
+ textfield_->SetText(ASCIIToUTF16("abc"));
+ textfield_->SelectAll(false);
+ SendKeyEvent(ui::VKEY_C, false, true);
+ EXPECT_STR_EQ("abc", string16(GetClipboardText()));
+ SendKeyEvent(ui::VKEY_HOME);
+ SendKeyEvent(ui::VKEY_V, false, true);
+ EXPECT_STR_EQ("abcabc", textfield_->text());
- // Insert
+ // Ensure [Ctrl]+[Insert] copies and [Shift]+[Insert] pastes.
textfield_->SetText(ASCIIToUTF16("123"));
+ textfield_->SelectAll(false);
+ SendKeyEvent(ui::VKEY_INSERT, false, true);
+ EXPECT_STR_EQ("123", string16(GetClipboardText()));
+ SendKeyEvent(ui::VKEY_HOME);
+ SendKeyEvent(ui::VKEY_INSERT, true, false);
+ EXPECT_STR_EQ("123123", textfield_->text());
+ // Ensure [Ctrl]+[Shift]+[Insert] is a no-op.
+ textfield_->SelectAll(false);
+ SendKeyEvent(ui::VKEY_INSERT, true, true);
+ EXPECT_STR_EQ("123", string16(GetClipboardText()));
+ EXPECT_STR_EQ("123123", textfield_->text());
+}
+
+TEST_F(NativeTextfieldViewsTest, OvertypeMode) {
+ InitTextfield(Textfield::STYLE_DEFAULT);
+ // Overtype mode should be disabled (no-op [Insert]).
+ textfield_->SetText(ASCIIToUTF16("2"));
SendKeyEvent(ui::VKEY_HOME);
SendKeyEvent(ui::VKEY_INSERT);
- SendKeyEvent(ui::VKEY_A);
- EXPECT_STR_EQ("a23", textfield_->text());
- SendKeyEvent(ui::VKEY_B);
- EXPECT_STR_EQ("ab3", textfield_->text());
- SendKeyEvent(ui::VKEY_Z, false, true);
- EXPECT_STR_EQ("123", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
- EXPECT_STR_EQ("ab3", textfield_->text());
+ SendKeyEvent(ui::VKEY_1, false, false);
+ EXPECT_STR_EQ("12", textfield_->text());
}
TEST_F(NativeTextfieldViewsTest, TextCursorDisplayTest) {
« no previous file with comments | « ui/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