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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 304793003: use enum to specify deviceSource for fling animation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased for parallel breaking changes Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 469 }
470 470
471 void SimulateGestureEventCoreWithLatencyInfo( 471 void SimulateGestureEventCoreWithLatencyInfo(
472 const WebGestureEvent& gesture_event, 472 const WebGestureEvent& gesture_event,
473 const ui::LatencyInfo& ui_latency) { 473 const ui::LatencyInfo& ui_latency) {
474 widget_host_->ForwardGestureEventWithLatencyInfo(gesture_event, ui_latency); 474 widget_host_->ForwardGestureEventWithLatencyInfo(gesture_event, ui_latency);
475 } 475 }
476 476
477 // Inject simple synthetic WebGestureEvent instances. 477 // Inject simple synthetic WebGestureEvent instances.
478 void SimulateGestureEvent(WebInputEvent::Type type, 478 void SimulateGestureEvent(WebInputEvent::Type type,
479 WebGestureEvent::SourceDevice sourceDevice) { 479 blink::WebGestureDevice sourceDevice) {
480 SimulateGestureEventCore( 480 SimulateGestureEventCore(
481 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); 481 SyntheticWebGestureEventBuilder::Build(type, sourceDevice));
482 } 482 }
483 483
484 void SimulateGestureEventWithLatencyInfo( 484 void SimulateGestureEventWithLatencyInfo(WebInputEvent::Type type,
485 WebInputEvent::Type type, 485 blink::WebGestureDevice sourceDevice,
486 WebGestureEvent::SourceDevice sourceDevice, 486 const ui::LatencyInfo& ui_latency) {
487 const ui::LatencyInfo& ui_latency) {
488 SimulateGestureEventCoreWithLatencyInfo( 487 SimulateGestureEventCoreWithLatencyInfo(
489 SyntheticWebGestureEventBuilder::Build(type, sourceDevice), ui_latency); 488 SyntheticWebGestureEventBuilder::Build(type, sourceDevice), ui_latency);
490 } 489 }
491 490
492 void SimulateGestureScrollUpdateEvent(float dX, float dY, int modifiers) { 491 void SimulateGestureScrollUpdateEvent(float dX, float dY, int modifiers) {
493 SimulateGestureEventCore( 492 SimulateGestureEventCore(
494 SyntheticWebGestureEventBuilder::BuildScrollUpdate(dX, dY, modifiers)); 493 SyntheticWebGestureEventBuilder::BuildScrollUpdate(dX, dY, modifiers));
495 } 494 }
496 495
497 void SimulateGesturePinchUpdateEvent(float scale, 496 void SimulateGesturePinchUpdateEvent(float scale,
498 float anchorX, 497 float anchorX,
499 float anchorY, 498 float anchorY,
500 int modifiers) { 499 int modifiers) {
501 SimulateGestureEventCore(SyntheticWebGestureEventBuilder::BuildPinchUpdate( 500 SimulateGestureEventCore(SyntheticWebGestureEventBuilder::BuildPinchUpdate(
502 scale, anchorX, anchorY, modifiers, WebGestureEvent::Touchscreen)); 501 scale,
502 anchorX,
503 anchorY,
504 modifiers,
505 blink::WebGestureDeviceTouchscreen));
503 } 506 }
504 507
505 // Inject synthetic GestureFlingStart events. 508 // Inject synthetic GestureFlingStart events.
506 void SimulateGestureFlingStartEvent( 509 void SimulateGestureFlingStartEvent(float velocityX,
507 float velocityX, 510 float velocityY,
508 float velocityY, 511 blink::WebGestureDevice sourceDevice) {
509 WebGestureEvent::SourceDevice sourceDevice) {
510 SimulateGestureEventCore(SyntheticWebGestureEventBuilder::BuildFling( 512 SimulateGestureEventCore(SyntheticWebGestureEventBuilder::BuildFling(
511 velocityX, velocityY, sourceDevice)); 513 velocityX, velocityY, sourceDevice));
512 } 514 }
513 515
514 void SendInputEventACK(WebInputEvent::Type type, 516 void SendInputEventACK(WebInputEvent::Type type,
515 InputEventAckState ack_result) { 517 InputEventAckState ack_result) {
516 InputHostMsg_HandleInputEvent_ACK_Params ack; 518 InputHostMsg_HandleInputEvent_ACK_Params ack;
517 ack.type = type; 519 ack.type = type;
518 ack.state = ack_result; 520 ack.state = ack_result;
519 InputHostMsg_HandleInputEvent_ACK response(0, ack); 521 InputHostMsg_HandleInputEvent_ACK response(0, ack);
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1876 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1875 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 1877 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
1876 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1878 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1877 1879
1878 SendInputEventACK(WebInputEvent::MouseWheel, 1880 SendInputEventACK(WebInputEvent::MouseWheel,
1879 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1881 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1880 EXPECT_EQ(0U, sink_->message_count()); 1882 EXPECT_EQ(0U, sink_->message_count());
1881 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 1883 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
1882 1884
1883 // Indicate the end of the scrolling from the touchpad. 1885 // Indicate the end of the scrolling from the touchpad.
1884 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad); 1886 SimulateGestureFlingStartEvent(-1200.f, 0.f, blink::WebGestureDeviceTouchpad);
1885 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1887 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1886 1888
1887 // Start another scroll. This time, do not consume any scroll events. 1889 // Start another scroll. This time, do not consume any scroll events.
1888 SimulateWheelEvent(0, -5, 0, true); // sent directly 1890 SimulateWheelEvent(0, -5, 0, true); // sent directly
1889 SimulateWheelEvent(0, -1, 0, true); // enqueued 1891 SimulateWheelEvent(0, -1, 0, true); // enqueued
1890 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 1892 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
1891 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 1893 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
1892 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 1894 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
1893 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 1895 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
1894 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 1896 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 1996 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
1995 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 1997 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
1996 EXPECT_EQ(60.f, overscroll_delta_x()); 1998 EXPECT_EQ(60.f, overscroll_delta_x());
1997 EXPECT_EQ(10.f, overscroll_delegate()->delta_x()); 1999 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
1998 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2000 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
1999 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2001 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2000 2002
2001 // Send a fling start, but with a small velocity, so that the overscroll is 2003 // Send a fling start, but with a small velocity, so that the overscroll is
2002 // aborted. The fling should proceed to the renderer, through the gesture 2004 // aborted. The fling should proceed to the renderer, through the gesture
2003 // event filter. 2005 // event filter.
2004 SimulateGestureFlingStartEvent(0.f, 0.1f, WebGestureEvent::Touchpad); 2006 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
2005 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2007 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2006 EXPECT_EQ(1U, sink_->message_count()); 2008 EXPECT_EQ(1U, sink_->message_count());
2007 } 2009 }
2008 2010
2009 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that 2011 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
2010 // the zero-velocity fling does not reach the renderer. 2012 // the zero-velocity fling does not reach the renderer.
2011 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2013 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2012 ScrollEventsOverscrollWithZeroFling) { 2014 ScrollEventsOverscrollWithZeroFling) {
2013 SetUpOverscrollEnvironment(); 2015 SetUpOverscrollEnvironment();
2014 2016
(...skipping 21 matching lines...) Expand all
2036 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2038 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2037 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2039 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2038 EXPECT_EQ(60.f, overscroll_delta_x()); 2040 EXPECT_EQ(60.f, overscroll_delta_x());
2039 EXPECT_EQ(10.f, overscroll_delegate()->delta_x()); 2041 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
2040 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2042 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2041 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2043 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2042 2044
2043 // Send a fling start, but with a small velocity, so that the overscroll is 2045 // Send a fling start, but with a small velocity, so that the overscroll is
2044 // aborted. The fling should proceed to the renderer, through the gesture 2046 // aborted. The fling should proceed to the renderer, through the gesture
2045 // event filter. 2047 // event filter.
2046 SimulateGestureFlingStartEvent(10.f, 0.f, WebGestureEvent::Touchpad); 2048 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad);
2047 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2049 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2048 EXPECT_EQ(1U, sink_->message_count()); 2050 EXPECT_EQ(1U, sink_->message_count());
2049 } 2051 }
2050 2052
2051 // Tests that a fling in the opposite direction of the overscroll cancels the 2053 // Tests that a fling in the opposite direction of the overscroll cancels the
2052 // overscroll nav instead of completing it. 2054 // overscroll nav instead of completing it.
2053 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ReverseFlingCancelsOverscroll) { 2055 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ReverseFlingCancelsOverscroll) {
2054 SetUpOverscrollEnvironment(); 2056 SetUpOverscrollEnvironment();
2055 2057
2056 { 2058 {
2057 // Start and end a gesture in the same direction without processing the 2059 // Start and end a gesture in the same direction without processing the
2058 // gesture events in the renderer. This should initiate and complete an 2060 // gesture events in the renderer. This should initiate and complete an
2059 // overscroll navigation. 2061 // overscroll navigation.
2060 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2062 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2061 WebGestureEvent::Touchscreen); 2063 blink::WebGestureDeviceTouchscreen);
2062 SimulateGestureScrollUpdateEvent(300, -5, 0); 2064 SimulateGestureScrollUpdateEvent(300, -5, 0);
2063 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2065 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2064 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2066 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2065 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2067 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2066 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2068 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2067 sink_->ClearMessages(); 2069 sink_->ClearMessages();
2068 2070
2069 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2071 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2070 WebGestureEvent::Touchscreen); 2072 blink::WebGestureDeviceTouchscreen);
2071 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 2073 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
2072 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2074 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2073 EXPECT_EQ(1U, sink_->message_count()); 2075 EXPECT_EQ(1U, sink_->message_count());
2074 } 2076 }
2075 2077
2076 { 2078 {
2077 // Start over, except instead of ending the gesture with ScrollEnd, end it 2079 // Start over, except instead of ending the gesture with ScrollEnd, end it
2078 // with a FlingStart, with velocity in the reverse direction. This should 2080 // with a FlingStart, with velocity in the reverse direction. This should
2079 // initiate an overscroll navigation, but it should be cancelled because of 2081 // initiate an overscroll navigation, but it should be cancelled because of
2080 // the fling in the opposite direction. 2082 // the fling in the opposite direction.
2081 overscroll_delegate()->Reset(); 2083 overscroll_delegate()->Reset();
2082 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2084 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2083 WebGestureEvent::Touchscreen); 2085 blink::WebGestureDeviceTouchscreen);
2084 SimulateGestureScrollUpdateEvent(-300, -5, 0); 2086 SimulateGestureScrollUpdateEvent(-300, -5, 0);
2085 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2087 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2086 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2088 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2087 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); 2089 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2088 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); 2090 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
2089 sink_->ClearMessages(); 2091 sink_->ClearMessages();
2090 2092
2091 SimulateGestureFlingStartEvent(100, 0, WebGestureEvent::Touchscreen); 2093 SimulateGestureFlingStartEvent(100, 0, blink::WebGestureDeviceTouchscreen);
2092 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 2094 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
2093 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2095 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2094 EXPECT_EQ(1U, sink_->message_count()); 2096 EXPECT_EQ(1U, sink_->message_count());
2095 } 2097 }
2096 } 2098 }
2097 2099
2098 // Tests that touch-scroll events are handled correctly by the overscroll 2100 // Tests that touch-scroll events are handled correctly by the overscroll
2099 // controller. This also tests that the overscroll controller and the 2101 // controller. This also tests that the overscroll controller and the
2100 // gesture-event filter play nice with each other. 2102 // gesture-event filter play nice with each other.
2101 TEST_F(RenderWidgetHostViewAuraOverscrollTest, GestureScrollOverscrolls) { 2103 TEST_F(RenderWidgetHostViewAuraOverscrollTest, GestureScrollOverscrolls) {
2102 SetUpOverscrollEnvironment(); 2104 SetUpOverscrollEnvironment();
2103 2105
2104 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2106 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2105 WebGestureEvent::Touchscreen); 2107 blink::WebGestureDeviceTouchscreen);
2106 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2108 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2107 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2109 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2108 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2110 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2109 2111
2110 // Send another gesture event and ACK as not being processed. This should 2112 // Send another gesture event and ACK as not being processed. This should
2111 // initiate the navigation gesture. 2113 // initiate the navigation gesture.
2112 SimulateGestureScrollUpdateEvent(55, -5, 0); 2114 SimulateGestureScrollUpdateEvent(55, -5, 0);
2113 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2115 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2114 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2116 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2115 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2117 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
(...skipping 13 matching lines...) Expand all
2129 EXPECT_EQ(65.f, overscroll_delta_x()); 2131 EXPECT_EQ(65.f, overscroll_delta_x());
2130 EXPECT_EQ(-10.f, overscroll_delta_y()); 2132 EXPECT_EQ(-10.f, overscroll_delta_y());
2131 EXPECT_EQ(15.f, overscroll_delegate()->delta_x()); 2133 EXPECT_EQ(15.f, overscroll_delegate()->delta_x());
2132 EXPECT_EQ(-10.f, overscroll_delegate()->delta_y()); 2134 EXPECT_EQ(-10.f, overscroll_delegate()->delta_y());
2133 EXPECT_EQ(0U, sink_->message_count()); 2135 EXPECT_EQ(0U, sink_->message_count());
2134 2136
2135 // Now send a scroll end. This should cancel the overscroll gesture, and send 2137 // Now send a scroll end. This should cancel the overscroll gesture, and send
2136 // the event to the renderer. The gesture-event filter should receive this 2138 // the event to the renderer. The gesture-event filter should receive this
2137 // event. 2139 // event.
2138 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2140 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2139 WebGestureEvent::Touchscreen); 2141 blink::WebGestureDeviceTouchscreen);
2140 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2142 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2141 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2143 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2142 EXPECT_EQ(1U, sink_->message_count()); 2144 EXPECT_EQ(1U, sink_->message_count());
2143 } 2145 }
2144 2146
2145 // Tests that if the page is scrolled because of a scroll-gesture, then that 2147 // Tests that if the page is scrolled because of a scroll-gesture, then that
2146 // particular scroll sequence never generates overscroll if the scroll direction 2148 // particular scroll sequence never generates overscroll if the scroll direction
2147 // is horizontal. 2149 // is horizontal.
2148 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2150 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2149 GestureScrollConsumedHorizontal) { 2151 GestureScrollConsumedHorizontal) {
2150 SetUpOverscrollEnvironment(); 2152 SetUpOverscrollEnvironment();
2151 2153
2152 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2154 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2153 WebGestureEvent::Touchscreen); 2155 blink::WebGestureDeviceTouchscreen);
2154 SimulateGestureScrollUpdateEvent(10, 0, 0); 2156 SimulateGestureScrollUpdateEvent(10, 0, 0);
2155 2157
2156 // Start scrolling on content. ACK both events as being processed. 2158 // Start scrolling on content. ACK both events as being processed.
2157 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2159 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2158 INPUT_EVENT_ACK_STATE_CONSUMED); 2160 INPUT_EVENT_ACK_STATE_CONSUMED);
2159 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2161 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2160 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2162 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2161 sink_->ClearMessages(); 2163 sink_->ClearMessages();
2162 2164
2163 // Send another gesture event and ACK as not being processed. This should 2165 // Send another gesture event and ACK as not being processed. This should
2164 // not initiate overscroll because the beginning of the scroll event did 2166 // not initiate overscroll because the beginning of the scroll event did
2165 // scroll some content on the page. Since there was no overscroll, the event 2167 // scroll some content on the page. Since there was no overscroll, the event
2166 // should reach the renderer. 2168 // should reach the renderer.
2167 SimulateGestureScrollUpdateEvent(55, 0, 0); 2169 SimulateGestureScrollUpdateEvent(55, 0, 0);
2168 EXPECT_EQ(1U, sink_->message_count()); 2170 EXPECT_EQ(1U, sink_->message_count());
2169 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2171 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2170 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2172 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2171 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2173 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2172 } 2174 }
2173 2175
2174 // Tests that the overscroll controller plays nice with touch-scrolls and the 2176 // Tests that the overscroll controller plays nice with touch-scrolls and the
2175 // gesture event filter with debounce filtering turned on. 2177 // gesture event filter with debounce filtering turned on.
2176 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2178 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2177 GestureScrollDebounceOverscrolls) { 2179 GestureScrollDebounceOverscrolls) {
2178 SetUpOverscrollEnvironmentWithDebounce(100); 2180 SetUpOverscrollEnvironmentWithDebounce(100);
2179 2181
2180 // Start scrolling. Receive ACK as it being processed. 2182 // Start scrolling. Receive ACK as it being processed.
2181 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2183 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2182 WebGestureEvent::Touchscreen); 2184 blink::WebGestureDeviceTouchscreen);
2183 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2185 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2184 2186
2185 // Send update events. 2187 // Send update events.
2186 SimulateGestureScrollUpdateEvent(25, 0, 0); 2188 SimulateGestureScrollUpdateEvent(25, 0, 0);
2187 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2189 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2188 2190
2189 // Quickly end and restart the scroll gesture. These two events should get 2191 // Quickly end and restart the scroll gesture. These two events should get
2190 // discarded. 2192 // discarded.
2191 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2193 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2192 WebGestureEvent::Touchscreen); 2194 blink::WebGestureDeviceTouchscreen);
2193 EXPECT_EQ(0U, sink_->message_count()); 2195 EXPECT_EQ(0U, sink_->message_count());
2194 2196
2195 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2197 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2196 WebGestureEvent::Touchscreen); 2198 blink::WebGestureDeviceTouchscreen);
2197 EXPECT_EQ(0U, sink_->message_count()); 2199 EXPECT_EQ(0U, sink_->message_count());
2198 2200
2199 // Send another update event. This should get into the queue. 2201 // Send another update event. This should get into the queue.
2200 SimulateGestureScrollUpdateEvent(30, 0, 0); 2202 SimulateGestureScrollUpdateEvent(30, 0, 0);
2201 EXPECT_EQ(0U, sink_->message_count()); 2203 EXPECT_EQ(0U, sink_->message_count());
2202 2204
2203 // Receive an ACK for the first scroll-update event as not being processed. 2205 // Receive an ACK for the first scroll-update event as not being processed.
2204 // This will contribute to the overscroll gesture, but not enough for the 2206 // This will contribute to the overscroll gesture, but not enough for the
2205 // overscroll controller to start consuming gesture events. This also cause 2207 // overscroll controller to start consuming gesture events. This also cause
2206 // the queued gesture event to be forwarded to the renderer. 2208 // the queued gesture event to be forwarded to the renderer.
(...skipping 22 matching lines...) Expand all
2229 } 2231 }
2230 2232
2231 // Tests that the gesture debounce timer plays nice with the overscroll 2233 // Tests that the gesture debounce timer plays nice with the overscroll
2232 // controller. 2234 // controller.
2233 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2235 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2234 GestureScrollDebounceTimerOverscroll) { 2236 GestureScrollDebounceTimerOverscroll) {
2235 SetUpOverscrollEnvironmentWithDebounce(10); 2237 SetUpOverscrollEnvironmentWithDebounce(10);
2236 2238
2237 // Start scrolling. Receive ACK as it being processed. 2239 // Start scrolling. Receive ACK as it being processed.
2238 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2240 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2239 WebGestureEvent::Touchscreen); 2241 blink::WebGestureDeviceTouchscreen);
2240 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2242 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2241 2243
2242 // Send update events. 2244 // Send update events.
2243 SimulateGestureScrollUpdateEvent(55, 0, 0); 2245 SimulateGestureScrollUpdateEvent(55, 0, 0);
2244 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2246 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2245 2247
2246 // Send an end event. This should get in the debounce queue. 2248 // Send an end event. This should get in the debounce queue.
2247 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2249 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2248 WebGestureEvent::Touchscreen); 2250 blink::WebGestureDeviceTouchscreen);
2249 EXPECT_EQ(0U, sink_->message_count()); 2251 EXPECT_EQ(0U, sink_->message_count());
2250 2252
2251 // Receive ACK for the scroll-update event. 2253 // Receive ACK for the scroll-update event.
2252 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2254 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2253 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2255 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2254 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2256 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2255 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2257 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2256 EXPECT_EQ(55.f, overscroll_delta_x()); 2258 EXPECT_EQ(55.f, overscroll_delta_x());
2257 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); 2259 EXPECT_EQ(5.f, overscroll_delegate()->delta_x());
2258 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2260 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
(...skipping 30 matching lines...) Expand all
2289 2291
2290 MoveTouchPoint(0, 20, 5); 2292 MoveTouchPoint(0, 20, 5);
2291 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2293 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2292 SendInputEventACK(WebInputEvent::TouchMove, 2294 SendInputEventACK(WebInputEvent::TouchMove,
2293 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2295 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2294 2296
2295 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2297 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2296 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2298 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2297 2299
2298 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2300 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2299 WebGestureEvent::Touchscreen); 2301 blink::WebGestureDeviceTouchscreen);
2300 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2302 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2301 SimulateGestureScrollUpdateEvent(20, 0, 0); 2303 SimulateGestureScrollUpdateEvent(20, 0, 0);
2302 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2304 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2303 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2305 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2304 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2306 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2305 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2307 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2306 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2308 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2307 2309
2308 // Another touch move event should reach the renderer since overscroll hasn't 2310 // Another touch move event should reach the renderer since overscroll hasn't
2309 // started yet. Note that touch events sent during the scroll period may 2311 // started yet. Note that touch events sent during the scroll period may
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 // The touch-end/cancel event should always reach the renderer if the page has 2358 // The touch-end/cancel event should always reach the renderer if the page has
2357 // touch handlers. 2359 // touch handlers.
2358 ReleaseTouchPoint(1); 2360 ReleaseTouchPoint(1);
2359 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2361 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2360 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2362 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2361 ReleaseTouchPoint(0); 2363 ReleaseTouchPoint(0);
2362 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2364 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2363 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2365 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2364 2366
2365 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, 2367 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
2366 WebGestureEvent::Touchscreen); 2368 blink::WebGestureDeviceTouchscreen);
2367 base::MessageLoop::current()->PostDelayedTask( 2369 base::MessageLoop::current()->PostDelayedTask(
2368 FROM_HERE, 2370 FROM_HERE,
2369 base::MessageLoop::QuitClosure(), 2371 base::MessageLoop::QuitClosure(),
2370 base::TimeDelta::FromMilliseconds(10)); 2372 base::TimeDelta::FromMilliseconds(10));
2371 base::MessageLoop::current()->Run(); 2373 base::MessageLoop::current()->Run();
2372 EXPECT_EQ(1U, sink_->message_count()); 2374 EXPECT_EQ(1U, sink_->message_count());
2373 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2375 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2374 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2376 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2375 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 2377 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
2376 } 2378 }
2377 2379
2378 // Tests that touch-gesture end is dispatched to the renderer at the end of a 2380 // Tests that touch-gesture end is dispatched to the renderer at the end of a
2379 // touch-gesture initiated overscroll. 2381 // touch-gesture initiated overscroll.
2380 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2382 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2381 TouchGestureEndDispatchedAfterOverscrollComplete) { 2383 TouchGestureEndDispatchedAfterOverscrollComplete) {
2382 SetUpOverscrollEnvironmentWithDebounce(10); 2384 SetUpOverscrollEnvironmentWithDebounce(10);
2383 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 2385 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
2384 sink_->ClearMessages(); 2386 sink_->ClearMessages();
2385 2387
2386 // Start scrolling. Receive ACK as it being processed. 2388 // Start scrolling. Receive ACK as it being processed.
2387 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2389 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2388 WebGestureEvent::Touchscreen); 2390 blink::WebGestureDeviceTouchscreen);
2389 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2391 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2390 // The scroll begin event will have received a synthetic ack from the input 2392 // The scroll begin event will have received a synthetic ack from the input
2391 // router. 2393 // router.
2392 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2394 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2393 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2395 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2394 2396
2395 // Send update events. 2397 // Send update events.
2396 SimulateGestureScrollUpdateEvent(55, -5, 0); 2398 SimulateGestureScrollUpdateEvent(55, -5, 0);
2397 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2399 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2398 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2400 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2399 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2401 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2400 2402
2401 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2403 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2402 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2404 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2403 EXPECT_EQ(0U, sink_->message_count()); 2405 EXPECT_EQ(0U, sink_->message_count());
2404 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2406 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2405 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2407 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2406 EXPECT_EQ(55.f, overscroll_delta_x()); 2408 EXPECT_EQ(55.f, overscroll_delta_x());
2407 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); 2409 EXPECT_EQ(5.f, overscroll_delegate()->delta_x());
2408 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); 2410 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y());
2409 2411
2410 // Send end event. 2412 // Send end event.
2411 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, 2413 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
2412 WebGestureEvent::Touchscreen); 2414 blink::WebGestureDeviceTouchscreen);
2413 EXPECT_EQ(0U, sink_->message_count()); 2415 EXPECT_EQ(0U, sink_->message_count());
2414 base::MessageLoop::current()->PostDelayedTask( 2416 base::MessageLoop::current()->PostDelayedTask(
2415 FROM_HERE, 2417 FROM_HERE,
2416 base::MessageLoop::QuitClosure(), 2418 base::MessageLoop::QuitClosure(),
2417 base::TimeDelta::FromMilliseconds(10)); 2419 base::TimeDelta::FromMilliseconds(10));
2418 base::MessageLoop::current()->Run(); 2420 base::MessageLoop::current()->Run();
2419 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2421 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2420 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2422 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2421 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 2423 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
2422 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2424 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2423 2425
2424 // Start scrolling. Receive ACK as it being processed. 2426 // Start scrolling. Receive ACK as it being processed.
2425 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2427 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2426 WebGestureEvent::Touchscreen); 2428 blink::WebGestureDeviceTouchscreen);
2427 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2429 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2428 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2430 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2429 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2431 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2430 2432
2431 // Send update events. 2433 // Send update events.
2432 SimulateGestureScrollUpdateEvent(235, -5, 0); 2434 SimulateGestureScrollUpdateEvent(235, -5, 0);
2433 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2435 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2434 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2436 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2435 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2437 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2436 2438
2437 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2439 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2438 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2440 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2439 EXPECT_EQ(0U, sink_->message_count()); 2441 EXPECT_EQ(0U, sink_->message_count());
2440 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2442 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2441 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2443 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2442 EXPECT_EQ(235.f, overscroll_delta_x()); 2444 EXPECT_EQ(235.f, overscroll_delta_x());
2443 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); 2445 EXPECT_EQ(185.f, overscroll_delegate()->delta_x());
2444 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); 2446 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y());
2445 2447
2446 // Send end event. 2448 // Send end event.
2447 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, 2449 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
2448 WebGestureEvent::Touchscreen); 2450 blink::WebGestureDeviceTouchscreen);
2449 EXPECT_EQ(0U, sink_->message_count()); 2451 EXPECT_EQ(0U, sink_->message_count());
2450 base::MessageLoop::current()->PostDelayedTask( 2452 base::MessageLoop::current()->PostDelayedTask(
2451 FROM_HERE, 2453 FROM_HERE,
2452 base::MessageLoop::QuitClosure(), 2454 base::MessageLoop::QuitClosure(),
2453 base::TimeDelta::FromMilliseconds(10)); 2455 base::TimeDelta::FromMilliseconds(10));
2454 base::MessageLoop::current()->Run(); 2456 base::MessageLoop::current()->Run();
2455 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2457 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2456 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2458 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2457 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 2459 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
2458 EXPECT_EQ(1U, sink_->message_count()); 2460 EXPECT_EQ(1U, sink_->message_count());
2459 } 2461 }
2460 2462
2461 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { 2463 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) {
2462 SetUpOverscrollEnvironmentWithDebounce(100); 2464 SetUpOverscrollEnvironmentWithDebounce(100);
2463 2465
2464 // Start scrolling. Receive ACK as it being processed. 2466 // Start scrolling. Receive ACK as it being processed.
2465 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2467 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2466 WebGestureEvent::Touchscreen); 2468 blink::WebGestureDeviceTouchscreen);
2467 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2469 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2468 2470
2469 // Send update events and receive ack as not consumed. 2471 // Send update events and receive ack as not consumed.
2470 SimulateGestureScrollUpdateEvent(125, -5, 0); 2472 SimulateGestureScrollUpdateEvent(125, -5, 0);
2471 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2473 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2472 2474
2473 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2475 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2474 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2476 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2475 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2477 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2476 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2478 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2532 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2531 2533
2532 // Moving the mouse more should continue to send the events to the renderer. 2534 // Moving the mouse more should continue to send the events to the renderer.
2533 SimulateMouseMove(5, 10, 0); 2535 SimulateMouseMove(5, 10, 0);
2534 SendInputEventACK(WebInputEvent::MouseMove, 2536 SendInputEventACK(WebInputEvent::MouseMove,
2535 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2537 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2536 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2538 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2537 2539
2538 // Now try with gestures. 2540 // Now try with gestures.
2539 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2541 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2540 WebGestureEvent::Touchscreen); 2542 blink::WebGestureDeviceTouchscreen);
2541 SimulateGestureScrollUpdateEvent(300, -5, 0); 2543 SimulateGestureScrollUpdateEvent(300, -5, 0);
2542 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2544 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2543 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2545 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2544 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2546 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2545 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2547 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2546 sink_->ClearMessages(); 2548 sink_->ClearMessages();
2547 2549
2548 // Overscroll gesture is in progress. Send a mouse-move now. This should 2550 // Overscroll gesture is in progress. Send a mouse-move now. This should
2549 // complete the gesture (because the amount overscrolled is above the 2551 // complete the gesture (because the amount overscrolled is above the
2550 // threshold). 2552 // threshold).
2551 SimulateMouseMove(5, 10, 0); 2553 SimulateMouseMove(5, 10, 0);
2552 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 2554 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
2553 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2555 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2554 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2556 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2555 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2557 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2556 SendInputEventACK(WebInputEvent::MouseMove, 2558 SendInputEventACK(WebInputEvent::MouseMove,
2557 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2559 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2558 2560
2559 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2561 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2560 WebGestureEvent::Touchscreen); 2562 blink::WebGestureDeviceTouchscreen);
2561 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2563 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2562 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2564 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2563 2565
2564 // Move mouse some more. The mouse-move events should reach the renderer. 2566 // Move mouse some more. The mouse-move events should reach the renderer.
2565 SimulateMouseMove(5, 10, 0); 2567 SimulateMouseMove(5, 10, 0);
2566 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2568 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2567 2569
2568 SendInputEventACK(WebInputEvent::MouseMove, 2570 SendInputEventACK(WebInputEvent::MouseMove,
2569 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2571 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2570 } 2572 }
(...skipping 15 matching lines...) Expand all
2586 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); 2588 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED);
2587 EXPECT_TRUE(ScrollStateIsContentScrolling()); 2589 EXPECT_TRUE(ScrollStateIsContentScrolling());
2588 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2590 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2589 2591
2590 // The second wheel event is consumed. 2592 // The second wheel event is consumed.
2591 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); 2593 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED);
2592 EXPECT_TRUE(ScrollStateIsContentScrolling()); 2594 EXPECT_TRUE(ScrollStateIsContentScrolling());
2593 2595
2594 // Touchpad scroll can end with a zero-velocity fling. But it is not 2596 // Touchpad scroll can end with a zero-velocity fling. But it is not
2595 // dispatched, but it should still reset the overscroll controller state. 2597 // dispatched, but it should still reset the overscroll controller state.
2596 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); 2598 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad);
2597 EXPECT_TRUE(ScrollStateIsUnknown()); 2599 EXPECT_TRUE(ScrollStateIsUnknown());
2598 EXPECT_EQ(0U, sink_->message_count()); 2600 EXPECT_EQ(0U, sink_->message_count());
2599 2601
2600 SimulateWheelEvent(-5, 0, 0, true); // sent directly 2602 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2601 SimulateWheelEvent(-60, 0, 0, true); // enqueued 2603 SimulateWheelEvent(-60, 0, 0, true); // enqueued
2602 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event 2604 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event
2603 EXPECT_TRUE(ScrollStateIsUnknown()); 2605 EXPECT_TRUE(ScrollStateIsUnknown());
2604 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2606 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2605 2607
2606 // The first wheel scroll did not scroll content. Overscroll should not start 2608 // The first wheel scroll did not scroll content. Overscroll should not start
2607 // yet, since enough hasn't been scrolled. 2609 // yet, since enough hasn't been scrolled.
2608 SendInputEventACK(WebInputEvent::MouseWheel, 2610 SendInputEventACK(WebInputEvent::MouseWheel,
2609 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2611 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2610 EXPECT_TRUE(ScrollStateIsUnknown()); 2612 EXPECT_TRUE(ScrollStateIsUnknown());
2611 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2613 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2612 2614
2613 SendInputEventACK(WebInputEvent::MouseWheel, 2615 SendInputEventACK(WebInputEvent::MouseWheel,
2614 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2616 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2615 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); 2617 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2616 EXPECT_TRUE(ScrollStateIsOverscrolling()); 2618 EXPECT_TRUE(ScrollStateIsOverscrolling());
2617 EXPECT_EQ(0U, sink_->message_count()); 2619 EXPECT_EQ(0U, sink_->message_count());
2618 2620
2619 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); 2621 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad);
2620 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2622 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2621 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->completed_mode()); 2623 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->completed_mode());
2622 EXPECT_TRUE(ScrollStateIsUnknown()); 2624 EXPECT_TRUE(ScrollStateIsUnknown());
2623 EXPECT_EQ(0U, sink_->message_count()); 2625 EXPECT_EQ(0U, sink_->message_count());
2624 } 2626 }
2625 2627
2626 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) { 2628 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) {
2627 SetUpOverscrollEnvironment(); 2629 SetUpOverscrollEnvironment();
2628 2630
2629 // Start an overscroll with gesture scroll. In the middle of the scroll, blur 2631 // Start an overscroll with gesture scroll. In the middle of the scroll, blur
2630 // the host. 2632 // the host.
2631 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2633 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2632 WebGestureEvent::Touchscreen); 2634 blink::WebGestureDeviceTouchscreen);
2633 SimulateGestureScrollUpdateEvent(300, -5, 0); 2635 SimulateGestureScrollUpdateEvent(300, -5, 0);
2634 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2636 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2635 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2637 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2636 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2638 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2637 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2639 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2638 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); 2640 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2639 2641
2640 view_->OnWindowFocused(NULL, view_->GetAttachedWindow()); 2642 view_->OnWindowFocused(NULL, view_->GetAttachedWindow());
2641 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2643 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2642 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2644 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2643 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 2645 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
2644 EXPECT_EQ(0.f, overscroll_delegate()->delta_x()); 2646 EXPECT_EQ(0.f, overscroll_delegate()->delta_x());
2645 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2647 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2646 sink_->ClearMessages(); 2648 sink_->ClearMessages();
2647 2649
2648 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2650 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2649 WebGestureEvent::Touchscreen); 2651 blink::WebGestureDeviceTouchscreen);
2650 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2652 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2651 2653
2652 // Start a scroll gesture again. This should correctly start the overscroll 2654 // Start a scroll gesture again. This should correctly start the overscroll
2653 // after the threshold. 2655 // after the threshold.
2654 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2656 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2655 WebGestureEvent::Touchscreen); 2657 blink::WebGestureDeviceTouchscreen);
2656 SimulateGestureScrollUpdateEvent(300, -5, 0); 2658 SimulateGestureScrollUpdateEvent(300, -5, 0);
2657 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2659 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2658 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2660 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2659 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2661 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2660 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2662 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2661 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 2663 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
2662 2664
2663 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2665 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2664 WebGestureEvent::Touchscreen); 2666 blink::WebGestureDeviceTouchscreen);
2665 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2667 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2666 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 2668 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
2667 EXPECT_EQ(3U, sink_->message_count()); 2669 EXPECT_EQ(3U, sink_->message_count());
2668 } 2670 }
2669 2671
2670 } // namespace content 2672 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | content/browser/renderer_host/ui_events_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698