OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/renderer_host/input/mouse_wheel_event_queue.h" | 5 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
16 #include "content/browser/renderer_host/input/timeout_monitor.h" | 17 #include "content/browser/renderer_host/input/timeout_monitor.h" |
17 #include "content/common/input/synthetic_web_input_event_builders.h" | 18 #include "content/common/input/synthetic_web_input_event_builders.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/WebKit/public/web/WebInputEvent.h" | 20 #include "third_party/WebKit/public/web/WebInputEvent.h" |
20 | 21 |
21 using blink::WebGestureEvent; | 22 using blink::WebGestureEvent; |
22 using blink::WebInputEvent; | 23 using blink::WebInputEvent; |
23 using blink::WebMouseWheelEvent; | 24 using blink::WebMouseWheelEvent; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 WebGestureEvent event; | 258 WebGestureEvent event; |
258 event.type = type; | 259 event.type = type; |
259 event.sourceDevice = blink::WebGestureDeviceTouchscreen; | 260 event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
260 queue_->OnGestureScrollEvent( | 261 queue_->OnGestureScrollEvent( |
261 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); | 262 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); |
262 } | 263 } |
263 | 264 |
264 static void RunTasksAndWait(base::TimeDelta delay) { | 265 static void RunTasksAndWait(base::TimeDelta delay) { |
265 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 266 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
266 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); | 267 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); |
267 base::MessageLoop::current()->Run(); | 268 base::RunLoop().Run(); |
268 } | 269 } |
269 | 270 |
270 void GestureSendingTest(bool high_precision) { | 271 void GestureSendingTest(bool high_precision) { |
271 const WebGestureEvent::ScrollUnits scroll_units = | 272 const WebGestureEvent::ScrollUnits scroll_units = |
272 high_precision ? WebGestureEvent::PrecisePixels | 273 high_precision ? WebGestureEvent::PrecisePixels |
273 : WebGestureEvent::Pixels; | 274 : WebGestureEvent::Pixels; |
274 SendMouseWheel(kWheelScrollX, kWheelScrollY, kWheelScrollGlobalX, | 275 SendMouseWheel(kWheelScrollX, kWheelScrollY, kWheelScrollGlobalX, |
275 kWheelScrollGlobalY, 1, 1, 0, high_precision); | 276 kWheelScrollGlobalY, 1, 1, 0, high_precision); |
276 EXPECT_EQ(0U, queued_event_count()); | 277 EXPECT_EQ(0U, queued_event_count()); |
277 EXPECT_TRUE(event_in_flight()); | 278 EXPECT_TRUE(event_in_flight()); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 552 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
552 EXPECT_EQ(2U, all_sent_events().size()); | 553 EXPECT_EQ(2U, all_sent_events().size()); |
553 EXPECT_GESTURE_SCROLL_BEGIN(sent_gesture_event(0)); | 554 EXPECT_GESTURE_SCROLL_BEGIN(sent_gesture_event(0)); |
554 EXPECT_GESTURE_SCROLL_UPDATE(sent_gesture_event(1)); | 555 EXPECT_GESTURE_SCROLL_UPDATE(sent_gesture_event(1)); |
555 EXPECT_EQ(0U, sent_gesture_event(1)->data.scrollUpdate.deltaX); | 556 EXPECT_EQ(0U, sent_gesture_event(1)->data.scrollUpdate.deltaX); |
556 EXPECT_EQ(1U, sent_gesture_event(1)->data.scrollUpdate.deltaY); | 557 EXPECT_EQ(1U, sent_gesture_event(1)->data.scrollUpdate.deltaY); |
557 EXPECT_EQ(2U, GetAndResetSentEventCount()); | 558 EXPECT_EQ(2U, GetAndResetSentEventCount()); |
558 } | 559 } |
559 | 560 |
560 } // namespace content | 561 } // namespace content |
OLD | NEW |