summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authorzyaozhujun@chromium.org <zyaozhujun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 04:03:09 +0000
committerzyaozhujun@chromium.org <zyaozhujun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 04:03:09 +0000
commit4654dc96afcd444bac4c42d808aef3fab3fa0a6f (patch)
tree0d0c9239eba87d5c606567bb61be8388609cc26c /ui/views
parent0421e068fa8cd2c4bb875adf89a98b77e631dfbc (diff)
downloadchromium_src-4654dc96afcd444bac4c42d808aef3fab3fa0a6f.zip
chromium_src-4654dc96afcd444bac4c42d808aef3fab3fa0a6f.tar.gz
chromium_src-4654dc96afcd444bac4c42d808aef3fab3fa0a6f.tar.bz2
Make drag drop work on textfield for long press gesture.
BUG=248291 Review URL: https://chromiumcodereview.appspot.com/17220003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207317 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/controls/textfield/native_textfield_views.cc1
-rw-r--r--ui/views/controls/textfield/native_textfield_views_unittest.cc21
2 files changed, 22 insertions, 0 deletions
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index 0e80755..68feb64 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -221,6 +221,7 @@ void NativeTextfieldViews::OnGestureEvent(ui::GestureEvent* event) {
if (touch_selection_controller_.get())
event->SetHandled();
} else if (switches::IsTouchDragDropEnabled()) {
+ initiating_drag_ = true;
touch_selection_controller_.reset();
} else {
if (!touch_selection_controller_.get())
diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc
index 56cd1d6..2ef5e6f 100644
--- a/ui/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc
@@ -1891,6 +1891,7 @@ TEST_F(NativeTextfieldViewsTest, TouchSelectionAndDraggingTest) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableTouchDragDrop);
textfield_view_->OnGestureEvent(&tap_down);
+
// Create a new long press event since the previous one is not marked handled.
GestureEventForTest long_press2(ui::ET_GESTURE_LONG_PRESS, eventX, eventY, 0);
textfield_view_->OnGestureEvent(&long_press2);
@@ -1899,4 +1900,24 @@ TEST_F(NativeTextfieldViewsTest, TouchSelectionAndDraggingTest) {
}
#endif
+// Long_Press gesture in NativeTextfieldViews can initiate a drag and drop now.
+TEST_F(NativeTextfieldViewsTest, TestLongPressInitiatesDragDrop) {
+ InitTextfield(Textfield::STYLE_DEFAULT);
+ textfield_->SetText(ASCIIToUTF16("Hello string world"));
+
+ // Ensure the textfield will provide selected text for drag data.
+ textfield_->SelectRange(ui::Range(6, 12));
+ const gfx::Point kStringPoint(GetCursorPositionX(9), 0);
+
+ // Enable touch-drag-drop to make long press effective.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableTouchDragDrop);
+
+ // Create a long press event in the selected region should start a drag.
+ GestureEventForTest long_press(ui::ET_GESTURE_LONG_PRESS,
+ kStringPoint.x(), kStringPoint.y(), 0);
+ textfield_view_->OnGestureEvent(&long_press);
+ EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL,
+ kStringPoint, kStringPoint));
+}
} // namespace views