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

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

Issue 2047093002: Remove enable/disable wheel gestures setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@can_scroll_remove
Patch Set: Remove unused, uninitialized variable on mac causing occasional failure Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 26 matching lines...) Expand all
37 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" 37 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h"
38 #include "content/browser/renderer_host/input/web_input_event_util.h" 38 #include "content/browser/renderer_host/input/web_input_event_util.h"
39 #include "content/browser/renderer_host/overscroll_controller.h" 39 #include "content/browser/renderer_host/overscroll_controller.h"
40 #include "content/browser/renderer_host/overscroll_controller_delegate.h" 40 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
41 #include "content/browser/renderer_host/render_view_host_factory.h" 41 #include "content/browser/renderer_host/render_view_host_factory.h"
42 #include "content/browser/renderer_host/render_widget_host_delegate.h" 42 #include "content/browser/renderer_host/render_widget_host_delegate.h"
43 #include "content/browser/renderer_host/render_widget_host_impl.h" 43 #include "content/browser/renderer_host/render_widget_host_impl.h"
44 #include "content/browser/renderer_host/resize_lock.h" 44 #include "content/browser/renderer_host/resize_lock.h"
45 #include "content/browser/web_contents/web_contents_view_aura.h" 45 #include "content/browser/web_contents/web_contents_view_aura.h"
46 #include "content/common/host_shared_bitmap_manager.h" 46 #include "content/common/host_shared_bitmap_manager.h"
47 #include "content/common/input/input_event_utils.h"
48 #include "content/common/input/synthetic_web_input_event_builders.h" 47 #include "content/common/input/synthetic_web_input_event_builders.h"
49 #include "content/common/input_messages.h" 48 #include "content/common/input_messages.h"
50 #include "content/common/view_messages.h" 49 #include "content/common/view_messages.h"
51 #include "content/public/browser/render_widget_host_view.h" 50 #include "content/public/browser/render_widget_host_view.h"
52 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 51 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
53 #include "content/public/browser/web_contents_view_delegate.h" 52 #include "content/public/browser/web_contents_view_delegate.h"
54 #include "content/public/common/context_menu_params.h" 53 #include "content/public/common/context_menu_params.h"
55 #include "content/public/test/mock_render_process_host.h" 54 #include "content/public/test/mock_render_process_host.h"
56 #include "content/public/test/test_browser_context.h" 55 #include "content/public/test/test_browser_context.h"
57 #include "content/test/test_render_view_host.h" 56 #include "content/test/test_render_view_host.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 class RenderWidgetHostViewAuraOverscrollTest 608 class RenderWidgetHostViewAuraOverscrollTest
610 : public RenderWidgetHostViewAuraTest { 609 : public RenderWidgetHostViewAuraTest {
611 public: 610 public:
612 RenderWidgetHostViewAuraOverscrollTest() {} 611 RenderWidgetHostViewAuraOverscrollTest() {}
613 612
614 // We explicitly invoke SetUp to allow gesture debounce customization. 613 // We explicitly invoke SetUp to allow gesture debounce customization.
615 void SetUp() override {} 614 void SetUp() override {}
616 615
617 protected: 616 protected:
618 void SetUpOverscrollEnvironmentWithDebounce(int debounce_interval_in_ms) { 617 void SetUpOverscrollEnvironmentWithDebounce(int debounce_interval_in_ms) {
619 SetUpOverscrollEnvironmentImpl(debounce_interval_in_ms, false); 618 SetUpOverscrollEnvironmentImpl(debounce_interval_in_ms);
620 } 619 }
621 620
622 void SetUpOverscrollEnvironmentWithWheelGestures() { 621 void SetUpOverscrollEnvironment() { SetUpOverscrollEnvironmentImpl(0); }
623 SetUpOverscrollEnvironmentImpl(0, true);
624 }
625 622
626 void SetUpOverscrollEnvironment() { 623 void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms) {
627 SetUpOverscrollEnvironmentImpl(0, false);
628 }
629
630 void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms,
631 bool enable_wheel_gestures) {
632 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
633 switches::kDisableWheelGestures) &&
634 !base::CommandLine::ForCurrentProcess()->HasSwitch(
635 switches::kEnableWheelGestures));
636 base::CommandLine::ForCurrentProcess()->AppendSwitch(
637 enable_wheel_gestures ? switches::kEnableWheelGestures
638 : switches::kDisableWheelGestures);
639
640 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms( 624 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms(
641 debounce_interval_in_ms); 625 debounce_interval_in_ms);
642 626
643 RenderWidgetHostViewAuraTest::SetUp(); 627 RenderWidgetHostViewAuraTest::SetUp();
644 628
645 view_->SetOverscrollControllerEnabled(true); 629 view_->SetOverscrollControllerEnabled(true);
646 overscroll_delegate_.reset(new TestOverscrollDelegate(view_)); 630 overscroll_delegate_.reset(new TestOverscrollDelegate(view_));
647 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get()); 631 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get());
648 632
649 view_->InitAsChild(NULL); 633 view_->InitAsChild(NULL);
(...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 press.set_location_f(gfx::PointF(kX, kY)); 2604 press.set_location_f(gfx::PointF(kX, kY));
2621 press.set_root_location_f(gfx::PointF(kX, kY)); 2605 press.set_root_location_f(gfx::PointF(kX, kY));
2622 2606
2623 view_->OnTouchEvent(&press); 2607 view_->OnTouchEvent(&press);
2624 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 2608 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
2625 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 2609 EXPECT_EQ(1U, pointer_state().GetPointerCount());
2626 EXPECT_EQ(kX, pointer_state().GetX(0)); 2610 EXPECT_EQ(kX, pointer_state().GetX(0));
2627 EXPECT_EQ(kY, pointer_state().GetY(0)); 2611 EXPECT_EQ(kY, pointer_state().GetY(0));
2628 } 2612 }
2629 2613
2630 // Tests that scroll ACKs are correctly handled by the overscroll-navigation
2631 // controller.
2632 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollEventOverscrolls) { 2614 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollEventOverscrolls) {
2633 SetUpOverscrollEnvironment(); 2615 SetUpOverscrollEnvironment();
2634 2616
2635 // Simulate wheel events. 2617 // Simulate wheel events.
2636 SimulateWheelEvent(-5, 0, 0, true); // sent directly 2618 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2637 SimulateWheelEvent(-1, 1, 0, true); // enqueued 2619 SimulateWheelEvent(-1, 1, 0, true); // enqueued
2638 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 2620 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2639 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 2621 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2640 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 2622 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2641 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 2623 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2642 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2624 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2643 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2625 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2644 2626
2645 // Receive ACK the first wheel event as not processed. 2627 // Receive ACK the first wheel event as not processed.
2646 SendInputEventACK(WebInputEvent::MouseWheel, 2628 SendInputEventACK(WebInputEvent::MouseWheel,
2647 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2629 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2648 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2649 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2650 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2651
2652 // Receive ACK for the second (coalesced) event as not processed. This will
2653 // start a back navigation. However, this will also cause the queued next
2654 // event to be sent to the renderer. But since overscroll navigation has
2655 // started, that event will also be included in the overscroll computation
2656 // instead of being sent to the renderer. So the result will be an overscroll
2657 // back navigation, and no event will be sent to the renderer.
2658 SendInputEventACK(WebInputEvent::MouseWheel,
2659 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2660 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2661 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
2662 EXPECT_EQ(-81.f, overscroll_delta_x());
2663 EXPECT_EQ(-31.f, overscroll_delegate()->delta_x());
2664 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2665 EXPECT_EQ(0U, sink_->message_count());
2666
2667 // Send a mouse-move event. This should cancel the overscroll navigation.
2668 SimulateMouseMove(5, 10, 0);
2669 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2670 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2671 EXPECT_EQ(1U, sink_->message_count());
2672 }
2673
2674 // Disabled on MacOS because it doesn't support wheel gestures
2675 // just yet.
2676 #if defined(OS_MACOSX)
2677 #define MAYBE_WheelScrollEventOverscrollsWithWheelGestures \
2678 DISABLED_WheelScrollEventOverscrollsWithWheelGestures
2679 #else
2680 #define MAYBE_WheelScrollEventOverscrollsWithWheelGestures \
2681 WheelScrollEventOverscrollsWithWheelGestures
2682 #endif
2683 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2684 MAYBE_WheelScrollEventOverscrollsWithWheelGestures) {
2685 SetUpOverscrollEnvironmentWithWheelGestures();
2686
2687 // Simulate wheel events.
2688 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2689 SimulateWheelEvent(-1, 1, 0, true); // enqueued
2690 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2691 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2692 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2693 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2694 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2695 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2696
2697 // Receive ACK the first wheel event as not processed.
2698 SendInputEventACK(WebInputEvent::MouseWheel,
2699 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2700 2630
2701 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events 2631 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events
2702 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); 2632 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
2703 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2633 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2704 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2634 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2705 2635
2706 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2636 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2707 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2637 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2708 2638
2709 // Receive ACK for the second (coalesced) event as not processed. This will 2639 // Receive ACK for the second (coalesced) event as not processed. This will
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2745 SimulateWheelEvent(-5, 0, 0, true); // sent directly 2675 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2746 SimulateWheelEvent(-1, -1, 0, true); // enqueued 2676 SimulateWheelEvent(-1, -1, 0, true); // enqueued
2747 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 2677 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2748 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 2678 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2749 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 2679 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2750 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers 2680 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2751 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2681 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2752 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2682 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2753 2683
2754 // Receive ACK the first wheel event as processed. 2684 // Receive ACK the first wheel event as processed.
2755 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED);
2756 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2757 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2758 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2759
2760 // Receive ACK for the second (coalesced) event as not processed. This should
2761 // not initiate overscroll, since the beginning of the scroll has been
2762 // consumed. The queued event with different modifiers should be sent to the
2763 // renderer.
2764 SendInputEventACK(WebInputEvent::MouseWheel,
2765 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2766 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2767 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2768
2769 SendInputEventACK(WebInputEvent::MouseWheel,
2770 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2771 EXPECT_EQ(0U, sink_->message_count());
2772 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2773
2774 // Indicate the end of the scrolling from the touchpad.
2775 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2776 blink::WebGestureDeviceTouchscreen);
2777 SimulateGestureFlingStartEvent(-1200.f, 0.f, blink::WebGestureDeviceTouchpad);
2778 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2779
2780 // Start another scroll. This time, do not consume any scroll events.
2781 SimulateWheelEvent(0, -5, 0, true); // sent directly
2782 SimulateWheelEvent(0, -1, 0, true); // enqueued
2783 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2784 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2785 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2786 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2787 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2788 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2789
2790 // Receive ACK for the first wheel and the subsequent coalesced event as not
2791 // processed. This should start a back-overscroll.
2792 SendInputEventACK(WebInputEvent::MouseWheel,
2793 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2794 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2795 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2796 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2797 SendInputEventACK(WebInputEvent::MouseWheel,
2798 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2799 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2800 }
2801
2802 // Tests that if some scroll events are consumed towards the start, then
2803 // subsequent scrolls do not horizontal overscroll.
2804 // Disabled on MacOS because it doesn't support wheel gestures
2805 // just yet.
2806 #if defined(OS_MACOSX)
2807 #define MAYBE_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures \
2808 DISABLED_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures
2809 #else
2810 #define MAYBE_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures \
2811 WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures
2812 #endif
2813 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2814 MAYBE_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures) {
2815 SetUpOverscrollEnvironmentWithWheelGestures();
2816
2817 // Simulate wheel events.
2818 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2819 SimulateWheelEvent(-1, -1, 0, true); // enqueued
2820 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2821 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2822 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2823 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2824 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2825 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2826
2827 // Receive ACK the first wheel event as processed.
2828 SendInputEventACK(WebInputEvent::MouseWheel, 2685 SendInputEventACK(WebInputEvent::MouseWheel,
2829 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2686 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2830 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events 2687 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events
2831 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); 2688 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
2832 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2689 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2833 INPUT_EVENT_ACK_STATE_CONSUMED); 2690 INPUT_EVENT_ACK_STATE_CONSUMED);
2834 2691
2835 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2692 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2836 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2693 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2837 2694
(...skipping 20 matching lines...) Expand all
2858 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2715 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2859 } 2716 }
2860 2717
2861 // Tests that wheel-scrolling correctly turns overscroll on and off. 2718 // Tests that wheel-scrolling correctly turns overscroll on and off.
2862 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollOverscrollToggle) { 2719 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollOverscrollToggle) {
2863 SetUpOverscrollEnvironment(); 2720 SetUpOverscrollEnvironment();
2864 2721
2865 // Send a wheel event. ACK the event as not processed. This should not 2722 // Send a wheel event. ACK the event as not processed. This should not
2866 // initiate an overscroll gesture since it doesn't cross the threshold yet. 2723 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2867 SimulateWheelEvent(10, 0, 0, true); 2724 SimulateWheelEvent(10, 0, 0, true);
2868 SendInputEventACK(WebInputEvent::MouseWheel,
2869 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2870 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2871 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2872 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2873
2874 // Scroll some more so as to not overscroll.
2875 SimulateWheelEvent(10, 0, 0, true);
2876 SendInputEventACK(WebInputEvent::MouseWheel,
2877 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2878 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2879 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2880 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2881
2882 // Scroll some more to initiate an overscroll.
2883 SimulateWheelEvent(40, 0, 0, true);
2884 SendInputEventACK(WebInputEvent::MouseWheel,
2885 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2886 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
2887 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
2888 EXPECT_EQ(60.f, overscroll_delta_x());
2889 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
2890 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2891 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2892
2893 // Scroll in the reverse direction enough to abort the overscroll.
2894 SimulateWheelEvent(-20, 0, 0, true);
2895 EXPECT_EQ(0U, sink_->message_count());
2896 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2897 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2898
2899 // Continue to scroll in the reverse direction.
2900 SimulateWheelEvent(-20, 0, 0, true);
2901 SendInputEventACK(WebInputEvent::MouseWheel,
2902 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2903 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2904 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2905 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2906
2907 // Continue to scroll in the reverse direction enough to initiate overscroll
2908 // in that direction.
2909 SimulateWheelEvent(-55, 0, 0, true);
2910 EXPECT_EQ(1U, sink_->message_count());
2911 SendInputEventACK(WebInputEvent::MouseWheel,
2912 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2913 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2914 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
2915 EXPECT_EQ(-75.f, overscroll_delta_x());
2916 EXPECT_EQ(-25.f, overscroll_delegate()->delta_x());
2917 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2918 }
2919
2920 // Tests that wheel-scrolling correctly turns overscroll on and off.
2921 // Disabled on MacOS because it doesn't support wheel gestures
2922 // just yet.
2923 #if defined(OS_MACOSX)
2924 #define MAYBE_WheelScrollOverscrollToggleWithWheelGestures \
2925 DISABLED_WheelScrollOverscrollToggleWithWheelGestures
2926 #else
2927 #define MAYBE_WheelScrollOverscrollToggleWithWheelGestures \
2928 WheelScrollOverscrollToggleWithWheelGestures
2929 #endif
2930 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2931 MAYBE_WheelScrollOverscrollToggleWithWheelGestures) {
2932 SetUpOverscrollEnvironmentWithWheelGestures();
2933
2934 // Send a wheel event. ACK the event as not processed. This should not
2935 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2936 SimulateWheelEvent(10, 0, 0, true);
2937 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2725 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2938 SendInputEventACK(WebInputEvent::MouseWheel, 2726 SendInputEventACK(WebInputEvent::MouseWheel,
2939 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2727 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2940 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); 2728 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2941 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2729 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2942 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2730 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2943 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2731 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2944 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2732 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2945 2733
2946 // Scroll some more so as to not overscroll. 2734 // Scroll some more so as to not overscroll.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2794 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
3007 } 2795 }
3008 2796
3009 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2797 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3010 ScrollEventsOverscrollWithFling) { 2798 ScrollEventsOverscrollWithFling) {
3011 SetUpOverscrollEnvironment(); 2799 SetUpOverscrollEnvironment();
3012 2800
3013 // Send a wheel event. ACK the event as not processed. This should not 2801 // Send a wheel event. ACK the event as not processed. This should not
3014 // initiate an overscroll gesture since it doesn't cross the threshold yet. 2802 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3015 SimulateWheelEvent(10, 0, 0, true); 2803 SimulateWheelEvent(10, 0, 0, true);
3016 SendInputEventACK(WebInputEvent::MouseWheel,
3017 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3018 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3019 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3020 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3021
3022 // Scroll some more so as to not overscroll.
3023 SimulateWheelEvent(20, 0, 0, true);
3024 EXPECT_EQ(1U, sink_->message_count());
3025 SendInputEventACK(WebInputEvent::MouseWheel,
3026 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3027 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3028 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3029 sink_->ClearMessages();
3030
3031 // Scroll some more to initiate an overscroll.
3032 SimulateWheelEvent(30, 0, 0, true);
3033 SendInputEventACK(WebInputEvent::MouseWheel,
3034 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3035 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3036 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3037 EXPECT_EQ(60.f, overscroll_delta_x());
3038 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
3039 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
3040 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3041
3042 // Send a fling start, but with a small velocity, so that the overscroll is
3043 // aborted. The fling should proceed to the renderer, through the gesture
3044 // event filter.
3045 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3046 blink::WebGestureDeviceTouchscreen);
3047 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
3048 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3049 EXPECT_EQ(2U, sink_->message_count());
3050 }
3051
3052 // Disabled on MacOS because it doesn't support wheel gestures
3053 // just yet.
3054 #if defined(OS_MACOSX)
3055 #define MAYBE_ScrollEventsOverscrollWithFlingAndWheelGestures \
3056 DISABLED_ScrollEventsOverscrollWithFlingAndWheelGestures
3057 #else
3058 #define MAYBE_ScrollEventsOverscrollWithFlingAndWheelGestures \
3059 ScrollEventsOverscrollWithFlingAndWheelGestures
3060 #endif
3061 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3062 MAYBE_ScrollEventsOverscrollWithFlingAndWheelGestures) {
3063 SetUpOverscrollEnvironmentWithWheelGestures();
3064
3065 // Send a wheel event. ACK the event as not processed. This should not
3066 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3067 SimulateWheelEvent(10, 0, 0, true);
3068 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2804 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3069 SendInputEventACK(WebInputEvent::MouseWheel, 2805 SendInputEventACK(WebInputEvent::MouseWheel,
3070 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2806 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3071 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); 2807 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
3072 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2808 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3073 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2809 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3074 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2810 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3075 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2811 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3076 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 2812 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
3077 2813
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 2849
3114 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that 2850 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
3115 // the zero-velocity fling does not reach the renderer. 2851 // the zero-velocity fling does not reach the renderer.
3116 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2852 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3117 ScrollEventsOverscrollWithZeroFling) { 2853 ScrollEventsOverscrollWithZeroFling) {
3118 SetUpOverscrollEnvironment(); 2854 SetUpOverscrollEnvironment();
3119 2855
3120 // Send a wheel event. ACK the event as not processed. This should not 2856 // Send a wheel event. ACK the event as not processed. This should not
3121 // initiate an overscroll gesture since it doesn't cross the threshold yet. 2857 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3122 SimulateWheelEvent(10, 0, 0, true); 2858 SimulateWheelEvent(10, 0, 0, true);
3123 SendInputEventACK(WebInputEvent::MouseWheel,
3124 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3125 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3126 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3127 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3128
3129 // Scroll some more so as to not overscroll.
3130 SimulateWheelEvent(20, 0, 0, true);
3131 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3132 SendInputEventACK(WebInputEvent::MouseWheel,
3133 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3134 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3135 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3136
3137 // Scroll some more to initiate an overscroll.
3138 SimulateWheelEvent(30, 0, 0, true);
3139 SendInputEventACK(WebInputEvent::MouseWheel,
3140 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3141 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3142 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3143 EXPECT_EQ(60.f, overscroll_delta_x());
3144 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
3145 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
3146 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3147
3148 // Send a fling start, but with a small velocity, so that the overscroll is
3149 // aborted. The fling should proceed to the renderer, through the gesture
3150 // event filter.
3151 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3152 blink::WebGestureDeviceTouchscreen);
3153 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad);
3154 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3155 EXPECT_EQ(2U, sink_->message_count());
3156 }
3157
3158 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
3159 // the zero-velocity fling does not reach the renderer.
3160 // Disabled on MacOS because it doesn't support wheel gestures
3161 // just yet.
3162 #if defined(OS_MACOSX)
3163 #define MAYBE_ScrollEventsOverscrollWithZeroFlingAndWheelGestures \
3164 DISABLED_ScrollEventsOverscrollWithZeroFlingAndWheelGestures
3165 #else
3166 #define MAYBE_ScrollEventsOverscrollWithZeroFlingAndWheelGestures \
3167 ScrollEventsOverscrollWithZeroFlingAndWheelGestures
3168 #endif
3169 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3170 MAYBE_ScrollEventsOverscrollWithZeroFlingAndWheelGestures) {
3171 SetUpOverscrollEnvironmentWithWheelGestures();
3172
3173 // Send a wheel event. ACK the event as not processed. This should not
3174 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3175 SimulateWheelEvent(10, 0, 0, true);
3176 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2859 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3177 SendInputEventACK(WebInputEvent::MouseWheel, 2860 SendInputEventACK(WebInputEvent::MouseWheel,
3178 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2861 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3179 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); 2862 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
3180 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 2863 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3181 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2864 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3182 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2865 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3183 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2866 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3184 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 2867 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
3185 2868
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 3349
3667 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 3350 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3668 OverscrollDirectionChangeMouseWheel) { 3351 OverscrollDirectionChangeMouseWheel) {
3669 SetUpOverscrollEnvironment(); 3352 SetUpOverscrollEnvironment();
3670 3353
3671 // Send wheel event and receive ack as not consumed. 3354 // Send wheel event and receive ack as not consumed.
3672 SimulateWheelEvent(125, -5, 0, true); 3355 SimulateWheelEvent(125, -5, 0, true);
3673 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3356 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3674 SendInputEventACK(WebInputEvent::MouseWheel, 3357 SendInputEventACK(WebInputEvent::MouseWheel,
3675 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3358 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3676 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3677 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3678 EXPECT_EQ(0U, sink_->message_count());
3679
3680 // Send another wheel event, but in the reverse direction. The overscroll
3681 // controller will not consume the event, because it is not triggering
3682 // gesture-nav.
3683 SimulateWheelEvent(-260, 0, 0, true);
3684 EXPECT_EQ(1U, sink_->message_count());
3685 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3686
3687 // Since the overscroll mode has been reset, the next wheel event should reach
3688 // the renderer.
3689 SimulateWheelEvent(-20, 0, 0, true);
3690 EXPECT_EQ(1U, sink_->message_count());
3691 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3692 }
3693
3694 // Disabled on MacOS because it doesn't support wheel gestures
3695 // just yet.
3696 #if defined(OS_MACOSX)
3697 #define MAYBE_OverscrollDirectionChangeMouseWheelWithWheelGestures \
3698 DISABLED_OverscrollDirectionChangeMouseWheelWithWheelGestures
3699 #else
3700 #define MAYBE_OverscrollDirectionChangeMouseWheelWithWheelGestures \
3701 OverscrollDirectionChangeMouseWheelWithWheelGestures
3702 #endif
3703 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3704 MAYBE_OverscrollDirectionChangeMouseWheelWithWheelGestures) {
3705 SetUpOverscrollEnvironmentWithWheelGestures();
3706
3707 // Send wheel event and receive ack as not consumed.
3708 SimulateWheelEvent(125, -5, 0, true);
3709 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3710 SendInputEventACK(WebInputEvent::MouseWheel,
3711 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3712 3359
3713 // ScrollBegin, ScrollUpdate messages. 3360 // ScrollBegin, ScrollUpdate messages.
3714 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); 3361 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
3715 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3362 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3716 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3363 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3717 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); 3364 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3718 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); 3365 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3719 3366
3720 // Send another wheel event, but in the reverse direction. The overscroll 3367 // Send another wheel event, but in the reverse direction. The overscroll
3721 // controller will not consume the event, because it is not triggering 3368 // controller will not consume the event, because it is not triggering
(...skipping 17 matching lines...) Expand all
3739 SendInputEventACK(WebInputEvent::MouseWheel, 3386 SendInputEventACK(WebInputEvent::MouseWheel,
3740 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3387 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3741 3388
3742 // wheel event ack generates gesture scroll update; which gets consumed 3389 // wheel event ack generates gesture scroll update; which gets consumed
3743 // solely by the overflow controller. 3390 // solely by the overflow controller.
3744 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 3391 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
3745 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); 3392 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
3746 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); 3393 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
3747 } 3394 }
3748 3395
3749 // Tests that if a mouse-move event completes the overscroll gesture, future
3750 // move events do reach the renderer.
3751 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollMouseMoveCompletion) { 3396 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollMouseMoveCompletion) {
3752 SetUpOverscrollEnvironment(); 3397 SetUpOverscrollEnvironment();
3753 3398
3754 SimulateWheelEvent(5, 0, 0, true); // sent directly 3399 SimulateWheelEvent(5, 0, 0, true); // sent directly
3755 SimulateWheelEvent(-1, 0, 0, true); // enqueued 3400 SimulateWheelEvent(-1, 0, 0, true); // enqueued
3756 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3401 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3757 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3402 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3758 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3403 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3759 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3404 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3760 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3405 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3761 3406
3762 // Receive ACK the first wheel event as not processed. 3407 // Receive ACK the first wheel event as not processed.
3763 SendInputEventACK(WebInputEvent::MouseWheel, 3408 SendInputEventACK(WebInputEvent::MouseWheel,
3764 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3409 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3765 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3766 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3767 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3768
3769 // Receive ACK for the second (coalesced) event as not processed. This will
3770 // start an overcroll gesture.
3771 SendInputEventACK(WebInputEvent::MouseWheel,
3772 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3773 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
3774 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
3775 EXPECT_EQ(0U, sink_->message_count());
3776
3777 // Send a mouse-move event. This should cancel the overscroll navigation
3778 // (since the amount overscrolled is not above the threshold), and so the
3779 // mouse-move should reach the renderer.
3780 SimulateMouseMove(5, 10, 0);
3781 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3782 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
3783 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3784 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3785
3786 SendInputEventACK(WebInputEvent::MouseMove,
3787 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3788
3789 // Moving the mouse more should continue to send the events to the renderer.
3790 SimulateMouseMove(5, 10, 0);
3791 SendInputEventACK(WebInputEvent::MouseMove,
3792 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3793 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3794
3795 // Now try with gestures.
3796 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3797 blink::WebGestureDeviceTouchscreen);
3798 SimulateGestureScrollUpdateEvent(300, -5, 0);
3799 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3800 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3801 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3802 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3803 sink_->ClearMessages();
3804
3805 // Overscroll gesture is in progress. Send a mouse-move now. This should
3806 // complete the gesture (because the amount overscrolled is above the
3807 // threshold).
3808 SimulateMouseMove(5, 10, 0);
3809 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
3810 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3811 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3812 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3813 SendInputEventACK(WebInputEvent::MouseMove,
3814 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3815
3816 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3817 blink::WebGestureDeviceTouchscreen);
3818 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3819 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3820
3821 // Move mouse some more. The mouse-move events should reach the renderer.
3822 SimulateMouseMove(5, 10, 0);
3823 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3824
3825 SendInputEventACK(WebInputEvent::MouseMove,
3826 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3827 }
3828
3829 // Tests that if a mouse-move event completes the overscroll gesture, future
3830 // move events do reach the renderer.
3831 // Disabled on MacOS because it doesn't support wheel gestures
3832 // just yet.
3833 #if defined(OS_MACOSX)
3834 #define MAYBE_OverscrollMouseMoveCompletionWheelGestures \
3835 DISABLED_OverscrollMouseMoveCompletionWheelGestures
3836 #else
3837 #define MAYBE_OverscrollMouseMoveCompletionWheelGestures \
3838 OverscrollMouseMoveCompletionWheelGestures
3839 #endif
3840 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3841 MAYBE_OverscrollMouseMoveCompletionWheelGestures) {
3842 SetUpOverscrollEnvironmentWithWheelGestures();
3843
3844 SimulateWheelEvent(5, 0, 0, true); // sent directly
3845 SimulateWheelEvent(-1, 0, 0, true); // enqueued
3846 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3847 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3848 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3849 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3850 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3851
3852 // Receive ACK the first wheel event as not processed.
3853 SendInputEventACK(WebInputEvent::MouseWheel,
3854 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3855 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); 3410 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
3856 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3411 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3857 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3412 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3858 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3413 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3859 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 3414 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3860 3415
3861 // Receive ACK for the second (coalesced) event as not processed. This will 3416 // Receive ACK for the second (coalesced) event as not processed. This will
3862 // start an overcroll gesture. 3417 // start an overcroll gesture.
3863 SendInputEventACK(WebInputEvent::MouseWheel, 3418 SendInputEventACK(WebInputEvent::MouseWheel,
3864 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3419 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3928 SetUpOverscrollEnvironment(); 3483 SetUpOverscrollEnvironment();
3929 3484
3930 SimulateWheelEvent(0, 5, 0, true); // sent directly 3485 SimulateWheelEvent(0, 5, 0, true); // sent directly
3931 SimulateWheelEvent(0, 30, 0, true); // enqueued 3486 SimulateWheelEvent(0, 30, 0, true); // enqueued
3932 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event 3487 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event
3933 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event 3488 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event
3934 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3489 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3935 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3490 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3936 3491
3937 // The first wheel event is consumed. Dispatches the queued wheel event. 3492 // The first wheel event is consumed. Dispatches the queued wheel event.
3938 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); 3493 SendInputEventACK(WebInputEvent::MouseWheel,
3494 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3495 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3496 INPUT_EVENT_ACK_STATE_CONSUMED);
3939 EXPECT_TRUE(ScrollStateIsContentScrolling()); 3497 EXPECT_TRUE(ScrollStateIsContentScrolling());
3940 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3498 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
3941 3499
3942 // The second wheel event is consumed. 3500 // The second wheel event is consumed.
3943 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); 3501 SendInputEventACK(WebInputEvent::MouseWheel,
3502 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3503 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3504 INPUT_EVENT_ACK_STATE_CONSUMED);
3944 EXPECT_TRUE(ScrollStateIsContentScrolling()); 3505 EXPECT_TRUE(ScrollStateIsContentScrolling());
3945 3506
3946 // Touchpad scroll can end with a zero-velocity fling. But it is not 3507 // Touchpad scroll can end with a zero-velocity fling. But it is not
3947 // dispatched, but it should still reset the overscroll controller state. 3508 // dispatched, but it should still reset the overscroll controller state.
3948 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3509 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3949 blink::WebGestureDeviceTouchscreen); 3510 blink::WebGestureDeviceTouchscreen);
3950 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); 3511 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad);
3951 EXPECT_TRUE(ScrollStateIsUnknown()); 3512 EXPECT_TRUE(ScrollStateIsUnknown());
3952 EXPECT_EQ(1U, sink_->message_count()); 3513 EXPECT_EQ(3U, sink_->message_count());
3953 3514
3954 // Dropped flings should neither propagate *nor* indicate that they were 3515 // Dropped flings should neither propagate *nor* indicate that they were
3955 // consumed and have triggered a fling animation (as tracked by the router). 3516 // consumed and have triggered a fling animation (as tracked by the router).
3956 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); 3517 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents());
3957 3518
3958 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 3519 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3959 blink::WebGestureDeviceTouchscreen); 3520 blink::WebGestureDeviceTouchscreen);
3960 3521
3961 SimulateWheelEvent(-5, 0, 0, true); // sent directly 3522 SimulateWheelEvent(-5, 0, 0, true); // sent directly
3962 SimulateWheelEvent(-60, 0, 0, true); // enqueued 3523 SimulateWheelEvent(-60, 0, 0, true); // enqueued
3963 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event 3524 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event
3964 EXPECT_TRUE(ScrollStateIsUnknown()); 3525 EXPECT_TRUE(ScrollStateIsUnknown());
3965 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); 3526 EXPECT_EQ(5U, GetSentMessageCountAndResetSink());
3966 3527
3967 // The first wheel scroll did not scroll content. Overscroll should not start 3528 // The first wheel scroll did not scroll content. Overscroll should not start
3968 // yet, since enough hasn't been scrolled. 3529 // yet, since enough hasn't been scrolled.
3969 SendInputEventACK(WebInputEvent::MouseWheel, 3530 SendInputEventACK(WebInputEvent::MouseWheel,
3970 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3531 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3532 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3533 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3971 EXPECT_TRUE(ScrollStateIsUnknown()); 3534 EXPECT_TRUE(ScrollStateIsUnknown());
3972 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3535 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
3973 3536
3974 SendInputEventACK(WebInputEvent::MouseWheel, 3537 SendInputEventACK(WebInputEvent::MouseWheel,
3975 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3538 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3539 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3540 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3976 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); 3541 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
3977 EXPECT_TRUE(ScrollStateIsOverscrolling()); 3542 EXPECT_TRUE(ScrollStateIsOverscrolling());
3978 EXPECT_EQ(0U, sink_->message_count()); 3543 EXPECT_EQ(1U, sink_->message_count());
3979 3544
3980 // The GestureScrollBegin will reset the delegate's mode, so check it here. 3545 // The GestureScrollBegin will reset the delegate's mode, so check it here.
3981 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); 3546 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
3982 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3547 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3983 blink::WebGestureDeviceTouchscreen); 3548 blink::WebGestureDeviceTouchscreen);
3984 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); 3549 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad);
3985 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3550 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3986 EXPECT_TRUE(ScrollStateIsUnknown()); 3551 EXPECT_TRUE(ScrollStateIsUnknown());
3987 EXPECT_EQ(1U, sink_->message_count()); 3552 EXPECT_EQ(3U, sink_->message_count());
3988 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); 3553 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents());
3989 } 3554 }
3990 3555
3991 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) { 3556 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) {
3992 SetUpOverscrollEnvironment(); 3557 SetUpOverscrollEnvironment();
3993 3558
3994 // Start an overscroll with gesture scroll. In the middle of the scroll, blur 3559 // Start an overscroll with gesture scroll. In the middle of the scroll, blur
3995 // the host. 3560 // the host.
3996 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3561 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3997 blink::WebGestureDeviceTouchscreen); 3562 blink::WebGestureDeviceTouchscreen);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4163 3728
4164 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 3729 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
4165 } 3730 }
4166 3731
4167 // Tests that the scroll deltas stored within the overscroll controller get 3732 // Tests that the scroll deltas stored within the overscroll controller get
4168 // reset at the end of the overscroll gesture even if the overscroll threshold 3733 // reset at the end of the overscroll gesture even if the overscroll threshold
4169 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. 3734 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE.
4170 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { 3735 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) {
4171 SetUpOverscrollEnvironment(); 3736 SetUpOverscrollEnvironment();
4172 // Wheel event scroll ending with mouse move. 3737 // Wheel event scroll ending with mouse move.
4173 SimulateWheelEvent(-30, -10, 0, true); // sent directly
4174 SendInputEventACK(WebInputEvent::MouseWheel,
4175 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4176 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
4177 EXPECT_EQ(-30.f, overscroll_delta_x());
4178 EXPECT_EQ(-10.f, overscroll_delta_y());
4179 SimulateMouseMove(5, 10, 0);
4180 EXPECT_EQ(0.f, overscroll_delta_x());
4181 EXPECT_EQ(0.f, overscroll_delta_y());
4182
4183 // Scroll gesture.
4184 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
4185 blink::WebGestureDeviceTouchscreen);
4186 SimulateGestureScrollUpdateEvent(-30, -5, 0);
4187 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
4188 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4189 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
4190 EXPECT_EQ(-30.f, overscroll_delta_x());
4191 EXPECT_EQ(-5.f, overscroll_delta_y());
4192 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
4193 blink::WebGestureDeviceTouchscreen);
4194 EXPECT_EQ(0.f, overscroll_delta_x());
4195 EXPECT_EQ(0.f, overscroll_delta_y());
4196
4197 // Wheel event scroll ending with a fling.
4198 SimulateWheelEvent(5, 0, 0, true);
4199 SendInputEventACK(WebInputEvent::MouseWheel,
4200 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4201 SimulateWheelEvent(10, -5, 0, true);
4202 SendInputEventACK(WebInputEvent::MouseWheel,
4203 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4204 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
4205 EXPECT_EQ(15.f, overscroll_delta_x());
4206 EXPECT_EQ(-5.f, overscroll_delta_y());
4207 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
4208 blink::WebGestureDeviceTouchscreen);
4209 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
4210 EXPECT_EQ(0.f, overscroll_delta_x());
4211 EXPECT_EQ(0.f, overscroll_delta_y());
4212 }
4213
4214 // Tests that the scroll deltas stored within the overscroll controller get
4215 // reset at the end of the overscroll gesture even if the overscroll threshold
4216 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE.
4217 // Disabled on MacOS because it doesn't support wheel gestures
4218 // just yet.
4219 #if defined(OS_MACOSX)
4220 #define MAYBE_ScrollDeltasResetOnEndWithWheelGestures \
4221 DISABLED_ScrollDeltasResetOnEndWithWheelGestures
4222 #else
4223 #define MAYBE_ScrollDeltasResetOnEndWithWheelGestures \
4224 ScrollDeltasResetOnEndWithWheelGestures
4225 #endif
4226 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
4227 MAYBE_ScrollDeltasResetOnEndWithWheelGestures) {
4228 SetUpOverscrollEnvironmentWithWheelGestures();
4229 // Wheel event scroll ending with mouse move.
4230 SimulateWheelEvent(-30, -10, 0, true); // sent directly 3738 SimulateWheelEvent(-30, -10, 0, true); // sent directly
4231 SendInputEventACK(WebInputEvent::MouseWheel, 3739 SendInputEventACK(WebInputEvent::MouseWheel,
4232 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3740 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4233 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 3741 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
4234 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3742 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4235 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3743 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
4236 EXPECT_EQ(-30.f, overscroll_delta_x()); 3744 EXPECT_EQ(-30.f, overscroll_delta_x());
4237 EXPECT_EQ(-10.f, overscroll_delta_y()); 3745 EXPECT_EQ(-10.f, overscroll_delta_y());
4238 SimulateMouseMove(5, 10, 0); 3746 SimulateMouseMove(5, 10, 0);
4239 EXPECT_EQ(0.f, overscroll_delta_x()); 3747 EXPECT_EQ(0.f, overscroll_delta_x());
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
4484 view()->OnGestureEvent(&gesture_event); 3992 view()->OnGestureEvent(&gesture_event);
4485 3993
4486 EXPECT_TRUE(delegate->context_menu_request_received()); 3994 EXPECT_TRUE(delegate->context_menu_request_received());
4487 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); 3995 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH);
4488 #endif 3996 #endif
4489 3997
4490 RenderViewHostFactory::set_is_real_render_view_host(false); 3998 RenderViewHostFactory::set_is_real_render_view_host(false);
4491 } 3999 }
4492 4000
4493 } // namespace content 4001 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/browser/renderer_host/render_widget_host_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698