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

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

Issue 1705323002: Follow on for gesture events generated by wheel events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners_3
Patch Set: Created 4 years, 10 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 #include <utility> 9 #include <utility>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "cc/output/compositor_frame_metadata.h" 21 #include "cc/output/compositor_frame_metadata.h"
22 #include "cc/output/copy_output_request.h" 22 #include "cc/output/copy_output_request.h"
23 #include "cc/surfaces/surface.h" 23 #include "cc/surfaces/surface.h"
24 #include "cc/surfaces/surface_manager.h" 24 #include "cc/surfaces/surface_manager.h"
25 #include "content/browser/browser_thread_impl.h" 25 #include "content/browser/browser_thread_impl.h"
26 #include "content/browser/compositor/resize_lock.h" 26 #include "content/browser/compositor/resize_lock.h"
27 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " 27 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
28 #include "content/browser/frame_host/render_widget_host_view_guest.h" 28 #include "content/browser/frame_host/render_widget_host_view_guest.h"
29 #include "content/browser/gpu/compositor_util.h" 29 #include "content/browser/gpu/compositor_util.h"
30 #include "content/browser/renderer_host/input/input_router.h" 30 #include "content/browser/renderer_host/input/input_router.h"
31 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h"
31 #include "content/browser/renderer_host/input/web_input_event_util.h" 32 #include "content/browser/renderer_host/input/web_input_event_util.h"
32 #include "content/browser/renderer_host/overscroll_controller.h" 33 #include "content/browser/renderer_host/overscroll_controller.h"
33 #include "content/browser/renderer_host/overscroll_controller_delegate.h" 34 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
34 #include "content/browser/renderer_host/render_view_host_factory.h" 35 #include "content/browser/renderer_host/render_view_host_factory.h"
35 #include "content/browser/renderer_host/render_widget_host_delegate.h" 36 #include "content/browser/renderer_host/render_widget_host_delegate.h"
36 #include "content/browser/renderer_host/render_widget_host_impl.h" 37 #include "content/browser/renderer_host/render_widget_host_impl.h"
37 #include "content/browser/web_contents/web_contents_view_aura.h" 38 #include "content/browser/web_contents/web_contents_view_aura.h"
38 #include "content/common/gpu/client/gl_helper.h" 39 #include "content/common/gpu/client/gl_helper.h"
39 #include "content/common/gpu/gpu_messages.h" 40 #include "content/common/gpu/gpu_messages.h"
40 #include "content/common/host_shared_bitmap_manager.h" 41 #include "content/common/host_shared_bitmap_manager.h"
42 #include "content/common/input/input_event_utils.h"
41 #include "content/common/input/synthetic_web_input_event_builders.h" 43 #include "content/common/input/synthetic_web_input_event_builders.h"
42 #include "content/common/input_messages.h" 44 #include "content/common/input_messages.h"
43 #include "content/common/view_messages.h" 45 #include "content/common/view_messages.h"
44 #include "content/public/browser/render_widget_host_view.h" 46 #include "content/public/browser/render_widget_host_view.h"
45 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 47 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
46 #include "content/public/browser/web_contents_view_delegate.h" 48 #include "content/public/browser/web_contents_view_delegate.h"
47 #include "content/public/common/context_menu_params.h" 49 #include "content/public/common/context_menu_params.h"
48 #include "content/public/test/mock_render_process_host.h" 50 #include "content/public/test/mock_render_process_host.h"
49 #include "content/public/test/test_browser_context.h" 51 #include "content/public/test/test_browser_context.h"
50 #include "content/test/test_render_view_host.h" 52 #include "content/test/test_render_view_host.h"
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 class RenderWidgetHostViewAuraOverscrollTest 585 class RenderWidgetHostViewAuraOverscrollTest
584 : public RenderWidgetHostViewAuraTest { 586 : public RenderWidgetHostViewAuraTest {
585 public: 587 public:
586 RenderWidgetHostViewAuraOverscrollTest() {} 588 RenderWidgetHostViewAuraOverscrollTest() {}
587 589
588 // We explicitly invoke SetUp to allow gesture debounce customization. 590 // We explicitly invoke SetUp to allow gesture debounce customization.
589 void SetUp() override {} 591 void SetUp() override {}
590 592
591 protected: 593 protected:
592 void SetUpOverscrollEnvironmentWithDebounce(int debounce_interval_in_ms) { 594 void SetUpOverscrollEnvironmentWithDebounce(int debounce_interval_in_ms) {
593 SetUpOverscrollEnvironmentImpl(debounce_interval_in_ms); 595 SetUpOverscrollEnvironmentImpl(debounce_interval_in_ms, false);
594 } 596 }
595 597
596 void SetUpOverscrollEnvironment() { SetUpOverscrollEnvironmentImpl(0); } 598 void SetUpOverscrollEnvironmentWithWheelGestures() {
599 SetUpOverscrollEnvironmentImpl(0, true);
600 }
597 601
598 void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms) { 602 void SetUpOverscrollEnvironment() {
603 SetUpOverscrollEnvironmentImpl(0, false);
604 }
605
606 void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms,
607 bool enable_wheel_gestures) {
608 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
609 switches::kDisableWheelGestures) &&
610 !base::CommandLine::ForCurrentProcess()->HasSwitch(
611 switches::kEnableWheelGestures));
612 base::CommandLine::ForCurrentProcess()->AppendSwitch(
613 enable_wheel_gestures ? switches::kEnableWheelGestures
614 : switches::kDisableWheelGestures);
615
599 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms( 616 ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms(
600 debounce_interval_in_ms); 617 debounce_interval_in_ms);
601 618
602 RenderWidgetHostViewAuraTest::SetUp(); 619 RenderWidgetHostViewAuraTest::SetUp();
603 620
604 view_->SetOverscrollControllerEnabled(true); 621 view_->SetOverscrollControllerEnabled(true);
605 overscroll_delegate_.reset(new TestOverscrollDelegate(view_)); 622 overscroll_delegate_.reset(new TestOverscrollDelegate(view_));
606 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get()); 623 view_->overscroll_controller()->set_delegate(overscroll_delegate_.get());
607 624
608 view_->InitAsChild(NULL); 625 view_->InitAsChild(NULL);
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2585 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2569 EXPECT_EQ(0U, sink_->message_count()); 2586 EXPECT_EQ(0U, sink_->message_count());
2570 2587
2571 // Send a mouse-move event. This should cancel the overscroll navigation. 2588 // Send a mouse-move event. This should cancel the overscroll navigation.
2572 SimulateMouseMove(5, 10, 0); 2589 SimulateMouseMove(5, 10, 0);
2573 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2590 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2574 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2591 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2575 EXPECT_EQ(1U, sink_->message_count()); 2592 EXPECT_EQ(1U, sink_->message_count());
2576 } 2593 }
2577 2594
2595 // Disabled on MacOS because it doesn't support wheel gestures
2596 // just yet.
2597 #if defined(OS_MACOSX)
2598 #define MAYBE_WheelScrollEventOverscrollsWithWheelGestures \
2599 DISABLED_WheelScrollEventOverscrollsWithWheelGestures
2600 #else
2601 #define MAYBE_WheelScrollEventOverscrollsWithWheelGestures \
2602 WheelScrollEventOverscrollsWithWheelGestures
2603 #endif
2604 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2605 MAYBE_WheelScrollEventOverscrollsWithWheelGestures) {
2606 SetUpOverscrollEnvironmentWithWheelGestures();
2607
2608 // Simulate wheel events.
2609 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2610 SimulateWheelEvent(-1, 1, 0, true); // enqueued
2611 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2612 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2613 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2614 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2615 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2616 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2617
2618 // Receive ACK the first wheel event as not processed.
2619 SendInputEventACK(WebInputEvent::MouseWheel,
2620 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2621
2622 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events
2623 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
2624 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2625 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2626
2627 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2628 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2629
2630 // Receive ACK for the second (coalesced) event as not processed. This will
2631 // start a back navigation. However, this will also cause the queued next
2632 // event to be sent to the renderer. But since overscroll navigation has
2633 // started, that event will also be included in the overscroll computation
2634 // instead of being sent to the renderer. So the result will be an overscroll
2635 // back navigation, and no event will be sent to the renderer.
2636 SendInputEventACK(WebInputEvent::MouseWheel,
2637 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2638 // ScrollUpdate, MouseWheel will be queued events
2639 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2640 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2641 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2642 SendInputEventACK(WebInputEvent::MouseWheel,
2643 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2644
2645 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2646 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
2647 EXPECT_EQ(-81.f, overscroll_delta_x());
2648 EXPECT_EQ(-31.f, overscroll_delegate()->delta_x());
2649 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2650 EXPECT_EQ(0U, sink_->message_count());
2651
2652 // Send a mouse-move event. This should cancel the overscroll navigation.
2653 SimulateMouseMove(5, 10, 0);
2654 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2655 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2656 EXPECT_EQ(1U, sink_->message_count());
2657 }
2658
2578 // Tests that if some scroll events are consumed towards the start, then 2659 // Tests that if some scroll events are consumed towards the start, then
2579 // subsequent scrolls do not horizontal overscroll. 2660 // subsequent scrolls do not horizontal overscroll.
2580 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2661 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2581 WheelScrollConsumedDoNotHorizOverscroll) { 2662 WheelScrollConsumedDoNotHorizOverscroll) {
2582 SetUpOverscrollEnvironment(); 2663 SetUpOverscrollEnvironment();
2583 2664
2584 // Simulate wheel events. 2665 // Simulate wheel events.
2585 SimulateWheelEvent(-5, 0, 0, true); // sent directly 2666 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2586 SimulateWheelEvent(-1, -1, 0, true); // enqueued 2667 SimulateWheelEvent(-1, -1, 0, true); // enqueued
2587 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 2668 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 SendInputEventACK(WebInputEvent::MouseWheel, 2713 SendInputEventACK(WebInputEvent::MouseWheel,
2633 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2714 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2634 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2715 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2635 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2716 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2636 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 2717 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2637 SendInputEventACK(WebInputEvent::MouseWheel, 2718 SendInputEventACK(WebInputEvent::MouseWheel,
2638 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2719 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2639 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); 2720 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2640 } 2721 }
2641 2722
2723 // Tests that if some scroll events are consumed towards the start, then
2724 // subsequent scrolls do not horizontal overscroll.
2725 // Disabled on MacOS because it doesn't support wheel gestures
2726 // just yet.
2727 #if defined(OS_MACOSX)
2728 #define MAYBE_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures \
2729 DISABLED_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures
2730 #else
2731 #define MAYBE_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures \
2732 WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures
2733 #endif
2734 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2735 MAYBE_WheelScrollConsumedDoNotHorizOverscrollWithWheelGestures) {
2736 SetUpOverscrollEnvironmentWithWheelGestures();
2737
2738 // Simulate wheel events.
2739 SimulateWheelEvent(-5, 0, 0, true); // sent directly
2740 SimulateWheelEvent(-1, -1, 0, true); // enqueued
2741 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
2742 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
2743 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
2744 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers
2745 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2746 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2747
2748 // Receive ACK the first wheel event as processed.
2749 SendInputEventACK(WebInputEvent::MouseWheel,
2750 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2751 // ScrollBegin, ScrollUpdate, MouseWheel will be queued events
2752 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
2753 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2754 INPUT_EVENT_ACK_STATE_CONSUMED);
2755
2756 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2757 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2758
2759 // Receive ACK for the second (coalesced) event as not processed. This should
2760 // not initiate overscroll, since the beginning of the scroll has been
2761 // consumed. The queued event with different modifiers should be sent to the
2762 // renderer.
2763 SendInputEventACK(WebInputEvent::MouseWheel,
2764 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2765 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2766 // ScrollUpdate, MouseWheel will be queued events
2767 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2768 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2769 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2770
2771 SendInputEventACK(WebInputEvent::MouseWheel,
2772 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2773 // ScrollUpdate will be queued events
2774 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2775 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2776 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2777
2778 EXPECT_EQ(0U, sink_->message_count());
2779 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2780 }
2781
2642 // Tests that wheel-scrolling correctly turns overscroll on and off. 2782 // Tests that wheel-scrolling correctly turns overscroll on and off.
2643 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollOverscrollToggle) { 2783 TEST_F(RenderWidgetHostViewAuraOverscrollTest, WheelScrollOverscrollToggle) {
2644 SetUpOverscrollEnvironment(); 2784 SetUpOverscrollEnvironment();
2645 2785
2646 // Send a wheel event. ACK the event as not processed. This should not 2786 // Send a wheel event. ACK the event as not processed. This should not
2647 // initiate an overscroll gesture since it doesn't cross the threshold yet. 2787 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2648 SimulateWheelEvent(10, 0, 0, true); 2788 SimulateWheelEvent(10, 0, 0, true);
2649 SendInputEventACK(WebInputEvent::MouseWheel, 2789 SendInputEventACK(WebInputEvent::MouseWheel,
2650 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2790 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2651 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2791 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 EXPECT_EQ(1U, sink_->message_count()); 2831 EXPECT_EQ(1U, sink_->message_count());
2692 SendInputEventACK(WebInputEvent::MouseWheel, 2832 SendInputEventACK(WebInputEvent::MouseWheel,
2693 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2833 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2694 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode()); 2834 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2695 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode()); 2835 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
2696 EXPECT_EQ(-75.f, overscroll_delta_x()); 2836 EXPECT_EQ(-75.f, overscroll_delta_x());
2697 EXPECT_EQ(-25.f, overscroll_delegate()->delta_x()); 2837 EXPECT_EQ(-25.f, overscroll_delegate()->delta_x());
2698 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); 2838 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2699 } 2839 }
2700 2840
2841 // Tests that wheel-scrolling correctly turns overscroll on and off.
2842 // Disabled on MacOS because it doesn't support wheel gestures
2843 // just yet.
2844 #if defined(OS_MACOSX)
2845 #define MAYBE_WheelScrollOverscrollToggleWithWheelGestures \
2846 DISABLED_WheelScrollOverscrollToggleWithWheelGestures
2847 #else
2848 #define MAYBE_WheelScrollOverscrollToggleWithWheelGestures \
2849 WheelScrollOverscrollToggleWithWheelGestures
2850 #endif
2851 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2852 MAYBE_WheelScrollOverscrollToggleWithWheelGestures) {
2853 SetUpOverscrollEnvironmentWithWheelGestures();
2854
2855 // Send a wheel event. ACK the event as not processed. This should not
2856 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2857 SimulateWheelEvent(10, 0, 0, true);
2858 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2859 SendInputEventACK(WebInputEvent::MouseWheel,
2860 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2861 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2862 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2863 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2864 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2865 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2866
2867 // Scroll some more so as to not overscroll.
2868 SimulateWheelEvent(10, 0, 0, true);
2869 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2870 SendInputEventACK(WebInputEvent::MouseWheel,
2871 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2872 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2873 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2874 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2875 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2876 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2877
2878 // Scroll some more to initiate an overscroll.
2879 SimulateWheelEvent(40, 0, 0, true);
2880 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2881 SendInputEventACK(WebInputEvent::MouseWheel,
2882 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2883 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2884 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
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
2892 // Scroll in the reverse direction enough to abort the overscroll.
2893 SimulateWheelEvent(-20, 0, 0, true);
2894 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2895 SendInputEventACK(WebInputEvent::MouseWheel,
2896 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2897 EXPECT_EQ(0U, sink_->message_count());
2898 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2899 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2900
2901 // Continue to scroll in the reverse direction.
2902 SimulateWheelEvent(-20, 0, 0, true);
2903 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2904 SendInputEventACK(WebInputEvent::MouseWheel,
2905 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2906 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2907 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2908 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2909 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
2910 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2911 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2912
2913 // Continue to scroll in the reverse direction enough to initiate overscroll
2914 // in that direction.
2915 SimulateWheelEvent(-55, 0, 0, true);
2916 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2917 SendInputEventACK(WebInputEvent::MouseWheel,
2918 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2919 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2920 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2921 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2922 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
2923 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
2924 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
2925 EXPECT_EQ(-75.f, overscroll_delta_x());
2926 EXPECT_EQ(-25.f, overscroll_delegate()->delta_x());
2927 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
2928 }
2929
2701 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 2930 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2702 ScrollEventsOverscrollWithFling) { 2931 ScrollEventsOverscrollWithFling) {
2703 SetUpOverscrollEnvironment(); 2932 SetUpOverscrollEnvironment();
2704 2933
2705 // Send a wheel event. ACK the event as not processed. This should not 2934 // Send a wheel event. ACK the event as not processed. This should not
2706 // initiate an overscroll gesture since it doesn't cross the threshold yet. 2935 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2707 SimulateWheelEvent(10, 0, 0, true); 2936 SimulateWheelEvent(10, 0, 0, true);
2708 SendInputEventACK(WebInputEvent::MouseWheel, 2937 SendInputEventACK(WebInputEvent::MouseWheel,
2709 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2938 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2710 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2939 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
(...skipping 23 matching lines...) Expand all
2734 // Send a fling start, but with a small velocity, so that the overscroll is 2963 // Send a fling start, but with a small velocity, so that the overscroll is
2735 // aborted. The fling should proceed to the renderer, through the gesture 2964 // aborted. The fling should proceed to the renderer, through the gesture
2736 // event filter. 2965 // event filter.
2737 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2966 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2738 blink::WebGestureDeviceTouchscreen); 2967 blink::WebGestureDeviceTouchscreen);
2739 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); 2968 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
2740 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 2969 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2741 EXPECT_EQ(2U, sink_->message_count()); 2970 EXPECT_EQ(2U, sink_->message_count());
2742 } 2971 }
2743 2972
2973 // Disabled on MacOS because it doesn't support wheel gestures
2974 // just yet.
2975 #if defined(OS_MACOSX)
2976 #define MAYBE_ScrollEventsOverscrollWithFlingAndWheelGestures \
2977 DISABLED_ScrollEventsOverscrollWithFlingAndWheelGestures
2978 #else
2979 #define MAYBE_ScrollEventsOverscrollWithFlingAndWheelGestures \
2980 ScrollEventsOverscrollWithFlingAndWheelGestures
2981 #endif
2982 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2983 MAYBE_ScrollEventsOverscrollWithFlingAndWheelGestures) {
2984 SetUpOverscrollEnvironmentWithWheelGestures();
2985
2986 // Send a wheel event. ACK the event as not processed. This should not
2987 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2988 SimulateWheelEvent(10, 0, 0, true);
2989 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
2990 SendInputEventACK(WebInputEvent::MouseWheel,
2991 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2992 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
2993 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2994 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2995 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2996 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2997 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
2998
2999 // Scroll some more so as to not overscroll.
3000 SimulateWheelEvent(20, 0, 0, true);
3001 EXPECT_EQ(1U, sink_->message_count());
3002 SendInputEventACK(WebInputEvent::MouseWheel,
3003 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3004 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3005 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3006 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3007 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3008 sink_->ClearMessages();
3009
3010 // Scroll some more to initiate an overscroll.
3011 SimulateWheelEvent(30, 0, 0, true);
3012 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3013 SendInputEventACK(WebInputEvent::MouseWheel,
3014 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3015 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3016 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3017 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3018 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3019 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3020 EXPECT_EQ(60.f, overscroll_delta_x());
3021 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
3022 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
3023 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
3024
3025 // Send a fling start, but with a small velocity, so that the overscroll is
3026 // aborted. The fling should proceed to the renderer, through the gesture
3027 // event filter.
3028 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3029 blink::WebGestureDeviceTouchscreen);
3030 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
3031 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3032 EXPECT_EQ(3U, sink_->message_count());
3033 }
3034
2744 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that 3035 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
2745 // the zero-velocity fling does not reach the renderer. 3036 // the zero-velocity fling does not reach the renderer.
2746 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 3037 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
2747 ScrollEventsOverscrollWithZeroFling) { 3038 ScrollEventsOverscrollWithZeroFling) {
2748 SetUpOverscrollEnvironment(); 3039 SetUpOverscrollEnvironment();
2749 3040
2750 // Send a wheel event. ACK the event as not processed. This should not 3041 // Send a wheel event. ACK the event as not processed. This should not
2751 // initiate an overscroll gesture since it doesn't cross the threshold yet. 3042 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2752 SimulateWheelEvent(10, 0, 0, true); 3043 SimulateWheelEvent(10, 0, 0, true);
2753 SendInputEventACK(WebInputEvent::MouseWheel, 3044 SendInputEventACK(WebInputEvent::MouseWheel,
(...skipping 24 matching lines...) Expand all
2778 // Send a fling start, but with a small velocity, so that the overscroll is 3069 // Send a fling start, but with a small velocity, so that the overscroll is
2779 // aborted. The fling should proceed to the renderer, through the gesture 3070 // aborted. The fling should proceed to the renderer, through the gesture
2780 // event filter. 3071 // event filter.
2781 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3072 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2782 blink::WebGestureDeviceTouchscreen); 3073 blink::WebGestureDeviceTouchscreen);
2783 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad); 3074 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad);
2784 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3075 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
2785 EXPECT_EQ(2U, sink_->message_count()); 3076 EXPECT_EQ(2U, sink_->message_count());
2786 } 3077 }
2787 3078
3079 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that
3080 // the zero-velocity fling does not reach the renderer.
3081 // Disabled on MacOS because it doesn't support wheel gestures
3082 // just yet.
3083 #if defined(OS_MACOSX)
3084 #define MAYBE_ScrollEventsOverscrollWithZeroFlingAndWheelGestures \
3085 DISABLED_ScrollEventsOverscrollWithZeroFlingAndWheelGestures
3086 #else
3087 #define MAYBE_ScrollEventsOverscrollWithZeroFlingAndWheelGestures \
3088 ScrollEventsOverscrollWithZeroFlingAndWheelGestures
3089 #endif
3090 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3091 MAYBE_ScrollEventsOverscrollWithZeroFlingAndWheelGestures) {
3092 SetUpOverscrollEnvironmentWithWheelGestures();
3093
3094 // Send a wheel event. ACK the event as not processed. This should not
3095 // initiate an overscroll gesture since it doesn't cross the threshold yet.
3096 SimulateWheelEvent(10, 0, 0, true);
3097 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3098 SendInputEventACK(WebInputEvent::MouseWheel,
3099 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3100 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
3101 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3102 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3103 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3104 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3105 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
3106
3107 // Scroll some more so as to not overscroll.
3108 SimulateWheelEvent(20, 0, 0, true);
3109 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3110 SendInputEventACK(WebInputEvent::MouseWheel,
3111 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3112 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3113 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3114 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3115 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3116 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3117
3118 // Scroll some more to initiate an overscroll.
3119 SimulateWheelEvent(30, 0, 0, true);
3120 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3121 SendInputEventACK(WebInputEvent::MouseWheel,
3122 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3123 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3124 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3125 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3126 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3127 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3128 EXPECT_EQ(60.f, overscroll_delta_x());
3129 EXPECT_EQ(10.f, overscroll_delegate()->delta_x());
3130 EXPECT_EQ(0.f, overscroll_delegate()->delta_y());
3131 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
3132
3133 // Send a fling start, but with a small velocity, so that the overscroll is
3134 // aborted. The fling should proceed to the renderer, through the gesture
3135 // event filter.
3136 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3137 blink::WebGestureDeviceTouchscreen);
3138 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad);
3139 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3140 EXPECT_EQ(3U, sink_->message_count());
3141 }
3142
2788 // Tests that a fling in the opposite direction of the overscroll cancels the 3143 // Tests that a fling in the opposite direction of the overscroll cancels the
2789 // overscroll nav instead of completing it. 3144 // overscroll nav instead of completing it.
2790 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ReverseFlingCancelsOverscroll) { 3145 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ReverseFlingCancelsOverscroll) {
2791 SetUpOverscrollEnvironment(); 3146 SetUpOverscrollEnvironment();
2792 3147
2793 { 3148 {
2794 // Start and end a gesture in the same direction without processing the 3149 // Start and end a gesture in the same direction without processing the
2795 // gesture events in the renderer. This should initiate and complete an 3150 // gesture events in the renderer. This should initiate and complete an
2796 // overscroll navigation. 3151 // overscroll navigation.
2797 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3152 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 EXPECT_EQ(1U, sink_->message_count()); 3605 EXPECT_EQ(1U, sink_->message_count());
3251 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3606 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3252 3607
3253 // Since the overscroll mode has been reset, the next wheel event should reach 3608 // Since the overscroll mode has been reset, the next wheel event should reach
3254 // the renderer. 3609 // the renderer.
3255 SimulateWheelEvent(-20, 0, 0, true); 3610 SimulateWheelEvent(-20, 0, 0, true);
3256 EXPECT_EQ(1U, sink_->message_count()); 3611 EXPECT_EQ(1U, sink_->message_count());
3257 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3612 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3258 } 3613 }
3259 3614
3615 // Disabled on MacOS because it doesn't support wheel gestures
3616 // just yet.
3617 #if defined(OS_MACOSX)
3618 #define MAYBE_OverscrollDirectionChangeMouseWheelWithWheelGestures \
3619 DISABLED_OverscrollDirectionChangeMouseWheelWithWheelGestures
3620 #else
3621 #define MAYBE_OverscrollDirectionChangeMouseWheelWithWheelGestures \
3622 OverscrollDirectionChangeMouseWheelWithWheelGestures
3623 #endif
3624 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3625 MAYBE_OverscrollDirectionChangeMouseWheelWithWheelGestures) {
3626 SetUpOverscrollEnvironmentWithWheelGestures();
3627
3628 // Send wheel event and receive ack as not consumed.
3629 SimulateWheelEvent(125, -5, 0, true);
3630 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3631 SendInputEventACK(WebInputEvent::MouseWheel,
3632 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3633
3634 // ScrollBegin, ScrollUpdate messages.
3635 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
3636 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3637 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3638 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3639 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3640
3641 // Send another wheel event, but in the reverse direction. The overscroll
3642 // controller will not consume the event, because it is not triggering
3643 // gesture-nav.
3644
3645 SimulateWheelEvent(-260, 0, 0, true);
3646 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3647 SendInputEventACK(WebInputEvent::MouseWheel,
3648 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3649 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3650 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3651 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3652 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3653
3654 // Since it was unhandled; the overscroll should now be west
3655 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
3656 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
3657
3658 SimulateWheelEvent(-20, 0, 0, true);
3659 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3660 SendInputEventACK(WebInputEvent::MouseWheel,
3661 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3662
3663 // wheel event ack generates gesture scroll update; which gets consumed
3664 // solely by the overflow controller.
3665 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
3666 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
3667 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
3668 }
3669
3260 // Tests that if a mouse-move event completes the overscroll gesture, future 3670 // Tests that if a mouse-move event completes the overscroll gesture, future
3261 // move events do reach the renderer. 3671 // move events do reach the renderer.
3262 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollMouseMoveCompletion) { 3672 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollMouseMoveCompletion) {
3263 SetUpOverscrollEnvironment(); 3673 SetUpOverscrollEnvironment();
3264 3674
3265 SimulateWheelEvent(5, 0, 0, true); // sent directly 3675 SimulateWheelEvent(5, 0, 0, true); // sent directly
3266 SimulateWheelEvent(-1, 0, 0, true); // enqueued 3676 SimulateWheelEvent(-1, 0, 0, true); // enqueued
3267 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event 3677 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3268 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event 3678 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3269 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event 3679 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3330 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3740 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3331 3741
3332 // Move mouse some more. The mouse-move events should reach the renderer. 3742 // Move mouse some more. The mouse-move events should reach the renderer.
3333 SimulateMouseMove(5, 10, 0); 3743 SimulateMouseMove(5, 10, 0);
3334 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3744 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3335 3745
3336 SendInputEventACK(WebInputEvent::MouseMove, 3746 SendInputEventACK(WebInputEvent::MouseMove,
3337 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3747 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3338 } 3748 }
3339 3749
3750 // Tests that if a mouse-move event completes the overscroll gesture, future
3751 // move events do reach the renderer.
3752 // Disabled on MacOS because it doesn't support wheel gestures
3753 // just yet.
3754 #if defined(OS_MACOSX)
3755 #define MAYBE_OverscrollMouseMoveCompletionWheelGestures \
3756 DISABLED_OverscrollMouseMoveCompletionWheelGestures
3757 #else
3758 #define MAYBE_OverscrollMouseMoveCompletionWheelGestures \
3759 OverscrollMouseMoveCompletionWheelGestures
3760 #endif
3761 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3762 MAYBE_OverscrollMouseMoveCompletionWheelGestures) {
3763 SetUpOverscrollEnvironmentWithWheelGestures();
3764
3765 SimulateWheelEvent(5, 0, 0, true); // sent directly
3766 SimulateWheelEvent(-1, 0, 0, true); // enqueued
3767 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event
3768 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event
3769 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event
3770 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3771 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3772
3773 // Receive ACK the first wheel event as not processed.
3774 SendInputEventACK(WebInputEvent::MouseWheel,
3775 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3776 EXPECT_EQ(3U, GetSentMessageCountAndResetSink());
3777 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3778 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3779 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3780 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3781
3782 // Receive ACK for the second (coalesced) event as not processed. This will
3783 // start an overcroll gesture.
3784 SendInputEventACK(WebInputEvent::MouseWheel,
3785 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3786 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3787 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3788 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3789 EXPECT_EQ(OVERSCROLL_WEST, overscroll_mode());
3790 EXPECT_EQ(OVERSCROLL_WEST, overscroll_delegate()->current_mode());
3791 EXPECT_EQ(0U, sink_->message_count());
3792
3793 // Send a mouse-move event. This should cancel the overscroll navigation
3794 // (since the amount overscrolled is not above the threshold), and so the
3795 // mouse-move should reach the renderer.
3796 SimulateMouseMove(5, 10, 0);
3797 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3798 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
3799 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3800 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3801
3802 SendInputEventACK(WebInputEvent::MouseMove,
3803 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3804
3805 // Moving the mouse more should continue to send the events to the renderer.
3806 SimulateMouseMove(5, 10, 0);
3807 SendInputEventACK(WebInputEvent::MouseMove,
3808 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3809 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3810
3811 // Now try with gestures.
3812 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3813 blink::WebGestureDeviceTouchscreen);
3814 SimulateGestureScrollUpdateEvent(300, -5, 0);
3815 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
3816 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3817 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode());
3818 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode());
3819 sink_->ClearMessages();
3820
3821 // Overscroll gesture is in progress. Send a mouse-move now. This should
3822 // complete the gesture (because the amount overscrolled is above the
3823 // threshold).
3824 SimulateMouseMove(5, 10, 0);
3825 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
3826 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3827 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3828 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3829 SendInputEventACK(WebInputEvent::MouseMove,
3830 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3831
3832 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
3833 blink::WebGestureDeviceTouchscreen);
3834 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3835 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3836
3837 // Move mouse some more. The mouse-move events should reach the renderer.
3838 SimulateMouseMove(5, 10, 0);
3839 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3840
3841 SendInputEventACK(WebInputEvent::MouseMove,
3842 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3843 }
3844
3340 // Tests that if a page scrolled, then the overscroll controller's states are 3845 // Tests that if a page scrolled, then the overscroll controller's states are
3341 // reset after the end of the scroll. 3846 // reset after the end of the scroll.
3342 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 3847 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3343 OverscrollStateResetsAfterScroll) { 3848 OverscrollStateResetsAfterScroll) {
3344 SetUpOverscrollEnvironment(); 3849 SetUpOverscrollEnvironment();
3345 3850
3346 SimulateWheelEvent(0, 5, 0, true); // sent directly 3851 SimulateWheelEvent(0, 5, 0, true); // sent directly
3347 SimulateWheelEvent(0, 30, 0, true); // enqueued 3852 SimulateWheelEvent(0, 30, 0, true); // enqueued
3348 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event 3853 SimulateWheelEvent(0, 40, 0, true); // coalesced into previous event
3349 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event 3854 SimulateWheelEvent(0, 10, 0, true); // coalesced into previous event
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 // Simulates the mouse wheel event with no modifier applied. 4034 // Simulates the mouse wheel event with no modifier applied.
3530 event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(), 4035 event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(),
3531 ui::EventTimeForNow(), ui::EF_NONE, 0); 4036 ui::EventTimeForNow(), ui::EF_NONE, 0);
3532 4037
3533 view_->OnMouseEvent(&event); 4038 view_->OnMouseEvent(&event);
3534 4039
3535 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); 4040 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0));
3536 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); 4041 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event);
3537 // Check if the canScroll set to true when no modifier is applied to the 4042 // Check if the canScroll set to true when no modifier is applied to the
3538 // mouse wheel event. 4043 // mouse wheel event.
3539 EXPECT_TRUE(wheel_event->canScroll); 4044 EXPECT_EQ(!UseGestureBasedWheelScrolling(), wheel_event->canScroll);
3540 sink_->ClearMessages(); 4045 sink_->ClearMessages();
3541 4046
3542 SendInputEventACK(blink::WebInputEvent::MouseWheel, 4047 SendInputEventACK(blink::WebInputEvent::MouseWheel,
3543 INPUT_EVENT_ACK_STATE_CONSUMED); 4048 INPUT_EVENT_ACK_STATE_CONSUMED);
3544 4049
3545 // Simulates the scroll event with ctrl modifier applied. 4050 // Simulates the scroll event with ctrl modifier applied.
3546 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(), 4051 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(),
3547 ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 2); 4052 ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 2);
3548 view_->OnScrollEvent(&scroll); 4053 view_->OnScrollEvent(&scroll);
3549 4054
3550 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); 4055 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0));
3551 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); 4056 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event);
3552 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated 4057 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated
3553 // from scroll event. 4058 // from scroll event.
3554 EXPECT_TRUE(wheel_event->canScroll); 4059 EXPECT_EQ(!UseGestureBasedWheelScrolling(), wheel_event->canScroll);
3555 } 4060 }
3556 4061
3557 // Ensures that the mapping from ui::TouchEvent to blink::WebTouchEvent doesn't 4062 // Ensures that the mapping from ui::TouchEvent to blink::WebTouchEvent doesn't
3558 // lose track of the number of acks required. 4063 // lose track of the number of acks required.
3559 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { 4064 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) {
3560 view_->InitAsFullscreen(parent_view_); 4065 view_->InitAsFullscreen(parent_view_);
3561 view_->Show(); 4066 view_->Show();
3562 view_->UseFakeDispatcher(); 4067 view_->UseFakeDispatcher();
3563 4068
3564 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, 4069 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3617 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 4122 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3618 EXPECT_EQ(15.f, overscroll_delta_x()); 4123 EXPECT_EQ(15.f, overscroll_delta_x());
3619 EXPECT_EQ(-5.f, overscroll_delta_y()); 4124 EXPECT_EQ(-5.f, overscroll_delta_y());
3620 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 4125 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3621 blink::WebGestureDeviceTouchscreen); 4126 blink::WebGestureDeviceTouchscreen);
3622 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); 4127 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
3623 EXPECT_EQ(0.f, overscroll_delta_x()); 4128 EXPECT_EQ(0.f, overscroll_delta_x());
3624 EXPECT_EQ(0.f, overscroll_delta_y()); 4129 EXPECT_EQ(0.f, overscroll_delta_y());
3625 } 4130 }
3626 4131
4132 // Tests that the scroll deltas stored within the overscroll controller get
4133 // reset at the end of the overscroll gesture even if the overscroll threshold
4134 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE.
4135 // Disabled on MacOS because it doesn't support wheel gestures
4136 // just yet.
4137 #if defined(OS_MACOSX)
4138 #define MAYBE_ScrollDeltasResetOnEndWithWheelGestures \
4139 DISABLED_ScrollDeltasResetOnEndWithWheelGestures
4140 #else
4141 #define MAYBE_ScrollDeltasResetOnEndWithWheelGestures \
4142 ScrollDeltasResetOnEndWithWheelGestures
4143 #endif
4144 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
4145 MAYBE_ScrollDeltasResetOnEndWithWheelGestures) {
4146 SetUpOverscrollEnvironmentWithWheelGestures();
4147 // Wheel event scroll ending with mouse move.
4148 SimulateWheelEvent(-30, -10, 0, true); // sent directly
4149 SendInputEventACK(WebInputEvent::MouseWheel,
4150 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4151 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
4152 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4153 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
4154 EXPECT_EQ(-30.f, overscroll_delta_x());
4155 EXPECT_EQ(-10.f, overscroll_delta_y());
4156 SimulateMouseMove(5, 10, 0);
4157 EXPECT_EQ(0.f, overscroll_delta_x());
4158 EXPECT_EQ(0.f, overscroll_delta_y());
4159
4160 // Scroll gesture.
4161 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
4162 blink::WebGestureDeviceTouchscreen);
4163 SimulateGestureScrollUpdateEvent(-30, -5, 0);
4164 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
4165 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4166 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
4167 EXPECT_EQ(-30.f, overscroll_delta_x());
4168 EXPECT_EQ(-5.f, overscroll_delta_y());
4169 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
4170 blink::WebGestureDeviceTouchscreen);
4171 EXPECT_EQ(0.f, overscroll_delta_x());
4172 EXPECT_EQ(0.f, overscroll_delta_y());
4173
4174 // Wheel event scroll ending with a fling.
4175 SimulateWheelEvent(5, 0, 0, true);
4176 SendInputEventACK(WebInputEvent::MouseWheel,
4177 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4178 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
4179 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4180 SimulateWheelEvent(10, -5, 0, true);
4181 SendInputEventACK(WebInputEvent::MouseWheel,
4182 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4183 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
4184 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
4185 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
4186 EXPECT_EQ(15.f, overscroll_delta_x());
4187 EXPECT_EQ(-5.f, overscroll_delta_y());
4188 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
4189 blink::WebGestureDeviceTouchscreen);
4190 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad);
4191 EXPECT_EQ(0.f, overscroll_delta_x());
4192 EXPECT_EQ(0.f, overscroll_delta_y());
4193 }
4194
3627 // Tests the RenderWidgetHostImpl sends the correct surface ID namespace to 4195 // Tests the RenderWidgetHostImpl sends the correct surface ID namespace to
3628 // the renderer process. 4196 // the renderer process.
3629 TEST_F(RenderWidgetHostViewAuraTest, SurfaceIdNamespaceInitialized) { 4197 TEST_F(RenderWidgetHostViewAuraTest, SurfaceIdNamespaceInitialized) {
3630 gfx::Size size(5, 5); 4198 gfx::Size size(5, 5);
3631 4199
3632 const IPC::Message* msg = 4200 const IPC::Message* msg =
3633 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceIdNamespace::ID); 4201 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceIdNamespace::ID);
3634 EXPECT_TRUE(msg); 4202 EXPECT_TRUE(msg);
3635 ViewMsg_SetSurfaceIdNamespace::Param params; 4203 ViewMsg_SetSurfaceIdNamespace::Param params;
3636 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params); 4204 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3791 view()->OnGestureEvent(&gesture_event); 4359 view()->OnGestureEvent(&gesture_event);
3792 4360
3793 EXPECT_TRUE(delegate->context_menu_request_received()); 4361 EXPECT_TRUE(delegate->context_menu_request_received());
3794 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); 4362 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH);
3795 #endif 4363 #endif
3796 4364
3797 RenderViewHostFactory::set_is_real_render_view_host(false); 4365 RenderViewHostFactory::set_is_real_render_view_host(false);
3798 } 4366 }
3799 4367
3800 } // namespace content 4368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698