OLD | NEW |
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 "content/browser/renderer_host/input/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 float y, | 229 float y, |
230 float dX, | 230 float dX, |
231 float dY, | 231 float dY, |
232 int modifiers, | 232 int modifiers, |
233 bool precise) { | 233 bool precise) { |
234 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( | 234 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( |
235 SyntheticWebMouseWheelEventBuilder::Build(x, y, dX, dY, modifiers, | 235 SyntheticWebMouseWheelEventBuilder::Build(x, y, dX, dY, modifiers, |
236 precise))); | 236 precise))); |
237 } | 237 } |
238 | 238 |
| 239 void SimulateWheelEventWithPhase(float x, |
| 240 float y, |
| 241 float dX, |
| 242 float dY, |
| 243 int modifiers, |
| 244 bool precise, |
| 245 WebMouseWheelEvent::Phase phase) { |
| 246 WebMouseWheelEvent wheel_event = SyntheticWebMouseWheelEventBuilder::Build( |
| 247 x, y, dX, dY, modifiers, precise); |
| 248 wheel_event.phase = phase; |
| 249 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo(wheel_event)); |
| 250 } |
| 251 |
239 void SimulateMouseEvent(WebInputEvent::Type type, int x, int y) { | 252 void SimulateMouseEvent(WebInputEvent::Type type, int x, int y) { |
240 input_router_->SendMouseEvent(MouseEventWithLatencyInfo( | 253 input_router_->SendMouseEvent(MouseEventWithLatencyInfo( |
241 SyntheticWebMouseEventBuilder::Build(type, x, y, 0))); | 254 SyntheticWebMouseEventBuilder::Build(type, x, y, 0))); |
242 } | 255 } |
243 | 256 |
244 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) { | 257 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) { |
245 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( | 258 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( |
246 SyntheticWebMouseWheelEventBuilder::Build(phase))); | 259 SyntheticWebMouseWheelEventBuilder::Build(phase))); |
247 } | 260 } |
248 | 261 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 } | 393 } |
381 | 394 |
382 static void RunTasksAndWait(base::TimeDelta delay) { | 395 static void RunTasksAndWait(base::TimeDelta delay) { |
383 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 396 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
384 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); | 397 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); |
385 base::RunLoop().Run(); | 398 base::RunLoop().Run(); |
386 } | 399 } |
387 | 400 |
388 void UnhandledWheelEvent(bool wheel_scroll_latching_enabled) { | 401 void UnhandledWheelEvent(bool wheel_scroll_latching_enabled) { |
389 // Simulate wheel events. | 402 // Simulate wheel events. |
390 SimulateWheelEvent(0, 0, 0, -5, 0, false); // sent directly | 403 if (wheel_scroll_latching_enabled) { |
391 SimulateWheelEvent(0, 0, 0, -10, 0, false); // enqueued | 404 SimulateWheelEventWithPhase( |
| 405 0, 0, 0, -5, 0, false, |
| 406 WebMouseWheelEvent::kPhaseBegan); // sent directly |
| 407 SimulateWheelEventWithPhase( |
| 408 0, 0, 0, -10, 0, false, |
| 409 WebMouseWheelEvent::kPhaseChanged); // enqueued |
| 410 } else { |
| 411 SimulateWheelEvent(0, 0, 0, -5, 0, false); // sent directly |
| 412 SimulateWheelEvent(0, 0, 0, -10, 0, false); // enqueued |
| 413 } |
392 | 414 |
393 // Check that only the first event was sent. | 415 // Check that only the first event was sent. |
394 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 416 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
395 InputMsg_HandleInputEvent::ID)); | 417 InputMsg_HandleInputEvent::ID)); |
396 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 418 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
397 | 419 |
398 // Indicate that the wheel event was unhandled. | 420 // Indicate that the wheel event was unhandled. |
399 SendInputEventACK(WebInputEvent::kMouseWheel, | 421 SendInputEventACK(WebInputEvent::kMouseWheel, |
400 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 422 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
401 | 423 |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 break; | 1112 break; |
1091 expected_events.erase(expected_events.begin(), | 1113 expected_events.erase(expected_events.begin(), |
1092 expected_events.begin() + acked.size()); | 1114 expected_events.begin() + acked.size()); |
1093 } | 1115 } |
1094 | 1116 |
1095 EXPECT_TRUE(TouchEventQueueEmpty()); | 1117 EXPECT_TRUE(TouchEventQueueEmpty()); |
1096 EXPECT_EQ(0U, expected_events.size()); | 1118 EXPECT_EQ(0U, expected_events.size()); |
1097 } | 1119 } |
1098 #endif // defined(USE_AURA) | 1120 #endif // defined(USE_AURA) |
1099 | 1121 |
1100 TEST_F(InputRouterImplTest, UnhandledWheelEventWithoutLatching) { | 1122 TEST_F(InputRouterImplTest, UnhandledWheelEvent) { |
1101 UnhandledWheelEvent(true); | 1123 UnhandledWheelEvent(true); |
1102 } | 1124 } |
1103 TEST_F(InputRouterImplWheelScrollLatchingDisabledTest, | 1125 TEST_F(InputRouterImplWheelScrollLatchingDisabledTest, UnhandledWheelEvent) { |
1104 UnhandledWheelEventWithLatching) { | |
1105 UnhandledWheelEvent(false); | 1126 UnhandledWheelEvent(false); |
1106 } | 1127 } |
1107 | 1128 |
1108 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { | 1129 TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { |
1109 OnHasTouchEventHandlers(true); | 1130 OnHasTouchEventHandlers(true); |
1110 // Only acks for TouchCancel should always be ignored. | 1131 // Only acks for TouchCancel should always be ignored. |
1111 ASSERT_TRUE( | 1132 ASSERT_TRUE( |
1112 ShouldBlockEventStream(GetEventWithType(WebInputEvent::kTouchStart))); | 1133 ShouldBlockEventStream(GetEventWithType(WebInputEvent::kTouchStart))); |
1113 ASSERT_TRUE( | 1134 ASSERT_TRUE( |
1114 ShouldBlockEventStream(GetEventWithType(WebInputEvent::kTouchMove))); | 1135 ShouldBlockEventStream(GetEventWithType(WebInputEvent::kTouchMove))); |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 EXPECT_EQ(80, sent_event->data.fling_start.velocity_y); | 2521 EXPECT_EQ(80, sent_event->data.fling_start.velocity_y); |
2501 | 2522 |
2502 const WebGestureEvent* filter_event = | 2523 const WebGestureEvent* filter_event = |
2503 GetFilterWebInputEvent<WebGestureEvent>(); | 2524 GetFilterWebInputEvent<WebGestureEvent>(); |
2504 TestLocationInFilterEvent(filter_event, orig); | 2525 TestLocationInFilterEvent(filter_event, orig); |
2505 EXPECT_EQ(30, filter_event->data.fling_start.velocity_x); | 2526 EXPECT_EQ(30, filter_event->data.fling_start.velocity_x); |
2506 EXPECT_EQ(40, filter_event->data.fling_start.velocity_y); | 2527 EXPECT_EQ(40, filter_event->data.fling_start.velocity_y); |
2507 } | 2528 } |
2508 | 2529 |
2509 } // namespace content | 2530 } // namespace content |
OLD | NEW |