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

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

Issue 1865063004: views: support vertical-drag-to-end on textfields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move logic into Textfield Created 4 years, 8 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/style/platform_style.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 97595c57cb4e5b61a1c8569801d43f7724a0607d..6a7a292592487d00aabcfaa5ee296ed7605fc240 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -39,6 +39,7 @@
#include "ui/views/controls/textfield/textfield_model.h"
#include "ui/views/controls/textfield/textfield_test_api.h"
#include "ui/views/focus/focus_manager.h"
+#include "ui/views/style/platform_style.h"
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/test/widget_test.h"
@@ -1195,6 +1196,43 @@ TEST_F(TextfieldTest, DragToSelect) {
EXPECT_EQ(textfield_->text(), textfield_->GetSelectedText());
}
+TEST_F(TextfieldTest, DragUpOrDownSelectsToEnd) {
tapted 2016/04/08 08:53:28 nit: although the other tests are missing one,...
Elly Fong-Jones 2016/04/08 16:46:47 Done.
+ if (!PlatformStyle::kTextfieldDragVerticallyDragsToEnd)
tapted 2016/04/08 08:53:28 Can we verify the behaviour when this is false as
Elly Fong-Jones 2016/04/08 16:46:48 Yes. I changed the test to test the correct behavi
+ return;
+ InitTextfield();
+ textfield_->SetText(ASCIIToUTF16("hello world"));
+ const int kStartX = GetCursorPositionX(5);
+ gfx::Point start_point(kStartX, 0);
+ gfx::Point down_point(kStartX, 500);
+ gfx::Point up_point(kStartX, -500);
+ ui::MouseEvent click_start(ui::ET_MOUSE_PRESSED, start_point, start_point,
tapted 2016/04/08 08:53:28 Can these be simplified with a ui::EventGenerator?
Elly Fong-Jones 2016/04/08 16:46:48 I spent a bit of time trying to use EventGenerator
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent click_down(ui::ET_MOUSE_PRESSED, down_point, down_point,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent drag_up(ui::ET_MOUSE_DRAGGED, up_point, up_point,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0);
+ ui::MouseEvent drag_down(ui::ET_MOUSE_DRAGGED, down_point, down_point,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0);
+ ui::MouseEvent release_up(ui::ET_MOUSE_RELEASED, up_point, up_point,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent release_down(ui::ET_MOUSE_RELEASED, down_point, down_point,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+
+ textfield_->OnMousePressed(click_start);
+ textfield_->OnMouseDragged(drag_up);
+ textfield_->OnMouseReleased(release_up);
+ EXPECT_EQ(textfield_->GetSelectedText(), base::ASCIIToUTF16("hello"));
+
+ textfield_->OnMousePressed(click_start);
+ textfield_->OnMouseDragged(drag_down);
+ textfield_->OnMouseReleased(release_down);
+ EXPECT_EQ(textfield_->GetSelectedText(), base::ASCIIToUTF16(" world"));
+}
+
#if defined(OS_WIN)
TEST_F(TextfieldTest, DragAndDrop_AcceptDrop) {
InitTextfield();
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/style/platform_style.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698