Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: content/browser/renderer_host/input/input_router_impl_unittest.cc

Issue 218633008: [Android] Provide unhandled tap event notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really now Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 PressTouchPoint(1, 1); 1278 PressTouchPoint(1, 1);
1279 SendTouchEvent(); 1279 SendTouchEvent();
1280 1280
1281 // First tap. 1281 // First tap.
1282 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); 1282 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
1283 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1283 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1284 WebGestureEvent::Touchscreen); 1284 WebGestureEvent::Touchscreen);
1285 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1285 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1286 1286
1287 // The GestureTapUnconfirmed is converted into a tap, as the touch action is 1287 // The GestureTapUnconfirmed is converted into a tap, as the touch action is
1288 // auto. 1288 // none.
1289 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed, 1289 SimulateGestureEvent(WebInputEvent::GestureTapUnconfirmed,
1290 WebGestureEvent::Touchscreen); 1290 WebGestureEvent::Touchscreen);
1291 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1292 // This test will become invalid if GestureTap stops requiring an ack.
1293 ASSERT_TRUE(!WebInputEventTraits::IgnoresAckDisposition(
1294 WebInputEvent::GestureTap));
1295 EXPECT_EQ(2, client_->in_flight_event_count());
1291 SendInputEventACK(WebInputEvent::GestureTap, 1296 SendInputEventACK(WebInputEvent::GestureTap,
1292 INPUT_EVENT_ACK_STATE_CONSUMED); 1297 INPUT_EVENT_ACK_STATE_CONSUMED);
1293 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1298 EXPECT_EQ(1, client_->in_flight_event_count());
1294 1299
1295 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned 1300 // This tap gesture is dropped, since the GestureTapUnconfirmed was turned
1296 // into a tap. 1301 // into a tap.
1297 SimulateGestureEvent(WebInputEvent::GestureTap, WebGestureEvent::Touchscreen); 1302 SimulateGestureEvent(WebInputEvent::GestureTap, WebGestureEvent::Touchscreen);
1298 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1303 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1299 1304
1300 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); 1305 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED);
1301 SendInputEventACK(WebInputEvent::TouchStart, 1306 SendInputEventACK(WebInputEvent::TouchStart,
1302 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); 1307 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
1303 1308
1304 // Second Tap. 1309 // Second Tap.
1305 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1310 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1306 SimulateGestureEvent(WebInputEvent::GestureTapDown, 1311 SimulateGestureEvent(WebInputEvent::GestureTapDown,
1307 WebGestureEvent::Touchscreen); 1312 WebGestureEvent::Touchscreen);
1308 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1313 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1309 1314
1310 // Although the touch-action is now auto, the double tap still won't be 1315 // Although the touch-action is now auto, the double tap still won't be
1311 // dispatched, because the first tap occured when the touch-action was none. 1316 // dispatched, because the first tap occured when the touch-action was none.
1312 SimulateGestureEvent(WebInputEvent::GestureDoubleTap, 1317 SimulateGestureEvent(WebInputEvent::GestureDoubleTap,
1313 WebGestureEvent::Touchscreen); 1318 WebGestureEvent::Touchscreen);
1314 // This test will become invalid if GestureDoubleTap stops requiring an ack. 1319 // This test will become invalid if GestureDoubleTap stops requiring an ack.
1315 DCHECK(!WebInputEventTraits::IgnoresAckDisposition( 1320 ASSERT_TRUE(!WebInputEventTraits::IgnoresAckDisposition(
1316 WebInputEvent::GestureDoubleTap)); 1321 WebInputEvent::GestureDoubleTap));
1322 EXPECT_EQ(1, client_->in_flight_event_count());
1323 SendInputEventACK(WebInputEvent::GestureTap, INPUT_EVENT_ACK_STATE_CONSUMED);
1317 EXPECT_EQ(0, client_->in_flight_event_count()); 1324 EXPECT_EQ(0, client_->in_flight_event_count());
1318 } 1325 }
1319 1326
1320 // Test that the router will call the client's |DidFlush| after all events have 1327 // Test that the router will call the client's |DidFlush| after all events have
1321 // been dispatched following a call to |Flush|. 1328 // been dispatched following a call to |Flush|.
1322 TEST_F(InputRouterImplTest, InputFlush) { 1329 TEST_F(InputRouterImplTest, InputFlush) {
1323 EXPECT_FALSE(HasPendingEvents()); 1330 EXPECT_FALSE(HasPendingEvents());
1324 1331
1325 // Flushing an empty router should immediately trigger DidFlush. 1332 // Flushing an empty router should immediately trigger DidFlush.
1326 Flush(); 1333 Flush();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 1439
1433 // Ack the second scroll. 1440 // Ack the second scroll.
1434 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 1441 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
1435 INPUT_EVENT_ACK_STATE_CONSUMED); 1442 INPUT_EVENT_ACK_STATE_CONSUMED);
1436 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1443 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1437 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1444 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1438 EXPECT_EQ(0, client_->in_flight_event_count()); 1445 EXPECT_EQ(0, client_->in_flight_event_count());
1439 } 1446 }
1440 1447
1441 } // namespace content 1448 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698