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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 9 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
10 #include "content/browser/renderer_host/input/input_router_client.h" | 10 #include "content/browser/renderer_host/input/input_router_client.h" |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 PressTouchPoint(1, 1); | 1272 PressTouchPoint(1, 1); |
1273 SendTouchEvent(); | 1273 SendTouchEvent(); |
1274 | 1274 |
1275 // First tap. | 1275 // First tap. |
1276 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 1276 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
1277 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1277 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1278 WebGestureEvent::Touchscreen); | 1278 WebGestureEvent::Touchscreen); |
1279 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1279 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1280 | 1280 |
1281 // The GestureTapUnconfirmed is converted into a tap, as the touch action is | 1281 // The GestureTapUnconfirmed is converted into a tap, as the touch action is |
1282 // none. | 1282 // auto. |
1283 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, | 1283 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, |
1284 WebGestureEvent::Touchscreen); | 1284 WebGestureEvent::Touchscreen); |
1285 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1285 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1286 // This test will become invalid if GestureTap stops requiring an ack. | |
1287 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | |
1288 GetEventWithType(WebInputEvent::GestureTap))); | |
1289 EXPECT_EQ(2, client_->in_flight_event_count()); | |
1290 SendInputEventACK(WebInputEvent::GestureTap, | |
1291 INPUT_EVENT_ACK_STATE_CONSUMED); | |
1292 EXPECT_EQ(1, client_->in_flight_event_count()); | |
1293 | 1286 |
1294 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned | 1287 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned |
1295 // into a tap. | 1288 // into a tap. |
1296 SimulateGestureEvent(WebInputEvent::GestureTap, WebGestureEvent::Touchscreen); | 1289 SimulateGestureEvent(WebInputEvent::GestureTap, WebGestureEvent::Touchscreen); |
1297 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1290 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1298 | 1291 |
1299 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); | 1292 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); |
1300 SendInputEventACK(WebInputEvent::TouchStart, | 1293 SendInputEventACK(WebInputEvent::TouchStart, |
1301 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 1294 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
1302 | 1295 |
1303 // Second Tap. | 1296 // Second Tap. |
1304 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1297 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1305 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1298 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1306 WebGestureEvent::Touchscreen); | 1299 WebGestureEvent::Touchscreen); |
1307 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1300 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1308 | 1301 |
1309 // Although the touch-action is now auto, the double tap still won't be | 1302 // Although the touch-action is now auto, the double tap still won't be |
1310 // dispatched, because the first tap occured when the touch-action was none. | 1303 // dispatched, because the first tap occured when the touch-action was none. |
1311 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, | 1304 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, |
1312 WebGestureEvent::Touchscreen); | 1305 WebGestureEvent::Touchscreen); |
1313 // This test will become invalid if GestureDoubleTap stops requiring an ack. | 1306 // This test will become invalid if GestureDoubleTap stops requiring an ack. |
1314 ASSERT_FALSE(WebInputEventTraits::IgnoresAckDisposition( | 1307 DCHECK(!WebInputEventTraits::IgnoresAckDisposition( |
1315 GetEventWithType(WebInputEvent::GestureDoubleTap))); | 1308 GetEventWithType(WebInputEvent::GestureDoubleTap))); |
1316 EXPECT_EQ(1, client_->in_flight_event_count()); | |
1317 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED); | |
1318 EXPECT_EQ(0, client_->in_flight_event_count()); | 1309 EXPECT_EQ(0, client_->in_flight_event_count()); |
1319 } | 1310 } |
1320 | 1311 |
1321 // Test that the router will call the client's |DidFlush| after all events have | 1312 // Test that the router will call the client's |DidFlush| after all events have |
1322 // been dispatched following a call to |Flush|. | 1313 // been dispatched following a call to |Flush|. |
1323 TEST_F(InputRouterImplTest, InputFlush) { | 1314 TEST_F(InputRouterImplTest, InputFlush) { |
1324 EXPECT_FALSE(HasPendingEvents()); | 1315 EXPECT_FALSE(HasPendingEvents()); |
1325 | 1316 |
1326 // Flushing an empty router should immediately trigger DidFlush. | 1317 // Flushing an empty router should immediately trigger DidFlush. |
1327 Flush(); | 1318 Flush(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1428 |
1438 // Ack the second scroll. | 1429 // Ack the second scroll. |
1439 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1430 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1440 INPUT_EVENT_ACK_STATE_CONSUMED); | 1431 INPUT_EVENT_ACK_STATE_CONSUMED); |
1441 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1432 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1442 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1433 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
1443 EXPECT_EQ(0, client_->in_flight_event_count()); | 1434 EXPECT_EQ(0, client_->in_flight_event_count()); |
1444 } | 1435 } |
1445 | 1436 |
1446 } // namespace content | 1437 } // namespace content |
OLD | NEW |