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

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

Issue 2552853002: [Compositor event queue] Coalesce gesture scroll&pinch of the same sequence (Closed)
Patch Set: sadrul's comments, fix dependency Created 4 years 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
« no previous file with comments | « ui/events/blink/event_with_callback.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/test/histogram_tester.h" 12 #include "base/test/histogram_tester.h"
13 #include "base/test/scoped_feature_list.h" 13 #include "base/test/scoped_feature_list.h"
14 #include "base/test/simple_test_tick_clock.h" 14 #include "base/test/simple_test_tick_clock.h"
15 #include "cc/input/main_thread_scrolling_reason.h" 15 #include "cc/input/main_thread_scrolling_reason.h"
16 #include "cc/trees/swap_promise_monitor.h" 16 #include "cc/trees/swap_promise_monitor.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 19 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
20 #include "third_party/WebKit/public/platform/WebFloatSize.h" 20 #include "third_party/WebKit/public/platform/WebFloatSize.h"
21 #include "third_party/WebKit/public/platform/WebGestureCurve.h" 21 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
22 #include "third_party/WebKit/public/platform/WebInputEvent.h" 22 #include "third_party/WebKit/public/platform/WebInputEvent.h"
23 #include "third_party/WebKit/public/platform/WebPoint.h" 23 #include "third_party/WebKit/public/platform/WebPoint.h"
24 #include "ui/events/blink/blink_event_util.h"
24 #include "ui/events/blink/compositor_thread_event_queue.h" 25 #include "ui/events/blink/compositor_thread_event_queue.h"
25 #include "ui/events/blink/did_overscroll_params.h" 26 #include "ui/events/blink/did_overscroll_params.h"
26 #include "ui/events/blink/event_with_callback.h" 27 #include "ui/events/blink/event_with_callback.h"
27 #include "ui/events/blink/input_handler_proxy_client.h" 28 #include "ui/events/blink/input_handler_proxy_client.h"
28 #include "ui/events/blink/web_input_event_traits.h" 29 #include "ui/events/blink/web_input_event_traits.h"
29 #include "ui/events/latency_info.h" 30 #include "ui/events/latency_info.h"
30 #include "ui/gfx/geometry/scroll_offset.h" 31 #include "ui/gfx/geometry/scroll_offset.h"
31 #include "ui/gfx/geometry/size_f.h" 32 #include "ui/gfx/geometry/size_f.h"
32 33
33 using blink::WebActiveWheelFlingParameters; 34 using blink::WebActiveWheelFlingParameters;
(...skipping 3046 matching lines...) Expand 10 before | Expand all | Expand 10 after
3080 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 3081 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3081 histogram_tester.ExpectUniqueSample(kContinuousHeadQueueingTimeHistogram, 140, 3082 histogram_tester.ExpectUniqueSample(kContinuousHeadQueueingTimeHistogram, 140,
3082 1); 3083 1);
3083 histogram_tester.ExpectUniqueSample(kContinuousTailQueueingTimeHistogram, 80, 3084 histogram_tester.ExpectUniqueSample(kContinuousTailQueueingTimeHistogram, 80,
3084 1); 3085 1);
3085 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 0, 1); 3086 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 0, 1);
3086 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70, 3087 histogram_tester.ExpectBucketCount(kNonContinuousQueueingTimeHistogram, 70,
3087 1); 3088 1);
3088 } 3089 }
3089 3090
3091 TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) {
3092 // Start scroll in the first frame.
3093 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
3094 .WillOnce(testing::Return(kImplThreadScrollState));
3095 EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
3096
3097 // GSUs and GPUs in one sequence should be coalesced into 1 GSU and 1 GPU.
3098 HandleGestureEvent(WebInputEvent::GestureScrollBegin);
3099 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -20);
3100 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -7);
3101 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 2.0f, 13, 10);
3102 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -10);
3103 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -6);
3104 HandleGestureEvent(WebInputEvent::GestureScrollEnd);
3105 HandleGestureEvent(WebInputEvent::GesturePinchBegin);
3106 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 0.2f, 2, 20);
3107 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 10.0f, 1, 10);
3108 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -30);
3109 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 0.25f, 3, 30);
3110 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -10);
3111 HandleGestureEvent(WebInputEvent::GesturePinchEnd);
3112
3113 // Only the first GSB was dispatched.
3114 EXPECT_EQ(7ul, event_queue().size());
3115 EXPECT_EQ(1ul, event_disposition_recorder_.size());
3116
3117 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, event_queue()[0]->event().type);
3118 EXPECT_EQ(
3119 -35,
3120 ToWebGestureEvent(event_queue()[0]->event()).data.scrollUpdate.deltaY);
3121 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, event_queue()[1]->event().type);
3122 EXPECT_EQ(
3123 2.0f,
3124 ToWebGestureEvent(event_queue()[1]->event()).data.pinchUpdate.scale);
3125 EXPECT_EQ(WebInputEvent::GestureScrollEnd, event_queue()[2]->event().type);
3126 EXPECT_EQ(WebInputEvent::GesturePinchBegin, event_queue()[3]->event().type);
3127 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, event_queue()[4]->event().type);
3128 EXPECT_EQ(
3129 -85,
3130 ToWebGestureEvent(event_queue()[4]->event()).data.scrollUpdate.deltaY);
3131 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, event_queue()[5]->event().type);
3132 EXPECT_EQ(
3133 0.5f,
3134 ToWebGestureEvent(event_queue()[5]->event()).data.pinchUpdate.scale);
3135 EXPECT_EQ(WebInputEvent::GesturePinchEnd, event_queue()[6]->event().type);
3136 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
3137 }
3138
3090 INSTANTIATE_TEST_CASE_P(AnimateInput, 3139 INSTANTIATE_TEST_CASE_P(AnimateInput,
3091 InputHandlerProxyTest, 3140 InputHandlerProxyTest,
3092 testing::ValuesIn(test_types)); 3141 testing::ValuesIn(test_types));
3093 3142
3094 } // namespace test 3143 } // namespace test
3095 } // namespace ui 3144 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/event_with_callback.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698