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

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

Issue 18603008: Seperate horizontal and vertical overscrolling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made changes requested by sadrul Created 7 years, 5 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 4fe7d1fed6baf5f5d78181f19eaecf0e63dcd7ee..6d4b5519e959a03904317114669b1d39a0dea298 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -3151,8 +3151,8 @@ TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) {
process_->sink().ClearMessages();
// Simulate wheel events.
- SimulateWheelEvent(0, -5, 0, true); // sent directly
- SimulateWheelEvent(0, -1, 0, true); // enqueued
+ SimulateWheelEvent(-5, 0, 0, true); // sent directly
+ SimulateWheelEvent(-1, 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
@@ -3179,8 +3179,8 @@ TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) {
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode());
- EXPECT_EQ(-75.f, host_->overscroll_delta_x());
- EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x());
+ EXPECT_EQ(-81.f, host_->overscroll_delta_x());
+ EXPECT_EQ(-31.f, host_->overscroll_delegate()->delta_x());
EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
EXPECT_EQ(0U, process_->sink().message_count());
@@ -3191,14 +3191,14 @@ TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) {
}
// Tests that if some scroll events are consumed towards the start, then
-// subsequent scrolls do not overscroll.
-TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotOverscroll) {
+// subsequent scrolls do not horizontal overscroll.
+TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotHorizOverscroll) {
host_->SetupForOverscrollControllerTest();
process_->sink().ClearMessages();
// Simulate wheel events.
- SimulateWheelEvent(0, -5, 0, true); // sent directly
- SimulateWheelEvent(0, -1, 0, true); // enqueued
+ SimulateWheelEvent(-5, 0, 0, true); // sent directly
+ SimulateWheelEvent(-1, -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
@@ -3222,7 +3222,7 @@ TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotOverscroll) {
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
- EXPECT_EQ(1U, process_->sink().message_count());
+ EXPECT_EQ(0U, process_->sink().message_count());
process_->sink().ClearMessages();
SendInputEventACK(WebInputEvent::MouseWheel,
@@ -3266,7 +3266,7 @@ TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
// Send a wheel event. ACK the event as not processed. This should not
// initiate an overscroll gesture since it doesn't cross the threshold yet.
- SimulateWheelEvent(10, -5, 0, true);
+ SimulateWheelEvent(10, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3275,7 +3275,7 @@ TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
process_->sink().ClearMessages();
// Scroll some more so as to not overscroll.
- SimulateWheelEvent(10, -4, 0, true);
+ SimulateWheelEvent(10, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3284,7 +3284,7 @@ TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
process_->sink().ClearMessages();
// Scroll some more to initiate an overscroll.
- SimulateWheelEvent(40, -4, 0, true);
+ SimulateWheelEvent(40, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3296,13 +3296,13 @@ TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
process_->sink().ClearMessages();
// Scroll in the reverse direction enough to abort the overscroll.
- SimulateWheelEvent(-20, -4, 0, true);
+ SimulateWheelEvent(-20, 0, 0, true);
EXPECT_EQ(0U, process_->sink().message_count());
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
// Continue to scroll in the reverse direction.
- SimulateWheelEvent(-20, 4, 0, true);
+ SimulateWheelEvent(-20, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3312,7 +3312,7 @@ TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
// Continue to scroll in the reverse direction enough to initiate overscroll
// in that direction.
- SimulateWheelEvent(-55, -2, 0, true);
+ SimulateWheelEvent(-55, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3329,7 +3329,7 @@ TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) {
// Send a wheel event. ACK the event as not processed. This should not
// initiate an overscroll gesture since it doesn't cross the threshold yet.
- SimulateWheelEvent(10, -5, 0, true);
+ SimulateWheelEvent(10, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3338,7 +3338,7 @@ TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) {
process_->sink().ClearMessages();
// Scroll some more so as to not overscroll.
- SimulateWheelEvent(20, -4, 0, true);
+ SimulateWheelEvent(20, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3347,7 +3347,7 @@ TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) {
process_->sink().ClearMessages();
// Scroll some more to initiate an overscroll.
- SimulateWheelEvent(30, -4, 0, true);
+ SimulateWheelEvent(30, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3376,7 +3376,7 @@ TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) {
// Send a wheel event. ACK the event as not processed. This should not
// initiate an overscroll gesture since it doesn't cross the threshold yet.
- SimulateWheelEvent(10, -5, 0, true);
+ SimulateWheelEvent(10, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3385,7 +3385,7 @@ TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) {
process_->sink().ClearMessages();
// Scroll some more so as to not overscroll.
- SimulateWheelEvent(20, -4, 0, true);
+ SimulateWheelEvent(20, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3394,7 +3394,7 @@ TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) {
process_->sink().ClearMessages();
// Scroll some more to initiate an overscroll.
- SimulateWheelEvent(30, -4, 0, true);
+ SimulateWheelEvent(30, 0, 0, true);
EXPECT_EQ(1U, process_->sink().message_count());
SendInputEventACK(WebInputEvent::MouseWheel,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -3493,7 +3493,7 @@ TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) {
EXPECT_EQ(55.f, host_->overscroll_delta_x());
EXPECT_EQ(-5.f, host_->overscroll_delta_y());
EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x());
- EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
+ EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
process_->sink().ClearMessages();
@@ -3506,7 +3506,7 @@ TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) {
EXPECT_EQ(65.f, host_->overscroll_delta_x());
EXPECT_EQ(-10.f, host_->overscroll_delta_y());
EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x());
- EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
+ EXPECT_EQ(-10.f, host_->overscroll_delegate()->delta_y());
EXPECT_EQ(0U, process_->sink().message_count());
EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
@@ -3522,9 +3522,9 @@ TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) {
}
// 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) {
+// particular scroll sequence never generates overscroll if the scroll direction
+// is horizontal.
+TEST_F(RenderWidgetHostTest, GestureScrollConsumedHorizontal) {
// Turn off debounce handling for test isolation.
host_->SetupForOverscrollControllerTest();
host_->set_debounce_interval_time_ms(0);
@@ -3532,9 +3532,9 @@ TEST_F(RenderWidgetHostTest, GestureScrollConsumedDoNotOverscroll) {
SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
WebGestureEvent::Touchscreen);
- SimulateGestureScrollUpdateEvent(8, -5, 0);
+ SimulateGestureScrollUpdateEvent(10, 0, 0);
- // ACK both events as being processed.
+ // Start scrolling on content. ACK both events as being processed.
SendInputEventACK(WebInputEvent::GestureScrollBegin,
INPUT_EVENT_ACK_STATE_CONSUMED);
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
@@ -3545,12 +3545,42 @@ TEST_F(RenderWidgetHostTest, GestureScrollConsumedDoNotOverscroll) {
// 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);
+ SimulateGestureScrollUpdateEvent(55, 0, 0);
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
}
+// Tests that if the page is scrolled because of a scroll-gesture, then that
+// particular scroll sequence never generates overscroll if the scroll direction
+// is vertical.
+TEST_F(RenderWidgetHostTest, GestureScrollConsumedVertical) {
+ // 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(0, -1, 0);
+
+ // Start scrolling on content. 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
+ // nitiate overscroll because the scroll was in the vertical direction even
sadrul 2013/07/23 14:42:22 *initiate
rharrison 2013/07/23 14:50:07 Done.
+ // though the beginning of the scroll did scroll content.
+ SimulateGestureScrollUpdateEvent(0, -50, 0);
+ SendInputEventACK(WebInputEvent::GestureScrollUpdate,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(OVERSCROLL_NORTH, host_->overscroll_mode());
sadrul 2013/07/23 14:42:22 Send a sufficiently large unprocessed horizontal s
rharrison 2013/07/23 14:50:07 Done.
+}
+
// Tests that the overscroll controller plays nice with touch-scrolls and the
// gesture event filter with debounce filtering turned on.
TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) {
@@ -3567,7 +3597,7 @@ TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) {
INPUT_EVENT_ACK_STATE_CONSUMED);
// Send update events.
- SimulateGestureScrollUpdateEvent(25, -5, 0);
+ SimulateGestureScrollUpdateEvent(25, 0, 0);
EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
EXPECT_TRUE(host_->ScrollingInProgress());
@@ -3589,7 +3619,7 @@ TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) {
EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize());
// Send another update event. This should get into the queue.
- SimulateGestureScrollUpdateEvent(30, 5, 0);
+ SimulateGestureScrollUpdateEvent(30, 0, 0);
EXPECT_EQ(0U, process_->sink().message_count());
EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
@@ -3609,7 +3639,7 @@ TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) {
process_->sink().ClearMessages();
// Send another update event. This should get into the queue.
- SimulateGestureScrollUpdateEvent(10, 5, 0);
+ SimulateGestureScrollUpdateEvent(10, 0, 0);
EXPECT_EQ(0U, process_->sink().message_count());
EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
@@ -3647,7 +3677,7 @@ TEST_F(RenderWidgetHostTest, GestureScrollDebounceTimerOverscroll) {
INPUT_EVENT_ACK_STATE_CONSUMED);
// Send update events.
- SimulateGestureScrollUpdateEvent(55, -5, 0);
+ SimulateGestureScrollUpdateEvent(55, 0, 0);
EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
EXPECT_TRUE(host_->ScrollingInProgress());
@@ -3722,7 +3752,7 @@ TEST_F(RenderWidgetHostTest, OverscrollWithTouchEvents) {
SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
WebGestureEvent::Touchscreen);
- SimulateGestureScrollUpdateEvent(20, 4, 0);
+ SimulateGestureScrollUpdateEvent(20, 0, 0);
SendInputEventACK(WebInputEvent::GestureScrollBegin,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
@@ -3740,7 +3770,7 @@ TEST_F(RenderWidgetHostTest, OverscrollWithTouchEvents) {
SendInputEventACK(WebInputEvent::TouchMove,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- SimulateGestureScrollUpdateEvent(45, 5, 0);
+ SimulateGestureScrollUpdateEvent(45, 0, 0);
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
@@ -3862,7 +3892,7 @@ TEST_F(RenderWidgetHostTest, TouchGestureEndDispatchedAfterOverscrollComplete) {
EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
EXPECT_EQ(55.f, host_->overscroll_delta_x());
EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x());
- EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
+ EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
// Send end event.
SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd,
@@ -3920,7 +3950,7 @@ TEST_F(RenderWidgetHostTest, TouchGestureEndDispatchedAfterOverscrollComplete) {
EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
EXPECT_EQ(235.f, host_->overscroll_delta_x());
EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x());
- EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
+ EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
// Send end event.
SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd,
@@ -4025,8 +4055,8 @@ TEST_F(RenderWidgetHostTest, OverscrollMouseMoveCompletion) {
view_->set_bounds(gfx::Rect(0, 0, 400, 200));
view_->Show();
- SimulateWheelEvent(0, -5, 0, true); // sent directly
- SimulateWheelEvent(0, -1, 0, true); // enqueued
+ SimulateWheelEvent(5, 0, 0, true); // sent directly
+ SimulateWheelEvent(-1, 0, 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
@@ -4143,9 +4173,9 @@ TEST_F(RenderWidgetHostTest, OverscrollStateResetsAfterScroll) {
EXPECT_TRUE(host_->ScrollStateIsUnknown());
EXPECT_EQ(0U, process_->sink().message_count());
- SimulateWheelEvent(0, -5, 0, true); // sent directly
- SimulateWheelEvent(-60, -1, 0, true); // enqueued
- SimulateWheelEvent(-100, -3, 0, true); // coalesced into previous event
+ SimulateWheelEvent(-5, 0, 0, true); // sent directly
+ SimulateWheelEvent(-60, 0, 0, true); // enqueued
+ SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event
EXPECT_EQ(1U, process_->sink().message_count());
EXPECT_TRUE(host_->ScrollStateIsUnknown());
process_->sink().ClearMessages();
« no previous file with comments | « content/browser/renderer_host/overscroll_controller.cc ('k') | content/browser/web_contents/aura/window_slider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698