Chromium Code Reviews| Index: content/browser/renderer_host/input/input_router_impl_unittest.cc |
| diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc |
| index 7655f222f4d45cafeb7fe26aff3480d76708fff5..7a60259cf4a510b76e9733a50fd0fcb9ffad291c 100644 |
| --- a/content/browser/renderer_host/input/input_router_impl_unittest.cc |
| +++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc |
| @@ -167,6 +167,18 @@ class InputRouterImplTest : public testing::Test { |
| browser_context_.reset(); |
| } |
| + void SetUpForGestureBasedWheelScrolling(bool enabled) { |
| + CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kDisableWheelGestures) && |
| + !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableWheelGestures)); |
| + base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| + enabled ? switches::kEnableWheelGestures |
| + : switches::kDisableWheelGestures); |
| + TearDown(); |
| + SetUp(); |
| + } |
| + |
| void SetUpForTouchAckTimeoutTest(int desktop_timeout_ms, |
| int mobile_timeout_ms) { |
| config_.touch_config.desktop_touch_ack_timeout_delay = |
| @@ -936,6 +948,8 @@ TEST_F(InputRouterImplTest, AckedTouchEventState) { |
| #endif // defined(USE_AURA) |
| TEST_F(InputRouterImplTest, UnhandledWheelEvent) { |
| + SetUpForGestureBasedWheelScrolling(false); |
| + |
| // Simulate wheel events. |
| SimulateWheelEvent(0, 0, 0, -5, 0, false); // sent directly |
| SimulateWheelEvent(0, 0, 0, -10, 0, false); // enqueued |
| @@ -959,8 +973,49 @@ TEST_F(InputRouterImplTest, UnhandledWheelEvent) { |
| InputMsg_HandleInputEvent::ID)); |
| EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| + // Indicate that the wheel event was unhandled. |
| + SendInputEventACK(WebInputEvent::MouseWheel, |
| + INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| + |
| + // Check that the correct unhandled wheel event was received. |
| + EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| + EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_handler_->ack_state()); |
| + EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -10); |
| +} |
| + |
| +TEST_F(InputRouterImplTest, UnhandledWheelEventWithGestureScrolling) { |
| + SetUpForGestureBasedWheelScrolling(true); |
| + |
| + // Simulate wheel events. |
| + SimulateWheelEvent(0, 0, 0, -5, 0, false); // sent directly |
| + SimulateWheelEvent(0, 0, 0, -10, 0, false); // enqueued |
| + |
| + // Check that only the first event was sent. |
| + EXPECT_TRUE( |
| + process_->sink().GetUniqueMessageMatching(InputMsg_HandleInputEvent::ID)); |
| + EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| + |
| + // Indicate that the wheel event was unhandled. |
| + SendInputEventACK(WebInputEvent::MouseWheel, |
| + INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| + |
| // Check that the correct unhandled wheel event was received. |
| + EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); |
|
tdresser
2016/02/18 14:39:10
Why do we have two acks here, but only one in the
dtapuska
2016/02/18 21:03:44
Added comments
|
| + |
| EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); |
| + SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| + INPUT_EVENT_ACK_STATE_CONSUMED); |
| + |
| + // Check that the second event was sent. |
| + EXPECT_EQ(3U, GetSentMessageCountAndResetSink()); |
| + |
| + SendInputEventACK(WebInputEvent::MouseWheel, |
| + INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| + |
| + // Check that the correct unhandled wheel event was received. |
| + EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount()); |
| + EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, ack_handler_->ack_state()); |
| + EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -10); |
| } |
| TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) { |