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