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

Unified Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 15742013: overscroll: Do not overscroll if the beginning of a scroll was consumed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
Index: content/browser/renderer_host/render_widget_host_unittest.cc
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
index 60360caeecf3d95d39187272cdb110f3be5d7ddf..fd0be0a8a206fb87e0bd70e46eaa564b470f8f01 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -3126,9 +3126,9 @@ TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) {
EXPECT_EQ(1U, process_->sink().message_count());
process_->sink().ClearMessages();
- // Receive ACK the first wheel event as processed.
+ // Receive ACK the first wheel event as not processed.
SendInputEventACK(WebInputEvent::MouseWheel,
- INPUT_EVENT_ACK_STATE_CONSUMED);
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
EXPECT_EQ(1U, process_->sink().message_count());
@@ -3155,6 +3155,75 @@ TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) {
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
}
+// Tests that if some scroll events are consumed towards the start, then
+// subsequent scrolls do not overscroll.
+TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotOverscroll) {
+ host_->SetupForOverscrollControllerTest();
+ process_->sink().ClearMessages();
+
+ // Simulate wheel events.
+ SimulateWheelEvent(0, -5, 0, true); // sent directly
+ SimulateWheelEvent(0, -1, 0, true); // enqueued
+ SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
+ SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
+ SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
+ SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+ EXPECT_EQ(1U, process_->sink().message_count());
+ process_->sink().ClearMessages();
+
+ // Receive ACK the first wheel event as processed.
+ SendInputEventACK(WebInputEvent::MouseWheel,
+ INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
+ EXPECT_EQ(1U, process_->sink().message_count());
+ process_->sink().ClearMessages();
+
+ // Receive ACK for the second (coalesced) event as not processed. This should
+ // not initiate overscroll, since the beginning of the scroll has been
+ // consumed. The queued event with different modifiers should be sent to the
+ // renderer.
+ SendInputEventACK(WebInputEvent::MouseWheel,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+ EXPECT_EQ(1U, process_->sink().message_count());
+
+ process_->sink().ClearMessages();
+ SendInputEventACK(WebInputEvent::MouseWheel,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(0U, process_->sink().message_count());
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+
+ // Indicate the end of the scrolling from the touchpad.
+ SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad);
+ EXPECT_EQ(1U, process_->sink().message_count());
+
+ // Start another scroll. This time, do not consume any scroll events.
+ process_->sink().ClearMessages();
+ SimulateWheelEvent(0, -5, 0, true); // sent directly
+ SimulateWheelEvent(0, -1, 0, true); // enqueued
+ SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
+ SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
+ SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
+ SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+ EXPECT_EQ(1U, process_->sink().message_count());
+ process_->sink().ClearMessages();
+
+ // Receive ACK for the first wheel and the subsequent coalesced event as not
+ // processed. This should start a back-overscroll.
+ SendInputEventACK(WebInputEvent::MouseWheel,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
+ EXPECT_EQ(1U, process_->sink().message_count());
+ process_->sink().ClearMessages();
+ SendInputEventACK(WebInputEvent::MouseWheel,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
+}
+
// Tests that wheel-scrolling correctly turns overscroll on and off.
TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
host_->SetupForOverscrollControllerTest();
@@ -3374,13 +3443,8 @@ TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) {
SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
WebGestureEvent::Touchscreen);
- SimulateGestureScrollUpdateEvent(8, -5, 0);
-
- // ACK both events as being processed.
SendInputEventACK(WebInputEvent::GestureScrollBegin,
- INPUT_EVENT_ACK_STATE_CONSUMED);
- SendInputEventACK(WebInputEvent::GestureScrollUpdate,
- INPUT_EVENT_ACK_STATE_CONSUMED);
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
@@ -3422,6 +3486,36 @@ TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) {
EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
}
+// Tests that if the page is scrolled because of a scroll-gesture, then that
+// particular scroll sequence never generates overscroll, even if there is no
+// content to scroll on the page anymore.
+TEST_F(RenderWidgetHostTest, GestureScrollConsumedDoNotOverscroll) {
+ // Turn off debounce handling for test isolation.
+ host_->SetupForOverscrollControllerTest();
+ host_->set_debounce_interval_time_ms(0);
+ process_->sink().ClearMessages();
+
+ SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
+ WebGestureEvent::Touchscreen);
+ SimulateGestureScrollUpdateEvent(8, -5, 0);
+
+ // ACK both events as being processed.
+ SendInputEventACK(WebInputEvent::GestureScrollBegin,
+ INPUT_EVENT_ACK_STATE_CONSUMED);
+ SendInputEventACK(WebInputEvent::GestureScrollUpdate,
+ INPUT_EVENT_ACK_STATE_CONSUMED);
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
+
+ // Send another gesture event and ACK as not being processed. This should
+ // not initiate overscroll because the beginning of the scroll event did
+ // scroll some content on the page.
+ SimulateGestureScrollUpdateEvent(55, -5, 0);
+ SendInputEventACK(WebInputEvent::GestureScrollUpdate,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
+}
+
// Tests that the overscroll controller plays nice with touch-scrolls and the
// gesture event filter with debounce filtering turned on.
TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) {

Powered by Google App Engine
This is Rietveld 408576698