| 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 "ipc/ipc_sender.h" | 17 #include "ipc/ipc_sender.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "testing/perf/perf_test.h" | 19 #include "testing/perf/perf_test.h" |
| 20 #include "ui/events/base_event_utils.h" |
| 20 #include "ui/events/blink/web_input_event_traits.h" | 21 #include "ui/events/blink/web_input_event_traits.h" |
| 21 #include "ui/gfx/geometry/vector2d_f.h" | 22 #include "ui/gfx/geometry/vector2d_f.h" |
| 22 | 23 |
| 23 using base::TimeDelta; | 24 using base::TimeDelta; |
| 24 using blink::WebGestureEvent; | 25 using blink::WebGestureEvent; |
| 25 using blink::WebInputEvent; | 26 using blink::WebInputEvent; |
| 26 using blink::WebTouchEvent; | 27 using blink::WebTouchEvent; |
| 27 using blink::WebTouchPoint; | 28 using blink::WebTouchPoint; |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 size_t sent_count_; | 119 size_t sent_count_; |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 typedef std::vector<WebGestureEvent> Gestures; | 122 typedef std::vector<WebGestureEvent> Gestures; |
| 122 Gestures BuildScrollSequence(size_t steps, | 123 Gestures BuildScrollSequence(size_t steps, |
| 123 const gfx::Vector2dF& origin, | 124 const gfx::Vector2dF& origin, |
| 124 const gfx::Vector2dF& distance) { | 125 const gfx::Vector2dF& distance) { |
| 125 Gestures gestures; | 126 Gestures gestures; |
| 126 const gfx::Vector2dF delta = ScaleVector2d(distance, 1.f / steps); | 127 const gfx::Vector2dF delta = ScaleVector2d(distance, 1.f / steps); |
| 127 | 128 |
| 128 WebGestureEvent gesture; | 129 WebGestureEvent gesture(WebInputEvent::GestureScrollBegin, |
| 129 gesture.type = WebInputEvent::GestureScrollBegin; | 130 WebInputEvent::NoModifiers, |
| 131 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 130 gesture.x = origin.x(); | 132 gesture.x = origin.x(); |
| 131 gesture.y = origin.y(); | 133 gesture.y = origin.y(); |
| 132 gestures.push_back(gesture); | 134 gestures.push_back(gesture); |
| 133 | 135 |
| 134 gesture.type = WebInputEvent::GestureScrollUpdate; | 136 gesture.setType(WebInputEvent::GestureScrollUpdate); |
| 135 gesture.data.scrollUpdate.deltaX = delta.x(); | 137 gesture.data.scrollUpdate.deltaX = delta.x(); |
| 136 gesture.data.scrollUpdate.deltaY = delta.y(); | 138 gesture.data.scrollUpdate.deltaY = delta.y(); |
| 137 for (size_t i = 0; i < steps; ++i) { | 139 for (size_t i = 0; i < steps; ++i) { |
| 138 gesture.x += delta.x(); | 140 gesture.x += delta.x(); |
| 139 gesture.y += delta.y(); | 141 gesture.y += delta.y(); |
| 140 gestures.push_back(gesture); | 142 gestures.push_back(gesture); |
| 141 } | 143 } |
| 142 | 144 |
| 143 gesture.type = WebInputEvent::GestureScrollEnd; | 145 gesture.setType(WebInputEvent::GestureScrollEnd); |
| 144 gestures.push_back(gesture); | 146 gestures.push_back(gesture); |
| 145 return gestures; | 147 return gestures; |
| 146 } | 148 } |
| 147 | 149 |
| 148 typedef std::vector<WebTouchEvent> Touches; | 150 typedef std::vector<WebTouchEvent> Touches; |
| 149 Touches BuildTouchSequence(size_t steps, | 151 Touches BuildTouchSequence(size_t steps, |
| 150 const gfx::Vector2dF& origin, | 152 const gfx::Vector2dF& origin, |
| 151 const gfx::Vector2dF& distance) { | 153 const gfx::Vector2dF& distance) { |
| 152 Touches touches; | 154 Touches touches; |
| 153 const gfx::Vector2dF delta = ScaleVector2d(distance, 1.f / steps); | 155 const gfx::Vector2dF delta = ScaleVector2d(distance, 1.f / steps); |
| 154 | 156 |
| 155 WebTouchEvent touch; | 157 WebTouchEvent touch(WebInputEvent::TouchStart, WebInputEvent::NoModifiers, |
| 158 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 156 touch.touchesLength = 1; | 159 touch.touchesLength = 1; |
| 157 touch.type = WebInputEvent::TouchStart; | |
| 158 touch.touches[0].id = 0; | 160 touch.touches[0].id = 0; |
| 159 touch.touches[0].state = WebTouchPoint::StatePressed; | 161 touch.touches[0].state = WebTouchPoint::StatePressed; |
| 160 touch.touches[0].position.x = origin.x(); | 162 touch.touches[0].position.x = origin.x(); |
| 161 touch.touches[0].position.y = origin.y(); | 163 touch.touches[0].position.y = origin.y(); |
| 162 touch.touches[0].screenPosition.x = origin.x(); | 164 touch.touches[0].screenPosition.x = origin.x(); |
| 163 touch.touches[0].screenPosition.y = origin.y(); | 165 touch.touches[0].screenPosition.y = origin.y(); |
| 164 touches.push_back(touch); | 166 touches.push_back(touch); |
| 165 | 167 |
| 166 touch.type = WebInputEvent::TouchMove; | 168 touch.setType(WebInputEvent::TouchMove); |
| 167 touch.touches[0].state = WebTouchPoint::StateMoved; | 169 touch.touches[0].state = WebTouchPoint::StateMoved; |
| 168 for (size_t i = 0; i < steps; ++i) { | 170 for (size_t i = 0; i < steps; ++i) { |
| 169 touch.touches[0].position.x += delta.x(); | 171 touch.touches[0].position.x += delta.x(); |
| 170 touch.touches[0].position.y += delta.y(); | 172 touch.touches[0].position.y += delta.y(); |
| 171 touch.touches[0].screenPosition.x += delta.x(); | 173 touch.touches[0].screenPosition.x += delta.x(); |
| 172 touch.touches[0].screenPosition.y += delta.y(); | 174 touch.touches[0].screenPosition.y += delta.y(); |
| 173 touches.push_back(touch); | 175 touches.push_back(touch); |
| 174 } | 176 } |
| 175 | 177 |
| 176 touch.type = WebInputEvent::TouchEnd; | 178 touch.setType(WebInputEvent::TouchEnd); |
| 177 touch.touches[0].state = WebTouchPoint::StateReleased; | 179 touch.touches[0].state = WebTouchPoint::StateReleased; |
| 178 touches.push_back(touch); | 180 touches.push_back(touch); |
| 179 return touches; | 181 return touches; |
| 180 } | 182 } |
| 181 | 183 |
| 182 class InputEventTimer { | 184 class InputEventTimer { |
| 183 public: | 185 public: |
| 184 InputEventTimer(const char* test_name, int64_t event_count) | 186 InputEventTimer(const char* test_name, int64_t event_count) |
| 185 : test_name_(test_name), | 187 : test_name_(test_name), |
| 186 event_count_(event_count), | 188 event_count_(event_count), |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 388 |
| 387 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) { | 389 TEST_F(InputRouterImplPerfTest, TouchSwipeToGestureScroll) { |
| 388 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ", | 390 SimulateTouchAndScrollEventSequence("TouchSwipeToGestureScroll ", |
| 389 kDefaultSteps, | 391 kDefaultSteps, |
| 390 kDefaultOrigin, | 392 kDefaultOrigin, |
| 391 kDefaultDistance, | 393 kDefaultDistance, |
| 392 kDefaultIterations); | 394 kDefaultIterations); |
| 393 } | 395 } |
| 394 | 396 |
| 395 } // namespace content | 397 } // namespace content |
| OLD | NEW |