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

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

Issue 1308273003: Resend unconsumed scroll update from guest back to embedder (WebView Scroll Bubble). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't require GestureScrollBegin for touch-pad GestureFlingStart. Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 2583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2594 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2595 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2595 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2596 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2596 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2597 2597
2598 SendInputEventACK(WebInputEvent::MouseWheel, 2598 SendInputEventACK(WebInputEvent::MouseWheel,
2599 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2599 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2600 EXPECT_EQ(0U, sink_->message_count()); 2600 EXPECT_EQ(0U, sink_->message_count());
2601 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2601 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2602 2602
2603 // Indicate the end of the scrolling from the touchpad. 2603 // Indicate the end of the scrolling from the touchpad.
2604 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2605 blink::WebGestureDeviceTouchscreen);
2604 SimulateGestureFlingStartEvent(-1200.f, 0.f, blink::WebGestureDeviceTouchpad); 2606 SimulateGestureFlingStartEvent(-1200.f, 0.f, blink::WebGestureDeviceTouchpad);
2605 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2607 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2606 2608
2607 // Start another scroll. This time, do not consume any scroll events. 2609 // Start another scroll. This time, do not consume any scroll events.
2608 SimulateWheelEvent(0, -5, 0, true); // sent directly 2610 SimulateWheelEvent(0, -5, 0, true); // sent directly
2609 SimulateWheelEvent(0, -1, 0, true); // enqueued 2611 SimulateWheelEvent(0, -1, 0, true); // enqueued
2610 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 2612 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2611 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 2613 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2612 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 2614 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2613 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 2615 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2614 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2616 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2615 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2617 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2716 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2715 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2717 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2716 EXPECT_EQ(60.f, overscroll_delta_x()); 2718 EXPECT_EQ(60.f, overscroll_delta_x());
2717 EXPECT_EQ(10.f, overscroll_delegate()->delta_x()); 2719 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
2718 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2720 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2719 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2721 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2720 2722
2721 // Send a fling start, but with a small velocity, so that the overscroll is 2723 // Send a fling start, but with a small velocity, so that the overscroll is
2722 // aborted. The fling should proceed to the renderer, through the gesture 2724 // aborted. The fling should proceed to the renderer, through the gesture
2723 // event filter. 2725 // event filter.
2726 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2727 blink::WebGestureDeviceTouchscreen);
2724 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); 2728 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
2725 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2729 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2726 EXPECT_EQ(1U, sink_->message_count()); 2730 EXPECT_EQ(2U, sink_->message_count());
2727 } 2731 }
2728 2732
2729 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that 2733 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
2730 // the zero-velocity fling does not reach the renderer. 2734 // the zero-velocity fling does not reach the renderer.
2731 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2735 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2732 ScrollEventsOverscrollWithZeroFling) { 2736 ScrollEventsOverscrollWithZeroFling) {
2733 SetUpOverscrollEnvironment(); 2737 SetUpOverscrollEnvironment();
2734 2738
2735 // Send a wheel event. ACK the event as not processed. This should not 2739 // Send a wheel event. ACK the event as not processed. This should not
2736 // initiate an overscroll gesture since it doesn't cross the threshold yet. 2740 // initiate an overscroll gesture since it doesn't cross the threshold yet.
(...skipping 19 matching lines...) Expand all
2756 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 2760 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2757 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 2761 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2758 EXPECT_EQ(60.f, overscroll_delta_x()); 2762 EXPECT_EQ(60.f, overscroll_delta_x());
2759 EXPECT_EQ(10.f, overscroll_delegate()->delta_x()); 2763 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
2760 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2764 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2761 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2765 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2762 2766
2763 // Send a fling start, but with a small velocity, so that the overscroll is 2767 // Send a fling start, but with a small velocity, so that the overscroll is
2764 // aborted. The fling should proceed to the renderer, through the gesture 2768 // aborted. The fling should proceed to the renderer, through the gesture
2765 // event filter. 2769 // event filter.
2770 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2771 blink::WebGestureDeviceTouchscreen);
2766 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad); 2772 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad);
2767 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2773 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2768 EXPECT_EQ(1U, sink_->message_count()); 2774 EXPECT_EQ(2U, sink_->message_count());
2769 } 2775 }
2770 2776
2771 // Tests that a fling in the opposite direction of the overscroll cancels the 2777 // Tests that a fling in the opposite direction of the overscroll cancels the
2772 // overscroll nav instead of completing it. 2778 // overscroll nav instead of completing it.
2773 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ReverseFlingCancelsOverscroll) { 2779 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ReverseFlingCancelsOverscroll) {
2774 SetUpOverscrollEnvironment(); 2780 SetUpOverscrollEnvironment();
2775 2781
2776 { 2782 {
2777 // Start and end a gesture in the same direction without processing the 2783 // Start and end a gesture in the same direction without processing the
2778 // gesture events in the renderer. This should initiate and complete an 2784 // gesture events in the renderer. This should initiate and complete an
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); 3347 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED);
3342 EXPECT_TRUE(ScrollStateIsContentScrolling()); 3348 EXPECT_TRUE(ScrollStateIsContentScrolling());
3343 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3349 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3344 3350
3345 // The second wheel event is consumed. 3351 // The second wheel event is consumed.
3346 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); 3352 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED);
3347 EXPECT_TRUE(ScrollStateIsContentScrolling()); 3353 EXPECT_TRUE(ScrollStateIsContentScrolling());
3348 3354
3349 // Touchpad scroll can end with a zero-velocity fling. But it is not 3355 // Touchpad scroll can end with a zero-velocity fling. But it is not
3350 // dispatched, but it should still reset the overscroll controller state. 3356 // dispatched, but it should still reset the overscroll controller state.
3357 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3358 blink::WebGestureDeviceTouchscreen);
3351 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); 3359 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad);
3352 EXPECT_TRUE(ScrollStateIsUnknown()); 3360 EXPECT_TRUE(ScrollStateIsUnknown());
3353 EXPECT_EQ(0U, sink_->message_count()); 3361 EXPECT_EQ(1U, sink_->message_count());
3354 3362
3355 // Dropped flings should neither propagate *nor* indicate that they were 3363 // Dropped flings should neither propagate *nor* indicate that they were
3356 // consumed and have triggered a fling animation (as tracked by the router). 3364 // consumed and have triggered a fling animation (as tracked by the router).
3357 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); 3365 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents());
3358 3366
3359 SimulateWheelEvent(-5, 0, 0, true); // sent directly 3367 SimulateWheelEvent(-5, 0, 0, true); // sent directly
3360 SimulateWheelEvent(-60, 0, 0, true); // enqueued 3368 SimulateWheelEvent(-60, 0, 0, true); // enqueued
3361 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event 3369 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event
3362 EXPECT_TRUE(ScrollStateIsUnknown()); 3370 EXPECT_TRUE(ScrollStateIsUnknown());
3363 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3371 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
3364 3372
3365 // The first wheel scroll did not scroll content. Overscroll should not start 3373 // The first wheel scroll did not scroll content. Overscroll should not start
3366 // yet, since enough hasn't been scrolled. 3374 // yet, since enough hasn't been scrolled.
3367 SendInputEventACK(WebInputEvent::MouseWheel, 3375 SendInputEventACK(WebInputEvent::MouseWheel,
3368 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3376 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3369 EXPECT_TRUE(ScrollStateIsUnknown()); 3377 EXPECT_TRUE(ScrollStateIsUnknown());
3370 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3378 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3371 3379
3372 SendInputEventACK(WebInputEvent::MouseWheel, 3380 SendInputEventACK(WebInputEvent::MouseWheel,
3373 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3381 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3374 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); 3382 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
3375 EXPECT_TRUE(ScrollStateIsOverscrolling()); 3383 EXPECT_TRUE(ScrollStateIsOverscrolling());
3376 EXPECT_EQ(0U, sink_->message_count()); 3384 EXPECT_EQ(0U, sink_->message_count());
3377 3385
3386 // The GestureScrollBegin will reset the delegate's mode, so check it here.
3387 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
3388 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3389 blink::WebGestureDeviceTouchscreen);
3378 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); 3390 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad);
3379 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3391 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3380 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->completed_mode());
3381 EXPECT_TRUE(ScrollStateIsUnknown()); 3392 EXPECT_TRUE(ScrollStateIsUnknown());
3382 EXPECT_EQ(0U, sink_->message_count()); 3393 EXPECT_EQ(1U, sink_->message_count());
3383 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); 3394 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents());
3384 } 3395 }
3385 3396
3386 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) { 3397 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) {
3387 SetUpOverscrollEnvironment(); 3398 SetUpOverscrollEnvironment();
3388 3399
3389 // Start an overscroll with gesture scroll. In the middle of the scroll, blur 3400 // Start an overscroll with gesture scroll. In the middle of the scroll, blur
3390 // the host. 3401 // the host.
3391 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3402 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3392 blink::WebGestureDeviceTouchscreen); 3403 blink::WebGestureDeviceTouchscreen);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 // Wheel event scroll ending with a fling. 3603 // Wheel event scroll ending with a fling.
3593 SimulateWheelEvent(5, 0, 0, true); 3604 SimulateWheelEvent(5, 0, 0, true);
3594 SendInputEventACK(WebInputEvent::MouseWheel, 3605 SendInputEventACK(WebInputEvent::MouseWheel,
3595 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3606 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3596 SimulateWheelEvent(10, -5, 0, true); 3607 SimulateWheelEvent(10, -5, 0, true);
3597 SendInputEventACK(WebInputEvent::MouseWheel, 3608 SendInputEventACK(WebInputEvent::MouseWheel,
3598 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3609 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3599 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3610 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3600 EXPECT_EQ(15.f, overscroll_delta_x()); 3611 EXPECT_EQ(15.f, overscroll_delta_x());
3601 EXPECT_EQ(-5.f, overscroll_delta_y()); 3612 EXPECT_EQ(-5.f, overscroll_delta_y());
3613 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3614 blink::WebGestureDeviceTouchscreen);
3602 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); 3615 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
3603 EXPECT_EQ(0.f, overscroll_delta_x()); 3616 EXPECT_EQ(0.f, overscroll_delta_x());
3604 EXPECT_EQ(0.f, overscroll_delta_y()); 3617 EXPECT_EQ(0.f, overscroll_delta_y());
3605 } 3618 }
3606 3619
3607 // Tests the RenderWidgetHostImpl sends the correct surface ID namespace to 3620 // Tests the RenderWidgetHostImpl sends the correct surface ID namespace to
3608 // the renderer process. 3621 // the renderer process.
3609 TEST_F(RenderWidgetHostViewAuraTest, SurfaceIdNamespaceInitialized) { 3622 TEST_F(RenderWidgetHostViewAuraTest, SurfaceIdNamespaceInitialized) {
3610 gfx::Size size(5, 5); 3623 gfx::Size size(5, 5);
3611 3624
3612 const IPC::Message* msg = 3625 const IPC::Message* msg =
3613 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceIdNamespace::ID); 3626 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceIdNamespace::ID);
3614 EXPECT_TRUE(msg); 3627 EXPECT_TRUE(msg);
3615 ViewMsg_SetSurfaceIdNamespace::Param params; 3628 ViewMsg_SetSurfaceIdNamespace::Param params;
3616 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params); 3629 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params);
3617 view_->InitAsChild(NULL); 3630 view_->InitAsChild(NULL);
3618 view_->Show(); 3631 view_->Show();
3619 view_->SetSize(size); 3632 view_->SetSize(size);
3620 view_->OnSwapCompositorFrame(0, 3633 view_->OnSwapCompositorFrame(0,
3621 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); 3634 MakeDelegatedFrame(1.f, size, gfx::Rect(size)));
3622 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); 3635 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params));
3623 } 3636 }
3624 3637
3625 } // namespace content 3638 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/public/test/browser_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698