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

Unified Diff: ui/touch_selection/touch_selection_controller_unittest.cc

Issue 1537493006: Allow scrolling a page with selection after long-press on whitespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments Created 4 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/touch_selection/touch_selection_controller.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/touch_selection_controller_unittest.cc
diff --git a/ui/touch_selection/touch_selection_controller_unittest.cc b/ui/touch_selection/touch_selection_controller_unittest.cc
index 73e11323534ffe527ac3ae5cce9af3ba8ea182c6..af4136bbddecb756caa3c46fb4f2ae3fd099ad7f 100644
--- a/ui/touch_selection/touch_selection_controller_unittest.cc
+++ b/ui/touch_selection/touch_selection_controller_unittest.cc
@@ -1274,6 +1274,46 @@ TEST_F(TouchSelectionControllerTest, NoLongPressDragIfDisabled) {
EXPECT_TRUE(test_controller.GetEndVisible());
}
+// When there is a selection on the page and long-press drag is performed
+// somewhere that has nothing to select, long-press drag selector should not get
+// activated so the page can scroll.
+TEST_F(TouchSelectionControllerTest, LongPressDragScroll) {
+ EnableLongPressDragSelection();
+ TouchSelectionControllerTestApi test_controller(&controller());
+
+ gfx::RectF start_rect(10, 0, 0, 10);
+ gfx::RectF end_rect(20, 0, 0, 10);
+ gfx::PointF touch_point(0, 0);
+ bool visible = true;
+ MockMotionEvent event;
+
+ // Pre-select something.
+ ChangeSelection(start_rect, visible, end_rect, visible);
+ EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_ESTABLISHED));
+
+ // Start the touch sequence and perform the long-press out of the existing
+ // selection.
+ EXPECT_FALSE(controller().WillHandleTouchEvent(
+ event.PressPoint(touch_point.x(), touch_point.y())));
+ OnLongPressEvent();
+
+ // Drag down. Selection controller should not consume the touch-move event.
+ touch_point.Offset(0, 2 * kDefaulTapSlop);
+ EXPECT_FALSE(controller().WillHandleTouchEvent(
+ event.MovePoint(0, touch_point.x(), touch_point.y())));
+
+ // Begin page scroll and update the selection. Selection handles should not be
+ // shown which means long-press drag selector is not activated.
+ controller().OnScrollBeginEvent();
+ start_rect.Offset(0, 2 * kDefaulTapSlop);
+ end_rect.Offset(0, 2 * kDefaulTapSlop);
+ ChangeSelection(start_rect, visible, end_rect, visible);
+ EXPECT_THAT(GetAndResetEvents(), IsEmpty());
+
+ // Release the touch sequence.
+ EXPECT_FALSE(controller().WillHandleTouchEvent(event.ReleasePoint()));
+}
+
TEST_F(TouchSelectionControllerTest, RectBetweenBounds) {
gfx::RectF start_rect(5, 5, 0, 10);
gfx::RectF end_rect(50, 5, 0, 10);
« no previous file with comments | « ui/touch_selection/touch_selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698