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

Unified Diff: ui/touch_selection/longpress_drag_selector_unittest.cc

Issue 1259593010: Fix issue with longpress drag selection motion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2454
Patch Set: Created 5 years, 4 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/touch_selection/longpress_drag_selector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/touch_selection/longpress_drag_selector_unittest.cc
diff --git a/ui/touch_selection/longpress_drag_selector_unittest.cc b/ui/touch_selection/longpress_drag_selector_unittest.cc
index 8c126d8022bfd51019d1d573b55e665ca1c3a541..885943957b65b6f075e2538509ed9f52e642c3f2 100644
--- a/ui/touch_selection/longpress_drag_selector_unittest.cc
+++ b/ui/touch_selection/longpress_drag_selector_unittest.cc
@@ -139,7 +139,7 @@ TEST_F(LongPressDragSelectorTest, BasicReverseDrag) {
EXPECT_FALSE(IsDragging());
// Initiate drag motion.
- EXPECT_TRUE(selector.WillHandleTouchEvent(event.MovePoint(0, 0, 0)));
+ EXPECT_TRUE(selector.WillHandleTouchEvent(event.MovePoint(0, 5, 0)));
EXPECT_FALSE(IsDragging());
// As the initial motion is leftward, toward the selection start, the
@@ -330,4 +330,38 @@ TEST_F(LongPressDragSelectorTest, SelectionDeactivated) {
EXPECT_FALSE(selector.WillHandleTouchEvent(event.ReleasePoint()));
}
+TEST_F(LongPressDragSelectorTest, DragFast) {
+ LongPressDragSelector selector(this);
+ MockMotionEvent event;
+
+ // Start a touch sequence.
+ EXPECT_FALSE(selector.WillHandleTouchEvent(event.PressPoint(0, 0)));
+ EXPECT_FALSE(GetAndResetActiveStateChanged());
+
+ // Activate a longpress-triggered selection.
+ gfx::PointF selection_start(0, 10);
+ gfx::PointF selection_end(10, 10);
+ selector.OnLongPressEvent(event.GetEventTime(), gfx::PointF());
+ EXPECT_TRUE(GetAndResetActiveStateChanged());
+ SetSelection(selection_start, selection_end);
+ selector.OnSelectionActivated();
+ EXPECT_FALSE(IsDragging());
+
+ // Initiate drag motion.
+ EXPECT_TRUE(selector.WillHandleTouchEvent(event.MovePoint(0, 15, 5)));
+ EXPECT_FALSE(IsDragging());
+
+ // As the initial motion exceeds both endpoints, the closer bound should
+ // be used for dragging, in this case the selection end.
+ EXPECT_TRUE(selector.WillHandleTouchEvent(
+ event.MovePoint(0, 15.f + kSlop * 2.f, 5.f + kSlop)));
+ EXPECT_TRUE(IsDragging());
+ EXPECT_EQ(selection_end, DragPosition());
+
+ // Release the touch sequence, ending the drag.
+ EXPECT_FALSE(selector.WillHandleTouchEvent(event.ReleasePoint()));
+ EXPECT_FALSE(IsDragging());
+ EXPECT_TRUE(GetAndResetActiveStateChanged());
+}
+
} // namespace ui
« no previous file with comments | « ui/touch_selection/longpress_drag_selector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698