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

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: Add hooks to Gesture UI and fixed threshold bug Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View 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/shared_memory.h" 7 #include "base/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 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 } 3134 }
3135 #endif 3135 #endif
3136 3136
3137 // Tests that scroll ACKs are correctly handled by the overscroll-navigation 3137 // Tests that scroll ACKs are correctly handled by the overscroll-navigation
3138 // controller. 3138 // controller.
3139 TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) { 3139 TEST_F(RenderWidgetHostTest, WheelScrollEventOverscrolls) {
3140 host_->SetupForOverscrollControllerTest(); 3140 host_->SetupForOverscrollControllerTest();
3141 process_->sink().ClearMessages(); 3141 process_->sink().ClearMessages();
3142 3142
3143 // Simulate wheel events. 3143 // Simulate wheel events.
3144 SimulateWheelEvent(0, -5, 0, true); // sent directly 3144 SimulateWheelEvent(-5, 0, 0, true); // sent directly
3145 SimulateWheelEvent(0, -1, 0, true); // enqueued 3145 SimulateWheelEvent(-1, 1, 0, true); // enqueued
3146 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3146 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3147 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3147 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3148 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3148 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3149 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 3149 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
3150 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3150 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3151 EXPECT_EQ(1U, process_->sink().message_count()); 3151 EXPECT_EQ(1U, process_->sink().message_count());
3152 process_->sink().ClearMessages(); 3152 process_->sink().ClearMessages();
3153 3153
3154 // Receive ACK the first wheel event as not processed. 3154 // Receive ACK the first wheel event as not processed.
3155 SendInputEventACK(WebInputEvent::MouseWheel, 3155 SendInputEventACK(WebInputEvent::MouseWheel,
3156 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3156 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3157 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3157 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3158 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3158 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3159 EXPECT_EQ(1U, process_->sink().message_count()); 3159 EXPECT_EQ(1U, process_->sink().message_count());
3160 process_->sink().ClearMessages(); 3160 process_->sink().ClearMessages();
3161 3161
3162 // Receive ACK for the second (coalesced) event as not processed. This will 3162 // Receive ACK for the second (coalesced) event as not processed. This will
3163 // start a back navigation. However, this will also cause the queued next 3163 // start a back navigation. However, this will also cause the queued next
3164 // event to be sent to the renderer. But since overscroll navigation has 3164 // event to be sent to the renderer. But since overscroll navigation has
3165 // started, that event will also be included in the overscroll computation 3165 // started, that event will also be included in the overscroll computation
3166 // instead of being sent to the renderer. So the result will be an overscroll 3166 // instead of being sent to the renderer. So the result will be an overscroll
3167 // back navigation, and no event will be sent to the renderer. 3167 // back navigation, and no event will be sent to the renderer.
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_WEST, host_->overscroll_mode()); 3170 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
3171 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); 3171 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode());
3172 EXPECT_EQ(-75.f, host_->overscroll_delta_x()); 3172 EXPECT_EQ(-81.f, host_->overscroll_delta_x());
3173 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x()); 3173 EXPECT_EQ(-31.f, host_->overscroll_delegate()->delta_x());
3174 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3174 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3175 EXPECT_EQ(0U, process_->sink().message_count()); 3175 EXPECT_EQ(0U, process_->sink().message_count());
3176 3176
3177 // Send a mouse-move event. This should cancel the overscroll navigation. 3177 // Send a mouse-move event. This should cancel the overscroll navigation.
3178 SimulateMouseMove(5, 10, 0); 3178 SimulateMouseMove(5, 10, 0);
3179 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3179 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3180 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3180 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3181 } 3181 }
3182 3182
3183 // Tests that if some scroll events are consumed towards the start, then 3183 // Tests that if some scroll events are consumed towards the start, then
3184 // subsequent scrolls do not overscroll. 3184 // subsequent scrolls do not horizontal overscroll.
3185 TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotOverscroll) { 3185 TEST_F(RenderWidgetHostTest, WheelScrollConsumedDoNotHorizOverscroll) {
3186 host_->SetupForOverscrollControllerTest(); 3186 host_->SetupForOverscrollControllerTest();
3187 process_->sink().ClearMessages(); 3187 process_->sink().ClearMessages();
3188 3188
3189 // Simulate wheel events. 3189 // Simulate wheel events.
3190 SimulateWheelEvent(0, -5, 0, true); // sent directly 3190 SimulateWheelEvent(-5, 0, 0, true); // sent directly
3191 SimulateWheelEvent(0, -1, 0, true); // enqueued 3191 SimulateWheelEvent(-1, -1, 0, true); // enqueued
3192 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3192 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3193 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3193 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3194 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3194 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3195 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 3195 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
3196 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3196 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3197 EXPECT_EQ(1U, process_->sink().message_count()); 3197 EXPECT_EQ(1U, process_->sink().message_count());
3198 process_->sink().ClearMessages(); 3198 process_->sink().ClearMessages();
3199 3199
3200 // Receive ACK the first wheel event as processed. 3200 // Receive ACK the first wheel event as processed.
3201 SendInputEventACK(WebInputEvent::MouseWheel, 3201 SendInputEventACK(WebInputEvent::MouseWheel,
3202 INPUT_EVENT_ACK_STATE_CONSUMED); 3202 INPUT_EVENT_ACK_STATE_CONSUMED);
3203 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3203 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3204 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3204 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3205 EXPECT_EQ(1U, process_->sink().message_count()); 3205 EXPECT_EQ(1U, process_->sink().message_count());
3206 process_->sink().ClearMessages(); 3206 process_->sink().ClearMessages();
3207 3207
3208 // Receive ACK for the second (coalesced) event as not processed. This should 3208 // Receive ACK for the second (coalesced) event as not processed. This should
3209 // not initiate overscroll, since the beginning of the scroll has been 3209 // not initiate overscroll, since the beginning of the scroll has been
3210 // consumed. The queued event with different modifiers should be sent to the 3210 // consumed. The queued event with different modifiers should be sent to the
3211 // renderer. 3211 // renderer.
3212 SendInputEventACK(WebInputEvent::MouseWheel, 3212 SendInputEventACK(WebInputEvent::MouseWheel,
3213 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3213 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3214 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3214 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3215 EXPECT_EQ(1U, process_->sink().message_count()); 3215 EXPECT_EQ(0U, process_->sink().message_count());
3216 3216
3217 process_->sink().ClearMessages(); 3217 process_->sink().ClearMessages();
3218 SendInputEventACK(WebInputEvent::MouseWheel, 3218 SendInputEventACK(WebInputEvent::MouseWheel,
3219 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3219 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3220 EXPECT_EQ(0U, process_->sink().message_count()); 3220 EXPECT_EQ(0U, process_->sink().message_count());
3221 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3221 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
sadrul 2013/07/18 22:51:41 Why does the expectation change here?
rharrison 2013/07/23 14:36:02 I don't know... this appears to be wrong now. Reve
3222 3222
3223 // Indicate the end of the scrolling from the touchpad. 3223 // Indicate the end of the scrolling from the touchpad.
3224 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad); 3224 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad);
3225 EXPECT_EQ(1U, process_->sink().message_count()); 3225 EXPECT_EQ(1U, process_->sink().message_count());
3226 3226
3227 // Start another scroll. This time, do not consume any scroll events. 3227 // Start another scroll. This time, do not consume any scroll events.
3228 process_->sink().ClearMessages(); 3228 process_->sink().ClearMessages();
3229 SimulateWheelEvent(0, -5, 0, true); // sent directly 3229 SimulateWheelEvent(0, -5, 0, true); // sent directly
3230 SimulateWheelEvent(0, -1, 0, true); // enqueued 3230 SimulateWheelEvent(0, -1, 0, true); // enqueued
3231 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3231 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3232 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3232 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3233 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3233 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3234 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 3234 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
3235 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3235 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3236 EXPECT_EQ(1U, process_->sink().message_count()); 3236 EXPECT_EQ(1U, process_->sink().message_count());
3237 process_->sink().ClearMessages(); 3237 process_->sink().ClearMessages();
3238 3238
3239 // Receive ACK for the first wheel and the subsequent coalesced event as not 3239 // Receive ACK for the first wheel and the subsequent coalesced event as not
3240 // processed. This should start a back-overscroll. 3240 // processed. This should start a back-overscroll.
3241 SendInputEventACK(WebInputEvent::MouseWheel, 3241 SendInputEventACK(WebInputEvent::MouseWheel,
3242 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3242 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3243 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3243 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3244 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3244 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3245 EXPECT_EQ(1U, process_->sink().message_count()); 3245 EXPECT_EQ(0U, process_->sink().message_count());
3246 process_->sink().ClearMessages(); 3246 process_->sink().ClearMessages();
3247 SendInputEventACK(WebInputEvent::MouseWheel, 3247 SendInputEventACK(WebInputEvent::MouseWheel,
3248 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3248 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3249 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); 3249 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
3250 } 3250 }
3251 3251
3252 // Tests that wheel-scrolling correctly turns overscroll on and off. 3252 // Tests that wheel-scrolling correctly turns overscroll on and off.
3253 TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) { 3253 TEST_F(RenderWidgetHostTest, WheelScrollOverscrollToggle) {
3254 host_->SetupForOverscrollControllerTest(); 3254 host_->SetupForOverscrollControllerTest();
3255 process_->sink().ClearMessages(); 3255 process_->sink().ClearMessages();
3256 3256
3257 // Send a wheel event. ACK the event as not processed. This should not 3257 // Send a wheel event. ACK the event as not processed. This should not
3258 // initiate an overscroll gesture since it doesn't cross the threshold yet. 3258 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3259 SimulateWheelEvent(10, -5, 0, true); 3259 SimulateWheelEvent(10, 0, 0, true);
3260 EXPECT_EQ(1U, process_->sink().message_count()); 3260 EXPECT_EQ(1U, process_->sink().message_count());
3261 SendInputEventACK(WebInputEvent::MouseWheel, 3261 SendInputEventACK(WebInputEvent::MouseWheel,
3262 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3262 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3263 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3263 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3264 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3264 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3265 process_->sink().ClearMessages(); 3265 process_->sink().ClearMessages();
3266 3266
3267 // Scroll some more so as to not overscroll. 3267 // Scroll some more so as to not overscroll.
3268 SimulateWheelEvent(10, -4, 0, true); 3268 SimulateWheelEvent(10, 0, 0, true);
3269 EXPECT_EQ(1U, process_->sink().message_count()); 3269 EXPECT_EQ(1U, process_->sink().message_count());
3270 SendInputEventACK(WebInputEvent::MouseWheel, 3270 SendInputEventACK(WebInputEvent::MouseWheel,
3271 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3271 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3272 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3272 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3273 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3273 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3274 process_->sink().ClearMessages(); 3274 process_->sink().ClearMessages();
3275 3275
3276 // Scroll some more to initiate an overscroll. 3276 // Scroll some more to initiate an overscroll.
3277 SimulateWheelEvent(40, -4, 0, true); 3277 SimulateWheelEvent(40, 0, 0, true);
3278 EXPECT_EQ(1U, process_->sink().message_count()); 3278 EXPECT_EQ(1U, process_->sink().message_count());
3279 SendInputEventACK(WebInputEvent::MouseWheel, 3279 SendInputEventACK(WebInputEvent::MouseWheel,
3280 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3280 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3281 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3281 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3282 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3282 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3283 EXPECT_EQ(60.f, host_->overscroll_delta_x()); 3283 EXPECT_EQ(60.f, host_->overscroll_delta_x());
3284 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); 3284 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x());
3285 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3285 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3286 process_->sink().ClearMessages(); 3286 process_->sink().ClearMessages();
3287 3287
3288 // Scroll in the reverse direction enough to abort the overscroll. 3288 // Scroll in the reverse direction enough to abort the overscroll.
3289 SimulateWheelEvent(-20, -4, 0, true); 3289 SimulateWheelEvent(-20, 0, 0, true);
3290 EXPECT_EQ(0U, process_->sink().message_count()); 3290 EXPECT_EQ(0U, process_->sink().message_count());
3291 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3291 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3292 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3292 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3293 3293
3294 // Continue to scroll in the reverse direction. 3294 // Continue to scroll in the reverse direction.
3295 SimulateWheelEvent(-20, 4, 0, true); 3295 SimulateWheelEvent(-20, 0, 0, true);
3296 EXPECT_EQ(1U, process_->sink().message_count()); 3296 EXPECT_EQ(1U, process_->sink().message_count());
3297 SendInputEventACK(WebInputEvent::MouseWheel, 3297 SendInputEventACK(WebInputEvent::MouseWheel,
3298 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3298 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3299 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3299 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3300 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3300 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3301 process_->sink().ClearMessages(); 3301 process_->sink().ClearMessages();
3302 3302
3303 // Continue to scroll in the reverse direction enough to initiate overscroll 3303 // Continue to scroll in the reverse direction enough to initiate overscroll
3304 // in that direction. 3304 // in that direction.
3305 SimulateWheelEvent(-55, -2, 0, true); 3305 SimulateWheelEvent(-55, 0, 0, true);
3306 EXPECT_EQ(1U, process_->sink().message_count()); 3306 EXPECT_EQ(1U, process_->sink().message_count());
3307 SendInputEventACK(WebInputEvent::MouseWheel, 3307 SendInputEventACK(WebInputEvent::MouseWheel,
3308 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3308 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3309 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); 3309 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
3310 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); 3310 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode());
3311 EXPECT_EQ(-75.f, host_->overscroll_delta_x()); 3311 EXPECT_EQ(-75.f, host_->overscroll_delta_x());
3312 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x()); 3312 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x());
3313 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3313 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3314 } 3314 }
3315 3315
3316 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) { 3316 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) {
3317 host_->SetupForOverscrollControllerTest(); 3317 host_->SetupForOverscrollControllerTest();
3318 process_->sink().ClearMessages(); 3318 process_->sink().ClearMessages();
3319 3319
3320 // Send a wheel event. ACK the event as not processed. This should not 3320 // Send a wheel event. ACK the event as not processed. This should not
3321 // initiate an overscroll gesture since it doesn't cross the threshold yet. 3321 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3322 SimulateWheelEvent(10, -5, 0, true); 3322 SimulateWheelEvent(10, 0, 0, true);
3323 EXPECT_EQ(1U, process_->sink().message_count()); 3323 EXPECT_EQ(1U, process_->sink().message_count());
3324 SendInputEventACK(WebInputEvent::MouseWheel, 3324 SendInputEventACK(WebInputEvent::MouseWheel,
3325 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3325 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3326 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3326 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3327 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3327 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3328 process_->sink().ClearMessages(); 3328 process_->sink().ClearMessages();
3329 3329
3330 // Scroll some more so as to not overscroll. 3330 // Scroll some more so as to not overscroll.
3331 SimulateWheelEvent(20, -4, 0, true); 3331 SimulateWheelEvent(20, 0, 0, true);
3332 EXPECT_EQ(1U, process_->sink().message_count()); 3332 EXPECT_EQ(1U, process_->sink().message_count());
3333 SendInputEventACK(WebInputEvent::MouseWheel, 3333 SendInputEventACK(WebInputEvent::MouseWheel,
3334 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3334 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3335 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3335 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3336 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3336 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3337 process_->sink().ClearMessages(); 3337 process_->sink().ClearMessages();
3338 3338
3339 // Scroll some more to initiate an overscroll. 3339 // Scroll some more to initiate an overscroll.
3340 SimulateWheelEvent(30, -4, 0, true); 3340 SimulateWheelEvent(30, 0, 0, true);
3341 EXPECT_EQ(1U, process_->sink().message_count()); 3341 EXPECT_EQ(1U, process_->sink().message_count());
3342 SendInputEventACK(WebInputEvent::MouseWheel, 3342 SendInputEventACK(WebInputEvent::MouseWheel,
3343 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3343 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3344 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3344 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3345 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3345 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3346 EXPECT_EQ(60.f, host_->overscroll_delta_x()); 3346 EXPECT_EQ(60.f, host_->overscroll_delta_x());
3347 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); 3347 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x());
3348 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3348 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3349 process_->sink().ClearMessages(); 3349 process_->sink().ClearMessages();
3350 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3350 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3351 3351
3352 // Send a fling start, but with a small velocity, so that the overscroll is 3352 // Send a fling start, but with a small velocity, so that the overscroll is
3353 // aborted. The fling should proceed to the renderer, through the gesture 3353 // aborted. The fling should proceed to the renderer, through the gesture
3354 // event filter. 3354 // event filter.
3355 SimulateGestureFlingStartEvent(0.f, 0.1f, WebGestureEvent::Touchpad); 3355 SimulateGestureFlingStartEvent(0.f, 0.1f, WebGestureEvent::Touchpad);
3356 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3356 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3357 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3357 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3358 EXPECT_EQ(1U, process_->sink().message_count()); 3358 EXPECT_EQ(1U, process_->sink().message_count());
3359 } 3359 }
3360 3360
3361 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that 3361 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
3362 // the zero-velocity fling does not reach the renderer. 3362 // the zero-velocity fling does not reach the renderer.
3363 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) { 3363 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) {
3364 host_->SetupForOverscrollControllerTest(); 3364 host_->SetupForOverscrollControllerTest();
3365 process_->sink().ClearMessages(); 3365 process_->sink().ClearMessages();
3366 3366
3367 // Send a wheel event. ACK the event as not processed. This should not 3367 // Send a wheel event. ACK the event as not processed. This should not
3368 // initiate an overscroll gesture since it doesn't cross the threshold yet. 3368 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3369 SimulateWheelEvent(10, -5, 0, true); 3369 SimulateWheelEvent(10, 0, 0, true);
3370 EXPECT_EQ(1U, process_->sink().message_count()); 3370 EXPECT_EQ(1U, process_->sink().message_count());
3371 SendInputEventACK(WebInputEvent::MouseWheel, 3371 SendInputEventACK(WebInputEvent::MouseWheel,
3372 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3372 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3373 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3373 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3374 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3374 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3375 process_->sink().ClearMessages(); 3375 process_->sink().ClearMessages();
3376 3376
3377 // Scroll some more so as to not overscroll. 3377 // Scroll some more so as to not overscroll.
3378 SimulateWheelEvent(20, -4, 0, true); 3378 SimulateWheelEvent(20, 0, 0, true);
3379 EXPECT_EQ(1U, process_->sink().message_count()); 3379 EXPECT_EQ(1U, process_->sink().message_count());
3380 SendInputEventACK(WebInputEvent::MouseWheel, 3380 SendInputEventACK(WebInputEvent::MouseWheel,
3381 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3381 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3382 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3382 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3383 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3383 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3384 process_->sink().ClearMessages(); 3384 process_->sink().ClearMessages();
3385 3385
3386 // Scroll some more to initiate an overscroll. 3386 // Scroll some more to initiate an overscroll.
3387 SimulateWheelEvent(30, -4, 0, true); 3387 SimulateWheelEvent(30, 0, 0, true);
3388 EXPECT_EQ(1U, process_->sink().message_count()); 3388 EXPECT_EQ(1U, process_->sink().message_count());
3389 SendInputEventACK(WebInputEvent::MouseWheel, 3389 SendInputEventACK(WebInputEvent::MouseWheel,
3390 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3390 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3391 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3391 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3392 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3392 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3393 EXPECT_EQ(60.f, host_->overscroll_delta_x()); 3393 EXPECT_EQ(60.f, host_->overscroll_delta_x());
3394 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); 3394 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x());
3395 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3395 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3396 process_->sink().ClearMessages(); 3396 process_->sink().ClearMessages();
3397 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3397 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3476 // Send another gesture event and ACK as not being processed. This should 3476 // Send another gesture event and ACK as not being processed. This should
3477 // initiate the navigation gesture. 3477 // initiate the navigation gesture.
3478 SimulateGestureScrollUpdateEvent(55, -5, 0); 3478 SimulateGestureScrollUpdateEvent(55, -5, 0);
3479 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3479 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3480 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3480 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3481 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3481 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3482 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3482 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3483 EXPECT_EQ(55.f, host_->overscroll_delta_x()); 3483 EXPECT_EQ(55.f, host_->overscroll_delta_x());
3484 EXPECT_EQ(-5.f, host_->overscroll_delta_y()); 3484 EXPECT_EQ(-5.f, host_->overscroll_delta_y());
3485 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x()); 3485 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x());
3486 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3486 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
3487 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3487 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3488 process_->sink().ClearMessages(); 3488 process_->sink().ClearMessages();
3489 3489
3490 // Send another gesture update event. This event should be consumed by the 3490 // Send another gesture update event. This event should be consumed by the
3491 // controller, and not be forwarded to the renderer. The gesture-event filter 3491 // controller, and not be forwarded to the renderer. The gesture-event filter
3492 // should not also receive this event. 3492 // should not also receive this event.
3493 SimulateGestureScrollUpdateEvent(10, -5, 0); 3493 SimulateGestureScrollUpdateEvent(10, -5, 0);
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(65.f, host_->overscroll_delta_x()); 3496 EXPECT_EQ(65.f, host_->overscroll_delta_x());
3497 EXPECT_EQ(-10.f, host_->overscroll_delta_y()); 3497 EXPECT_EQ(-10.f, host_->overscroll_delta_y());
3498 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x()); 3498 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x());
3499 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3499 EXPECT_EQ(-10.f, host_->overscroll_delegate()->delta_y());
3500 EXPECT_EQ(0U, process_->sink().message_count()); 3500 EXPECT_EQ(0U, process_->sink().message_count());
3501 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3501 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3502 3502
3503 // Now send a scroll end. This should cancel the overscroll gesture, and send 3503 // Now send a scroll end. This should cancel the overscroll gesture, and send
3504 // the event to the renderer. The gesture-event filter should receive this 3504 // the event to the renderer. The gesture-event filter should receive this
3505 // event. 3505 // event.
3506 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3506 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3507 WebGestureEvent::Touchscreen); 3507 WebGestureEvent::Touchscreen);
3508 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3508 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3509 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3509 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3510 EXPECT_EQ(1U, process_->sink().message_count()); 3510 EXPECT_EQ(1U, process_->sink().message_count());
3511 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3511 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3512 } 3512 }
3513 3513
3514 // Tests that if the page is scrolled because of a scroll-gesture, then that
3515 // particular scroll sequence never generates overscroll, even if there is no
3516 // content to scroll on the page anymore.
3517 TEST_F(RenderWidgetHostTest, GestureScrollConsumedDoNotOverscroll) {
3518 // Turn off debounce handling for test isolation.
3519 host_->SetupForOverscrollControllerTest();
3520 host_->set_debounce_interval_time_ms(0);
3521 process_->sink().ClearMessages();
3522
3523 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3524 WebGestureEvent::Touchscreen);
3525 SimulateGestureScrollUpdateEvent(8, -5, 0);
3526
3527 // ACK both events as being processed.
3528 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3529 INPUT_EVENT_ACK_STATE_CONSUMED);
3530 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3531 INPUT_EVENT_ACK_STATE_CONSUMED);
3532 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3533 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3534
3535 // Send another gesture event and ACK as not being processed. This should
3536 // not initiate overscroll because the beginning of the scroll event did
3537 // scroll some content on the page.
3538 SimulateGestureScrollUpdateEvent(55, -5, 0);
3539 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3540 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3541 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3542 }
sadrul 2013/07/18 22:51:41 Can you update this test to test that there is no
rharrison 2013/07/23 14:36:02 Done.
3543
3544 // Tests that the overscroll controller plays nice with touch-scrolls and the 3514 // Tests that the overscroll controller plays nice with touch-scrolls and the
3545 // gesture event filter with debounce filtering turned on. 3515 // gesture event filter with debounce filtering turned on.
3546 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { 3516 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) {
3547 host_->SetupForOverscrollControllerTest(); 3517 host_->SetupForOverscrollControllerTest();
3548 host_->set_debounce_interval_time_ms(100); 3518 host_->set_debounce_interval_time_ms(100);
3549 process_->sink().ClearMessages(); 3519 process_->sink().ClearMessages();
3550 3520
3551 // Start scrolling. Receive ACK as it being processed. 3521 // Start scrolling. Receive ACK as it being processed.
3552 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3522 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3553 WebGestureEvent::Touchscreen); 3523 WebGestureEvent::Touchscreen);
3554 EXPECT_EQ(1U, process_->sink().message_count()); 3524 EXPECT_EQ(1U, process_->sink().message_count());
3555 process_->sink().ClearMessages(); 3525 process_->sink().ClearMessages();
3556 SendInputEventACK(WebInputEvent::GestureScrollBegin, 3526 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3557 INPUT_EVENT_ACK_STATE_CONSUMED); 3527 INPUT_EVENT_ACK_STATE_CONSUMED);
3558 3528
3559 // Send update events. 3529 // Send update events.
3560 SimulateGestureScrollUpdateEvent(25, -5, 0); 3530 SimulateGestureScrollUpdateEvent(25, 0, 0);
3561 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3531 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3562 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3532 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3563 EXPECT_TRUE(host_->ScrollingInProgress()); 3533 EXPECT_TRUE(host_->ScrollingInProgress());
3564 EXPECT_EQ(1U, process_->sink().message_count()); 3534 EXPECT_EQ(1U, process_->sink().message_count());
3565 process_->sink().ClearMessages(); 3535 process_->sink().ClearMessages();
3566 3536
3567 // Quickly end and restart the scroll gesture. These two events should get 3537 // Quickly end and restart the scroll gesture. These two events should get
3568 // discarded. 3538 // discarded.
3569 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3539 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3570 WebGestureEvent::Touchscreen); 3540 WebGestureEvent::Touchscreen);
3571 EXPECT_EQ(0U, process_->sink().message_count()); 3541 EXPECT_EQ(0U, process_->sink().message_count());
3572 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3542 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3573 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 3543 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
3574 3544
3575 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3545 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3576 WebGestureEvent::Touchscreen); 3546 WebGestureEvent::Touchscreen);
3577 EXPECT_EQ(0U, process_->sink().message_count()); 3547 EXPECT_EQ(0U, process_->sink().message_count());
3578 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3548 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3579 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize()); 3549 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize());
3580 3550
3581 // Send another update event. This should get into the queue. 3551 // Send another update event. This should get into the queue.
3582 SimulateGestureScrollUpdateEvent(30, 5, 0); 3552 SimulateGestureScrollUpdateEvent(30, 0, 0);
3583 EXPECT_EQ(0U, process_->sink().message_count()); 3553 EXPECT_EQ(0U, process_->sink().message_count());
3584 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); 3554 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
3585 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3555 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3586 EXPECT_TRUE(host_->ScrollingInProgress()); 3556 EXPECT_TRUE(host_->ScrollingInProgress());
3587 3557
3588 // Receive an ACK for the first scroll-update event as not being processed. 3558 // Receive an ACK for the first scroll-update event as not being processed.
3589 // This will contribute to the overscroll gesture, but not enough for the 3559 // This will contribute to the overscroll gesture, but not enough for the
3590 // overscroll controller to start consuming gesture events. This also cause 3560 // overscroll controller to start consuming gesture events. This also cause
3591 // the queued gesture event to be forwarded to the renderer. 3561 // the queued gesture event to be forwarded to the renderer.
3592 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3562 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3593 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3563 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3594 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3564 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3595 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3565 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3596 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3566 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3597 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3567 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3598 EXPECT_EQ(1U, process_->sink().message_count()); 3568 EXPECT_EQ(1U, process_->sink().message_count());
3599 process_->sink().ClearMessages(); 3569 process_->sink().ClearMessages();
3600 3570
3601 // Send another update event. This should get into the queue. 3571 // Send another update event. This should get into the queue.
3602 SimulateGestureScrollUpdateEvent(10, 5, 0); 3572 SimulateGestureScrollUpdateEvent(10, 0, 0);
3603 EXPECT_EQ(0U, process_->sink().message_count()); 3573 EXPECT_EQ(0U, process_->sink().message_count());
3604 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); 3574 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
3605 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3575 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3606 EXPECT_TRUE(host_->ScrollingInProgress()); 3576 EXPECT_TRUE(host_->ScrollingInProgress());
3607 3577
3608 // Receive an ACK for the second scroll-update event as not being processed. 3578 // Receive an ACK for the second scroll-update event as not being processed.
3609 // This will now initiate an overscroll. This will also cause the queued 3579 // This will now initiate an overscroll. This will also cause the queued
3610 // gesture event to be released. But instead of going to the renderer, it will 3580 // gesture event to be released. But instead of going to the renderer, it will
3611 // be consumed by the overscroll controller. 3581 // be consumed by the overscroll controller.
3612 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3582 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
(...skipping 17 matching lines...) Expand all
3630 3600
3631 // Start scrolling. Receive ACK as it being processed. 3601 // Start scrolling. Receive ACK as it being processed.
3632 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3602 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3633 WebGestureEvent::Touchscreen); 3603 WebGestureEvent::Touchscreen);
3634 EXPECT_EQ(1U, process_->sink().message_count()); 3604 EXPECT_EQ(1U, process_->sink().message_count());
3635 process_->sink().ClearMessages(); 3605 process_->sink().ClearMessages();
3636 SendInputEventACK(WebInputEvent::GestureScrollBegin, 3606 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3637 INPUT_EVENT_ACK_STATE_CONSUMED); 3607 INPUT_EVENT_ACK_STATE_CONSUMED);
3638 3608
3639 // Send update events. 3609 // Send update events.
3640 SimulateGestureScrollUpdateEvent(55, -5, 0); 3610 SimulateGestureScrollUpdateEvent(55, 0, 0);
3641 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3611 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3642 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3612 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3643 EXPECT_TRUE(host_->ScrollingInProgress()); 3613 EXPECT_TRUE(host_->ScrollingInProgress());
3644 EXPECT_EQ(1U, process_->sink().message_count()); 3614 EXPECT_EQ(1U, process_->sink().message_count());
3645 process_->sink().ClearMessages(); 3615 process_->sink().ClearMessages();
3646 3616
3647 // Send an end event. This should get in the debounce queue. 3617 // Send an end event. This should get in the debounce queue.
3648 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3618 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3649 WebGestureEvent::Touchscreen); 3619 WebGestureEvent::Touchscreen);
3650 EXPECT_EQ(0U, process_->sink().message_count()); 3620 EXPECT_EQ(0U, process_->sink().message_count());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 EXPECT_EQ(1U, process_->sink().message_count()); 3675 EXPECT_EQ(1U, process_->sink().message_count());
3706 process_->sink().ClearMessages(); 3676 process_->sink().ClearMessages();
3707 SendInputEventACK(WebInputEvent::TouchMove, 3677 SendInputEventACK(WebInputEvent::TouchMove,
3708 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3678 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3709 3679
3710 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3680 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3711 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3681 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3712 3682
3713 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3683 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3714 WebGestureEvent::Touchscreen); 3684 WebGestureEvent::Touchscreen);
3715 SimulateGestureScrollUpdateEvent(20, 4, 0); 3685 SimulateGestureScrollUpdateEvent(20, 0, 0);
3716 SendInputEventACK(WebInputEvent::GestureScrollBegin, 3686 SendInputEventACK(WebInputEvent::GestureScrollBegin,
3717 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3687 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3718 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3688 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3719 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3689 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3720 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3690 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3721 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3691 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3722 process_->sink().ClearMessages(); 3692 process_->sink().ClearMessages();
3723 3693
3724 // Another touch move event should reach the renderer since overscroll hasn't 3694 // Another touch move event should reach the renderer since overscroll hasn't
3725 // started yet. 3695 // started yet.
3726 MoveTouchPoint(0, 65, 10); 3696 MoveTouchPoint(0, 65, 10);
3727 SendTouchEvent(); 3697 SendTouchEvent();
3728 EXPECT_EQ(1U, process_->sink().message_count()); 3698 EXPECT_EQ(1U, process_->sink().message_count());
3729 process_->sink().ClearMessages(); 3699 process_->sink().ClearMessages();
3730 3700
3731 SendInputEventACK(WebInputEvent::TouchMove, 3701 SendInputEventACK(WebInputEvent::TouchMove,
3732 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3702 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3733 SimulateGestureScrollUpdateEvent(45, 5, 0); 3703 SimulateGestureScrollUpdateEvent(45, 0, 0);
3734 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3704 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3735 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3705 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3736 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3706 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3737 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3707 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3738 EXPECT_EQ(65.f, host_->overscroll_delta_x()); 3708 EXPECT_EQ(65.f, host_->overscroll_delta_x());
3739 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x()); 3709 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x());
3740 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3710 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
3741 EXPECT_EQ(0U, host_->TouchEventQueueSize()); 3711 EXPECT_EQ(0U, host_->TouchEventQueueSize());
3742 process_->sink().ClearMessages(); 3712 process_->sink().ClearMessages();
3743 3713
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3845 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3815 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3846 3816
3847 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3817 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3848 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3818 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3849 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3819 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3850 EXPECT_EQ(0U, process_->sink().message_count()); 3820 EXPECT_EQ(0U, process_->sink().message_count());
3851 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3821 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3852 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3822 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3853 EXPECT_EQ(55.f, host_->overscroll_delta_x()); 3823 EXPECT_EQ(55.f, host_->overscroll_delta_x());
3854 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x()); 3824 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x());
3855 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3825 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
3856 3826
3857 // Send end event. 3827 // Send end event.
3858 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, 3828 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd,
3859 WebGestureEvent::Touchscreen); 3829 WebGestureEvent::Touchscreen);
3860 EXPECT_EQ(0U, process_->sink().message_count()); 3830 EXPECT_EQ(0U, process_->sink().message_count());
3861 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3831 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3862 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3832 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3863 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); 3833 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode());
3864 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3834 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3865 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 3835 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3873 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3904 3874
3905 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3875 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3906 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3876 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3907 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3877 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3908 EXPECT_EQ(0U, process_->sink().message_count()); 3878 EXPECT_EQ(0U, process_->sink().message_count());
3909 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 3879 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
3910 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 3880 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
3911 EXPECT_EQ(235.f, host_->overscroll_delta_x()); 3881 EXPECT_EQ(235.f, host_->overscroll_delta_x());
3912 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x()); 3882 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x());
3913 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 3883 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
3914 3884
3915 // Send end event. 3885 // Send end event.
3916 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, 3886 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd,
3917 WebGestureEvent::Touchscreen); 3887 WebGestureEvent::Touchscreen);
3918 EXPECT_EQ(0U, process_->sink().message_count()); 3888 EXPECT_EQ(0U, process_->sink().message_count());
3919 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3889 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3920 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 3890 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
3921 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); 3891 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode());
3922 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3892 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3923 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 3893 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 3978
4009 // Tests that if a mouse-move event completes the overscroll gesture, future 3979 // Tests that if a mouse-move event completes the overscroll gesture, future
4010 // move events do reach the renderer. 3980 // move events do reach the renderer.
4011 TEST_F(RenderWidgetHostTest, OverscrollMouseMoveCompletion) { 3981 TEST_F(RenderWidgetHostTest, OverscrollMouseMoveCompletion) {
4012 host_->SetupForOverscrollControllerTest(); 3982 host_->SetupForOverscrollControllerTest();
4013 host_->set_debounce_interval_time_ms(0); 3983 host_->set_debounce_interval_time_ms(0);
4014 process_->sink().ClearMessages(); 3984 process_->sink().ClearMessages();
4015 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); 3985 view_->set_bounds(gfx::Rect(0, 0, 400, 200));
4016 view_->Show(); 3986 view_->Show();
4017 3987
4018 SimulateWheelEvent(0, -5, 0, true); // sent directly 3988 SimulateWheelEvent(5, 0, 0, true); // sent directly
4019 SimulateWheelEvent(0, -1, 0, true); // enqueued 3989 SimulateWheelEvent(-1, 0, 0, true); // enqueued
4020 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3990 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
4021 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3991 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
4022 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3992 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
4023 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3993 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
4024 EXPECT_EQ(1U, process_->sink().message_count()); 3994 EXPECT_EQ(1U, process_->sink().message_count());
4025 process_->sink().ClearMessages(); 3995 process_->sink().ClearMessages();
4026 3996
4027 // Receive ACK the first wheel event as not processed. 3997 // Receive ACK the first wheel event as not processed.
4028 SendInputEventACK(WebInputEvent::MouseWheel, 3998 SendInputEventACK(WebInputEvent::MouseWheel,
4029 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3999 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4126 SendInputEventACK(WebInputEvent::MouseWheel, 4096 SendInputEventACK(WebInputEvent::MouseWheel,
4127 INPUT_EVENT_ACK_STATE_CONSUMED); 4097 INPUT_EVENT_ACK_STATE_CONSUMED);
4128 EXPECT_TRUE(host_->ScrollStateIsContentScrolling()); 4098 EXPECT_TRUE(host_->ScrollStateIsContentScrolling());
4129 4099
4130 // Touchpad scroll can end with a zero-velocity fling. But it is not 4100 // Touchpad scroll can end with a zero-velocity fling. But it is not
4131 // dispatched, but it should still reset the overscroll controller state. 4101 // dispatched, but it should still reset the overscroll controller state.
4132 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); 4102 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad);
4133 EXPECT_TRUE(host_->ScrollStateIsUnknown()); 4103 EXPECT_TRUE(host_->ScrollStateIsUnknown());
4134 EXPECT_EQ(0U, process_->sink().message_count()); 4104 EXPECT_EQ(0U, process_->sink().message_count());
4135 4105
4136 SimulateWheelEvent(0, -5, 0, true); // sent directly 4106 SimulateWheelEvent(-5, 0, 0, true); // sent directly
4137 SimulateWheelEvent(-60, -1, 0, true); // enqueued 4107 SimulateWheelEvent(-60, 0, 0, true); // enqueued
4138 SimulateWheelEvent(-100, -3, 0, true); // coalesced into previous event 4108 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event
4139 EXPECT_EQ(1U, process_->sink().message_count()); 4109 EXPECT_EQ(1U, process_->sink().message_count());
4140 EXPECT_TRUE(host_->ScrollStateIsUnknown()); 4110 EXPECT_TRUE(host_->ScrollStateIsUnknown());
4141 process_->sink().ClearMessages(); 4111 process_->sink().ClearMessages();
4142 4112
4143 // The first wheel scroll did not scroll content. Overscroll should not start 4113 // The first wheel scroll did not scroll content. Overscroll should not start
4144 // yet, since enough hasn't been scrolled. 4114 // yet, since enough hasn't been scrolled.
4145 SendInputEventACK(WebInputEvent::MouseWheel, 4115 SendInputEventACK(WebInputEvent::MouseWheel,
4146 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 4116 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4147 EXPECT_TRUE(host_->ScrollStateIsUnknown()); 4117 EXPECT_TRUE(host_->ScrollStateIsUnknown());
4148 EXPECT_EQ(1U, process_->sink().message_count()); 4118 EXPECT_EQ(1U, process_->sink().message_count());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4204 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); 4174 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode());
4205 4175
4206 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 4176 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
4207 WebGestureEvent::Touchscreen); 4177 WebGestureEvent::Touchscreen);
4208 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 4178 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
4209 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); 4179 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode());
4210 process_->sink().ClearMessages(); 4180 process_->sink().ClearMessages();
4211 } 4181 }
4212 4182
4213 } // namespace content 4183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698