| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "content/browser/renderer_host/input/input_ack_handler.h" | 12 #include "content/browser/renderer_host/input/input_ack_handler.h" |
| 13 #include "content/browser/renderer_host/input/input_router_client.h" | 13 #include "content/browser/renderer_host/input/input_router_client.h" |
| 14 #include "content/browser/renderer_host/input/input_router_impl.h" | 14 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 15 #include "content/common/input_messages.h" | 15 #include "content/common/input_messages.h" |
| 16 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 17 #include "content/public/common/content_features.h" |
| 17 #include "ipc/ipc_sender.h" | 18 #include "ipc/ipc_sender.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "testing/perf/perf_test.h" | 20 #include "testing/perf/perf_test.h" |
| 20 #include "ui/events/base_event_utils.h" | 21 #include "ui/events/base_event_utils.h" |
| 21 #include "ui/events/blink/web_input_event_traits.h" | 22 #include "ui/events/blink/web_input_event_traits.h" |
| 22 #include "ui/gfx/geometry/vector2d_f.h" | 23 #include "ui/gfx/geometry/vector2d_f.h" |
| 23 | 24 |
| 24 using base::TimeDelta; | 25 using base::TimeDelta; |
| 25 using blink::WebGestureEvent; | 26 using blink::WebGestureEvent; |
| 26 using blink::WebInputEvent; | 27 using blink::WebInputEvent; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 true); | 200 true); |
| 200 } | 201 } |
| 201 | 202 |
| 202 private: | 203 private: |
| 203 const char* test_name_; | 204 const char* test_name_; |
| 204 int64_t event_count_; | 205 int64_t event_count_; |
| 205 base::TimeTicks start_; | 206 base::TimeTicks start_; |
| 206 DISALLOW_COPY_AND_ASSIGN(InputEventTimer); | 207 DISALLOW_COPY_AND_ASSIGN(InputEventTimer); |
| 207 }; | 208 }; |
| 208 | 209 |
| 210 bool ShouldBlockEventStream(const blink::WebInputEvent& event) { |
| 211 return ui::WebInputEventTraits::ShouldBlockEventStream( |
| 212 event, |
| 213 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)); |
| 214 } |
| 215 |
| 209 } // namespace | 216 } // namespace |
| 210 | 217 |
| 211 class InputRouterImplPerfTest : public testing::Test { | 218 class InputRouterImplPerfTest : public testing::Test { |
| 212 public: | 219 public: |
| 213 InputRouterImplPerfTest() : last_input_id_(0) {} | 220 InputRouterImplPerfTest() : last_input_id_(0) {} |
| 214 ~InputRouterImplPerfTest() override {} | 221 ~InputRouterImplPerfTest() override {} |
| 215 | 222 |
| 216 protected: | 223 protected: |
| 217 // testing::Test | 224 // testing::Test |
| 218 void SetUp() override { | 225 void SetUp() override { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 240 input_router_->SendGestureEvent( | 247 input_router_->SendGestureEvent( |
| 241 GestureEventWithLatencyInfo(gesture, latency)); | 248 GestureEventWithLatencyInfo(gesture, latency)); |
| 242 } | 249 } |
| 243 | 250 |
| 244 void SendEvent(const WebTouchEvent& touch, const ui::LatencyInfo& latency) { | 251 void SendEvent(const WebTouchEvent& touch, const ui::LatencyInfo& latency) { |
| 245 input_router_->SendTouchEvent(TouchEventWithLatencyInfo(touch, latency)); | 252 input_router_->SendTouchEvent(TouchEventWithLatencyInfo(touch, latency)); |
| 246 } | 253 } |
| 247 | 254 |
| 248 void SendEventAckIfNecessary(const blink::WebInputEvent& event, | 255 void SendEventAckIfNecessary(const blink::WebInputEvent& event, |
| 249 InputEventAckState ack_result) { | 256 InputEventAckState ack_result) { |
| 250 if (!ui::WebInputEventTraits::ShouldBlockEventStream(event)) | 257 if (!ShouldBlockEventStream(event)) |
| 251 return; | 258 return; |
| 252 InputEventAck ack(InputEventAckSource::COMPOSITOR_THREAD, event.type(), | 259 InputEventAck ack(InputEventAckSource::COMPOSITOR_THREAD, event.type(), |
| 253 ack_result); | 260 ack_result); |
| 254 InputHostMsg_HandleInputEvent_ACK response(0, ack); | 261 InputHostMsg_HandleInputEvent_ACK response(0, ack); |
| 255 input_router_->OnMessageReceived(response); | 262 input_router_->OnMessageReceived(response); |
| 256 } | 263 } |
| 257 | 264 |
| 258 void OnHasTouchEventHandlers(bool has_handlers) { | 265 void OnHasTouchEventHandlers(bool has_handlers) { |
| 259 input_router_->OnMessageReceived( | 266 input_router_->OnMessageReceived( |
| 260 ViewHostMsg_HasTouchEventHandlers(0, has_handlers)); | 267 ViewHostMsg_HasTouchEventHandlers(0, has_handlers)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 395 |
| 389 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) { | 396 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) { |
| 390 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ", | 397 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ", |
| 391 kDefaultSteps, | 398 kDefaultSteps, |
| 392 kDefaultOrigin, | 399 kDefaultOrigin, |
| 393 kDefaultDistance, | 400 kDefaultDistance, |
| 394 kDefaultIterations); | 401 kDefaultIterations); |
| 395 } | 402 } |
| 396 | 403 |
| 397 } // namespace content | 404 } // namespace content |
| OLD | NEW |