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

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

Issue 927743002: Focus and trail cursor on Views Textfield selection clipboard paste. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Leave the test disabled... 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/controls/textfield/textfield.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/textfield_unittest.cc
diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
index 8a14df79d331b9fd73f871ab030fc9d20f88a584..60809aacc9cf8d2479cde09812bdb910dd1cc6b3 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -1956,29 +1956,28 @@ TEST_F(TextfieldTest, DISABLED_SelectionClipboard) {
EXPECT_EQ(ui::CLIPBOARD_TYPE_LAST, GetAndResetCopiedToClipboard());
// Middle clicking should paste at the mouse (not cursor) location.
+ // The cursor should be placed at the end of the pasted text.
ui::MouseEvent middle(ui::ET_MOUSE_PRESSED, point_4, point_4,
ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON);
textfield_->OnMousePressed(middle);
EXPECT_STR_EQ("01230123", textfield_->text());
- EXPECT_EQ(gfx::Range(0, 0), textfield_->GetSelectedRange());
+ EXPECT_EQ(gfx::Range(8, 8), textfield_->GetSelectedRange());
EXPECT_STR_EQ("0123", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION));
- // Middle click pasting should adjust trailing cursors.
- textfield_->SelectRange(gfx::Range(5, 5));
+ // Middle clicking on an unfocused textfield should focus it and paste.
+ // TODO(msw): Add tests with stored selections and select-all on focus.
msw 2015/02/13 23:38:43 I tested this manually, but didn't bother writing
+ textfield_->GetFocusManager()->ClearFocus();
+ EXPECT_FALSE(textfield_->HasFocus());
textfield_->OnMousePressed(middle);
+ EXPECT_TRUE(textfield_->HasFocus());
EXPECT_STR_EQ("012301230123", textfield_->text());
- EXPECT_EQ(gfx::Range(9, 9), textfield_->GetSelectedRange());
-
- // Middle click pasting should adjust trailing selections.
- textfield_->SelectRange(gfx::Range(7, 9));
- textfield_->OnMousePressed(middle);
- EXPECT_STR_EQ("0123012301230123", textfield_->text());
- EXPECT_EQ(gfx::Range(11, 13), textfield_->GetSelectedRange());
+ EXPECT_EQ(gfx::Range(8, 8), textfield_->GetSelectedRange());
+ EXPECT_STR_EQ("0123", GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION));
// Middle clicking in the selection should clear the clipboard and selection.
textfield_->SelectRange(gfx::Range(2, 6));
textfield_->OnMousePressed(middle);
- EXPECT_STR_EQ("0123012301230123", textfield_->text());
+ EXPECT_STR_EQ("012301230123", textfield_->text());
EXPECT_EQ(gfx::Range(6, 6), textfield_->GetSelectedRange());
EXPECT_TRUE(GetClipboardText(ui::CLIPBOARD_TYPE_SELECTION).empty());
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698