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

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

Issue 923903002: MacViews: Merge single-character edits, map (and validate) undo and redo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ugh. left the MAYBE_ on Created 5 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/cocoa/bridged_content_view.mm ('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 e5ddf39b7593f4fb96c6dde5352fe83cc1dbe07c..cb2ea22c79fffb66f97ce2ae0d21a67a4ed16d61 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -1075,11 +1075,11 @@ TEST_F(TextfieldTest, DragAndDrop_ToTheRight) {
EXPECT_STR_EQ("", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("hello world", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("h welloorld", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("h welloorld", textfield_->text());
}
@@ -1128,11 +1128,11 @@ TEST_F(TextfieldTest, DragAndDrop_ToTheLeft) {
EXPECT_STR_EQ("", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("hello world", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("h worlellod", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("h worlellod", textfield_->text());
}
@@ -1349,9 +1349,9 @@ TEST_F(TextfieldTest, UndoRedoTest) {
EXPECT_STR_EQ("", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("a", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("a", textfield_->text());
// AppendText
@@ -1360,7 +1360,7 @@ TEST_F(TextfieldTest, UndoRedoTest) {
EXPECT_STR_EQ("ab", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("a", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("ab", textfield_->text());
// SetText
@@ -1372,9 +1372,9 @@ TEST_F(TextfieldTest, UndoRedoTest) {
EXPECT_STR_EQ("abc", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("ab", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("abc", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("abc", textfield_->text());
textfield_->SetText(ASCIIToUTF16("123"));
textfield_->SetText(ASCIIToUTF16("123"));
@@ -1391,11 +1391,11 @@ TEST_F(TextfieldTest, UndoRedoTest) {
EXPECT_STR_EQ("ab", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("a", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("ab", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("123", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("1234", textfield_->text());
// Undoing to the same text shouldn't call ContentsChanged.
@@ -1407,13 +1407,13 @@ TEST_F(TextfieldTest, UndoRedoTest) {
EXPECT_STR_EQ("abc", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("1234", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("abc", textfield_->text());
// Delete/Backspace
SendKeyEvent(ui::VKEY_BACK);
EXPECT_STR_EQ("ab", textfield_->text());
- SendKeyEvent(ui::VKEY_HOME);
+ SendHomeEvent(false);
SendKeyEvent(ui::VKEY_DELETE);
EXPECT_STR_EQ("b", textfield_->text());
SendKeyEvent(ui::VKEY_A, false, true);
@@ -1425,16 +1425,38 @@ TEST_F(TextfieldTest, UndoRedoTest) {
EXPECT_STR_EQ("ab", textfield_->text());
SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("abc", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("ab", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
EXPECT_STR_EQ("b", textfield_->text());
- SendKeyEvent(ui::VKEY_Y, false, true);
+ SendKeyEvent(ui::VKEY_Z, true, true);
+ EXPECT_STR_EQ("", textfield_->text());
+ SendKeyEvent(ui::VKEY_Z, true, true);
+ EXPECT_STR_EQ("", textfield_->text());
+}
+
+// Most platforms support Ctrl+Y as an alternative to Ctrl+Shift+Z, but on Mac
+// that is bound to "Show full history", so is not mapped as an editing
+// command. So, on Mac, send Cmd+Shift+Z.
+#if !defined(OS_MACOSX)
+
+// Test that Ctrl+Y works for Redo, as well as Ctrl+Shift+Z.
+TEST_F(TextfieldTest, RedoWithCtrlY) {
+ InitTextfield();
+ SendKeyEvent(ui::VKEY_A);
+ EXPECT_STR_EQ("a", textfield_->text());
+ SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("", textfield_->text());
SendKeyEvent(ui::VKEY_Y, false, true);
+ EXPECT_STR_EQ("a", textfield_->text());
+ SendKeyEvent(ui::VKEY_Z, false, true);
EXPECT_STR_EQ("", textfield_->text());
+ SendKeyEvent(ui::VKEY_Z, true, true);
+ EXPECT_STR_EQ("a", textfield_->text());
}
+#endif // !defined(OS_MACOSX)
+
TEST_F(TextfieldTest, CutCopyPaste) {
InitTextfield();
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698