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

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 14487003: Add a new pair of IPC categories for messages that need handling as input events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addresses feedback Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/shared_memory.h" 7 #include "base/shared_memory.h"
8 #include "base/timer.h" 8 #include "base/timer.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/renderer_host/backing_store.h" 10 #include "content/browser/renderer_host/backing_store.h"
11 #include "content/browser/renderer_host/render_widget_host_delegate.h"
12 #include "content/browser/renderer_host/gesture_event_filter.h" 11 #include "content/browser/renderer_host/gesture_event_filter.h"
13 #include "content/browser/renderer_host/overscroll_controller.h" 12 #include "content/browser/renderer_host/overscroll_controller.h"
14 #include "content/browser/renderer_host/overscroll_controller_delegate.h" 13 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
14 #include "content/browser/renderer_host/render_widget_host_delegate.h"
15 #include "content/browser/renderer_host/tap_suppression_controller.h" 15 #include "content/browser/renderer_host/tap_suppression_controller.h"
16 #include "content/browser/renderer_host/tap_suppression_controller_client.h" 16 #include "content/browser/renderer_host/tap_suppression_controller_client.h"
17 #include "content/browser/renderer_host/test_render_view_host.h" 17 #include "content/browser/renderer_host/test_render_view_host.h"
18 #include "content/browser/renderer_host/touch_event_queue.h" 18 #include "content/browser/renderer_host/touch_event_queue.h"
19 #include "content/common/input_messages.h"
19 #include "content/common/view_messages.h" 20 #include "content/common/view_messages.h"
20 #include "content/port/browser/render_widget_host_view_port.h" 21 #include "content/port/browser/render_widget_host_view_port.h"
21 #include "content/public/browser/notification_details.h" 22 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_observer.h" 23 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
25 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
26 #include "content/public/test/mock_render_process_host.h" 27 #include "content/public/test/mock_render_process_host.h"
27 #include "content/public/test/test_browser_context.h" 28 #include "content/public/test/test_browser_context.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 screen_.reset(); 657 screen_.reset();
657 #endif 658 #endif
658 659
659 // Process all pending tasks to avoid leaks. 660 // Process all pending tasks to avoid leaks.
660 MessageLoop::current()->RunUntilIdle(); 661 MessageLoop::current()->RunUntilIdle();
661 } 662 }
662 663
663 void SendInputEventACK(WebInputEvent::Type type, 664 void SendInputEventACK(WebInputEvent::Type type,
664 InputEventAckState ack_result) { 665 InputEventAckState ack_result) {
665 scoped_ptr<IPC::Message> response( 666 scoped_ptr<IPC::Message> response(
666 new ViewHostMsg_HandleInputEvent_ACK(0, type, ack_result)); 667 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result));
667 host_->OnMessageReceived(*response); 668 host_->OnMessageReceived(*response);
668 } 669 }
669 670
670 void SimulateKeyboardEvent(WebInputEvent::Type type) { 671 void SimulateKeyboardEvent(WebInputEvent::Type type) {
671 NativeWebKeyboardEvent key_event; 672 NativeWebKeyboardEvent key_event;
672 key_event.type = type; 673 key_event.type = type;
673 key_event.windowsKeyCode = ui::VKEY_L; // non-null made up value. 674 key_event.windowsKeyCode = ui::VKEY_L; // non-null made up value.
674 host_->ForwardKeyboardEvent(key_event); 675 host_->ForwardKeyboardEvent(key_event);
675 } 676 }
676 677
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 #define MAYBE_HandleKeyEventsWeSent DISABLED_HandleKeyEventsWeSent 1154 #define MAYBE_HandleKeyEventsWeSent DISABLED_HandleKeyEventsWeSent
1154 #else 1155 #else
1155 #define MAYBE_HandleKeyEventsWeSent HandleKeyEventsWeSent 1156 #define MAYBE_HandleKeyEventsWeSent HandleKeyEventsWeSent
1156 #endif 1157 #endif
1157 TEST_F(RenderWidgetHostTest, MAYBE_HandleKeyEventsWeSent) { 1158 TEST_F(RenderWidgetHostTest, MAYBE_HandleKeyEventsWeSent) {
1158 // Simulate a keyboard event. 1159 // Simulate a keyboard event.
1159 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); 1160 SimulateKeyboardEvent(WebInputEvent::RawKeyDown);
1160 1161
1161 // Make sure we sent the input event to the renderer. 1162 // Make sure we sent the input event to the renderer.
1162 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1163 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1163 ViewMsg_HandleInputEvent::ID)); 1164 InputMsg_HandleInputEvent::ID));
1164 process_->sink().ClearMessages(); 1165 process_->sink().ClearMessages();
1165 1166
1166 // Send the simulated response from the renderer back. 1167 // Send the simulated response from the renderer back.
1167 SendInputEventACK(WebInputEvent::RawKeyDown, 1168 SendInputEventACK(WebInputEvent::RawKeyDown,
1168 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1169 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1169 1170
1170 EXPECT_TRUE(delegate_->unhandled_keyboard_event_called()); 1171 EXPECT_TRUE(delegate_->unhandled_keyboard_event_called());
1171 EXPECT_EQ(WebInputEvent::RawKeyDown, 1172 EXPECT_EQ(WebInputEvent::RawKeyDown,
1172 delegate_->unhandled_keyboard_event_type()); 1173 delegate_->unhandled_keyboard_event_type());
1173 } 1174 }
1174 1175
1175 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsWeDidntSend) { 1176 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsWeDidntSend) {
1176 // Send a simulated, unrequested key response. We should ignore this. 1177 // Send a simulated, unrequested key response. We should ignore this.
1177 SendInputEventACK(WebInputEvent::RawKeyDown, 1178 SendInputEventACK(WebInputEvent::RawKeyDown,
1178 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1179 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1179 1180
1180 EXPECT_FALSE(delegate_->unhandled_keyboard_event_called()); 1181 EXPECT_FALSE(delegate_->unhandled_keyboard_event_called());
1181 } 1182 }
1182 1183
1183 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsHandledByRenderer) { 1184 TEST_F(RenderWidgetHostTest, IgnoreKeyEventsHandledByRenderer) {
1184 // Simulate a keyboard event. 1185 // Simulate a keyboard event.
1185 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); 1186 SimulateKeyboardEvent(WebInputEvent::RawKeyDown);
1186 1187
1187 // Make sure we sent the input event to the renderer. 1188 // Make sure we sent the input event to the renderer.
1188 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1189 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1189 ViewMsg_HandleInputEvent::ID)); 1190 InputMsg_HandleInputEvent::ID));
1190 process_->sink().ClearMessages(); 1191 process_->sink().ClearMessages();
1191 1192
1192 // Send the simulated response from the renderer back. 1193 // Send the simulated response from the renderer back.
1193 SendInputEventACK(WebInputEvent::RawKeyDown, 1194 SendInputEventACK(WebInputEvent::RawKeyDown,
1194 INPUT_EVENT_ACK_STATE_CONSUMED); 1195 INPUT_EVENT_ACK_STATE_CONSUMED);
1195 EXPECT_FALSE(delegate_->unhandled_keyboard_event_called()); 1196 EXPECT_FALSE(delegate_->unhandled_keyboard_event_called());
1196 } 1197 }
1197 1198
1198 TEST_F(RenderWidgetHostTest, PreHandleRawKeyDownEvent) { 1199 TEST_F(RenderWidgetHostTest, PreHandleRawKeyDownEvent) {
1199 // Simluate the situation that the browser handled the key down event during 1200 // Simluate the situation that the browser handled the key down event during
(...skipping 18 matching lines...) Expand all
1218 SimulateKeyboardEvent(WebInputEvent::Char); 1219 SimulateKeyboardEvent(WebInputEvent::Char);
1219 1220
1220 // Make sure the Char event is suppressed. 1221 // Make sure the Char event is suppressed.
1221 EXPECT_EQ(0U, process_->sink().message_count()); 1222 EXPECT_EQ(0U, process_->sink().message_count());
1222 1223
1223 // Forward the KeyUp event. 1224 // Forward the KeyUp event.
1224 SimulateKeyboardEvent(WebInputEvent::KeyUp); 1225 SimulateKeyboardEvent(WebInputEvent::KeyUp);
1225 1226
1226 // Make sure only KeyUp was sent to the renderer. 1227 // Make sure only KeyUp was sent to the renderer.
1227 EXPECT_EQ(1U, process_->sink().message_count()); 1228 EXPECT_EQ(1U, process_->sink().message_count());
1228 EXPECT_EQ(ViewMsg_HandleInputEvent::ID, 1229 EXPECT_EQ(InputMsg_HandleInputEvent::ID,
1229 process_->sink().GetMessageAt(0)->type()); 1230 process_->sink().GetMessageAt(0)->type());
1230 process_->sink().ClearMessages(); 1231 process_->sink().ClearMessages();
1231 1232
1232 // Send the simulated response from the renderer back. 1233 // Send the simulated response from the renderer back.
1233 SendInputEventACK(WebInputEvent::KeyUp, 1234 SendInputEventACK(WebInputEvent::KeyUp,
1234 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1235 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1235 1236
1236 EXPECT_TRUE(delegate_->unhandled_keyboard_event_called()); 1237 EXPECT_TRUE(delegate_->unhandled_keyboard_event_called());
1237 EXPECT_EQ(WebInputEvent::KeyUp, delegate_->unhandled_keyboard_event_type()); 1238 EXPECT_EQ(WebInputEvent::KeyUp, delegate_->unhandled_keyboard_event_type());
1238 } 1239 }
1239 1240
1240 TEST_F(RenderWidgetHostTest, CoalescesWheelEvents) { 1241 TEST_F(RenderWidgetHostTest, CoalescesWheelEvents) {
1241 process_->sink().ClearMessages(); 1242 process_->sink().ClearMessages();
1242 1243
1243 // Simulate wheel events. 1244 // Simulate wheel events.
1244 SimulateWheelEvent(0, -5, 0, false); // sent directly 1245 SimulateWheelEvent(0, -5, 0, false); // sent directly
1245 SimulateWheelEvent(0, -10, 0, false); // enqueued 1246 SimulateWheelEvent(0, -10, 0, false); // enqueued
1246 SimulateWheelEvent(8, -6, 0, false); // coalesced into previous event 1247 SimulateWheelEvent(8, -6, 0, false); // coalesced into previous event
1247 SimulateWheelEvent(9, -7, 1, false); // enqueued, different modifiers 1248 SimulateWheelEvent(9, -7, 1, false); // enqueued, different modifiers
1248 1249
1249 // Check that only the first event was sent. 1250 // Check that only the first event was sent.
1250 EXPECT_EQ(1U, process_->sink().message_count()); 1251 EXPECT_EQ(1U, process_->sink().message_count());
1251 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1252 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1252 ViewMsg_HandleInputEvent::ID)); 1253 InputMsg_HandleInputEvent::ID));
1253 process_->sink().ClearMessages(); 1254 process_->sink().ClearMessages();
1254 1255
1255 // Check that the ACK sends the second message. 1256 // Check that the ACK sends the second message.
1256 SendInputEventACK(WebInputEvent::MouseWheel, 1257 SendInputEventACK(WebInputEvent::MouseWheel,
1257 INPUT_EVENT_ACK_STATE_CONSUMED); 1258 INPUT_EVENT_ACK_STATE_CONSUMED);
1258 // The coalesced events can queue up a delayed ack 1259 // The coalesced events can queue up a delayed ack
1259 // so that additional input events can be processed before 1260 // so that additional input events can be processed before
1260 // we turn off coalescing. 1261 // we turn off coalescing.
1261 MessageLoop::current()->RunUntilIdle(); 1262 MessageLoop::current()->RunUntilIdle();
1262 EXPECT_EQ(1U, process_->sink().message_count()); 1263 EXPECT_EQ(1U, process_->sink().message_count());
1263 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1264 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1264 ViewMsg_HandleInputEvent::ID)); 1265 InputMsg_HandleInputEvent::ID));
1265 process_->sink().ClearMessages(); 1266 process_->sink().ClearMessages();
1266 1267
1267 // One more time. 1268 // One more time.
1268 SendInputEventACK(WebInputEvent::MouseWheel, 1269 SendInputEventACK(WebInputEvent::MouseWheel,
1269 INPUT_EVENT_ACK_STATE_CONSUMED); 1270 INPUT_EVENT_ACK_STATE_CONSUMED);
1270 MessageLoop::current()->RunUntilIdle(); 1271 MessageLoop::current()->RunUntilIdle();
1271 EXPECT_EQ(1U, process_->sink().message_count()); 1272 EXPECT_EQ(1U, process_->sink().message_count());
1272 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1273 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1273 ViewMsg_HandleInputEvent::ID)); 1274 InputMsg_HandleInputEvent::ID));
1274 process_->sink().ClearMessages(); 1275 process_->sink().ClearMessages();
1275 1276
1276 // After the final ack, the queue should be empty. 1277 // After the final ack, the queue should be empty.
1277 SendInputEventACK(WebInputEvent::MouseWheel, 1278 SendInputEventACK(WebInputEvent::MouseWheel,
1278 INPUT_EVENT_ACK_STATE_CONSUMED); 1279 INPUT_EVENT_ACK_STATE_CONSUMED);
1279 MessageLoop::current()->RunUntilIdle(); 1280 MessageLoop::current()->RunUntilIdle();
1280 EXPECT_EQ(0U, process_->sink().message_count()); 1281 EXPECT_EQ(0U, process_->sink().message_count());
1281 1282
1282 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); 1283 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad);
1283 EXPECT_EQ(0U, process_->sink().message_count()); 1284 EXPECT_EQ(0U, process_->sink().message_count());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); 1359 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type);
1359 EXPECT_EQ(1, merged_event.modifiers); 1360 EXPECT_EQ(1, merged_event.modifiers);
1360 1361
1361 // Different. 1362 // Different.
1362 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 1363 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
1363 WebGestureEvent::Touchscreen); 1364 WebGestureEvent::Touchscreen);
1364 1365
1365 // Check that only the first event was sent. 1366 // Check that only the first event was sent.
1366 EXPECT_EQ(1U, process_->sink().message_count()); 1367 EXPECT_EQ(1U, process_->sink().message_count());
1367 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1368 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1368 ViewMsg_HandleInputEvent::ID)); 1369 InputMsg_HandleInputEvent::ID));
1369 process_->sink().ClearMessages(); 1370 process_->sink().ClearMessages();
1370 1371
1371 // Check that the ACK sends the second message. 1372 // Check that the ACK sends the second message.
1372 SendInputEventACK(WebInputEvent::GestureScrollBegin, 1373 SendInputEventACK(WebInputEvent::GestureScrollBegin,
1373 INPUT_EVENT_ACK_STATE_CONSUMED); 1374 INPUT_EVENT_ACK_STATE_CONSUMED);
1374 MessageLoop::current()->RunUntilIdle(); 1375 MessageLoop::current()->RunUntilIdle();
1375 EXPECT_EQ(1U, process_->sink().message_count()); 1376 EXPECT_EQ(1U, process_->sink().message_count());
1376 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1377 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1377 ViewMsg_HandleInputEvent::ID)); 1378 InputMsg_HandleInputEvent::ID));
1378 process_->sink().ClearMessages(); 1379 process_->sink().ClearMessages();
1379 1380
1380 // Ack for queued coalesced event. 1381 // Ack for queued coalesced event.
1381 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 1382 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
1382 INPUT_EVENT_ACK_STATE_CONSUMED); 1383 INPUT_EVENT_ACK_STATE_CONSUMED);
1383 MessageLoop::current()->RunUntilIdle(); 1384 MessageLoop::current()->RunUntilIdle();
1384 EXPECT_EQ(1U, process_->sink().message_count()); 1385 EXPECT_EQ(1U, process_->sink().message_count());
1385 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1386 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1386 ViewMsg_HandleInputEvent::ID)); 1387 InputMsg_HandleInputEvent::ID));
1387 process_->sink().ClearMessages(); 1388 process_->sink().ClearMessages();
1388 1389
1389 // Ack for queued uncoalesced event. 1390 // Ack for queued uncoalesced event.
1390 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 1391 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
1391 INPUT_EVENT_ACK_STATE_CONSUMED); 1392 INPUT_EVENT_ACK_STATE_CONSUMED);
1392 MessageLoop::current()->RunUntilIdle(); 1393 MessageLoop::current()->RunUntilIdle();
1393 EXPECT_EQ(1U, process_->sink().message_count()); 1394 EXPECT_EQ(1U, process_->sink().message_count());
1394 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1395 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1395 ViewMsg_HandleInputEvent::ID)); 1396 InputMsg_HandleInputEvent::ID));
1396 process_->sink().ClearMessages(); 1397 process_->sink().ClearMessages();
1397 1398
1398 // After the final ack, the queue should be empty. 1399 // After the final ack, the queue should be empty.
1399 SendInputEventACK(WebInputEvent::GestureScrollEnd, 1400 SendInputEventACK(WebInputEvent::GestureScrollEnd,
1400 INPUT_EVENT_ACK_STATE_CONSUMED); 1401 INPUT_EVENT_ACK_STATE_CONSUMED);
1401 MessageLoop::current()->RunUntilIdle(); 1402 MessageLoop::current()->RunUntilIdle();
1402 EXPECT_EQ(0U, process_->sink().message_count()); 1403 EXPECT_EQ(0U, process_->sink().message_count());
1403 } 1404 }
1404 1405
1405 TEST_F(RenderWidgetHostTest, CoalescesScrollAndPinchEvents) { 1406 TEST_F(RenderWidgetHostTest, CoalescesScrollAndPinchEvents) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 EXPECT_EQ(1, merged_event.modifiers); 1481 EXPECT_EQ(1, merged_event.modifiers);
1481 merged_event = host_->GestureEventSecondFromLastQueueEvent(); 1482 merged_event = host_->GestureEventSecondFromLastQueueEvent();
1482 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); 1483 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type);
1483 EXPECT_EQ(12, merged_event.data.scrollUpdate.deltaX); 1484 EXPECT_EQ(12, merged_event.data.scrollUpdate.deltaX);
1484 EXPECT_EQ(-6, merged_event.data.scrollUpdate.deltaY); 1485 EXPECT_EQ(-6, merged_event.data.scrollUpdate.deltaY);
1485 EXPECT_EQ(1, merged_event.modifiers); 1486 EXPECT_EQ(1, merged_event.modifiers);
1486 1487
1487 // Check that only the first event was sent. 1488 // Check that only the first event was sent.
1488 EXPECT_EQ(1U, process_->sink().message_count()); 1489 EXPECT_EQ(1U, process_->sink().message_count());
1489 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1490 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1490 ViewMsg_HandleInputEvent::ID)); 1491 InputMsg_HandleInputEvent::ID));
1491 process_->sink().ClearMessages(); 1492 process_->sink().ClearMessages();
1492 1493
1493 // Check that the ACK sends the second message. 1494 // Check that the ACK sends the second message.
1494 SendInputEventACK(WebInputEvent::GestureScrollBegin, 1495 SendInputEventACK(WebInputEvent::GestureScrollBegin,
1495 INPUT_EVENT_ACK_STATE_CONSUMED); 1496 INPUT_EVENT_ACK_STATE_CONSUMED);
1496 MessageLoop::current()->RunUntilIdle(); 1497 MessageLoop::current()->RunUntilIdle();
1497 EXPECT_EQ(1U, process_->sink().message_count()); 1498 EXPECT_EQ(1U, process_->sink().message_count());
1498 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1499 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1499 ViewMsg_HandleInputEvent::ID)); 1500 InputMsg_HandleInputEvent::ID));
1500 process_->sink().ClearMessages(); 1501 process_->sink().ClearMessages();
1501 1502
1502 // Enqueued. 1503 // Enqueued.
1503 SimulateGestureScrollUpdateEvent(6, -6, 1); 1504 SimulateGestureScrollUpdateEvent(6, -6, 1);
1504 1505
1505 // Check whether coalesced correctly. 1506 // Check whether coalesced correctly.
1506 EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize()); 1507 EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize());
1507 merged_event = host_->GestureEventLastQueueEvent(); 1508 merged_event = host_->GestureEventLastQueueEvent();
1508 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type); 1509 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type);
1509 EXPECT_EQ(6, merged_event.data.pinchUpdate.scale); 1510 EXPECT_EQ(6, merged_event.data.pinchUpdate.scale);
1510 EXPECT_EQ(1, merged_event.modifiers); 1511 EXPECT_EQ(1, merged_event.modifiers);
1511 merged_event = host_->GestureEventSecondFromLastQueueEvent(); 1512 merged_event = host_->GestureEventSecondFromLastQueueEvent();
1512 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); 1513 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type);
1513 EXPECT_EQ(13, merged_event.data.scrollUpdate.deltaX); 1514 EXPECT_EQ(13, merged_event.data.scrollUpdate.deltaX);
1514 EXPECT_EQ(-7, merged_event.data.scrollUpdate.deltaY); 1515 EXPECT_EQ(-7, merged_event.data.scrollUpdate.deltaY);
1515 EXPECT_EQ(1, merged_event.modifiers); 1516 EXPECT_EQ(1, merged_event.modifiers);
1516 1517
1517 // At this point ACKs shouldn't be getting ignored. 1518 // At this point ACKs shouldn't be getting ignored.
1518 EXPECT_FALSE(host_->WillIgnoreNextACK()); 1519 EXPECT_FALSE(host_->WillIgnoreNextACK());
1519 1520
1520 // Check that the ACK sends both scroll and pinch updates. 1521 // Check that the ACK sends both scroll and pinch updates.
1521 SendInputEventACK(WebInputEvent::GesturePinchBegin, 1522 SendInputEventACK(WebInputEvent::GesturePinchBegin,
1522 INPUT_EVENT_ACK_STATE_CONSUMED); 1523 INPUT_EVENT_ACK_STATE_CONSUMED);
1523 MessageLoop::current()->RunUntilIdle(); 1524 MessageLoop::current()->RunUntilIdle();
1524 EXPECT_EQ(2U, process_->sink().message_count()); 1525 EXPECT_EQ(2U, process_->sink().message_count());
1525 EXPECT_TRUE(process_->sink().GetFirstMessageMatching( 1526 EXPECT_TRUE(process_->sink().GetFirstMessageMatching(
1526 ViewMsg_HandleInputEvent::ID)); 1527 InputMsg_HandleInputEvent::ID));
1527 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( 1528 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(
1528 ViewMsg_HandleInputEvent::ID)); 1529 InputMsg_HandleInputEvent::ID));
1529 process_->sink().ClearMessages(); 1530 process_->sink().ClearMessages();
1530 1531
1531 // The next ACK should be getting ignored. 1532 // The next ACK should be getting ignored.
1532 EXPECT_TRUE(host_->WillIgnoreNextACK()); 1533 EXPECT_TRUE(host_->WillIgnoreNextACK());
1533 1534
1534 // Enqueued. 1535 // Enqueued.
1535 SimulateGestureScrollUpdateEvent(1, -1, 1); 1536 SimulateGestureScrollUpdateEvent(1, -1, 1);
1536 1537
1537 // Check whether coalesced correctly. 1538 // Check whether coalesced correctly.
1538 EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize()); 1539 EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type); 1599 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type);
1599 EXPECT_EQ(0.5, merged_event.data.pinchUpdate.scale); 1600 EXPECT_EQ(0.5, merged_event.data.pinchUpdate.scale);
1600 EXPECT_EQ(1, merged_event.modifiers); 1601 EXPECT_EQ(1, merged_event.modifiers);
1601 1602
1602 // Check that the ACK sends the next scroll pinch pair. 1603 // Check that the ACK sends the next scroll pinch pair.
1603 SendInputEventACK(WebInputEvent::GesturePinchUpdate, 1604 SendInputEventACK(WebInputEvent::GesturePinchUpdate,
1604 INPUT_EVENT_ACK_STATE_CONSUMED); 1605 INPUT_EVENT_ACK_STATE_CONSUMED);
1605 MessageLoop::current()->RunUntilIdle(); 1606 MessageLoop::current()->RunUntilIdle();
1606 EXPECT_EQ(2U, process_->sink().message_count()); 1607 EXPECT_EQ(2U, process_->sink().message_count());
1607 EXPECT_TRUE(process_->sink().GetFirstMessageMatching( 1608 EXPECT_TRUE(process_->sink().GetFirstMessageMatching(
1608 ViewMsg_HandleInputEvent::ID)); 1609 InputMsg_HandleInputEvent::ID));
1609 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( 1610 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(
1610 ViewMsg_HandleInputEvent::ID)); 1611 InputMsg_HandleInputEvent::ID));
1611 process_->sink().ClearMessages(); 1612 process_->sink().ClearMessages();
1612 1613
1613 // Check that the ACK sends the second message. 1614 // Check that the ACK sends the second message.
1614 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 1615 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
1615 INPUT_EVENT_ACK_STATE_CONSUMED); 1616 INPUT_EVENT_ACK_STATE_CONSUMED);
1616 MessageLoop::current()->RunUntilIdle(); 1617 MessageLoop::current()->RunUntilIdle();
1617 EXPECT_EQ(0U, process_->sink().message_count()); 1618 EXPECT_EQ(0U, process_->sink().message_count());
1618 1619
1619 // Check that the ACK sends the second message. 1620 // Check that the ACK sends the second message.
1620 SendInputEventACK(WebInputEvent::GesturePinchUpdate, 1621 SendInputEventACK(WebInputEvent::GesturePinchUpdate,
1621 INPUT_EVENT_ACK_STATE_CONSUMED); 1622 INPUT_EVENT_ACK_STATE_CONSUMED);
1622 MessageLoop::current()->RunUntilIdle(); 1623 MessageLoop::current()->RunUntilIdle();
1623 EXPECT_EQ(1U, process_->sink().message_count()); 1624 EXPECT_EQ(1U, process_->sink().message_count());
1624 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 1625 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
1625 ViewMsg_HandleInputEvent::ID)); 1626 InputMsg_HandleInputEvent::ID));
1626 process_->sink().ClearMessages(); 1627 process_->sink().ClearMessages();
1627 1628
1628 // Check that the queue is empty after ACK and no messages get sent. 1629 // Check that the queue is empty after ACK and no messages get sent.
1629 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 1630 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
1630 INPUT_EVENT_ACK_STATE_CONSUMED); 1631 INPUT_EVENT_ACK_STATE_CONSUMED);
1631 MessageLoop::current()->RunUntilIdle(); 1632 MessageLoop::current()->RunUntilIdle();
1632 EXPECT_EQ(0U, process_->sink().message_count()); 1633 EXPECT_EQ(0U, process_->sink().message_count());
1633 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 1634 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
1634 } 1635 }
1635 1636
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3770 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3771 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3771 3772
3772 // Since the overscroll mode has been reset, the next scroll update events 3773 // Since the overscroll mode has been reset, the next scroll update events
3773 // should reach the renderer. 3774 // should reach the renderer.
3774 SimulateGestureScrollUpdateEvent(-20, 0, 0); 3775 SimulateGestureScrollUpdateEvent(-20, 0, 0);
3775 EXPECT_EQ(1U, process_->sink().message_count()); 3776 EXPECT_EQ(1U, process_->sink().message_count());
3776 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 3777 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
3777 } 3778 }
3778 3779
3779 } // namespace content 3780 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698