OLD | NEW |
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 Loading... |
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" |
47 #include "content/common/input/synthetic_web_input_event_builders.h" | 48 #include "content/common/input/synthetic_web_input_event_builders.h" |
48 #include "content/common/input_messages.h" | 49 #include "content/common/input_messages.h" |
49 #include "content/common/view_messages.h" | 50 #include "content/common/view_messages.h" |
50 #include "content/public/browser/render_widget_host_view.h" | 51 #include "content/public/browser/render_widget_host_view.h" |
51 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 52 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
52 #include "content/public/browser/web_contents_view_delegate.h" | 53 #include "content/public/browser/web_contents_view_delegate.h" |
53 #include "content/public/common/context_menu_params.h" | 54 #include "content/public/common/context_menu_params.h" |
54 #include "content/public/test/mock_render_process_host.h" | 55 #include "content/public/test/mock_render_process_host.h" |
55 #include "content/public/test/test_browser_context.h" | 56 #include "content/public/test/test_browser_context.h" |
56 #include "content/test/test_render_view_host.h" | 57 #include "content/test/test_render_view_host.h" |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 class RenderWidgetHostViewAuraOverscrollTest | 609 class RenderWidgetHostViewAuraOverscrollTest |
609 : public RenderWidgetHostViewAuraTest { | 610 : public RenderWidgetHostViewAuraTest { |
610 public: | 611 public: |
611 RenderWidgetHostViewAuraOverscrollTest() {} | 612 RenderWidgetHostViewAuraOverscrollTest() {} |
612 | 613 |
613 // We explicitly invoke SetUp to allow gesture debounce customization. | 614 // We explicitly invoke SetUp to allow gesture debounce customization. |
614 void SetUp() override {} | 615 void SetUp() override {} |
615 | 616 |
616 protected: | 617 protected: |
617 void SetUpOverscrollEnvironmentWithDebounce(int debounce_interval_in_ms) { | 618 void SetUpOverscrollEnvironmentWithDebounce(int debounce_interval_in_ms) { |
618 SetUpOverscrollEnvironmentImpl(debounce_interval_in_ms); | 619 SetUpOverscrollEnvironmentImpl(debounce_interval_in_ms, false); |
619 } | 620 } |
620 | 621 |
621 void SetUpOverscrollEnvironment() { SetUpOverscrollEnvironmentImpl(0); } | 622 void SetUpOverscrollEnvironmentWithWheelGestures() { |
| 623 SetUpOverscrollEnvironmentImpl(0, true); |
| 624 } |
622 | 625 |
623 void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms) { | 626 void SetUpOverscrollEnvironment() { |
| 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 |
624 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms( | 640 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms( |
625 debounce_interval_in_ms); | 641 debounce_interval_in_ms); |
626 | 642 |
627 RenderWidgetHostViewAuraTest::SetUp(); | 643 RenderWidgetHostViewAuraTest::SetUp(); |
628 | 644 |
629 view_->SetOverscrollControllerEnabled(true); | 645 view_->SetOverscrollControllerEnabled(true); |
630 overscroll_delegate_.reset(new TestOverscrollDelegate(view_)); | 646 overscroll_delegate_.reset(new TestOverscrollDelegate(view_)); |
631 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get()); | 647 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get()); |
632 | 648 |
633 view_->InitAsChild(NULL); | 649 view_->InitAsChild(NULL); |
(...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2604 press.set_location_f(gfx::PointF(kX, kY)); | 2620 press.set_location_f(gfx::PointF(kX, kY)); |
2605 press.set_root_location_f(gfx::PointF(kX, kY)); | 2621 press.set_root_location_f(gfx::PointF(kX, kY)); |
2606 | 2622 |
2607 view_->OnTouchEvent(&press); | 2623 view_->OnTouchEvent(&press); |
2608 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); | 2624 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); |
2609 EXPECT_EQ(1U, pointer_state().GetPointerCount()); | 2625 EXPECT_EQ(1U, pointer_state().GetPointerCount()); |
2610 EXPECT_EQ(kX, pointer_state().GetX(0)); | 2626 EXPECT_EQ(kX, pointer_state().GetX(0)); |
2611 EXPECT_EQ(kY, pointer_state().GetY(0)); | 2627 EXPECT_EQ(kY, pointer_state().GetY(0)); |
2612 } | 2628 } |
2613 | 2629 |
| 2630 // Tests that scroll ACKs are correctly handled by the overscroll-navigation |
| 2631 // controller. |
2614 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollEventOverscrolls) { | 2632 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollEventOverscrolls) { |
2615 SetUpOverscrollEnvironment(); | 2633 SetUpOverscrollEnvironment(); |
2616 | 2634 |
2617 // Simulate wheel events. | 2635 // Simulate wheel events. |
2618 SimulateWheelEvent(-5, 0, 0, true); // sent directly | 2636 SimulateWheelEvent(-5, 0, 0, true); // sent directly |
2619 SimulateWheelEvent(-1, 1, 0, true); // enqueued | 2637 SimulateWheelEvent(-1, 1, 0, true); // enqueued |
2620 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event | 2638 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event |
2621 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event | 2639 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event |
2622 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event | 2640 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event |
2623 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers | 2641 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers |
2624 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2642 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2625 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2643 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
2626 | 2644 |
2627 // Receive ACK the first wheel event as not processed. | 2645 // Receive ACK the first wheel event as not processed. |
2628 SendInputEventACK(WebInputEvent::MouseWheel, | 2646 SendInputEventACK(WebInputEvent::MouseWheel, |
2629 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2647 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); |
2630 | 2700 |
2631 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events | 2701 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events |
2632 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | 2702 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); |
2633 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2703 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2634 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2704 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2635 | 2705 |
2636 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2706 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2637 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2707 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2638 | 2708 |
2639 // Receive ACK for the second (coalesced) event as not processed. This will | 2709 // Receive ACK for the second (coalesced) event as not processed. This will |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2675 SimulateWheelEvent(-5, 0, 0, true); // sent directly | 2745 SimulateWheelEvent(-5, 0, 0, true); // sent directly |
2676 SimulateWheelEvent(-1, -1, 0, true); // enqueued | 2746 SimulateWheelEvent(-1, -1, 0, true); // enqueued |
2677 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event | 2747 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event |
2678 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event | 2748 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event |
2679 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event | 2749 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event |
2680 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers | 2750 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers |
2681 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2751 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2682 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2752 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
2683 | 2753 |
2684 // Receive ACK the first wheel event as processed. | 2754 // 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. |
2685 SendInputEventACK(WebInputEvent::MouseWheel, | 2828 SendInputEventACK(WebInputEvent::MouseWheel, |
2686 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2829 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2687 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events | 2830 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events |
2688 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | 2831 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); |
2689 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2832 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2690 INPUT_EVENT_ACK_STATE_CONSUMED); | 2833 INPUT_EVENT_ACK_STATE_CONSUMED); |
2691 | 2834 |
2692 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2835 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2693 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2836 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2694 | 2837 |
(...skipping 19 matching lines...) Expand all Loading... |
2714 EXPECT_EQ(0U, sink_->message_count()); | 2857 EXPECT_EQ(0U, sink_->message_count()); |
2715 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2858 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2716 } | 2859 } |
2717 | 2860 |
2718 // Tests that wheel-scrolling correctly turns overscroll on and off. | 2861 // Tests that wheel-scrolling correctly turns overscroll on and off. |
2719 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollOverscrollToggle) { | 2862 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollOverscrollToggle) { |
2720 SetUpOverscrollEnvironment(); | 2863 SetUpOverscrollEnvironment(); |
2721 | 2864 |
2722 // Send a wheel event. ACK the event as not processed. This should not | 2865 // Send a wheel event. ACK the event as not processed. This should not |
2723 // initiate an overscroll gesture since it doesn't cross the threshold yet. | 2866 // initiate an overscroll gesture since it doesn't cross the threshold yet. |
| 2867 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. |
2724 SimulateWheelEvent(10, 0, 0, true); | 2936 SimulateWheelEvent(10, 0, 0, true); |
2725 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2937 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
2726 SendInputEventACK(WebInputEvent::MouseWheel, | 2938 SendInputEventACK(WebInputEvent::MouseWheel, |
2727 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2939 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2728 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 2940 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
2729 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2941 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2730 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2942 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2731 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2943 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2732 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2944 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2733 | 2945 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2794 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 3006 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
2795 } | 3007 } |
2796 | 3008 |
2797 TEST_F(RenderWidgetHostViewAuraOverscrollTest, | 3009 TEST_F(RenderWidgetHostViewAuraOverscrollTest, |
2798 ScrollEventsOverscrollWithFling) { | 3010 ScrollEventsOverscrollWithFling) { |
2799 SetUpOverscrollEnvironment(); | 3011 SetUpOverscrollEnvironment(); |
2800 | 3012 |
2801 // Send a wheel event. ACK the event as not processed. This should not | 3013 // Send a wheel event. ACK the event as not processed. This should not |
2802 // initiate an overscroll gesture since it doesn't cross the threshold yet. | 3014 // initiate an overscroll gesture since it doesn't cross the threshold yet. |
2803 SimulateWheelEvent(10, 0, 0, true); | 3015 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); |
2804 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3068 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
2805 SendInputEventACK(WebInputEvent::MouseWheel, | 3069 SendInputEventACK(WebInputEvent::MouseWheel, |
2806 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3070 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2807 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 3071 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
2808 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 3072 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2809 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3073 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2810 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3074 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2811 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3075 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2812 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 3076 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
2813 | 3077 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2848 } | 3112 } |
2849 | 3113 |
2850 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that | 3114 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that |
2851 // the zero-velocity fling does not reach the renderer. | 3115 // the zero-velocity fling does not reach the renderer. |
2852 TEST_F(RenderWidgetHostViewAuraOverscrollTest, | 3116 TEST_F(RenderWidgetHostViewAuraOverscrollTest, |
2853 ScrollEventsOverscrollWithZeroFling) { | 3117 ScrollEventsOverscrollWithZeroFling) { |
2854 SetUpOverscrollEnvironment(); | 3118 SetUpOverscrollEnvironment(); |
2855 | 3119 |
2856 // Send a wheel event. ACK the event as not processed. This should not | 3120 // Send a wheel event. ACK the event as not processed. This should not |
2857 // initiate an overscroll gesture since it doesn't cross the threshold yet. | 3121 // initiate an overscroll gesture since it doesn't cross the threshold yet. |
| 3122 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. |
2858 SimulateWheelEvent(10, 0, 0, true); | 3175 SimulateWheelEvent(10, 0, 0, true); |
2859 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3176 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
2860 SendInputEventACK(WebInputEvent::MouseWheel, | 3177 SendInputEventACK(WebInputEvent::MouseWheel, |
2861 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3178 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2862 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 3179 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
2863 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 3180 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2864 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3181 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2865 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3182 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2866 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3183 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2867 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 3184 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3349 | 3666 |
3350 TEST_F(RenderWidgetHostViewAuraOverscrollTest, | 3667 TEST_F(RenderWidgetHostViewAuraOverscrollTest, |
3351 OverscrollDirectionChangeMouseWheel) { | 3668 OverscrollDirectionChangeMouseWheel) { |
3352 SetUpOverscrollEnvironment(); | 3669 SetUpOverscrollEnvironment(); |
3353 | 3670 |
3354 // Send wheel event and receive ack as not consumed. | 3671 // Send wheel event and receive ack as not consumed. |
3355 SimulateWheelEvent(125, -5, 0, true); | 3672 SimulateWheelEvent(125, -5, 0, true); |
3356 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3673 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3357 SendInputEventACK(WebInputEvent::MouseWheel, | 3674 SendInputEventACK(WebInputEvent::MouseWheel, |
3358 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3675 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); |
3359 | 3712 |
3360 // ScrollBegin, ScrollUpdate messages. | 3713 // ScrollBegin, ScrollUpdate messages. |
3361 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 3714 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
3362 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 3715 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
3363 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3716 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3364 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 3717 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
3365 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 3718 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
3366 | 3719 |
3367 // Send another wheel event, but in the reverse direction. The overscroll | 3720 // Send another wheel event, but in the reverse direction. The overscroll |
3368 // controller will not consume the event, because it is not triggering | 3721 // controller will not consume the event, because it is not triggering |
(...skipping 17 matching lines...) Expand all Loading... |
3386 SendInputEventACK(WebInputEvent::MouseWheel, | 3739 SendInputEventACK(WebInputEvent::MouseWheel, |
3387 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3740 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3388 | 3741 |
3389 // wheel event ack generates gesture scroll update; which gets consumed | 3742 // wheel event ack generates gesture scroll update; which gets consumed |
3390 // solely by the overflow controller. | 3743 // solely by the overflow controller. |
3391 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 3744 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
3392 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); | 3745 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); |
3393 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); | 3746 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); |
3394 } | 3747 } |
3395 | 3748 |
| 3749 // Tests that if a mouse-move event completes the overscroll gesture, future |
| 3750 // move events do reach the renderer. |
3396 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollMouseMoveCompletion) { | 3751 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollMouseMoveCompletion) { |
3397 SetUpOverscrollEnvironment(); | 3752 SetUpOverscrollEnvironment(); |
3398 | 3753 |
3399 SimulateWheelEvent(5, 0, 0, true); // sent directly | 3754 SimulateWheelEvent(5, 0, 0, true); // sent directly |
3400 SimulateWheelEvent(-1, 0, 0, true); // enqueued | 3755 SimulateWheelEvent(-1, 0, 0, true); // enqueued |
3401 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event | 3756 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event |
3402 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event | 3757 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event |
3403 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event | 3758 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event |
3404 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3759 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3405 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3760 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3406 | 3761 |
3407 // Receive ACK the first wheel event as not processed. | 3762 // Receive ACK the first wheel event as not processed. |
3408 SendInputEventACK(WebInputEvent::MouseWheel, | 3763 SendInputEventACK(WebInputEvent::MouseWheel, |
3409 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3764 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3410 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | |
3411 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
3412 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
3413 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3765 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3414 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3766 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3767 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3415 | 3768 |
3416 // Receive ACK for the second (coalesced) event as not processed. This will | 3769 // Receive ACK for the second (coalesced) event as not processed. This will |
3417 // start an overcroll gesture. | 3770 // start an overcroll gesture. |
3418 SendInputEventACK(WebInputEvent::MouseWheel, | 3771 SendInputEventACK(WebInputEvent::MouseWheel, |
3419 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3772 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3420 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | |
3421 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
3422 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
3423 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); | 3773 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); |
3424 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); | 3774 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); |
3425 EXPECT_EQ(0U, sink_->message_count()); | 3775 EXPECT_EQ(0U, sink_->message_count()); |
3426 | 3776 |
3427 // Send a mouse-move event. This should cancel the overscroll navigation | 3777 // Send a mouse-move event. This should cancel the overscroll navigation |
3428 // (since the amount overscrolled is not above the threshold), and so the | 3778 // (since the amount overscrolled is not above the threshold), and so the |
3429 // mouse-move should reach the renderer. | 3779 // mouse-move should reach the renderer. |
3430 SimulateMouseMove(5, 10, 0); | 3780 SimulateMouseMove(5, 10, 0); |
3431 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3781 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3432 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 3782 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3469 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3819 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3470 | 3820 |
3471 // Move mouse some more. The mouse-move events should reach the renderer. | 3821 // Move mouse some more. The mouse-move events should reach the renderer. |
3472 SimulateMouseMove(5, 10, 0); | 3822 SimulateMouseMove(5, 10, 0); |
3473 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3823 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3474 | 3824 |
3475 SendInputEventACK(WebInputEvent::MouseMove, | 3825 SendInputEventACK(WebInputEvent::MouseMove, |
3476 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3826 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3477 } | 3827 } |
3478 | 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()); |
| 3856 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 3857 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3858 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3859 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3860 |
| 3861 // Receive ACK for the second (coalesced) event as not processed. This will |
| 3862 // start an overcroll gesture. |
| 3863 SendInputEventACK(WebInputEvent::MouseWheel, |
| 3864 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3865 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3866 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 3867 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3868 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); |
| 3869 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); |
| 3870 EXPECT_EQ(0U, sink_->message_count()); |
| 3871 |
| 3872 // Send a mouse-move event. This should cancel the overscroll navigation |
| 3873 // (since the amount overscrolled is not above the threshold), and so the |
| 3874 // mouse-move should reach the renderer. |
| 3875 SimulateMouseMove(5, 10, 0); |
| 3876 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3877 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
| 3878 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3879 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3880 |
| 3881 SendInputEventACK(WebInputEvent::MouseMove, |
| 3882 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3883 |
| 3884 // Moving the mouse more should continue to send the events to the renderer. |
| 3885 SimulateMouseMove(5, 10, 0); |
| 3886 SendInputEventACK(WebInputEvent::MouseMove, |
| 3887 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3888 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3889 |
| 3890 // Now try with gestures. |
| 3891 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 3892 blink::WebGestureDeviceTouchscreen); |
| 3893 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 3894 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 3895 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3896 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 3897 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 3898 sink_->ClearMessages(); |
| 3899 |
| 3900 // Overscroll gesture is in progress. Send a mouse-move now. This should |
| 3901 // complete the gesture (because the amount overscrolled is above the |
| 3902 // threshold). |
| 3903 SimulateMouseMove(5, 10, 0); |
| 3904 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 3905 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3906 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3907 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3908 SendInputEventACK(WebInputEvent::MouseMove, |
| 3909 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3910 |
| 3911 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 3912 blink::WebGestureDeviceTouchscreen); |
| 3913 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3914 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3915 |
| 3916 // Move mouse some more. The mouse-move events should reach the renderer. |
| 3917 SimulateMouseMove(5, 10, 0); |
| 3918 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3919 |
| 3920 SendInputEventACK(WebInputEvent::MouseMove, |
| 3921 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3922 } |
| 3923 |
3479 // Tests that if a page scrolled, then the overscroll controller's states are | 3924 // Tests that if a page scrolled, then the overscroll controller's states are |
3480 // reset after the end of the scroll. | 3925 // reset after the end of the scroll. |
3481 TEST_F(RenderWidgetHostViewAuraOverscrollTest, | 3926 TEST_F(RenderWidgetHostViewAuraOverscrollTest, |
3482 OverscrollStateResetsAfterScroll) { | 3927 OverscrollStateResetsAfterScroll) { |
3483 SetUpOverscrollEnvironment(); | 3928 SetUpOverscrollEnvironment(); |
3484 | 3929 |
3485 SimulateWheelEvent(0, 5, 0, true); // sent directly | 3930 SimulateWheelEvent(0, 5, 0, true); // sent directly |
3486 SimulateWheelEvent(0, 30, 0, true); // enqueued | 3931 SimulateWheelEvent(0, 30, 0, true); // enqueued |
3487 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event | 3932 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event |
3488 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event | 3933 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event |
3489 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3934 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3490 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3935 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3491 | 3936 |
3492 // The first wheel event is consumed. Dispatches the queued wheel event. | 3937 // The first wheel event is consumed. Dispatches the queued wheel event. |
3493 SendInputEventACK(WebInputEvent::MouseWheel, | 3938 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); |
3494 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
3495 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
3496 INPUT_EVENT_ACK_STATE_CONSUMED); | |
3497 EXPECT_TRUE(ScrollStateIsContentScrolling()); | 3939 EXPECT_TRUE(ScrollStateIsContentScrolling()); |
3498 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | 3940 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3499 | 3941 |
3500 // The second wheel event is consumed. | 3942 // The second wheel event is consumed. |
3501 SendInputEventACK(WebInputEvent::MouseWheel, | 3943 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); |
3502 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
3503 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
3504 INPUT_EVENT_ACK_STATE_CONSUMED); | |
3505 EXPECT_TRUE(ScrollStateIsContentScrolling()); | 3944 EXPECT_TRUE(ScrollStateIsContentScrolling()); |
3506 | 3945 |
3507 // Touchpad scroll can end with a zero-velocity fling. But it is not | 3946 // Touchpad scroll can end with a zero-velocity fling. But it is not |
3508 // dispatched, but it should still reset the overscroll controller state. | 3947 // dispatched, but it should still reset the overscroll controller state. |
3509 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3948 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
3510 blink::WebGestureDeviceTouchscreen); | 3949 blink::WebGestureDeviceTouchscreen); |
3511 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); | 3950 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); |
3512 EXPECT_TRUE(ScrollStateIsUnknown()); | 3951 EXPECT_TRUE(ScrollStateIsUnknown()); |
3513 EXPECT_EQ(3U, sink_->message_count()); | 3952 EXPECT_EQ(1U, sink_->message_count()); |
3514 | 3953 |
3515 // Dropped flings should neither propagate *nor* indicate that they were | 3954 // Dropped flings should neither propagate *nor* indicate that they were |
3516 // consumed and have triggered a fling animation (as tracked by the router). | 3955 // consumed and have triggered a fling animation (as tracked by the router). |
3517 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); | 3956 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); |
3518 | 3957 |
3519 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 3958 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
3520 blink::WebGestureDeviceTouchscreen); | 3959 blink::WebGestureDeviceTouchscreen); |
3521 | 3960 |
3522 SimulateWheelEvent(-5, 0, 0, true); // sent directly | 3961 SimulateWheelEvent(-5, 0, 0, true); // sent directly |
3523 SimulateWheelEvent(-60, 0, 0, true); // enqueued | 3962 SimulateWheelEvent(-60, 0, 0, true); // enqueued |
3524 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event | 3963 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event |
3525 EXPECT_TRUE(ScrollStateIsUnknown()); | 3964 EXPECT_TRUE(ScrollStateIsUnknown()); |
3526 EXPECT_EQ(5U, GetSentMessageCountAndResetSink()); | 3965 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); |
3527 | 3966 |
3528 // The first wheel scroll did not scroll content. Overscroll should not start | 3967 // The first wheel scroll did not scroll content. Overscroll should not start |
3529 // yet, since enough hasn't been scrolled. | 3968 // yet, since enough hasn't been scrolled. |
3530 SendInputEventACK(WebInputEvent::MouseWheel, | 3969 SendInputEventACK(WebInputEvent::MouseWheel, |
3531 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3970 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3532 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
3533 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
3534 EXPECT_TRUE(ScrollStateIsUnknown()); | 3971 EXPECT_TRUE(ScrollStateIsUnknown()); |
3535 EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); | 3972 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3536 | 3973 |
3537 SendInputEventACK(WebInputEvent::MouseWheel, | 3974 SendInputEventACK(WebInputEvent::MouseWheel, |
3538 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3975 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3539 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | |
3540 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
3541 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); | 3976 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); |
3542 EXPECT_TRUE(ScrollStateIsOverscrolling()); | 3977 EXPECT_TRUE(ScrollStateIsOverscrolling()); |
3543 EXPECT_EQ(1U, sink_->message_count()); | 3978 EXPECT_EQ(0U, sink_->message_count()); |
3544 | 3979 |
3545 // The GestureScrollBegin will reset the delegate's mode, so check it here. | 3980 // The GestureScrollBegin will reset the delegate's mode, so check it here. |
3546 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); | 3981 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); |
3547 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3982 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
3548 blink::WebGestureDeviceTouchscreen); | 3983 blink::WebGestureDeviceTouchscreen); |
3549 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); | 3984 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); |
3550 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3985 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3551 EXPECT_TRUE(ScrollStateIsUnknown()); | 3986 EXPECT_TRUE(ScrollStateIsUnknown()); |
3552 EXPECT_EQ(3U, sink_->message_count()); | 3987 EXPECT_EQ(1U, sink_->message_count()); |
3553 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); | 3988 EXPECT_FALSE(parent_host_->input_router()->HasPendingEvents()); |
3554 } | 3989 } |
3555 | 3990 |
3556 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) { | 3991 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollResetsOnBlur) { |
3557 SetUpOverscrollEnvironment(); | 3992 SetUpOverscrollEnvironment(); |
3558 | 3993 |
3559 // Start an overscroll with gesture scroll. In the middle of the scroll, blur | 3994 // Start an overscroll with gesture scroll. In the middle of the scroll, blur |
3560 // the host. | 3995 // the host. |
3561 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3996 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
3562 blink::WebGestureDeviceTouchscreen); | 3997 blink::WebGestureDeviceTouchscreen); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3728 | 4163 |
3729 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 4164 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
3730 } | 4165 } |
3731 | 4166 |
3732 // Tests that the scroll deltas stored within the overscroll controller get | 4167 // Tests that the scroll deltas stored within the overscroll controller get |
3733 // reset at the end of the overscroll gesture even if the overscroll threshold | 4168 // reset at the end of the overscroll gesture even if the overscroll threshold |
3734 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. | 4169 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. |
3735 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { | 4170 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { |
3736 SetUpOverscrollEnvironment(); | 4171 SetUpOverscrollEnvironment(); |
3737 // Wheel event scroll ending with mouse move. | 4172 // 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. |
3738 SimulateWheelEvent(-30, -10, 0, true); // sent directly | 4230 SimulateWheelEvent(-30, -10, 0, true); // sent directly |
3739 SendInputEventACK(WebInputEvent::MouseWheel, | 4231 SendInputEventACK(WebInputEvent::MouseWheel, |
3740 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 4232 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3741 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 4233 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
3742 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 4234 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3743 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 4235 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3744 EXPECT_EQ(-30.f, overscroll_delta_x()); | 4236 EXPECT_EQ(-30.f, overscroll_delta_x()); |
3745 EXPECT_EQ(-10.f, overscroll_delta_y()); | 4237 EXPECT_EQ(-10.f, overscroll_delta_y()); |
3746 SimulateMouseMove(5, 10, 0); | 4238 SimulateMouseMove(5, 10, 0); |
3747 EXPECT_EQ(0.f, overscroll_delta_x()); | 4239 EXPECT_EQ(0.f, overscroll_delta_x()); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3992 view()->OnGestureEvent(&gesture_event); | 4484 view()->OnGestureEvent(&gesture_event); |
3993 | 4485 |
3994 EXPECT_TRUE(delegate->context_menu_request_received()); | 4486 EXPECT_TRUE(delegate->context_menu_request_received()); |
3995 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); | 4487 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); |
3996 #endif | 4488 #endif |
3997 | 4489 |
3998 RenderViewHostFactory::set_is_real_render_view_host(false); | 4490 RenderViewHostFactory::set_is_real_render_view_host(false); |
3999 } | 4491 } |
4000 | 4492 |
4001 } // namespace content | 4493 } // namespace content |
OLD | NEW |