OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/events/blink/input_handler_proxy.h" | 5 #include "ui/events/blink/input_handler_proxy.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
| 9 #include "base/bind.h" |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" |
10 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
| 13 #include "base/test/scoped_feature_list.h" |
| 14 #include "base/test/simple_test_tick_clock.h" |
11 #include "cc/input/main_thread_scrolling_reason.h" | 15 #include "cc/input/main_thread_scrolling_reason.h" |
12 #include "cc/trees/swap_promise_monitor.h" | 16 #include "cc/trees/swap_promise_monitor.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 19 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
16 #include "third_party/WebKit/public/platform/WebFloatSize.h" | 20 #include "third_party/WebKit/public/platform/WebFloatSize.h" |
17 #include "third_party/WebKit/public/platform/WebGestureCurve.h" | 21 #include "third_party/WebKit/public/platform/WebGestureCurve.h" |
18 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 22 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
19 #include "third_party/WebKit/public/platform/WebPoint.h" | 23 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 24 #include "ui/events/blink/compositor_thread_event_queue.h" |
| 25 #include "ui/events/blink/did_overscroll_params.h" |
| 26 #include "ui/events/blink/event_with_callback.h" |
20 #include "ui/events/blink/input_handler_proxy_client.h" | 27 #include "ui/events/blink/input_handler_proxy_client.h" |
| 28 #include "ui/events/blink/web_input_event_traits.h" |
21 #include "ui/events/latency_info.h" | 29 #include "ui/events/latency_info.h" |
22 #include "ui/gfx/geometry/scroll_offset.h" | 30 #include "ui/gfx/geometry/scroll_offset.h" |
23 #include "ui/gfx/geometry/size_f.h" | 31 #include "ui/gfx/geometry/size_f.h" |
24 | 32 |
25 using blink::WebActiveWheelFlingParameters; | 33 using blink::WebActiveWheelFlingParameters; |
26 using blink::WebFloatPoint; | 34 using blink::WebFloatPoint; |
27 using blink::WebFloatSize; | 35 using blink::WebFloatSize; |
28 using blink::WebGestureDevice; | 36 using blink::WebGestureDevice; |
29 using blink::WebGestureEvent; | 37 using blink::WebGestureEvent; |
30 using blink::WebInputEvent; | 38 using blink::WebInputEvent; |
31 using blink::WebKeyboardEvent; | 39 using blink::WebKeyboardEvent; |
32 using blink::WebMouseWheelEvent; | 40 using blink::WebMouseWheelEvent; |
33 using blink::WebPoint; | 41 using blink::WebPoint; |
34 using blink::WebSize; | 42 using blink::WebSize; |
35 using blink::WebTouchEvent; | 43 using blink::WebTouchEvent; |
36 using blink::WebTouchPoint; | 44 using blink::WebTouchPoint; |
37 using testing::Field; | 45 using testing::Field; |
38 | 46 |
39 namespace ui { | 47 namespace ui { |
40 namespace test { | 48 namespace test { |
41 | 49 |
42 namespace { | 50 namespace { |
43 | 51 |
| 52 const char* kCoalescedCountHistogram = |
| 53 "Event.CompositorThreadEventQueue.CoalescedCount"; |
| 54 const char* kContinuousHeadQueueingTimeHistogram = |
| 55 "Event.CompositorThreadEventQueue.Continuous.HeadQueueingTime"; |
| 56 const char* kContinuousTailQueueingTimeHistogram = |
| 57 "Event.CompositorThreadEventQueue.Continuous.TailQueueingTime"; |
| 58 const char* kNonContinuousQueueingTimeHistogram = |
| 59 "Event.CompositorThreadEventQueue.NonContinuous.QueueingTime"; |
| 60 |
44 enum InputHandlerProxyTestType { | 61 enum InputHandlerProxyTestType { |
45 ROOT_SCROLL_NORMAL_HANDLER, | 62 ROOT_SCROLL_NORMAL_HANDLER, |
46 ROOT_SCROLL_SYNCHRONOUS_HANDLER, | 63 ROOT_SCROLL_SYNCHRONOUS_HANDLER, |
47 CHILD_SCROLL_NORMAL_HANDLER, | 64 CHILD_SCROLL_NORMAL_HANDLER, |
48 CHILD_SCROLL_SYNCHRONOUS_HANDLER, | 65 CHILD_SCROLL_SYNCHRONOUS_HANDLER, |
49 }; | 66 }; |
50 static const InputHandlerProxyTestType test_types[] = { | 67 static const InputHandlerProxyTestType test_types[] = { |
51 ROOT_SCROLL_NORMAL_HANDLER, ROOT_SCROLL_SYNCHRONOUS_HANDLER, | 68 ROOT_SCROLL_NORMAL_HANDLER, ROOT_SCROLL_SYNCHRONOUS_HANDLER, |
52 CHILD_SCROLL_NORMAL_HANDLER, CHILD_SCROLL_SYNCHRONOUS_HANDLER}; | 69 CHILD_SCROLL_NORMAL_HANDLER, CHILD_SCROLL_SYNCHRONOUS_HANDLER}; |
53 | 70 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 WebPoint global_point, | 113 WebPoint global_point, |
97 int modifiers) { | 114 int modifiers) { |
98 return CreateFling(base::TimeTicks(), | 115 return CreateFling(base::TimeTicks(), |
99 source_device, | 116 source_device, |
100 velocity, | 117 velocity, |
101 point, | 118 point, |
102 global_point, | 119 global_point, |
103 modifiers); | 120 modifiers); |
104 } | 121 } |
105 | 122 |
| 123 ScopedWebInputEvent CreateGestureScrollOrPinch(WebInputEvent::Type type, |
| 124 float deltaYOrScale = 0, |
| 125 int x = 0, |
| 126 int y = 0) { |
| 127 WebGestureEvent gesture; |
| 128 gesture.sourceDevice = blink::WebGestureDeviceTouchpad; |
| 129 gesture.type = type; |
| 130 if (type == WebInputEvent::GestureScrollUpdate) { |
| 131 gesture.data.scrollUpdate.deltaY = deltaYOrScale; |
| 132 } else if (type == WebInputEvent::GesturePinchUpdate) { |
| 133 gesture.data.pinchUpdate.scale = deltaYOrScale; |
| 134 gesture.x = x; |
| 135 gesture.y = y; |
| 136 } |
| 137 return WebInputEventTraits::Clone(gesture); |
| 138 } |
| 139 |
106 class MockInputHandler : public cc::InputHandler { | 140 class MockInputHandler : public cc::InputHandler { |
107 public: | 141 public: |
108 MockInputHandler() {} | 142 MockInputHandler() {} |
109 ~MockInputHandler() override {} | 143 ~MockInputHandler() override {} |
110 | 144 |
111 MOCK_METHOD0(PinchGestureBegin, void()); | 145 MOCK_METHOD0(PinchGestureBegin, void()); |
112 MOCK_METHOD2(PinchGestureUpdate, | 146 MOCK_METHOD2(PinchGestureUpdate, |
113 void(float magnify_delta, const gfx::Point& anchor)); | 147 void(float magnify_delta, const gfx::Point& anchor)); |
114 MOCK_METHOD0(PinchGestureEnd, void()); | 148 MOCK_METHOD0(PinchGestureEnd, void()); |
115 | 149 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 mock_synchronous_input_handler_; | 464 mock_synchronous_input_handler_; |
431 std::unique_ptr<TestInputHandlerProxy> input_handler_; | 465 std::unique_ptr<TestInputHandlerProxy> input_handler_; |
432 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; | 466 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; |
433 WebGestureEvent gesture_; | 467 WebGestureEvent gesture_; |
434 InputHandlerProxy::EventDisposition expected_disposition_; | 468 InputHandlerProxy::EventDisposition expected_disposition_; |
435 base::HistogramTester histogram_tester_; | 469 base::HistogramTester histogram_tester_; |
436 cc::InputHandlerScrollResult scroll_result_did_scroll_; | 470 cc::InputHandlerScrollResult scroll_result_did_scroll_; |
437 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; | 471 cc::InputHandlerScrollResult scroll_result_did_not_scroll_; |
438 }; | 472 }; |
439 | 473 |
| 474 class InputHandlerProxyEventQueueTest : public testing::Test { |
| 475 public: |
| 476 InputHandlerProxyEventQueueTest() : weak_ptr_factory_(this) { |
| 477 feature_list_.InitAndEnableFeature(features::kVsyncAlignedInputEvents); |
| 478 } |
| 479 |
| 480 ~InputHandlerProxyEventQueueTest() { input_handler_proxy_.reset(); } |
| 481 |
| 482 void SetUp() override { |
| 483 event_disposition_recorder_.clear(); |
| 484 input_handler_proxy_ = base::MakeUnique<TestInputHandlerProxy>( |
| 485 &mock_input_handler_, &mock_client_); |
| 486 if (input_handler_proxy_->compositor_event_queue_) |
| 487 input_handler_proxy_->compositor_event_queue_ = |
| 488 base::MakeUnique<CompositorThreadEventQueue>(); |
| 489 } |
| 490 |
| 491 void HandleGestureEvent(WebInputEvent::Type type, |
| 492 float deltay_or_scale = 0, |
| 493 int x = 0, |
| 494 int y = 0) { |
| 495 LatencyInfo latency; |
| 496 input_handler_proxy_->HandleInputEventWithLatencyInfo( |
| 497 CreateGestureScrollOrPinch(type, deltay_or_scale, x, y), latency, |
| 498 base::Bind( |
| 499 &InputHandlerProxyEventQueueTest::DidHandleInputEventAndOverscroll, |
| 500 weak_ptr_factory_.GetWeakPtr())); |
| 501 } |
| 502 |
| 503 void DidHandleInputEventAndOverscroll( |
| 504 InputHandlerProxy::EventDisposition event_disposition, |
| 505 ui::ScopedWebInputEvent input_event, |
| 506 const ui::LatencyInfo& latency_info, |
| 507 std::unique_ptr<ui::DidOverscrollParams> overscroll_params) { |
| 508 event_disposition_recorder_.push_back(event_disposition); |
| 509 } |
| 510 |
| 511 std::deque<std::unique_ptr<EventWithCallback>>& event_queue() { |
| 512 return input_handler_proxy_->compositor_event_queue_->queue_; |
| 513 } |
| 514 |
| 515 void SetInputHandlerProxyTickClockForTesting( |
| 516 std::unique_ptr<base::TickClock> tick_clock) { |
| 517 input_handler_proxy_->SetTickClockForTesting(std::move(tick_clock)); |
| 518 } |
| 519 |
| 520 protected: |
| 521 base::test::ScopedFeatureList feature_list_; |
| 522 testing::StrictMock<MockInputHandler> mock_input_handler_; |
| 523 std::unique_ptr<TestInputHandlerProxy> input_handler_proxy_; |
| 524 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; |
| 525 std::vector<InputHandlerProxy::EventDisposition> event_disposition_recorder_; |
| 526 |
| 527 base::WeakPtrFactory<InputHandlerProxyEventQueueTest> weak_ptr_factory_; |
| 528 }; |
| 529 |
440 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { | 530 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { |
441 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 531 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
442 EXPECT_CALL(mock_input_handler_, | 532 EXPECT_CALL(mock_input_handler_, |
443 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) | 533 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
444 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); | 534 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
445 | 535 |
446 WebMouseWheelEvent wheel; | 536 WebMouseWheelEvent wheel; |
447 wheel.type = WebInputEvent::MouseWheel; | 537 wheel.type = WebInputEvent::MouseWheel; |
448 wheel.modifiers = WebInputEvent::ControlKey; | 538 wheel.modifiers = WebInputEvent::ControlKey; |
449 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); | 539 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); |
(...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2808 input_handler_->RecordMainThreadScrollingReasonsForTest( | 2898 input_handler_->RecordMainThreadScrollingReasonsForTest( |
2809 blink::WebGestureDeviceTouchpad, | 2899 blink::WebGestureDeviceTouchpad, |
2810 cc::MainThreadScrollingReason::kHandlingScrollFromMainThread); | 2900 cc::MainThreadScrollingReason::kHandlingScrollFromMainThread); |
2811 | 2901 |
2812 EXPECT_THAT( | 2902 EXPECT_THAT( |
2813 histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"), | 2903 histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"), |
2814 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), | 2904 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), |
2815 base::Bucket(5, 1), base::Bucket(14, 1))); | 2905 base::Bucket(5, 1), base::Bucket(14, 1))); |
2816 } | 2906 } |
2817 | 2907 |
| 2908 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) { |
| 2909 base::HistogramTester histogram_tester; |
| 2910 |
| 2911 // Handle scroll on compositor. |
| 2912 cc::InputHandlerScrollResult scroll_result_did_scroll_; |
| 2913 scroll_result_did_scroll_.did_scroll = true; |
| 2914 |
| 2915 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 2916 .WillOnce(testing::Return(kImplThreadScrollState)); |
| 2917 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); |
| 2918 |
| 2919 HandleGestureEvent(WebInputEvent::GestureScrollBegin); |
| 2920 |
| 2921 // GestureScrollBegin will be processed immediately. |
| 2922 EXPECT_EQ(0ul, event_queue().size()); |
| 2923 EXPECT_EQ(1ul, event_disposition_recorder_.size()); |
| 2924 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[0]); |
| 2925 |
| 2926 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20); |
| 2927 |
| 2928 // GestureScrollUpdate will be queued. |
| 2929 EXPECT_EQ(1ul, event_queue().size()); |
| 2930 EXPECT_EQ(-20, static_cast<const blink::WebGestureEvent&>( |
| 2931 event_queue().front()->event()) |
| 2932 .data.scrollUpdate.deltaY); |
| 2933 EXPECT_EQ(1ul, event_queue().front()->coalesced_count()); |
| 2934 EXPECT_EQ(1ul, event_disposition_recorder_.size()); |
| 2935 |
| 2936 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -40); |
| 2937 |
| 2938 // GestureScrollUpdate will be coalesced. |
| 2939 EXPECT_EQ(1ul, event_queue().size()); |
| 2940 EXPECT_EQ(-60, static_cast<const blink::WebGestureEvent&>( |
| 2941 event_queue().front()->event()) |
| 2942 .data.scrollUpdate.deltaY); |
| 2943 EXPECT_EQ(2ul, event_queue().front()->coalesced_count()); |
| 2944 EXPECT_EQ(1ul, event_disposition_recorder_.size()); |
| 2945 |
| 2946 HandleGestureEvent(WebInputEvent::GestureScrollEnd); |
| 2947 |
| 2948 // GestureScrollEnd will be queued. |
| 2949 EXPECT_EQ(2ul, event_queue().size()); |
| 2950 EXPECT_EQ(1ul, event_disposition_recorder_.size()); |
| 2951 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 2952 |
| 2953 EXPECT_CALL( |
| 2954 mock_input_handler_, |
| 2955 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) |
| 2956 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
| 2957 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
| 2958 |
| 2959 // Dispatch all queued events. |
| 2960 input_handler_proxy_->DeliverInputForBeginFrame(); |
| 2961 EXPECT_EQ(0ul, event_queue().size()); |
| 2962 // Should run callbacks for every original events. |
| 2963 EXPECT_EQ(4ul, event_disposition_recorder_.size()); |
| 2964 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[1]); |
| 2965 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[2]); |
| 2966 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[3]); |
| 2967 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 2968 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 1); |
| 2969 } |
| 2970 |
| 2971 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) { |
| 2972 base::HistogramTester histogram_tester; |
| 2973 |
| 2974 // Handle scroll on compositor. |
| 2975 cc::InputHandlerScrollResult scroll_result_did_scroll_; |
| 2976 scroll_result_did_scroll_.did_scroll = true; |
| 2977 |
| 2978 // Start scroll in the first frame. |
| 2979 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 2980 .WillOnce(testing::Return(kImplThreadScrollState)); |
| 2981 EXPECT_CALL( |
| 2982 mock_input_handler_, |
| 2983 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) |
| 2984 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
| 2985 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); |
| 2986 |
| 2987 HandleGestureEvent(WebInputEvent::GestureScrollBegin); |
| 2988 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20); |
| 2989 |
| 2990 EXPECT_EQ(1ul, event_queue().size()); |
| 2991 EXPECT_EQ(1ul, event_disposition_recorder_.size()); |
| 2992 |
| 2993 input_handler_proxy_->DeliverInputForBeginFrame(); |
| 2994 |
| 2995 EXPECT_EQ(0ul, event_queue().size()); |
| 2996 EXPECT_EQ(2ul, event_disposition_recorder_.size()); |
| 2997 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 2998 |
| 2999 // Continue scroll in the second frame, pinch, then start another scroll. |
| 3000 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 3001 .WillOnce(testing::Return(kImplThreadScrollState)); |
| 3002 EXPECT_CALL( |
| 3003 mock_input_handler_, |
| 3004 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) |
| 3005 .WillRepeatedly(testing::Return(scroll_result_did_scroll_)); |
| 3006 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(2); |
| 3007 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); |
| 3008 EXPECT_CALL(mock_input_handler_, |
| 3009 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 3010 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
| 3011 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); |
| 3012 // Two |GesturePinchUpdate| will be coalesced. |
| 3013 EXPECT_CALL(mock_input_handler_, |
| 3014 PinchGestureUpdate(0.7f, gfx::Point(13, 17))); |
| 3015 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); |
| 3016 |
| 3017 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -30); |
| 3018 HandleGestureEvent(WebInputEvent::GestureScrollEnd); |
| 3019 HandleGestureEvent(WebInputEvent::GesturePinchBegin); |
| 3020 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 1.4f, 13, 17); |
| 3021 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 0.5f, 13, 17); |
| 3022 HandleGestureEvent(WebInputEvent::GesturePinchEnd); |
| 3023 HandleGestureEvent(WebInputEvent::GestureScrollBegin); |
| 3024 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -70); |
| 3025 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -5); |
| 3026 HandleGestureEvent(WebInputEvent::GestureScrollEnd); |
| 3027 |
| 3028 EXPECT_EQ(8ul, event_queue().size()); |
| 3029 EXPECT_EQ(2ul, event_disposition_recorder_.size()); |
| 3030 |
| 3031 input_handler_proxy_->DeliverInputForBeginFrame(); |
| 3032 |
| 3033 EXPECT_EQ(0ul, event_queue().size()); |
| 3034 EXPECT_EQ(12ul, event_disposition_recorder_.size()); |
| 3035 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 3036 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 1, 2); |
| 3037 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 2, 2); |
| 3038 } |
| 3039 |
| 3040 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) { |
| 3041 base::HistogramTester histogram_tester; |
| 3042 std::unique_ptr<base::SimpleTestTickClock> tick_clock = |
| 3043 base::MakeUnique<base::SimpleTestTickClock>(); |
| 3044 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); |
| 3045 tick_clock_ptr->SetNowTicks(base::TimeTicks::Now()); |
| 3046 SetInputHandlerProxyTickClockForTesting(std::move(tick_clock)); |
| 3047 |
| 3048 // Handle scroll on compositor. |
| 3049 cc::InputHandlerScrollResult scroll_result_did_scroll_; |
| 3050 scroll_result_did_scroll_.did_scroll = true; |
| 3051 |
| 3052 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 3053 .WillOnce(testing::Return(kImplThreadScrollState)); |
| 3054 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); |
| 3055 EXPECT_CALL( |
| 3056 mock_input_handler_, |
| 3057 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) |
| 3058 .WillOnce(testing::Return(scroll_result_did_scroll_)); |
| 3059 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); |
| 3060 |
| 3061 HandleGestureEvent(WebInputEvent::GestureScrollBegin); |
| 3062 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(10)); |
| 3063 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20); |
| 3064 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(40)); |
| 3065 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -40); |
| 3066 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(20)); |
| 3067 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -10); |
| 3068 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(10)); |
| 3069 HandleGestureEvent(WebInputEvent::GestureScrollEnd); |
| 3070 |
| 3071 // Dispatch all queued events. |
| 3072 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(70)); |
| 3073 input_handler_proxy_->DeliverInputForBeginFrame(); |
| 3074 EXPECT_EQ(0ul, event_queue().size()); |
| 3075 EXPECT_EQ(5ul, event_disposition_recorder_.size()); |
| 3076 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 3077 histogram_tester.ExpectUniqueSample(kContinuousHeadQueueingTimeHistogram, 140, |
| 3078 1); |
| 3079 histogram_tester.ExpectUniqueSample(kContinuousTailQueueingTimeHistogram, 80, |
| 3080 1); |
| 3081 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 0, 1); |
| 3082 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70, |
| 3083 1); |
| 3084 } |
2818 | 3085 |
2819 INSTANTIATE_TEST_CASE_P(AnimateInput, | 3086 INSTANTIATE_TEST_CASE_P(AnimateInput, |
2820 InputHandlerProxyTest, | 3087 InputHandlerProxyTest, |
2821 testing::ValuesIn(test_types)); | 3088 testing::ValuesIn(test_types)); |
| 3089 |
2822 } // namespace test | 3090 } // namespace test |
2823 } // namespace ui | 3091 } // namespace ui |
OLD | NEW |