Chromium Code Reviews| 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..815ad8d2e242968b4838bcfd6e2187ad2be5e473 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,37 @@ 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, 30, 15))); |
|
mfomitchev
2015/08/04 18:31:36
would be nice to express the coordinates in terms
jdduke (slow)
2015/08/04 19:14:51
Done.
|
| + 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 |