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

Side by Side Diff: ui/events/blink/input_handler_proxy_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698