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

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

Issue 2650963002: MacViews: Select all text on right clicking an unfocused text view. (Closed)
Patch Set: Nit Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/selection_controller.h » ('j') | 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 858e7d51f2517f9eb67c6988f9f4a44735e3b1df..d292e972bcb357282adc136963320487fe3e1dbe 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -1463,7 +1463,7 @@ TEST_F(TextfieldTest, DoubleAndTripleClickTest) {
}
// Tests text selection behavior on a right click.
-TEST_F(TextfieldTest, SelectWordOnRightClick) {
+TEST_F(TextfieldTest, SelectionOnRightClick) {
InitTextfield();
textfield_->SetText(ASCIIToUTF16("hello world"));
@@ -1478,10 +1478,23 @@ TEST_F(TextfieldTest, SelectWordOnRightClick) {
// Verify right clicking outside the selection, selects the word under the
// cursor on platforms where this is expected.
MoveMouseTo(gfx::Point(GetCursorPositionX(8), cursor_y));
- const char* expected_right_click =
+ const char* expected_right_click_word =
PlatformStyle::kSelectWordOnRightClick ? "world" : "ello";
ClickRightMouseButton();
- EXPECT_STR_EQ(expected_right_click, textfield_->GetSelectedText());
+ EXPECT_STR_EQ(expected_right_click_word, textfield_->GetSelectedText());
+
+ // Verify right clicking inside an unfocused textfield selects all the text on
+ // platforms where this is expected. Else the older selection is retained.
+ widget_->GetFocusManager()->ClearFocus();
+ EXPECT_FALSE(textfield_->HasFocus());
+ MoveMouseTo(gfx::Point(GetCursorPositionX(0), cursor_y));
+ ClickRightMouseButton();
+ EXPECT_TRUE(textfield_->HasFocus());
+ const char* expected_right_click_unfocused =
+ PlatformStyle::kSelectAllOnRightClickWhenUnfocused
+ ? "hello world"
+ : expected_right_click_word;
+ EXPECT_STR_EQ(expected_right_click_unfocused, textfield_->GetSelectedText());
}
TEST_F(TextfieldTest, DragToSelect) {
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/selection_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698