Chromium Code Reviews| 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 | |
| 475 : public testing::Test, | |
| 476 public testing::WithParamInterface<bool> { | |
| 477 public: | |
| 478 InputHandlerProxyEventQueueTest() | |
| 479 : enable_compositor_event_queue_(GetParam()), weak_ptr_factory_(this) { | |
| 480 if (enable_compositor_event_queue_) | |
| 481 feature_list_.InitAndEnableFeature(features::kVsyncAlignedInputEvents); | |
| 482 } | |
| 483 | |
| 484 ~InputHandlerProxyEventQueueTest() { input_handler_proxy_.reset(); } | |
| 485 | |
| 486 void SetUp() override { | |
| 487 event_disposition_recorder_.clear(); | |
| 488 input_handler_proxy_ = base::MakeUnique<TestInputHandlerProxy>( | |
| 489 &mock_input_handler_, &mock_client_); | |
| 490 if (input_handler_proxy_->compositor_event_queue_) | |
| 491 input_handler_proxy_->compositor_event_queue_ = | |
| 492 base::MakeUnique<CompositorThreadEventQueue>(); | |
| 493 } | |
| 494 | |
| 495 void HandleGestureEvent(WebInputEvent::Type type, | |
| 496 float deltaYOrScale = 0, | |
|
enne (OOO)
2016/11/14 23:59:46
style nit: more blink style here and elsewhere
chongz
2016/11/17 21:36:13
Done.
| |
| 497 int x = 0, | |
| 498 int y = 0) { | |
| 499 LatencyInfo latency; | |
| 500 input_handler_proxy_->HandleInputEventWithLatencyInfo( | |
| 501 CreateGestureScrollOrPinch(type, deltaYOrScale, x, y), latency, | |
| 502 base::Bind( | |
| 503 &InputHandlerProxyEventQueueTest::DidHandleInputEventAndOverscroll, | |
| 504 weak_ptr_factory_.GetWeakPtr())); | |
| 505 } | |
| 506 | |
| 507 void DidHandleInputEventAndOverscroll( | |
| 508 InputHandlerProxy::EventDisposition event_disposition, | |
| 509 ui::ScopedWebInputEvent input_event, | |
| 510 const ui::LatencyInfo& latency_info, | |
| 511 std::unique_ptr<ui::DidOverscrollParams> overscroll_params) { | |
| 512 event_disposition_recorder_.push_back(event_disposition); | |
| 513 } | |
| 514 | |
| 515 std::deque<std::unique_ptr<EventWithCallback>>& event_queue() { | |
| 516 return input_handler_proxy_->compositor_event_queue_->queue_; | |
| 517 } | |
| 518 | |
| 519 void SetInputHandlerProxyTickClockForTesting( | |
| 520 std::unique_ptr<base::TickClock> tick_clock) { | |
| 521 input_handler_proxy_->SetTickClockForTesting(std::move(tick_clock)); | |
| 522 } | |
| 523 | |
| 524 protected: | |
| 525 base::test::ScopedFeatureList feature_list_; | |
| 526 bool enable_compositor_event_queue_; | |
| 527 testing::StrictMock<MockInputHandler> mock_input_handler_; | |
| 528 std::unique_ptr<TestInputHandlerProxy> input_handler_proxy_; | |
| 529 testing::StrictMock<MockInputHandlerProxyClient> mock_client_; | |
| 530 std::vector<InputHandlerProxy::EventDisposition> event_disposition_recorder_; | |
| 531 | |
| 532 base::WeakPtrFactory<InputHandlerProxyEventQueueTest> weak_ptr_factory_; | |
| 533 }; | |
| 534 | |
| 440 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { | 535 TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { |
| 441 expected_disposition_ = InputHandlerProxy::DROP_EVENT; | 536 expected_disposition_ = InputHandlerProxy::DROP_EVENT; |
| 442 EXPECT_CALL(mock_input_handler_, | 537 EXPECT_CALL(mock_input_handler_, |
| 443 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) | 538 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) |
| 444 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); | 539 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); |
| 445 | 540 |
| 446 WebMouseWheelEvent wheel; | 541 WebMouseWheelEvent wheel; |
| 447 wheel.type = WebInputEvent::MouseWheel; | 542 wheel.type = WebInputEvent::MouseWheel; |
| 448 wheel.modifiers = WebInputEvent::ControlKey; | 543 wheel.modifiers = WebInputEvent::ControlKey; |
| 449 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel)); | 544 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( | 2903 input_handler_->RecordMainThreadScrollingReasonsForTest( |
| 2809 blink::WebGestureDeviceTouchpad, | 2904 blink::WebGestureDeviceTouchpad, |
| 2810 cc::MainThreadScrollingReason::kHandlingScrollFromMainThread); | 2905 cc::MainThreadScrollingReason::kHandlingScrollFromMainThread); |
| 2811 | 2906 |
| 2812 EXPECT_THAT( | 2907 EXPECT_THAT( |
| 2813 histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"), | 2908 histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"), |
| 2814 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), | 2909 testing::ElementsAre(base::Bucket(1, 1), base::Bucket(3, 1), |
| 2815 base::Bucket(5, 1), base::Bucket(14, 1))); | 2910 base::Bucket(5, 1), base::Bucket(14, 1))); |
| 2816 } | 2911 } |
| 2817 | 2912 |
| 2913 TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) { | |
| 2914 // Don't run the test if we aren't supporting VSync aligned input. | |
| 2915 if (!enable_compositor_event_queue_) | |
| 2916 return; | |
| 2917 | |
| 2918 base::HistogramTester histogram_tester; | |
| 2919 | |
| 2920 // Handle scroll on compositor. | |
| 2921 cc::InputHandlerScrollResult scroll_result_did_scroll_; | |
| 2922 scroll_result_did_scroll_.did_scroll = true; | |
| 2923 | |
| 2924 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | |
| 2925 .WillOnce(testing::Return(kImplThreadScrollState)); | |
| 2926 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); | |
| 2927 | |
| 2928 HandleGestureEvent(WebInputEvent::GestureScrollBegin); | |
| 2929 | |
| 2930 // GestureScrollBegin will be processed immediately. | |
| 2931 EXPECT_EQ(0ul, event_queue().size()); | |
| 2932 EXPECT_EQ(1ul, event_disposition_recorder_.size()); | |
| 2933 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[0]); | |
| 2934 | |
| 2935 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20); | |
| 2936 | |
| 2937 // GestureScrollUpdate will be queued. | |
| 2938 EXPECT_EQ(1ul, event_queue().size()); | |
| 2939 EXPECT_EQ(-20, static_cast<const blink::WebGestureEvent&>( | |
| 2940 event_queue().front()->event()) | |
| 2941 .data.scrollUpdate.deltaY); | |
| 2942 EXPECT_EQ(1ul, event_queue().front()->coalescedCount()); | |
| 2943 EXPECT_EQ(1ul, event_disposition_recorder_.size()); | |
| 2944 | |
| 2945 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -40); | |
| 2946 | |
| 2947 // GestureScrollUpdate will be coalesced. | |
| 2948 EXPECT_EQ(1ul, event_queue().size()); | |
| 2949 EXPECT_EQ(-60, static_cast<const blink::WebGestureEvent&>( | |
| 2950 event_queue().front()->event()) | |
| 2951 .data.scrollUpdate.deltaY); | |
| 2952 EXPECT_EQ(2ul, event_queue().front()->coalescedCount()); | |
| 2953 EXPECT_EQ(1ul, event_disposition_recorder_.size()); | |
| 2954 | |
| 2955 HandleGestureEvent(WebInputEvent::GestureScrollEnd); | |
| 2956 | |
| 2957 // GestureScrollEnd will be queued. | |
| 2958 EXPECT_EQ(2ul, event_queue().size()); | |
| 2959 EXPECT_EQ(1ul, event_disposition_recorder_.size()); | |
| 2960 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | |
| 2961 | |
| 2962 EXPECT_CALL( | |
| 2963 mock_input_handler_, | |
| 2964 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) | |
| 2965 .WillOnce(testing::Return(scroll_result_did_scroll_)); | |
| 2966 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | |
| 2967 | |
| 2968 // Dispatch all queued events. | |
| 2969 input_handler_proxy_->DeliverInputForBeginFrame(); | |
| 2970 EXPECT_EQ(0ul, event_queue().size()); | |
| 2971 // Should run callbacks for every original events. | |
| 2972 EXPECT_EQ(4ul, event_disposition_recorder_.size()); | |
| 2973 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[1]); | |
| 2974 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[2]); | |
| 2975 EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[3]); | |
| 2976 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | |
| 2977 histogram_tester.ExpectUniqueSample(kCoalescedCountHistogram, 2, 1); | |
| 2978 } | |
| 2979 | |
| 2980 TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScrollPinchScroll) { | |
| 2981 // Don't run the test if we aren't supporting VSync aligned input. | |
| 2982 if (!enable_compositor_event_queue_) | |
| 2983 return; | |
| 2984 | |
| 2985 base::HistogramTester histogram_tester; | |
| 2986 | |
| 2987 // Handle scroll on compositor. | |
| 2988 cc::InputHandlerScrollResult scroll_result_did_scroll_; | |
| 2989 scroll_result_did_scroll_.did_scroll = true; | |
| 2990 | |
| 2991 // Start scroll in the first frame. | |
| 2992 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | |
| 2993 .WillOnce(testing::Return(kImplThreadScrollState)); | |
| 2994 EXPECT_CALL( | |
| 2995 mock_input_handler_, | |
| 2996 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) | |
| 2997 .WillOnce(testing::Return(scroll_result_did_scroll_)); | |
| 2998 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); | |
| 2999 | |
| 3000 HandleGestureEvent(WebInputEvent::GestureScrollBegin); | |
| 3001 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20); | |
| 3002 | |
| 3003 EXPECT_EQ(1ul, event_queue().size()); | |
| 3004 EXPECT_EQ(1ul, event_disposition_recorder_.size()); | |
| 3005 | |
| 3006 input_handler_proxy_->DeliverInputForBeginFrame(); | |
| 3007 | |
| 3008 EXPECT_EQ(0ul, event_queue().size()); | |
| 3009 EXPECT_EQ(2ul, event_disposition_recorder_.size()); | |
| 3010 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | |
| 3011 | |
| 3012 // Continue scroll in the second frame, pinch, then start another scroll. | |
| 3013 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | |
| 3014 .WillOnce(testing::Return(kImplThreadScrollState)); | |
| 3015 EXPECT_CALL( | |
| 3016 mock_input_handler_, | |
| 3017 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) | |
| 3018 .WillRepeatedly(testing::Return(scroll_result_did_scroll_)); | |
| 3019 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)).Times(2); | |
| 3020 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); | |
| 3021 EXPECT_CALL(mock_input_handler_, | |
| 3022 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel)) | |
| 3023 .WillOnce(testing::Return(cc::EventListenerProperties::kNone)); | |
| 3024 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); | |
| 3025 // Two |GesturePinchUpdate| will be coalesced. | |
| 3026 EXPECT_CALL(mock_input_handler_, | |
| 3027 PinchGestureUpdate(0.7f, gfx::Point(13, 17))); | |
| 3028 EXPECT_CALL(mock_input_handler_, PinchGestureEnd()); | |
| 3029 | |
| 3030 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -30); | |
| 3031 HandleGestureEvent(WebInputEvent::GestureScrollEnd); | |
| 3032 HandleGestureEvent(WebInputEvent::GesturePinchBegin); | |
| 3033 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 1.4f, 13, 17); | |
| 3034 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 0.5f, 13, 17); | |
| 3035 HandleGestureEvent(WebInputEvent::GesturePinchEnd); | |
| 3036 HandleGestureEvent(WebInputEvent::GestureScrollBegin); | |
| 3037 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -70); | |
| 3038 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -5); | |
| 3039 HandleGestureEvent(WebInputEvent::GestureScrollEnd); | |
| 3040 | |
| 3041 EXPECT_EQ(8ul, event_queue().size()); | |
| 3042 EXPECT_EQ(2ul, event_disposition_recorder_.size()); | |
| 3043 | |
| 3044 input_handler_proxy_->DeliverInputForBeginFrame(); | |
| 3045 | |
| 3046 EXPECT_EQ(0ul, event_queue().size()); | |
| 3047 EXPECT_EQ(12ul, event_disposition_recorder_.size()); | |
| 3048 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | |
| 3049 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 1, 2); | |
| 3050 histogram_tester.ExpectBucketCount(kCoalescedCountHistogram, 2, 2); | |
| 3051 } | |
| 3052 | |
| 3053 TEST_P(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) { | |
| 3054 // Don't run the test if we aren't supporting VSync aligned input. | |
| 3055 if (!enable_compositor_event_queue_) | |
| 3056 return; | |
| 3057 | |
| 3058 base::HistogramTester histogram_tester; | |
| 3059 std::unique_ptr<base::SimpleTestTickClock> tick_clock = | |
| 3060 base::MakeUnique<base::SimpleTestTickClock>(); | |
| 3061 base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); | |
| 3062 tick_clock_ptr->SetNowTicks(base::TimeTicks::Now()); | |
| 3063 SetInputHandlerProxyTickClockForTesting(std::move(tick_clock)); | |
| 3064 | |
| 3065 // Handle scroll on compositor. | |
| 3066 cc::InputHandlerScrollResult scroll_result_did_scroll_; | |
| 3067 scroll_result_did_scroll_.did_scroll = true; | |
| 3068 | |
| 3069 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) | |
| 3070 .WillOnce(testing::Return(kImplThreadScrollState)); | |
| 3071 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1); | |
| 3072 EXPECT_CALL( | |
| 3073 mock_input_handler_, | |
| 3074 ScrollBy(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)))) | |
| 3075 .WillOnce(testing::Return(scroll_result_did_scroll_)); | |
| 3076 EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_)); | |
| 3077 | |
| 3078 HandleGestureEvent(WebInputEvent::GestureScrollBegin); | |
| 3079 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(10)); | |
| 3080 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20); | |
| 3081 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(40)); | |
| 3082 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -40); | |
| 3083 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(20)); | |
| 3084 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -10); | |
| 3085 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(10)); | |
| 3086 HandleGestureEvent(WebInputEvent::GestureScrollEnd); | |
| 3087 | |
| 3088 // Dispatch all queued events. | |
| 3089 tick_clock_ptr->Advance(base::TimeDelta::FromMicroseconds(70)); | |
| 3090 input_handler_proxy_->DeliverInputForBeginFrame(); | |
| 3091 EXPECT_EQ(0ul, event_queue().size()); | |
| 3092 EXPECT_EQ(5ul, event_disposition_recorder_.size()); | |
| 3093 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | |
| 3094 histogram_tester.ExpectUniqueSample(kContinuousHeadQueueingTimeHistogram, 140, | |
| 3095 1); | |
| 3096 histogram_tester.ExpectUniqueSample(kContinuousTailQueueingTimeHistogram, 80, | |
| 3097 1); | |
| 3098 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 0, 1); | |
| 3099 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70, | |
| 3100 1); | |
| 3101 } | |
| 2818 | 3102 |
| 2819 INSTANTIATE_TEST_CASE_P(AnimateInput, | 3103 INSTANTIATE_TEST_CASE_P(AnimateInput, |
| 2820 InputHandlerProxyTest, | 3104 InputHandlerProxyTest, |
| 2821 testing::ValuesIn(test_types)); | 3105 testing::ValuesIn(test_types)); |
| 3106 | |
| 3107 INSTANTIATE_TEST_CASE_P(InputHandlerProxyEventQueueTests, | |
|
enne (OOO)
2016/11/14 23:59:46
Why is this parameterized? It looks like all cases
chongz
2016/11/17 21:36:13
Removed.
| |
| 3108 InputHandlerProxyEventQueueTest, | |
| 3109 testing::Bool()); | |
| 2822 } // namespace test | 3110 } // namespace test |
| 2823 } // namespace ui | 3111 } // namespace ui |
| OLD | NEW |