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

Side by Side 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: Fixed broken unit test Created 7 years, 4 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/renderer_host/backing_store.h" 10 #include "content/browser/renderer_host/backing_store.h"
(...skipping 3136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3147 } 3147 }
3148 #endif 3148 #endif
3149 3149
3150 // Tests that scroll ACKs are correctly handled by the overscroll-navigation 3150 // Tests that scroll ACKs are correctly handled by the overscroll-navigation
3151 // controller. 3151 // controller.
3152 TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) { 3152 TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) {
3153 host_->SetupForOverscrollControllerTest(); 3153 host_->SetupForOverscrollControllerTest();
3154 process_->sink().ClearMessages(); 3154 process_->sink().ClearMessages();
3155 3155
3156 // Simulate wheel events. 3156 // Simulate wheel events.
3157 SimulateWheelEvent(0, -5, 0, true); // sent directly 3157 SimulateWheelEvent(-5, 0, 0, true); // sent directly
3158 SimulateWheelEvent(0, -1, 0, true); // enqueued 3158 SimulateWheelEvent(-1, 1, 0, true); // enqueued
3159 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3159 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3160 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3160 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3161 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3161 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3162 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 3162 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
3163 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3163 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3164 EXPECT_EQ(1U, process_->sink().message_count()); 3164 EXPECT_EQ(1U, process_->sink().message_count());
3165 process_->sink().ClearMessages(); 3165 process_->sink().ClearMessages();
3166 3166
3167 // Receive ACK the first wheel event as not processed. 3167 // Receive ACK the first wheel event as not processed.
3168 SendInputEventACK(WebInputEvent::MouseWheel, 3168 SendInputEventACK(WebInputEvent::MouseWheel,
3169 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3169 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3170 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3170 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3171 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3171 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3172 EXPECT_EQ(1U, process_->sink().message_count()); 3172 EXPECT_EQ(1U, process_->sink().message_count());
3173 process_->sink().ClearMessages(); 3173 process_->sink().ClearMessages();
3174 3174
3175 // Receive ACK for the second (coalesced) event as not processed. This will 3175 // Receive ACK for the second (coalesced) event as not processed. This will
3176 // start a back navigation. However, this will also cause the queued next 3176 // start a back navigation. However, this will also cause the queued next
3177 // event to be sent to the renderer. But since overscroll navigation has 3177 // event to be sent to the renderer. But since overscroll navigation has
3178 // started, that event will also be included in the overscroll computation 3178 // started, that event will also be included in the overscroll computation
3179 // instead of being sent to the renderer. So the result will be an overscroll 3179 // instead of being sent to the renderer. So the result will be an overscroll
3180 // back navigation, and no event will be sent to the renderer. 3180 // back navigation, and no event will be sent to the renderer.
3181 SendInputEventACK(WebInputEvent::MouseWheel, 3181 SendInputEventACK(WebInputEvent::MouseWheel,
3182 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3182 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3183 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); 3183 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
3184 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); 3184 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode());
3185 EXPECT_EQ(-75.f, host_->overscroll_delta_x()); 3185 EXPECT_EQ(-81.f, host_->overscroll_delta_x());
3186 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x()); 3186 EXPECT_EQ(-31.f, host_->overscroll_delegate()->delta_x());
3187 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3187 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3188 EXPECT_EQ(0U, process_->sink().message_count()); 3188 EXPECT_EQ(0U, process_->sink().message_count());
3189 3189
3190 // Send a mouse-move event. This should cancel the overscroll navigation. 3190 // Send a mouse-move event. This should cancel the overscroll navigation.
3191 SimulateMouseMove(5, 10, 0); 3191 SimulateMouseMove(5, 10, 0);
3192 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3192 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3193 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3193 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3194 } 3194 }
3195 3195
3196 // Tests that if some scroll events are consumed towards the start, then 3196 // Tests that if some scroll events are consumed towards the start, then
3197 // subsequent scrolls do not overscroll. 3197 // subsequent scrolls do not horizontal overscroll.
3198 TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotOverscroll) { 3198 TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotHorizOverscroll) {
3199 host_->SetupForOverscrollControllerTest(); 3199 host_->SetupForOverscrollControllerTest();
3200 process_->sink().ClearMessages(); 3200 process_->sink().ClearMessages();
3201 3201
3202 // Simulate wheel events. 3202 // Simulate wheel events.
3203 SimulateWheelEvent(0, -5, 0, true); // sent directly 3203 SimulateWheelEvent(-5, 0, 0, true); // sent directly
3204 SimulateWheelEvent(0, -1, 0, true); // enqueued 3204 SimulateWheelEvent(-1, -1, 0, true); // enqueued
3205 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3205 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3206 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3206 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3207 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3207 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3208 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 3208 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
3209 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3209 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3210 EXPECT_EQ(1U, process_->sink().message_count()); 3210 EXPECT_EQ(1U, process_->sink().message_count());
3211 process_->sink().ClearMessages(); 3211 process_->sink().ClearMessages();
3212 3212
3213 // Receive ACK the first wheel event as processed. 3213 // Receive ACK the first wheel event as processed.
3214 SendInputEventACK(WebInputEvent::MouseWheel, 3214 SendInputEventACK(WebInputEvent::MouseWheel,
3215 INPUT_EVENT_ACK_STATE_CONSUMED); 3215 INPUT_EVENT_ACK_STATE_CONSUMED);
3216 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3216 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3217 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3217 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3218 EXPECT_EQ(1U, process_->sink().message_count()); 3218 EXPECT_EQ(1U, process_->sink().message_count());
3219 process_->sink().ClearMessages(); 3219 process_->sink().ClearMessages();
3220 3220
3221 // Receive ACK for the second (coalesced) event as not processed. This should 3221 // Receive ACK for the second (coalesced) event as not processed. This should
3222 // not initiate overscroll, since the beginning of the scroll has been 3222 // not initiate overscroll, since the beginning of the scroll has been
3223 // consumed. The queued event with different modifiers should be sent to the 3223 // consumed. The queued event with different modifiers should be sent to the
3224 // renderer. 3224 // renderer.
3225 SendInputEventACK(WebInputEvent::MouseWheel, 3225 SendInputEventACK(WebInputEvent::MouseWheel,
3226 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3226 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3227 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3227 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3228 EXPECT_EQ(1U, process_->sink().message_count()); 3228 EXPECT_EQ(0U, process_->sink().message_count());
3229 3229
3230 process_->sink().ClearMessages(); 3230 process_->sink().ClearMessages();
3231 SendInputEventACK(WebInputEvent::MouseWheel, 3231 SendInputEventACK(WebInputEvent::MouseWheel,
3232 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3232 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3233 EXPECT_EQ(0U, process_->sink().message_count()); 3233 EXPECT_EQ(0U, process_->sink().message_count());
3234 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3234 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3235 3235
3236 // Indicate the end of the scrolling from the touchpad. 3236 // Indicate the end of the scrolling from the touchpad.
3237 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad); 3237 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad);
3238 EXPECT_EQ(1U, process_->sink().message_count()); 3238 EXPECT_EQ(1U, process_->sink().message_count());
(...skipping 23 matching lines...) Expand all
3262 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); 3262 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
3263 } 3263 }
3264 3264
3265 // Tests that wheel-scrolling correctly turns overscroll on and off. 3265 // Tests that wheel-scrolling correctly turns overscroll on and off.
3266 TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) { 3266 TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
3267 host_->SetupForOverscrollControllerTest(); 3267 host_->SetupForOverscrollControllerTest();
3268 process_->sink().ClearMessages(); 3268 process_->sink().ClearMessages();
3269 3269
3270 // Send a wheel event. ACK the event as not processed. This should not 3270 // Send a wheel event. ACK the event as not processed. This should not
3271 // initiate an overscroll gesture since it doesn't cross the threshold yet. 3271 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3272 SimulateWheelEvent(10, -5, 0, true); 3272 SimulateWheelEvent(10, 0, 0, true);
3273 EXPECT_EQ(1U, process_->sink().message_count()); 3273 EXPECT_EQ(1U, process_->sink().message_count());
3274 SendInputEventACK(WebInputEvent::MouseWheel, 3274 SendInputEventACK(WebInputEvent::MouseWheel,
3275 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3275 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3276 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3276 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3277 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3277 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3278 process_->sink().ClearMessages(); 3278 process_->sink().ClearMessages();
3279 3279
3280 // Scroll some more so as to not overscroll. 3280 // Scroll some more so as to not overscroll.
3281 SimulateWheelEvent(10, -4, 0, true); 3281 SimulateWheelEvent(10, 0, 0, true);
3282 EXPECT_EQ(1U, process_->sink().message_count()); 3282 EXPECT_EQ(1U, process_->sink().message_count());
3283 SendInputEventACK(WebInputEvent::MouseWheel, 3283 SendInputEventACK(WebInputEvent::MouseWheel,
3284 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3284 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3285 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3285 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3286 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3286 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3287 process_->sink().ClearMessages(); 3287 process_->sink().ClearMessages();
3288 3288
3289 // Scroll some more to initiate an overscroll. 3289 // Scroll some more to initiate an overscroll.
3290 SimulateWheelEvent(40, -4, 0, true); 3290 SimulateWheelEvent(40, 0, 0, true);
3291 EXPECT_EQ(1U, process_->sink().message_count()); 3291 EXPECT_EQ(1U, process_->sink().message_count());
3292 SendInputEventACK(WebInputEvent::MouseWheel, 3292 SendInputEventACK(WebInputEvent::MouseWheel,
3293 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3293 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3294 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3294 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3295 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3295 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3296 EXPECT_EQ(60.f, host_->overscroll_delta_x()); 3296 EXPECT_EQ(60.f, host_->overscroll_delta_x());
3297 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); 3297 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x());
3298 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3298 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3299 process_->sink().ClearMessages(); 3299 process_->sink().ClearMessages();
3300 3300
3301 // Scroll in the reverse direction enough to abort the overscroll. 3301 // Scroll in the reverse direction enough to abort the overscroll.
3302 SimulateWheelEvent(-20, -4, 0, true); 3302 SimulateWheelEvent(-20, 0, 0, true);
3303 EXPECT_EQ(0U, process_->sink().message_count()); 3303 EXPECT_EQ(0U, process_->sink().message_count());
3304 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3304 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3305 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3305 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3306 3306
3307 // Continue to scroll in the reverse direction. 3307 // Continue to scroll in the reverse direction.
3308 SimulateWheelEvent(-20, 4, 0, true); 3308 SimulateWheelEvent(-20, 0, 0, true);
3309 EXPECT_EQ(1U, process_->sink().message_count()); 3309 EXPECT_EQ(1U, process_->sink().message_count());
3310 SendInputEventACK(WebInputEvent::MouseWheel, 3310 SendInputEventACK(WebInputEvent::MouseWheel,
3311 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3311 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3312 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3312 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3313 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3313 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3314 process_->sink().ClearMessages(); 3314 process_->sink().ClearMessages();
3315 3315
3316 // Continue to scroll in the reverse direction enough to initiate overscroll 3316 // Continue to scroll in the reverse direction enough to initiate overscroll
3317 // in that direction. 3317 // in that direction.
3318 SimulateWheelEvent(-55, -2, 0, true); 3318 SimulateWheelEvent(-55, 0, 0, true);
3319 EXPECT_EQ(1U, process_->sink().message_count()); 3319 EXPECT_EQ(1U, process_->sink().message_count());
3320 SendInputEventACK(WebInputEvent::MouseWheel, 3320 SendInputEventACK(WebInputEvent::MouseWheel,
3321 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3321 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3322 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); 3322 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
3323 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); 3323 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode());
3324 EXPECT_EQ(-75.f, host_->overscroll_delta_x()); 3324 EXPECT_EQ(-75.f, host_->overscroll_delta_x());
3325 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x()); 3325 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x());
3326 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3326 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3327 } 3327 }
3328 3328
3329 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) { 3329 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) {
3330 host_->SetupForOverscrollControllerTest(); 3330 host_->SetupForOverscrollControllerTest();
3331 process_->sink().ClearMessages(); 3331 process_->sink().ClearMessages();
3332 3332
3333 // Send a wheel event. ACK the event as not processed. This should not 3333 // Send a wheel event. ACK the event as not processed. This should not
3334 // initiate an overscroll gesture since it doesn't cross the threshold yet. 3334 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3335 SimulateWheelEvent(10, -5, 0, true); 3335 SimulateWheelEvent(10, 0, 0, true);
3336 EXPECT_EQ(1U, process_->sink().message_count()); 3336 EXPECT_EQ(1U, process_->sink().message_count());
3337 SendInputEventACK(WebInputEvent::MouseWheel, 3337 SendInputEventACK(WebInputEvent::MouseWheel,
3338 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3338 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3339 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3339 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3340 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3340 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3341 process_->sink().ClearMessages(); 3341 process_->sink().ClearMessages();
3342 3342
3343 // Scroll some more so as to not overscroll. 3343 // Scroll some more so as to not overscroll.
3344 SimulateWheelEvent(20, -4, 0, true); 3344 SimulateWheelEvent(20, 0, 0, true);
3345 EXPECT_EQ(1U, process_->sink().message_count()); 3345 EXPECT_EQ(1U, process_->sink().message_count());
3346 SendInputEventACK(WebInputEvent::MouseWheel, 3346 SendInputEventACK(WebInputEvent::MouseWheel,
3347 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3347 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3348 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3348 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3349 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3349 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3350 process_->sink().ClearMessages(); 3350 process_->sink().ClearMessages();
3351 3351
3352 // Scroll some more to initiate an overscroll. 3352 // Scroll some more to initiate an overscroll.
3353 SimulateWheelEvent(30, -4, 0, true); 3353 SimulateWheelEvent(30, 0, 0, true);
3354 EXPECT_EQ(1U, process_->sink().message_count()); 3354 EXPECT_EQ(1U, process_->sink().message_count());
3355 SendInputEventACK(WebInputEvent::MouseWheel, 3355 SendInputEventACK(WebInputEvent::MouseWheel,
3356 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3356 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3357 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3357 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3358 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3358 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3359 EXPECT_EQ(60.f, host_->overscroll_delta_x()); 3359 EXPECT_EQ(60.f, host_->overscroll_delta_x());
3360 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); 3360 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x());
3361 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3361 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3362 process_->sink().ClearMessages(); 3362 process_->sink().ClearMessages();
3363 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3363 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3364 3364
3365 // Send a fling start, but with a small velocity, so that the overscroll is 3365 // Send a fling start, but with a small velocity, so that the overscroll is
3366 // aborted. The fling should proceed to the renderer, through the gesture 3366 // aborted. The fling should proceed to the renderer, through the gesture
3367 // event filter. 3367 // event filter.
3368 SimulateGestureFlingStartEvent(0.f, 0.1f, WebGestureEvent::Touchpad); 3368 SimulateGestureFlingStartEvent(0.f, 0.1f, WebGestureEvent::Touchpad);
3369 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3369 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3370 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3370 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3371 EXPECT_EQ(1U, process_->sink().message_count()); 3371 EXPECT_EQ(1U, process_->sink().message_count());
3372 } 3372 }
3373 3373
3374 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that 3374 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
3375 // the zero-velocity fling does not reach the renderer. 3375 // the zero-velocity fling does not reach the renderer.
3376 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) { 3376 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) {
3377 host_->SetupForOverscrollControllerTest(); 3377 host_->SetupForOverscrollControllerTest();
3378 process_->sink().ClearMessages(); 3378 process_->sink().ClearMessages();
3379 3379
3380 // Send a wheel event. ACK the event as not processed. This should not 3380 // Send a wheel event. ACK the event as not processed. This should not
3381 // initiate an overscroll gesture since it doesn't cross the threshold yet. 3381 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3382 SimulateWheelEvent(10, -5, 0, true); 3382 SimulateWheelEvent(10, 0, 0, true);
3383 EXPECT_EQ(1U, process_->sink().message_count()); 3383 EXPECT_EQ(1U, process_->sink().message_count());
3384 SendInputEventACK(WebInputEvent::MouseWheel, 3384 SendInputEventACK(WebInputEvent::MouseWheel,
3385 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3385 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3386 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3386 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3387 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3387 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3388 process_->sink().ClearMessages(); 3388 process_->sink().ClearMessages();
3389 3389
3390 // Scroll some more so as to not overscroll. 3390 // Scroll some more so as to not overscroll.
3391 SimulateWheelEvent(20, -4, 0, true); 3391 SimulateWheelEvent(20, 0, 0, true);
3392 EXPECT_EQ(1U, process_->sink().message_count()); 3392 EXPECT_EQ(1U, process_->sink().message_count());
3393 SendInputEventACK(WebInputEvent::MouseWheel, 3393 SendInputEventACK(WebInputEvent::MouseWheel,
3394 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3394 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3395 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3395 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3396 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3396 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3397 process_->sink().ClearMessages(); 3397 process_->sink().ClearMessages();
3398 3398
3399 // Scroll some more to initiate an overscroll. 3399 // Scroll some more to initiate an overscroll.
3400 SimulateWheelEvent(30, -4, 0, true); 3400 SimulateWheelEvent(30, 0, 0, true);
3401 EXPECT_EQ(1U, process_->sink().message_count()); 3401 EXPECT_EQ(1U, process_->sink().message_count());
3402 SendInputEventACK(WebInputEvent::MouseWheel, 3402 SendInputEventACK(WebInputEvent::MouseWheel,
3403 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3403 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3404 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3404 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3405 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3405 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3406 EXPECT_EQ(60.f, host_->overscroll_delta_x()); 3406 EXPECT_EQ(60.f, host_->overscroll_delta_x());
3407 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); 3407 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x());
3408 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3408 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3409 process_->sink().ClearMessages(); 3409 process_->sink().ClearMessages();
3410 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3410 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3489 // Send another gesture event and ACK as not being processed. This should 3489 // Send another gesture event and ACK as not being processed. This should
3490 // initiate the navigation gesture. 3490 // initiate the navigation gesture.
3491 SimulateGestureScrollUpdateEvent(55, -5, 0); 3491 SimulateGestureScrollUpdateEvent(55, -5, 0);
3492 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3492 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3493 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3493 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3494 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3494 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3495 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3495 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3496 EXPECT_EQ(55.f, host_->overscroll_delta_x()); 3496 EXPECT_EQ(55.f, host_->overscroll_delta_x());
3497 EXPECT_EQ(-5.f, host_->overscroll_delta_y()); 3497 EXPECT_EQ(-5.f, host_->overscroll_delta_y());
3498 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x()); 3498 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x());
3499 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3499 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
3500 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3500 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3501 process_->sink().ClearMessages(); 3501 process_->sink().ClearMessages();
3502 3502
3503 // Send another gesture update event. This event should be consumed by the 3503 // Send another gesture update event. This event should be consumed by the
3504 // controller, and not be forwarded to the renderer. The gesture-event filter 3504 // controller, and not be forwarded to the renderer. The gesture-event filter
3505 // should not also receive this event. 3505 // should not also receive this event.
3506 SimulateGestureScrollUpdateEvent(10, -5, 0); 3506 SimulateGestureScrollUpdateEvent(10, -5, 0);
3507 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3507 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3508 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3508 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3509 EXPECT_EQ(65.f, host_->overscroll_delta_x()); 3509 EXPECT_EQ(65.f, host_->overscroll_delta_x());
3510 EXPECT_EQ(-10.f, host_->overscroll_delta_y()); 3510 EXPECT_EQ(-10.f, host_->overscroll_delta_y());
3511 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x()); 3511 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x());
3512 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3512 EXPECT_EQ(-10.f, host_->overscroll_delegate()->delta_y());
3513 EXPECT_EQ(0U, process_->sink().message_count()); 3513 EXPECT_EQ(0U, process_->sink().message_count());
3514 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3514 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3515 3515
3516 // Now send a scroll end. This should cancel the overscroll gesture, and send 3516 // Now send a scroll end. This should cancel the overscroll gesture, and send
3517 // the event to the renderer. The gesture-event filter should receive this 3517 // the event to the renderer. The gesture-event filter should receive this
3518 // event. 3518 // event.
3519 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3519 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3520 WebGestureEvent::Touchscreen); 3520 WebGestureEvent::Touchscreen);
3521 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3521 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3522 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3522 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3523 EXPECT_EQ(1U, process_->sink().message_count()); 3523 EXPECT_EQ(1U, process_->sink().message_count());
3524 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3524 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3525 } 3525 }
3526 3526
3527 // Tests that if the page is scrolled because of a scroll-gesture, then that 3527 // Tests that if the page is scrolled because of a scroll-gesture, then that
3528 // particular scroll sequence never generates overscroll, even if there is no 3528 // particular scroll sequence never generates overscroll if the scroll direction
3529 // content to scroll on the page anymore. 3529 // is horizontal.
3530 TEST_F(RenderWidgetHostTest, GestureScrollConsumedDoNotOverscroll) { 3530 TEST_F(RenderWidgetHostTest, GestureScrollConsumedHorizontal) {
3531 // Turn off debounce handling for test isolation. 3531 // Turn off debounce handling for test isolation.
3532 host_->SetupForOverscrollControllerTest(); 3532 host_->SetupForOverscrollControllerTest();
3533 host_->set_debounce_interval_time_ms(0); 3533 host_->set_debounce_interval_time_ms(0);
3534 process_->sink().ClearMessages(); 3534 process_->sink().ClearMessages();
3535 3535
3536 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3536 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3537 WebGestureEvent::Touchscreen); 3537 WebGestureEvent::Touchscreen);
3538 SimulateGestureScrollUpdateEvent(8, -5, 0); 3538 SimulateGestureScrollUpdateEvent(10, 0, 0);
3539 3539
3540 // ACK both events as being processed. 3540 // Start scrolling on content. ACK both events as being processed.
3541 SendInputEventACK(WebInputEvent::GestureScrollBegin, 3541 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3542 INPUT_EVENT_ACK_STATE_CONSUMED); 3542 INPUT_EVENT_ACK_STATE_CONSUMED);
3543 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3543 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3544 INPUT_EVENT_ACK_STATE_CONSUMED); 3544 INPUT_EVENT_ACK_STATE_CONSUMED);
3545 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3545 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3546 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3546 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3547 3547
3548 // Send another gesture event and ACK as not being processed. This should 3548 // Send another gesture event and ACK as not being processed. This should
3549 // not initiate overscroll because the beginning of the scroll event did 3549 // not initiate overscroll because the beginning of the scroll event did
3550 // scroll some content on the page. 3550 // scroll some content on the page.
3551 SimulateGestureScrollUpdateEvent(55, -5, 0); 3551 SimulateGestureScrollUpdateEvent(55, 0, 0);
3552 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3552 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3553 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3553 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3554 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3554 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3555 } 3555 }
3556 3556
3557 // Tests that if the page is scrolled because of a scroll-gesture, then that
3558 // particular scroll sequence never generates overscroll if the scroll direction
3559 // is vertical.
3560 TEST_F(RenderWidgetHostTest, GestureScrollConsumedVertical) {
3561 // Turn off debounce handling for test isolation.
3562 host_->SetupForOverscrollControllerTest();
3563 host_->set_debounce_interval_time_ms(0);
3564 process_->sink().ClearMessages();
3565
3566 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3567 WebGestureEvent::Touchscreen);
3568 SimulateGestureScrollUpdateEvent(0, -1, 0);
3569
3570 // Start scrolling on content. ACK both events as being processed.
3571 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3572 INPUT_EVENT_ACK_STATE_CONSUMED);
3573 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3574 INPUT_EVENT_ACK_STATE_CONSUMED);
3575 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3576 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3577
3578 // Send another gesture event and ACK as not being processed. This should
3579 // initiate overscroll because the scroll was in the vertical direction even
3580 // though the beginning of the scroll did scroll content.
3581 SimulateGestureScrollUpdateEvent(0, -50, 0);
3582 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3583 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3584 EXPECT_EQ(OVERSCROLL_NORTH, host_->overscroll_mode());
3585
3586 // Changing direction of scroll to be horizontal to test that this causes the
3587 // vertical overscroll to stop.
3588 SimulateGestureScrollUpdateEvent(500, 0, 0);
3589 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3590 }
3591
3557 // Tests that the overscroll controller plays nice with touch-scrolls and the 3592 // Tests that the overscroll controller plays nice with touch-scrolls and the
3558 // gesture event filter with debounce filtering turned on. 3593 // gesture event filter with debounce filtering turned on.
3559 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { 3594 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) {
3560 host_->SetupForOverscrollControllerTest(); 3595 host_->SetupForOverscrollControllerTest();
3561 host_->set_debounce_interval_time_ms(100); 3596 host_->set_debounce_interval_time_ms(100);
3562 process_->sink().ClearMessages(); 3597 process_->sink().ClearMessages();
3563 3598
3564 // Start scrolling. Receive ACK as it being processed. 3599 // Start scrolling. Receive ACK as it being processed.
3565 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3600 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3566 WebGestureEvent::Touchscreen); 3601 WebGestureEvent::Touchscreen);
3567 EXPECT_EQ(1U, process_->sink().message_count()); 3602 EXPECT_EQ(1U, process_->sink().message_count());
3568 process_->sink().ClearMessages(); 3603 process_->sink().ClearMessages();
3569 SendInputEventACK(WebInputEvent::GestureScrollBegin, 3604 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3570 INPUT_EVENT_ACK_STATE_CONSUMED); 3605 INPUT_EVENT_ACK_STATE_CONSUMED);
3571 3606
3572 // Send update events. 3607 // Send update events.
3573 SimulateGestureScrollUpdateEvent(25, -5, 0); 3608 SimulateGestureScrollUpdateEvent(25, 0, 0);
3574 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3609 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3575 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3610 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3576 EXPECT_TRUE(host_->ScrollingInProgress()); 3611 EXPECT_TRUE(host_->ScrollingInProgress());
3577 EXPECT_EQ(1U, process_->sink().message_count()); 3612 EXPECT_EQ(1U, process_->sink().message_count());
3578 process_->sink().ClearMessages(); 3613 process_->sink().ClearMessages();
3579 3614
3580 // Quickly end and restart the scroll gesture. These two events should get 3615 // Quickly end and restart the scroll gesture. These two events should get
3581 // discarded. 3616 // discarded.
3582 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3617 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3583 WebGestureEvent::Touchscreen); 3618 WebGestureEvent::Touchscreen);
3584 EXPECT_EQ(0U, process_->sink().message_count()); 3619 EXPECT_EQ(0U, process_->sink().message_count());
3585 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3620 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3586 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 3621 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
3587 3622
3588 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3623 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3589 WebGestureEvent::Touchscreen); 3624 WebGestureEvent::Touchscreen);
3590 EXPECT_EQ(0U, process_->sink().message_count()); 3625 EXPECT_EQ(0U, process_->sink().message_count());
3591 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3626 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3592 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize()); 3627 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize());
3593 3628
3594 // Send another update event. This should get into the queue. 3629 // Send another update event. This should get into the queue.
3595 SimulateGestureScrollUpdateEvent(30, 5, 0); 3630 SimulateGestureScrollUpdateEvent(30, 0, 0);
3596 EXPECT_EQ(0U, process_->sink().message_count()); 3631 EXPECT_EQ(0U, process_->sink().message_count());
3597 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); 3632 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
3598 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3633 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3599 EXPECT_TRUE(host_->ScrollingInProgress()); 3634 EXPECT_TRUE(host_->ScrollingInProgress());
3600 3635
3601 // Receive an ACK for the first scroll-update event as not being processed. 3636 // Receive an ACK for the first scroll-update event as not being processed.
3602 // This will contribute to the overscroll gesture, but not enough for the 3637 // This will contribute to the overscroll gesture, but not enough for the
3603 // overscroll controller to start consuming gesture events. This also cause 3638 // overscroll controller to start consuming gesture events. This also cause
3604 // the queued gesture event to be forwarded to the renderer. 3639 // the queued gesture event to be forwarded to the renderer.
3605 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3640 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3606 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3641 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3607 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3642 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3608 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3643 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3609 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3644 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3610 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3645 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3611 EXPECT_EQ(1U, process_->sink().message_count()); 3646 EXPECT_EQ(1U, process_->sink().message_count());
3612 process_->sink().ClearMessages(); 3647 process_->sink().ClearMessages();
3613 3648
3614 // Send another update event. This should get into the queue. 3649 // Send another update event. This should get into the queue.
3615 SimulateGestureScrollUpdateEvent(10, 5, 0); 3650 SimulateGestureScrollUpdateEvent(10, 0, 0);
3616 EXPECT_EQ(0U, process_->sink().message_count()); 3651 EXPECT_EQ(0U, process_->sink().message_count());
3617 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); 3652 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
3618 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3653 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3619 EXPECT_TRUE(host_->ScrollingInProgress()); 3654 EXPECT_TRUE(host_->ScrollingInProgress());
3620 3655
3621 // Receive an ACK for the second scroll-update event as not being processed. 3656 // Receive an ACK for the second scroll-update event as not being processed.
3622 // This will now initiate an overscroll. This will also cause the queued 3657 // This will now initiate an overscroll. This will also cause the queued
3623 // gesture event to be released. But instead of going to the renderer, it will 3658 // gesture event to be released. But instead of going to the renderer, it will
3624 // be consumed by the overscroll controller. 3659 // be consumed by the overscroll controller.
3625 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3660 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
(...skipping 17 matching lines...) Expand all
3643 3678
3644 // Start scrolling. Receive ACK as it being processed. 3679 // Start scrolling. Receive ACK as it being processed.
3645 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3680 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3646 WebGestureEvent::Touchscreen); 3681 WebGestureEvent::Touchscreen);
3647 EXPECT_EQ(1U, process_->sink().message_count()); 3682 EXPECT_EQ(1U, process_->sink().message_count());
3648 process_->sink().ClearMessages(); 3683 process_->sink().ClearMessages();
3649 SendInputEventACK(WebInputEvent::GestureScrollBegin, 3684 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3650 INPUT_EVENT_ACK_STATE_CONSUMED); 3685 INPUT_EVENT_ACK_STATE_CONSUMED);
3651 3686
3652 // Send update events. 3687 // Send update events.
3653 SimulateGestureScrollUpdateEvent(55, -5, 0); 3688 SimulateGestureScrollUpdateEvent(55, 0, 0);
3654 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3689 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3655 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3690 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3656 EXPECT_TRUE(host_->ScrollingInProgress()); 3691 EXPECT_TRUE(host_->ScrollingInProgress());
3657 EXPECT_EQ(1U, process_->sink().message_count()); 3692 EXPECT_EQ(1U, process_->sink().message_count());
3658 process_->sink().ClearMessages(); 3693 process_->sink().ClearMessages();
3659 3694
3660 // Send an end event. This should get in the debounce queue. 3695 // Send an end event. This should get in the debounce queue.
3661 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3696 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3662 WebGestureEvent::Touchscreen); 3697 WebGestureEvent::Touchscreen);
3663 EXPECT_EQ(0U, process_->sink().message_count()); 3698 EXPECT_EQ(0U, process_->sink().message_count());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 EXPECT_EQ(1U, process_->sink().message_count()); 3753 EXPECT_EQ(1U, process_->sink().message_count());
3719 process_->sink().ClearMessages(); 3754 process_->sink().ClearMessages();
3720 SendInputEventACK(WebInputEvent::TouchMove, 3755 SendInputEventACK(WebInputEvent::TouchMove,
3721 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3756 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3722 3757
3723 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3758 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3724 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3759 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3725 3760
3726 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3761 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3727 WebGestureEvent::Touchscreen); 3762 WebGestureEvent::Touchscreen);
3728 SimulateGestureScrollUpdateEvent(20, 4, 0); 3763 SimulateGestureScrollUpdateEvent(20, 0, 0);
3729 SendInputEventACK(WebInputEvent::GestureScrollBegin, 3764 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3730 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3765 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3731 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3766 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3732 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3767 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3733 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3768 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3734 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3769 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3735 process_->sink().ClearMessages(); 3770 process_->sink().ClearMessages();
3736 3771
3737 // Another touch move event should reach the renderer since overscroll hasn't 3772 // Another touch move event should reach the renderer since overscroll hasn't
3738 // started yet. 3773 // started yet.
3739 MoveTouchPoint(0, 65, 10); 3774 MoveTouchPoint(0, 65, 10);
3740 SendTouchEvent(); 3775 SendTouchEvent();
3741 EXPECT_EQ(1U, process_->sink().message_count()); 3776 EXPECT_EQ(1U, process_->sink().message_count());
3742 process_->sink().ClearMessages(); 3777 process_->sink().ClearMessages();
3743 3778
3744 SendInputEventACK(WebInputEvent::TouchMove, 3779 SendInputEventACK(WebInputEvent::TouchMove,
3745 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3780 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3746 SimulateGestureScrollUpdateEvent(45, 5, 0); 3781 SimulateGestureScrollUpdateEvent(45, 0, 0);
3747 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3782 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3748 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3783 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3749 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3784 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3750 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3785 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3751 EXPECT_EQ(65.f, host_->overscroll_delta_x()); 3786 EXPECT_EQ(65.f, host_->overscroll_delta_x());
3752 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x()); 3787 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x());
3753 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3788 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3754 EXPECT_EQ(0U, host_->TouchEventQueueSize()); 3789 EXPECT_EQ(0U, host_->TouchEventQueueSize());
3755 process_->sink().ClearMessages(); 3790 process_->sink().ClearMessages();
3756 3791
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3858 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3893 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3859 3894
3860 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3895 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3861 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3896 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3862 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3897 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3863 EXPECT_EQ(0U, process_->sink().message_count()); 3898 EXPECT_EQ(0U, process_->sink().message_count());
3864 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3899 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3865 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3900 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3866 EXPECT_EQ(55.f, host_->overscroll_delta_x()); 3901 EXPECT_EQ(55.f, host_->overscroll_delta_x());
3867 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x()); 3902 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x());
3868 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3903 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
3869 3904
3870 // Send end event. 3905 // Send end event.
3871 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, 3906 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd,
3872 WebGestureEvent::Touchscreen); 3907 WebGestureEvent::Touchscreen);
3873 EXPECT_EQ(0U, process_->sink().message_count()); 3908 EXPECT_EQ(0U, process_->sink().message_count());
3874 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3909 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3875 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3910 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3876 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); 3911 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode());
3877 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3912 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3878 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 3913 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3951 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3917 3952
3918 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3953 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3919 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3954 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3920 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3955 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3921 EXPECT_EQ(0U, process_->sink().message_count()); 3956 EXPECT_EQ(0U, process_->sink().message_count());
3922 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3957 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3923 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3958 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3924 EXPECT_EQ(235.f, host_->overscroll_delta_x()); 3959 EXPECT_EQ(235.f, host_->overscroll_delta_x());
3925 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x()); 3960 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x());
3926 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3961 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
3927 3962
3928 // Send end event. 3963 // Send end event.
3929 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, 3964 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd,
3930 WebGestureEvent::Touchscreen); 3965 WebGestureEvent::Touchscreen);
3931 EXPECT_EQ(0U, process_->sink().message_count()); 3966 EXPECT_EQ(0U, process_->sink().message_count());
3932 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3967 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3933 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3968 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3934 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); 3969 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode());
3935 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3970 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3936 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 3971 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4021 4056
4022 // Tests that if a mouse-move event completes the overscroll gesture, future 4057 // Tests that if a mouse-move event completes the overscroll gesture, future
4023 // move events do reach the renderer. 4058 // move events do reach the renderer.
4024 TEST_F(RenderWidgetHostTest, OverscrollMouseMoveCompletion) { 4059 TEST_F(RenderWidgetHostTest, OverscrollMouseMoveCompletion) {
4025 host_->SetupForOverscrollControllerTest(); 4060 host_->SetupForOverscrollControllerTest();
4026 host_->set_debounce_interval_time_ms(0); 4061 host_->set_debounce_interval_time_ms(0);
4027 process_->sink().ClearMessages(); 4062 process_->sink().ClearMessages();
4028 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); 4063 view_->set_bounds(gfx::Rect(0, 0, 400, 200));
4029 view_->Show(); 4064 view_->Show();
4030 4065
4031 SimulateWheelEvent(0, -5, 0, true); // sent directly 4066 SimulateWheelEvent(5, 0, 0, true); // sent directly
4032 SimulateWheelEvent(0, -1, 0, true); // enqueued 4067 SimulateWheelEvent(-1, 0, 0, true); // enqueued
4033 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 4068 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
4034 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 4069 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
4035 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 4070 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
4036 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 4071 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
4037 EXPECT_EQ(1U, process_->sink().message_count()); 4072 EXPECT_EQ(1U, process_->sink().message_count());
4038 process_->sink().ClearMessages(); 4073 process_->sink().ClearMessages();
4039 4074
4040 // Receive ACK the first wheel event as not processed. 4075 // Receive ACK the first wheel event as not processed.
4041 SendInputEventACK(WebInputEvent::MouseWheel, 4076 SendInputEventACK(WebInputEvent::MouseWheel,
4042 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 4077 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4139 SendInputEventACK(WebInputEvent::MouseWheel, 4174 SendInputEventACK(WebInputEvent::MouseWheel,
4140 INPUT_EVENT_ACK_STATE_CONSUMED); 4175 INPUT_EVENT_ACK_STATE_CONSUMED);
4141 EXPECT_TRUE(host_->ScrollStateIsContentScrolling()); 4176 EXPECT_TRUE(host_->ScrollStateIsContentScrolling());
4142 4177
4143 // Touchpad scroll can end with a zero-velocity fling. But it is not 4178 // Touchpad scroll can end with a zero-velocity fling. But it is not
4144 // dispatched, but it should still reset the overscroll controller state. 4179 // dispatched, but it should still reset the overscroll controller state.
4145 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); 4180 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad);
4146 EXPECT_TRUE(host_->ScrollStateIsUnknown()); 4181 EXPECT_TRUE(host_->ScrollStateIsUnknown());
4147 EXPECT_EQ(0U, process_->sink().message_count()); 4182 EXPECT_EQ(0U, process_->sink().message_count());
4148 4183
4149 SimulateWheelEvent(0, -5, 0, true); // sent directly 4184 SimulateWheelEvent(-5, 0, 0, true); // sent directly
4150 SimulateWheelEvent(-60, -1, 0, true); // enqueued 4185 SimulateWheelEvent(-60, 0, 0, true); // enqueued
4151 SimulateWheelEvent(-100, -3, 0, true); // coalesced into previous event 4186 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event
4152 EXPECT_EQ(1U, process_->sink().message_count()); 4187 EXPECT_EQ(1U, process_->sink().message_count());
4153 EXPECT_TRUE(host_->ScrollStateIsUnknown()); 4188 EXPECT_TRUE(host_->ScrollStateIsUnknown());
4154 process_->sink().ClearMessages(); 4189 process_->sink().ClearMessages();
4155 4190
4156 // The first wheel scroll did not scroll content. Overscroll should not start 4191 // The first wheel scroll did not scroll content. Overscroll should not start
4157 // yet, since enough hasn't been scrolled. 4192 // yet, since enough hasn't been scrolled.
4158 SendInputEventACK(WebInputEvent::MouseWheel, 4193 SendInputEventACK(WebInputEvent::MouseWheel,
4159 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 4194 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4160 EXPECT_TRUE(host_->ScrollStateIsUnknown()); 4195 EXPECT_TRUE(host_->ScrollStateIsUnknown());
4161 EXPECT_EQ(1U, process_->sink().message_count()); 4196 EXPECT_EQ(1U, process_->sink().message_count());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4217 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); 4252 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode());
4218 4253
4219 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 4254 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
4220 WebGestureEvent::Touchscreen); 4255 WebGestureEvent::Touchscreen);
4221 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 4256 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
4222 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); 4257 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode());
4223 process_->sink().ClearMessages(); 4258 process_->sink().ClearMessages();
4224 } 4259 }
4225 4260
4226 } // namespace content 4261 } // namespace content
OLDNEW
« 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