OLD | NEW |
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" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 process_ = NULL; | 651 process_ = NULL; |
652 browser_context_.reset(); | 652 browser_context_.reset(); |
653 | 653 |
654 #if defined(USE_AURA) | 654 #if defined(USE_AURA) |
655 tap_suppression_controller_.reset(); | 655 tap_suppression_controller_.reset(); |
656 aura::Env::DeleteInstance(); | 656 aura::Env::DeleteInstance(); |
657 screen_.reset(); | 657 screen_.reset(); |
658 #endif | 658 #endif |
659 | 659 |
660 // Process all pending tasks to avoid leaks. | 660 // Process all pending tasks to avoid leaks. |
661 MessageLoop::current()->RunUntilIdle(); | 661 base::MessageLoop::current()->RunUntilIdle(); |
662 } | 662 } |
663 | 663 |
664 void SendInputEventACK(WebInputEvent::Type type, | 664 void SendInputEventACK(WebInputEvent::Type type, |
665 InputEventAckState ack_result) { | 665 InputEventAckState ack_result) { |
666 scoped_ptr<IPC::Message> response( | 666 scoped_ptr<IPC::Message> response( |
667 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result)); | 667 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result)); |
668 host_->OnMessageReceived(*response); | 668 host_->OnMessageReceived(*response); |
669 } | 669 } |
670 | 670 |
671 void SimulateKeyboardEvent(WebInputEvent::Type type) { | 671 void SimulateKeyboardEvent(WebInputEvent::Type type) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 815 |
816 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | 816 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
817 PickleIterator iter(message); | 817 PickleIterator iter(message); |
818 const char* data; | 818 const char* data; |
819 int data_length; | 819 int data_length; |
820 if (!message.ReadData(&iter, &data, &data_length)) | 820 if (!message.ReadData(&iter, &data, &data_length)) |
821 return NULL; | 821 return NULL; |
822 return reinterpret_cast<const WebInputEvent*>(data); | 822 return reinterpret_cast<const WebInputEvent*>(data); |
823 } | 823 } |
824 | 824 |
825 MessageLoopForUI message_loop_; | 825 base::MessageLoopForUI message_loop_; |
826 | 826 |
827 scoped_ptr<TestBrowserContext> browser_context_; | 827 scoped_ptr<TestBrowserContext> browser_context_; |
828 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 828 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
829 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; | 829 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; |
830 scoped_ptr<MockRenderWidgetHost> host_; | 830 scoped_ptr<MockRenderWidgetHost> host_; |
831 scoped_ptr<TestView> view_; | 831 scoped_ptr<TestView> view_; |
832 scoped_ptr<gfx::Screen> screen_; | 832 scoped_ptr<gfx::Screen> screen_; |
833 #if defined(USE_AURA) | 833 #if defined(USE_AURA) |
834 scoped_ptr<MockTapSuppressionController> tap_suppression_controller_; | 834 scoped_ptr<MockTapSuppressionController> tap_suppression_controller_; |
835 #endif // defined(USE_AURA) | 835 #endif // defined(USE_AURA) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 backing = host_->GetBackingStore(true); | 1090 backing = host_->GetBackingStore(true); |
1091 EXPECT_TRUE(backing); | 1091 EXPECT_TRUE(backing); |
1092 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Repaint::ID)); | 1092 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Repaint::ID)); |
1093 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( | 1093 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( |
1094 ViewMsg_UpdateRect_ACK::ID)); | 1094 ViewMsg_UpdateRect_ACK::ID)); |
1095 } | 1095 } |
1096 | 1096 |
1097 // Test that we don't paint when we're hidden, but we still send the ACK. Most | 1097 // Test that we don't paint when we're hidden, but we still send the ACK. Most |
1098 // of the rest of the painting is tested in the GetBackingStore* ones. | 1098 // of the rest of the painting is tested in the GetBackingStore* ones. |
1099 TEST_F(RenderWidgetHostTest, HiddenPaint) { | 1099 TEST_F(RenderWidgetHostTest, HiddenPaint) { |
1100 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 1100 BrowserThreadImpl ui_thread(BrowserThread::UI, base::MessageLoop::current()); |
1101 // Hide the widget, it should have sent out a message to the renderer. | 1101 // Hide the widget, it should have sent out a message to the renderer. |
1102 EXPECT_FALSE(host_->is_hidden_); | 1102 EXPECT_FALSE(host_->is_hidden_); |
1103 host_->WasHidden(); | 1103 host_->WasHidden(); |
1104 EXPECT_TRUE(host_->is_hidden_); | 1104 EXPECT_TRUE(host_->is_hidden_); |
1105 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_WasHidden::ID)); | 1105 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_WasHidden::ID)); |
1106 | 1106 |
1107 // Send it an update as from the renderer. | 1107 // Send it an update as from the renderer. |
1108 process_->sink().ClearMessages(); | 1108 process_->sink().ClearMessages(); |
1109 ViewHostMsg_UpdateRect_Params params; | 1109 ViewHostMsg_UpdateRect_Params params; |
1110 process_->InitUpdateRectParams(¶ms); | 1110 process_->InitUpdateRectParams(¶ms); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1252 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1253 InputMsg_HandleInputEvent::ID)); | 1253 InputMsg_HandleInputEvent::ID)); |
1254 process_->sink().ClearMessages(); | 1254 process_->sink().ClearMessages(); |
1255 | 1255 |
1256 // Check that the ACK sends the second message. | 1256 // Check that the ACK sends the second message. |
1257 SendInputEventACK(WebInputEvent::MouseWheel, | 1257 SendInputEventACK(WebInputEvent::MouseWheel, |
1258 INPUT_EVENT_ACK_STATE_CONSUMED); | 1258 INPUT_EVENT_ACK_STATE_CONSUMED); |
1259 // The coalesced events can queue up a delayed ack | 1259 // The coalesced events can queue up a delayed ack |
1260 // so that additional input events can be processed before | 1260 // so that additional input events can be processed before |
1261 // we turn off coalescing. | 1261 // we turn off coalescing. |
1262 MessageLoop::current()->RunUntilIdle(); | 1262 base::MessageLoop::current()->RunUntilIdle(); |
1263 EXPECT_EQ(1U, process_->sink().message_count()); | 1263 EXPECT_EQ(1U, process_->sink().message_count()); |
1264 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1264 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1265 InputMsg_HandleInputEvent::ID)); | 1265 InputMsg_HandleInputEvent::ID)); |
1266 process_->sink().ClearMessages(); | 1266 process_->sink().ClearMessages(); |
1267 | 1267 |
1268 // One more time. | 1268 // One more time. |
1269 SendInputEventACK(WebInputEvent::MouseWheel, | 1269 SendInputEventACK(WebInputEvent::MouseWheel, |
1270 INPUT_EVENT_ACK_STATE_CONSUMED); | 1270 INPUT_EVENT_ACK_STATE_CONSUMED); |
1271 MessageLoop::current()->RunUntilIdle(); | 1271 base::MessageLoop::current()->RunUntilIdle(); |
1272 EXPECT_EQ(1U, process_->sink().message_count()); | 1272 EXPECT_EQ(1U, process_->sink().message_count()); |
1273 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1273 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1274 InputMsg_HandleInputEvent::ID)); | 1274 InputMsg_HandleInputEvent::ID)); |
1275 process_->sink().ClearMessages(); | 1275 process_->sink().ClearMessages(); |
1276 | 1276 |
1277 // After the final ack, the queue should be empty. | 1277 // After the final ack, the queue should be empty. |
1278 SendInputEventACK(WebInputEvent::MouseWheel, | 1278 SendInputEventACK(WebInputEvent::MouseWheel, |
1279 INPUT_EVENT_ACK_STATE_CONSUMED); | 1279 INPUT_EVENT_ACK_STATE_CONSUMED); |
1280 MessageLoop::current()->RunUntilIdle(); | 1280 base::MessageLoop::current()->RunUntilIdle(); |
1281 EXPECT_EQ(0U, process_->sink().message_count()); | 1281 EXPECT_EQ(0U, process_->sink().message_count()); |
1282 | 1282 |
1283 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); | 1283 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); |
1284 EXPECT_EQ(0U, process_->sink().message_count()); | 1284 EXPECT_EQ(0U, process_->sink().message_count()); |
1285 } | 1285 } |
1286 | 1286 |
1287 TEST_F(RenderWidgetHostTest, CoalescesWheelEventsQueuedPhaseEndIsNotDropped) { | 1287 TEST_F(RenderWidgetHostTest, CoalescesWheelEventsQueuedPhaseEndIsNotDropped) { |
1288 process_->sink().ClearMessages(); | 1288 process_->sink().ClearMessages(); |
1289 | 1289 |
1290 // Send an initial gesture begin and ACK it. | 1290 // Send an initial gesture begin and ACK it. |
1291 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1291 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1292 WebGestureEvent::Touchpad); | 1292 WebGestureEvent::Touchpad); |
1293 EXPECT_EQ(1U, process_->sink().message_count()); | 1293 EXPECT_EQ(1U, process_->sink().message_count()); |
1294 SendInputEventACK(WebInputEvent::GestureScrollBegin, | 1294 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
1295 INPUT_EVENT_ACK_STATE_CONSUMED); | 1295 INPUT_EVENT_ACK_STATE_CONSUMED); |
1296 MessageLoop::current()->RunUntilIdle(); | 1296 base::MessageLoop::current()->RunUntilIdle(); |
1297 | 1297 |
1298 // Send a wheel event, should get sent directly. | 1298 // Send a wheel event, should get sent directly. |
1299 SimulateWheelEvent(0, -5, 0, false); | 1299 SimulateWheelEvent(0, -5, 0, false); |
1300 EXPECT_EQ(2U, process_->sink().message_count()); | 1300 EXPECT_EQ(2U, process_->sink().message_count()); |
1301 | 1301 |
1302 // Send a wheel phase end event before an ACK is received for the previous | 1302 // Send a wheel phase end event before an ACK is received for the previous |
1303 // wheel event, which should get queued. | 1303 // wheel event, which should get queued. |
1304 SimulateWheelEventWithPhase(WebMouseWheelEvent::PhaseEnded); | 1304 SimulateWheelEventWithPhase(WebMouseWheelEvent::PhaseEnded); |
1305 EXPECT_EQ(2U, process_->sink().message_count()); | 1305 EXPECT_EQ(2U, process_->sink().message_count()); |
1306 | 1306 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 | 1365 |
1366 // Check that only the first event was sent. | 1366 // Check that only the first event was sent. |
1367 EXPECT_EQ(1U, process_->sink().message_count()); | 1367 EXPECT_EQ(1U, process_->sink().message_count()); |
1368 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1368 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1369 InputMsg_HandleInputEvent::ID)); | 1369 InputMsg_HandleInputEvent::ID)); |
1370 process_->sink().ClearMessages(); | 1370 process_->sink().ClearMessages(); |
1371 | 1371 |
1372 // Check that the ACK sends the second message. | 1372 // Check that the ACK sends the second message. |
1373 SendInputEventACK(WebInputEvent::GestureScrollBegin, | 1373 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
1374 INPUT_EVENT_ACK_STATE_CONSUMED); | 1374 INPUT_EVENT_ACK_STATE_CONSUMED); |
1375 MessageLoop::current()->RunUntilIdle(); | 1375 base::MessageLoop::current()->RunUntilIdle(); |
1376 EXPECT_EQ(1U, process_->sink().message_count()); | 1376 EXPECT_EQ(1U, process_->sink().message_count()); |
1377 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1377 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1378 InputMsg_HandleInputEvent::ID)); | 1378 InputMsg_HandleInputEvent::ID)); |
1379 process_->sink().ClearMessages(); | 1379 process_->sink().ClearMessages(); |
1380 | 1380 |
1381 // Ack for queued coalesced event. | 1381 // Ack for queued coalesced event. |
1382 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1382 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1383 INPUT_EVENT_ACK_STATE_CONSUMED); | 1383 INPUT_EVENT_ACK_STATE_CONSUMED); |
1384 MessageLoop::current()->RunUntilIdle(); | 1384 base::MessageLoop::current()->RunUntilIdle(); |
1385 EXPECT_EQ(1U, process_->sink().message_count()); | 1385 EXPECT_EQ(1U, process_->sink().message_count()); |
1386 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1386 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1387 InputMsg_HandleInputEvent::ID)); | 1387 InputMsg_HandleInputEvent::ID)); |
1388 process_->sink().ClearMessages(); | 1388 process_->sink().ClearMessages(); |
1389 | 1389 |
1390 // Ack for queued uncoalesced event. | 1390 // Ack for queued uncoalesced event. |
1391 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1391 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1392 INPUT_EVENT_ACK_STATE_CONSUMED); | 1392 INPUT_EVENT_ACK_STATE_CONSUMED); |
1393 MessageLoop::current()->RunUntilIdle(); | 1393 base::MessageLoop::current()->RunUntilIdle(); |
1394 EXPECT_EQ(1U, process_->sink().message_count()); | 1394 EXPECT_EQ(1U, process_->sink().message_count()); |
1395 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1395 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1396 InputMsg_HandleInputEvent::ID)); | 1396 InputMsg_HandleInputEvent::ID)); |
1397 process_->sink().ClearMessages(); | 1397 process_->sink().ClearMessages(); |
1398 | 1398 |
1399 // After the final ack, the queue should be empty. | 1399 // After the final ack, the queue should be empty. |
1400 SendInputEventACK(WebInputEvent::GestureScrollEnd, | 1400 SendInputEventACK(WebInputEvent::GestureScrollEnd, |
1401 INPUT_EVENT_ACK_STATE_CONSUMED); | 1401 INPUT_EVENT_ACK_STATE_CONSUMED); |
1402 MessageLoop::current()->RunUntilIdle(); | 1402 base::MessageLoop::current()->RunUntilIdle(); |
1403 EXPECT_EQ(0U, process_->sink().message_count()); | 1403 EXPECT_EQ(0U, process_->sink().message_count()); |
1404 } | 1404 } |
1405 | 1405 |
1406 TEST_F(RenderWidgetHostTest, CoalescesScrollAndPinchEvents) { | 1406 TEST_F(RenderWidgetHostTest, CoalescesScrollAndPinchEvents) { |
1407 // Turn off debounce handling for test isolation. | 1407 // Turn off debounce handling for test isolation. |
1408 host_->set_debounce_interval_time_ms(0); | 1408 host_->set_debounce_interval_time_ms(0); |
1409 process_->sink().ClearMessages(); | 1409 process_->sink().ClearMessages(); |
1410 // Test coalescing of only GestureScrollUpdate events. | 1410 // Test coalescing of only GestureScrollUpdate events. |
1411 // Simulate gesture events. | 1411 // Simulate gesture events. |
1412 | 1412 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 | 1487 |
1488 // Check that only the first event was sent. | 1488 // Check that only the first event was sent. |
1489 EXPECT_EQ(1U, process_->sink().message_count()); | 1489 EXPECT_EQ(1U, process_->sink().message_count()); |
1490 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1490 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1491 InputMsg_HandleInputEvent::ID)); | 1491 InputMsg_HandleInputEvent::ID)); |
1492 process_->sink().ClearMessages(); | 1492 process_->sink().ClearMessages(); |
1493 | 1493 |
1494 // Check that the ACK sends the second message. | 1494 // Check that the ACK sends the second message. |
1495 SendInputEventACK(WebInputEvent::GestureScrollBegin, | 1495 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
1496 INPUT_EVENT_ACK_STATE_CONSUMED); | 1496 INPUT_EVENT_ACK_STATE_CONSUMED); |
1497 MessageLoop::current()->RunUntilIdle(); | 1497 base::MessageLoop::current()->RunUntilIdle(); |
1498 EXPECT_EQ(1U, process_->sink().message_count()); | 1498 EXPECT_EQ(1U, process_->sink().message_count()); |
1499 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1499 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1500 InputMsg_HandleInputEvent::ID)); | 1500 InputMsg_HandleInputEvent::ID)); |
1501 process_->sink().ClearMessages(); | 1501 process_->sink().ClearMessages(); |
1502 | 1502 |
1503 // Enqueued. | 1503 // Enqueued. |
1504 SimulateGestureScrollUpdateEvent(6, -6, 1); | 1504 SimulateGestureScrollUpdateEvent(6, -6, 1); |
1505 | 1505 |
1506 // Check whether coalesced correctly. | 1506 // Check whether coalesced correctly. |
1507 EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize()); | 1507 EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize()); |
1508 merged_event = host_->GestureEventLastQueueEvent(); | 1508 merged_event = host_->GestureEventLastQueueEvent(); |
1509 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type); | 1509 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type); |
1510 EXPECT_EQ(6, merged_event.data.pinchUpdate.scale); | 1510 EXPECT_EQ(6, merged_event.data.pinchUpdate.scale); |
1511 EXPECT_EQ(1, merged_event.modifiers); | 1511 EXPECT_EQ(1, merged_event.modifiers); |
1512 merged_event = host_->GestureEventSecondFromLastQueueEvent(); | 1512 merged_event = host_->GestureEventSecondFromLastQueueEvent(); |
1513 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); | 1513 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); |
1514 EXPECT_EQ(13, merged_event.data.scrollUpdate.deltaX); | 1514 EXPECT_EQ(13, merged_event.data.scrollUpdate.deltaX); |
1515 EXPECT_EQ(-7, merged_event.data.scrollUpdate.deltaY); | 1515 EXPECT_EQ(-7, merged_event.data.scrollUpdate.deltaY); |
1516 EXPECT_EQ(1, merged_event.modifiers); | 1516 EXPECT_EQ(1, merged_event.modifiers); |
1517 | 1517 |
1518 // At this point ACKs shouldn't be getting ignored. | 1518 // At this point ACKs shouldn't be getting ignored. |
1519 EXPECT_FALSE(host_->WillIgnoreNextACK()); | 1519 EXPECT_FALSE(host_->WillIgnoreNextACK()); |
1520 | 1520 |
1521 // Check that the ACK sends both scroll and pinch updates. | 1521 // Check that the ACK sends both scroll and pinch updates. |
1522 SendInputEventACK(WebInputEvent::GesturePinchBegin, | 1522 SendInputEventACK(WebInputEvent::GesturePinchBegin, |
1523 INPUT_EVENT_ACK_STATE_CONSUMED); | 1523 INPUT_EVENT_ACK_STATE_CONSUMED); |
1524 MessageLoop::current()->RunUntilIdle(); | 1524 base::MessageLoop::current()->RunUntilIdle(); |
1525 EXPECT_EQ(2U, process_->sink().message_count()); | 1525 EXPECT_EQ(2U, process_->sink().message_count()); |
1526 EXPECT_TRUE(process_->sink().GetFirstMessageMatching( | 1526 EXPECT_TRUE(process_->sink().GetFirstMessageMatching( |
1527 InputMsg_HandleInputEvent::ID)); | 1527 InputMsg_HandleInputEvent::ID)); |
1528 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( | 1528 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( |
1529 InputMsg_HandleInputEvent::ID)); | 1529 InputMsg_HandleInputEvent::ID)); |
1530 process_->sink().ClearMessages(); | 1530 process_->sink().ClearMessages(); |
1531 | 1531 |
1532 // The next ACK should be getting ignored. | 1532 // The next ACK should be getting ignored. |
1533 EXPECT_TRUE(host_->WillIgnoreNextACK()); | 1533 EXPECT_TRUE(host_->WillIgnoreNextACK()); |
1534 | 1534 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 EXPECT_EQ(1, merged_event.modifiers); | 1573 EXPECT_EQ(1, merged_event.modifiers); |
1574 merged_event = host_->GestureEventSecondFromLastQueueEvent(); | 1574 merged_event = host_->GestureEventSecondFromLastQueueEvent(); |
1575 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); | 1575 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); |
1576 EXPECT_EQ(3, merged_event.data.scrollUpdate.deltaX); | 1576 EXPECT_EQ(3, merged_event.data.scrollUpdate.deltaX); |
1577 EXPECT_EQ(-3, merged_event.data.scrollUpdate.deltaY); | 1577 EXPECT_EQ(-3, merged_event.data.scrollUpdate.deltaY); |
1578 EXPECT_EQ(1, merged_event.modifiers); | 1578 EXPECT_EQ(1, merged_event.modifiers); |
1579 | 1579 |
1580 // Check that the ACK gets ignored. | 1580 // Check that the ACK gets ignored. |
1581 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1581 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1582 INPUT_EVENT_ACK_STATE_CONSUMED); | 1582 INPUT_EVENT_ACK_STATE_CONSUMED); |
1583 MessageLoop::current()->RunUntilIdle(); | 1583 base::MessageLoop::current()->RunUntilIdle(); |
1584 EXPECT_EQ(0U, process_->sink().message_count()); | 1584 EXPECT_EQ(0U, process_->sink().message_count()); |
1585 // The flag should have been flipped back to false. | 1585 // The flag should have been flipped back to false. |
1586 EXPECT_FALSE(host_->WillIgnoreNextACK()); | 1586 EXPECT_FALSE(host_->WillIgnoreNextACK()); |
1587 | 1587 |
1588 // Enqueued. | 1588 // Enqueued. |
1589 SimulateGestureScrollUpdateEvent(2, -2, 2); | 1589 SimulateGestureScrollUpdateEvent(2, -2, 2); |
1590 | 1590 |
1591 // Shouldn't coalesce with different modifiers. | 1591 // Shouldn't coalesce with different modifiers. |
1592 EXPECT_EQ(4U, host_->GestureEventLastQueueEventSize()); | 1592 EXPECT_EQ(4U, host_->GestureEventLastQueueEventSize()); |
1593 merged_event = host_->GestureEventLastQueueEvent(); | 1593 merged_event = host_->GestureEventLastQueueEvent(); |
1594 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); | 1594 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type); |
1595 EXPECT_EQ(2, merged_event.data.scrollUpdate.deltaX); | 1595 EXPECT_EQ(2, merged_event.data.scrollUpdate.deltaX); |
1596 EXPECT_EQ(-2, merged_event.data.scrollUpdate.deltaY); | 1596 EXPECT_EQ(-2, merged_event.data.scrollUpdate.deltaY); |
1597 EXPECT_EQ(2, merged_event.modifiers); | 1597 EXPECT_EQ(2, merged_event.modifiers); |
1598 merged_event = host_->GestureEventSecondFromLastQueueEvent(); | 1598 merged_event = host_->GestureEventSecondFromLastQueueEvent(); |
1599 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type); | 1599 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, merged_event.type); |
1600 EXPECT_EQ(0.5, merged_event.data.pinchUpdate.scale); | 1600 EXPECT_EQ(0.5, merged_event.data.pinchUpdate.scale); |
1601 EXPECT_EQ(1, merged_event.modifiers); | 1601 EXPECT_EQ(1, merged_event.modifiers); |
1602 | 1602 |
1603 // Check that the ACK sends the next scroll pinch pair. | 1603 // Check that the ACK sends the next scroll pinch pair. |
1604 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 1604 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
1605 INPUT_EVENT_ACK_STATE_CONSUMED); | 1605 INPUT_EVENT_ACK_STATE_CONSUMED); |
1606 MessageLoop::current()->RunUntilIdle(); | 1606 base::MessageLoop::current()->RunUntilIdle(); |
1607 EXPECT_EQ(2U, process_->sink().message_count()); | 1607 EXPECT_EQ(2U, process_->sink().message_count()); |
1608 EXPECT_TRUE(process_->sink().GetFirstMessageMatching( | 1608 EXPECT_TRUE(process_->sink().GetFirstMessageMatching( |
1609 InputMsg_HandleInputEvent::ID)); | 1609 InputMsg_HandleInputEvent::ID)); |
1610 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( | 1610 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching( |
1611 InputMsg_HandleInputEvent::ID)); | 1611 InputMsg_HandleInputEvent::ID)); |
1612 process_->sink().ClearMessages(); | 1612 process_->sink().ClearMessages(); |
1613 | 1613 |
1614 // Check that the ACK sends the second message. | 1614 // Check that the ACK sends the second message. |
1615 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1615 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1616 INPUT_EVENT_ACK_STATE_CONSUMED); | 1616 INPUT_EVENT_ACK_STATE_CONSUMED); |
1617 MessageLoop::current()->RunUntilIdle(); | 1617 base::MessageLoop::current()->RunUntilIdle(); |
1618 EXPECT_EQ(0U, process_->sink().message_count()); | 1618 EXPECT_EQ(0U, process_->sink().message_count()); |
1619 | 1619 |
1620 // Check that the ACK sends the second message. | 1620 // Check that the ACK sends the second message. |
1621 SendInputEventACK(WebInputEvent::GesturePinchUpdate, | 1621 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
1622 INPUT_EVENT_ACK_STATE_CONSUMED); | 1622 INPUT_EVENT_ACK_STATE_CONSUMED); |
1623 MessageLoop::current()->RunUntilIdle(); | 1623 base::MessageLoop::current()->RunUntilIdle(); |
1624 EXPECT_EQ(1U, process_->sink().message_count()); | 1624 EXPECT_EQ(1U, process_->sink().message_count()); |
1625 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1625 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
1626 InputMsg_HandleInputEvent::ID)); | 1626 InputMsg_HandleInputEvent::ID)); |
1627 process_->sink().ClearMessages(); | 1627 process_->sink().ClearMessages(); |
1628 | 1628 |
1629 // 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. |
1630 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1630 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1631 INPUT_EVENT_ACK_STATE_CONSUMED); | 1631 INPUT_EVENT_ACK_STATE_CONSUMED); |
1632 MessageLoop::current()->RunUntilIdle(); | 1632 base::MessageLoop::current()->RunUntilIdle(); |
1633 EXPECT_EQ(0U, process_->sink().message_count()); | 1633 EXPECT_EQ(0U, process_->sink().message_count()); |
1634 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1634 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1635 } | 1635 } |
1636 | 1636 |
1637 #if GTEST_HAS_PARAM_TEST | 1637 #if GTEST_HAS_PARAM_TEST |
1638 TEST_P(RenderWidgetHostWithSourceTest, GestureFlingCancelsFiltered) { | 1638 TEST_P(RenderWidgetHostWithSourceTest, GestureFlingCancelsFiltered) { |
1639 WebGestureEvent::SourceDevice source_device = GetParam(); | 1639 WebGestureEvent::SourceDevice source_device = GetParam(); |
1640 | 1640 |
1641 // Turn off debounce handling for test isolation. | 1641 // Turn off debounce handling for test isolation. |
1642 host_->set_debounce_interval_time_ms(0); | 1642 host_->set_debounce_interval_time_ms(0); |
1643 process_->sink().ClearMessages(); | 1643 process_->sink().ClearMessages(); |
1644 // GFC without previous GFS is dropped. | 1644 // GFC without previous GFS is dropped. |
1645 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); | 1645 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); |
1646 EXPECT_EQ(0U, process_->sink().message_count()); | 1646 EXPECT_EQ(0U, process_->sink().message_count()); |
1647 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1647 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1648 | 1648 |
1649 // GFC after previous GFS is dispatched and acked. | 1649 // GFC after previous GFS is dispatched and acked. |
1650 process_->sink().ClearMessages(); | 1650 process_->sink().ClearMessages(); |
1651 SimulateGestureFlingStartEvent(0, -10, source_device); | 1651 SimulateGestureFlingStartEvent(0, -10, source_device); |
1652 EXPECT_TRUE(host_->FlingInProgress()); | 1652 EXPECT_TRUE(host_->FlingInProgress()); |
1653 SendInputEventACK(WebInputEvent::GestureFlingStart, | 1653 SendInputEventACK(WebInputEvent::GestureFlingStart, |
1654 INPUT_EVENT_ACK_STATE_CONSUMED); | 1654 INPUT_EVENT_ACK_STATE_CONSUMED); |
1655 MessageLoop::current()->RunUntilIdle(); | 1655 base::MessageLoop::current()->RunUntilIdle(); |
1656 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); | 1656 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); |
1657 EXPECT_FALSE(host_->FlingInProgress()); | 1657 EXPECT_FALSE(host_->FlingInProgress()); |
1658 EXPECT_EQ(2U, process_->sink().message_count()); | 1658 EXPECT_EQ(2U, process_->sink().message_count()); |
1659 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 1659 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
1660 INPUT_EVENT_ACK_STATE_CONSUMED); | 1660 INPUT_EVENT_ACK_STATE_CONSUMED); |
1661 MessageLoop::current()->RunUntilIdle(); | 1661 base::MessageLoop::current()->RunUntilIdle(); |
1662 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1662 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1663 | 1663 |
1664 // GFC before previous GFS is acked. | 1664 // GFC before previous GFS is acked. |
1665 process_->sink().ClearMessages(); | 1665 process_->sink().ClearMessages(); |
1666 SimulateGestureFlingStartEvent(0, -10, source_device); | 1666 SimulateGestureFlingStartEvent(0, -10, source_device); |
1667 EXPECT_TRUE(host_->FlingInProgress()); | 1667 EXPECT_TRUE(host_->FlingInProgress()); |
1668 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); | 1668 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, source_device); |
1669 EXPECT_FALSE(host_->FlingInProgress()); | 1669 EXPECT_FALSE(host_->FlingInProgress()); |
1670 EXPECT_EQ(1U, process_->sink().message_count()); | 1670 EXPECT_EQ(1U, process_->sink().message_count()); |
1671 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); | 1671 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); |
1672 | 1672 |
1673 // Advance state realistically. | 1673 // Advance state realistically. |
1674 SendInputEventACK(WebInputEvent::GestureFlingStart, | 1674 SendInputEventACK(WebInputEvent::GestureFlingStart, |
1675 INPUT_EVENT_ACK_STATE_CONSUMED); | 1675 INPUT_EVENT_ACK_STATE_CONSUMED); |
1676 MessageLoop::current()->RunUntilIdle(); | 1676 base::MessageLoop::current()->RunUntilIdle(); |
1677 SendInputEventACK(WebInputEvent::GestureFlingCancel, | 1677 SendInputEventACK(WebInputEvent::GestureFlingCancel, |
1678 INPUT_EVENT_ACK_STATE_CONSUMED); | 1678 INPUT_EVENT_ACK_STATE_CONSUMED); |
1679 MessageLoop::current()->RunUntilIdle(); | 1679 base::MessageLoop::current()->RunUntilIdle(); |
1680 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1680 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1681 | 1681 |
1682 // GFS is added to the queue if another event is pending | 1682 // GFS is added to the queue if another event is pending |
1683 process_->sink().ClearMessages(); | 1683 process_->sink().ClearMessages(); |
1684 SimulateGestureScrollUpdateEvent(8, -7, 0); | 1684 SimulateGestureScrollUpdateEvent(8, -7, 0); |
1685 SimulateGestureFlingStartEvent(0, -10, source_device); | 1685 SimulateGestureFlingStartEvent(0, -10, source_device); |
1686 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); | 1686 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); |
1687 EXPECT_EQ(1U, process_->sink().message_count()); | 1687 EXPECT_EQ(1U, process_->sink().message_count()); |
1688 WebGestureEvent merged_event = host_->GestureEventLastQueueEvent(); | 1688 WebGestureEvent merged_event = host_->GestureEventLastQueueEvent(); |
1689 EXPECT_EQ(WebInputEvent::GestureFlingStart, merged_event.type); | 1689 EXPECT_EQ(WebInputEvent::GestureFlingStart, merged_event.type); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 | 1736 |
1737 // Set some sort of short deferral timeout | 1737 // Set some sort of short deferral timeout |
1738 host_->set_maximum_tap_gap_time_ms(5); | 1738 host_->set_maximum_tap_gap_time_ms(5); |
1739 | 1739 |
1740 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1740 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1741 WebGestureEvent::Touchscreen); | 1741 WebGestureEvent::Touchscreen); |
1742 EXPECT_EQ(0U, process_->sink().message_count()); | 1742 EXPECT_EQ(0U, process_->sink().message_count()); |
1743 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1743 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1744 | 1744 |
1745 // Wait long enough for first timeout and see if it fired. | 1745 // Wait long enough for first timeout and see if it fired. |
1746 MessageLoop::current()->PostDelayedTask( | 1746 base::MessageLoop::current()->PostDelayedTask( |
1747 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 1747 FROM_HERE, |
1748 MessageLoop::current()->Run(); | 1748 base::MessageLoop::QuitClosure(), |
| 1749 TimeDelta::FromMilliseconds(10)); |
| 1750 base::MessageLoop::current()->Run(); |
1749 | 1751 |
1750 EXPECT_EQ(1U, process_->sink().message_count()); | 1752 EXPECT_EQ(1U, process_->sink().message_count()); |
1751 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1753 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1752 EXPECT_EQ(WebInputEvent::GestureTapDown, | 1754 EXPECT_EQ(WebInputEvent::GestureTapDown, |
1753 host_->GestureEventLastQueueEvent().type); | 1755 host_->GestureEventLastQueueEvent().type); |
1754 } | 1756 } |
1755 | 1757 |
1756 // Test that GestureTapDown events are sent immediately on GestureTap. | 1758 // Test that GestureTapDown events are sent immediately on GestureTap. |
1757 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownSentOnTap) { | 1759 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownSentOnTap) { |
1758 process_->sink().ClearMessages(); | 1760 process_->sink().ClearMessages(); |
1759 | 1761 |
1760 // Set some sort of short deferral timeout | 1762 // Set some sort of short deferral timeout |
1761 host_->set_maximum_tap_gap_time_ms(5); | 1763 host_->set_maximum_tap_gap_time_ms(5); |
1762 | 1764 |
1763 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1765 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1764 WebGestureEvent::Touchscreen); | 1766 WebGestureEvent::Touchscreen); |
1765 EXPECT_EQ(0U, process_->sink().message_count()); | 1767 EXPECT_EQ(0U, process_->sink().message_count()); |
1766 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1768 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1767 | 1769 |
1768 SimulateGestureEvent(WebInputEvent::GestureTap, | 1770 SimulateGestureEvent(WebInputEvent::GestureTap, |
1769 WebGestureEvent::Touchscreen); | 1771 WebGestureEvent::Touchscreen); |
1770 EXPECT_EQ(1U, process_->sink().message_count()); | 1772 EXPECT_EQ(1U, process_->sink().message_count()); |
1771 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); | 1773 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); |
1772 EXPECT_EQ(WebInputEvent::GestureTap, | 1774 EXPECT_EQ(WebInputEvent::GestureTap, |
1773 host_->GestureEventLastQueueEvent().type); | 1775 host_->GestureEventLastQueueEvent().type); |
1774 | 1776 |
1775 MessageLoop::current()->PostDelayedTask( | 1777 base::MessageLoop::current()->PostDelayedTask( |
1776 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 1778 FROM_HERE, |
1777 MessageLoop::current()->Run(); | 1779 base::MessageLoop::QuitClosure(), |
| 1780 TimeDelta::FromMilliseconds(10)); |
| 1781 base::MessageLoop::current()->Run(); |
1778 | 1782 |
1779 // If the deferral timer incorrectly fired, it sent an extra message. | 1783 // If the deferral timer incorrectly fired, it sent an extra message. |
1780 EXPECT_EQ(1U, process_->sink().message_count()); | 1784 EXPECT_EQ(1U, process_->sink().message_count()); |
1781 } | 1785 } |
1782 | 1786 |
1783 // Test that only a single GestureTapDown event is sent when tap occurs after | 1787 // Test that only a single GestureTapDown event is sent when tap occurs after |
1784 // the timeout. | 1788 // the timeout. |
1785 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownOnlyOnce) { | 1789 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownOnlyOnce) { |
1786 process_->sink().ClearMessages(); | 1790 process_->sink().ClearMessages(); |
1787 | 1791 |
1788 // Set some sort of short deferral timeout | 1792 // Set some sort of short deferral timeout |
1789 host_->set_maximum_tap_gap_time_ms(5); | 1793 host_->set_maximum_tap_gap_time_ms(5); |
1790 | 1794 |
1791 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1795 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1792 WebGestureEvent::Touchscreen); | 1796 WebGestureEvent::Touchscreen); |
1793 EXPECT_EQ(0U, process_->sink().message_count()); | 1797 EXPECT_EQ(0U, process_->sink().message_count()); |
1794 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1798 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1795 | 1799 |
1796 // Wait long enough for the timeout and verify it fired. | 1800 // Wait long enough for the timeout and verify it fired. |
1797 MessageLoop::current()->PostDelayedTask( | 1801 base::MessageLoop::current()->PostDelayedTask( |
1798 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 1802 FROM_HERE, |
1799 MessageLoop::current()->Run(); | 1803 base::MessageLoop::QuitClosure(), |
| 1804 TimeDelta::FromMilliseconds(10)); |
| 1805 base::MessageLoop::current()->Run(); |
1800 | 1806 |
1801 EXPECT_EQ(1U, process_->sink().message_count()); | 1807 EXPECT_EQ(1U, process_->sink().message_count()); |
1802 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1808 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1803 EXPECT_EQ(WebInputEvent::GestureTapDown, | 1809 EXPECT_EQ(WebInputEvent::GestureTapDown, |
1804 host_->GestureEventLastQueueEvent().type); | 1810 host_->GestureEventLastQueueEvent().type); |
1805 | 1811 |
1806 // Now send the tap gesture and verify we didn't get an extra TapDown. | 1812 // Now send the tap gesture and verify we didn't get an extra TapDown. |
1807 SimulateGestureEvent(WebInputEvent::GestureTap, | 1813 SimulateGestureEvent(WebInputEvent::GestureTap, |
1808 WebGestureEvent::Touchscreen); | 1814 WebGestureEvent::Touchscreen); |
1809 EXPECT_EQ(1U, process_->sink().message_count()); | 1815 EXPECT_EQ(1U, process_->sink().message_count()); |
(...skipping 14 matching lines...) Expand all Loading... |
1824 EXPECT_EQ(0U, process_->sink().message_count()); | 1830 EXPECT_EQ(0U, process_->sink().message_count()); |
1825 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1831 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1826 | 1832 |
1827 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1833 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1828 WebGestureEvent::Touchscreen); | 1834 WebGestureEvent::Touchscreen); |
1829 EXPECT_EQ(1U, process_->sink().message_count()); | 1835 EXPECT_EQ(1U, process_->sink().message_count()); |
1830 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1836 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1831 EXPECT_EQ(WebInputEvent::GestureScrollBegin, | 1837 EXPECT_EQ(WebInputEvent::GestureScrollBegin, |
1832 host_->GestureEventLastQueueEvent().type); | 1838 host_->GestureEventLastQueueEvent().type); |
1833 | 1839 |
1834 MessageLoop::current()->PostDelayedTask( | 1840 base::MessageLoop::current()->PostDelayedTask( |
1835 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 1841 FROM_HERE, |
1836 MessageLoop::current()->Run(); | 1842 base::MessageLoop::QuitClosure(), |
| 1843 TimeDelta::FromMilliseconds(10)); |
| 1844 base::MessageLoop::current()->Run(); |
1837 | 1845 |
1838 // If the deferral timer incorrectly fired, it will send an extra message. | 1846 // If the deferral timer incorrectly fired, it will send an extra message. |
1839 EXPECT_EQ(1U, process_->sink().message_count()); | 1847 EXPECT_EQ(1U, process_->sink().message_count()); |
1840 } | 1848 } |
1841 | 1849 |
1842 // Test that a tap cancel event during the deferral interval drops the | 1850 // Test that a tap cancel event during the deferral interval drops the |
1843 // GestureTapDown. | 1851 // GestureTapDown. |
1844 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownAnulledOnTapCancel) { | 1852 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownAnulledOnTapCancel) { |
1845 process_->sink().ClearMessages(); | 1853 process_->sink().ClearMessages(); |
1846 | 1854 |
1847 // Set some sort of short deferral timeout | 1855 // Set some sort of short deferral timeout |
1848 host_->set_maximum_tap_gap_time_ms(5); | 1856 host_->set_maximum_tap_gap_time_ms(5); |
1849 | 1857 |
1850 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1858 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1851 WebGestureEvent::Touchscreen); | 1859 WebGestureEvent::Touchscreen); |
1852 EXPECT_EQ(0U, process_->sink().message_count()); | 1860 EXPECT_EQ(0U, process_->sink().message_count()); |
1853 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1861 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1854 | 1862 |
1855 SimulateGestureEvent(WebInputEvent::GestureTapCancel, | 1863 SimulateGestureEvent(WebInputEvent::GestureTapCancel, |
1856 WebGestureEvent::Touchscreen); | 1864 WebGestureEvent::Touchscreen); |
1857 EXPECT_EQ(0U, process_->sink().message_count()); | 1865 EXPECT_EQ(0U, process_->sink().message_count()); |
1858 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1866 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1859 | 1867 |
1860 MessageLoop::current()->PostDelayedTask( | 1868 base::MessageLoop::current()->PostDelayedTask( |
1861 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 1869 FROM_HERE, |
1862 MessageLoop::current()->Run(); | 1870 base::MessageLoop::QuitClosure(), |
| 1871 TimeDelta::FromMilliseconds(10)); |
| 1872 base::MessageLoop::current()->Run(); |
1863 | 1873 |
1864 // If the deferral timer incorrectly fired, it will send an extra message. | 1874 // If the deferral timer incorrectly fired, it will send an extra message. |
1865 EXPECT_EQ(0U, process_->sink().message_count()); | 1875 EXPECT_EQ(0U, process_->sink().message_count()); |
1866 } | 1876 } |
1867 | 1877 |
1868 // Test that if a GestureTapDown gets sent, any corresponding GestureTapCancel | 1878 // Test that if a GestureTapDown gets sent, any corresponding GestureTapCancel |
1869 // is also sent. | 1879 // is also sent. |
1870 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownTapCancel) { | 1880 TEST_F(RenderWidgetHostTest, DeferredGestureTapDownTapCancel) { |
1871 process_->sink().ClearMessages(); | 1881 process_->sink().ClearMessages(); |
1872 | 1882 |
1873 // Set some sort of short deferral timeout | 1883 // Set some sort of short deferral timeout |
1874 host_->set_maximum_tap_gap_time_ms(5); | 1884 host_->set_maximum_tap_gap_time_ms(5); |
1875 | 1885 |
1876 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1886 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1877 WebGestureEvent::Touchscreen); | 1887 WebGestureEvent::Touchscreen); |
1878 EXPECT_EQ(0U, process_->sink().message_count()); | 1888 EXPECT_EQ(0U, process_->sink().message_count()); |
1879 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1889 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
1880 | 1890 |
1881 MessageLoop::current()->PostDelayedTask( | 1891 base::MessageLoop::current()->PostDelayedTask( |
1882 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 1892 FROM_HERE, |
1883 MessageLoop::current()->Run(); | 1893 base::MessageLoop::QuitClosure(), |
| 1894 TimeDelta::FromMilliseconds(10)); |
| 1895 base::MessageLoop::current()->Run(); |
1884 | 1896 |
1885 EXPECT_EQ(1U, process_->sink().message_count()); | 1897 EXPECT_EQ(1U, process_->sink().message_count()); |
1886 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1898 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
1887 | 1899 |
1888 SimulateGestureEvent(WebInputEvent::GestureTapCancel, | 1900 SimulateGestureEvent(WebInputEvent::GestureTapCancel, |
1889 WebGestureEvent::Touchscreen); | 1901 WebGestureEvent::Touchscreen); |
1890 EXPECT_EQ(1U, process_->sink().message_count()); | 1902 EXPECT_EQ(1U, process_->sink().message_count()); |
1891 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); | 1903 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); |
1892 } | 1904 } |
1893 | 1905 |
(...skipping 29 matching lines...) Expand all Loading... |
1923 EXPECT_EQ(1U, process_->sink().message_count()); | 1935 EXPECT_EQ(1U, process_->sink().message_count()); |
1924 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); | 1936 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); |
1925 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize()); | 1937 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize()); |
1926 | 1938 |
1927 SimulateGestureEvent(WebInputEvent::GestureTapDown, | 1939 SimulateGestureEvent(WebInputEvent::GestureTapDown, |
1928 WebGestureEvent::Touchscreen); | 1940 WebGestureEvent::Touchscreen); |
1929 EXPECT_EQ(1U, process_->sink().message_count()); | 1941 EXPECT_EQ(1U, process_->sink().message_count()); |
1930 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); | 1942 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); |
1931 EXPECT_EQ(3U, host_->GestureEventDebouncingQueueSize()); | 1943 EXPECT_EQ(3U, host_->GestureEventDebouncingQueueSize()); |
1932 | 1944 |
1933 MessageLoop::current()->PostDelayedTask( | 1945 base::MessageLoop::current()->PostDelayedTask( |
1934 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(5)); | 1946 FROM_HERE, |
1935 MessageLoop::current()->Run(); | 1947 base::MessageLoop::QuitClosure(), |
| 1948 TimeDelta::FromMilliseconds(5)); |
| 1949 base::MessageLoop::current()->Run(); |
1936 | 1950 |
1937 // The deferred events are correctly queued in coalescing queue. | 1951 // The deferred events are correctly queued in coalescing queue. |
1938 EXPECT_EQ(1U, process_->sink().message_count()); | 1952 EXPECT_EQ(1U, process_->sink().message_count()); |
1939 if (host_->shouldDeferTapDownEvents()) | 1953 if (host_->shouldDeferTapDownEvents()) |
1940 // NOTE: The TapDown is still deferred hence not queued. | 1954 // NOTE: The TapDown is still deferred hence not queued. |
1941 EXPECT_EQ(4U, host_->GestureEventLastQueueEventSize()); | 1955 EXPECT_EQ(4U, host_->GestureEventLastQueueEventSize()); |
1942 else | 1956 else |
1943 EXPECT_EQ(5U, host_->GestureEventLastQueueEventSize()); | 1957 EXPECT_EQ(5U, host_->GestureEventLastQueueEventSize()); |
1944 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1958 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
1945 EXPECT_FALSE(host_->ScrollingInProgress()); | 1959 EXPECT_FALSE(host_->ScrollingInProgress()); |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2970 // while one is in progress (see crbug.com/11007). | 2984 // while one is in progress (see crbug.com/11007). |
2971 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { | 2985 TEST_F(RenderWidgetHostTest, DontPostponeHangMonitorTimeout) { |
2972 // Start with a short timeout. | 2986 // Start with a short timeout. |
2973 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 2987 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
2974 | 2988 |
2975 // Immediately try to add a long 30 second timeout. | 2989 // Immediately try to add a long 30 second timeout. |
2976 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 2990 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
2977 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); | 2991 host_->StartHangMonitorTimeout(TimeDelta::FromSeconds(30)); |
2978 | 2992 |
2979 // Wait long enough for first timeout and see if it fired. | 2993 // Wait long enough for first timeout and see if it fired. |
2980 MessageLoop::current()->PostDelayedTask( | 2994 base::MessageLoop::current()->PostDelayedTask( |
2981 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 2995 FROM_HERE, |
2982 MessageLoop::current()->Run(); | 2996 base::MessageLoop::QuitClosure(), |
| 2997 TimeDelta::FromMilliseconds(10)); |
| 2998 base::MessageLoop::current()->Run(); |
2983 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 2999 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
2984 } | 3000 } |
2985 | 3001 |
2986 // Test that the hang monitor timer expires properly if it is started, stopped, | 3002 // Test that the hang monitor timer expires properly if it is started, stopped, |
2987 // and then started again. | 3003 // and then started again. |
2988 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { | 3004 TEST_F(RenderWidgetHostTest, StopAndStartHangMonitorTimeout) { |
2989 // Start with a short timeout, then stop it. | 3005 // Start with a short timeout, then stop it. |
2990 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 3006 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
2991 host_->StopHangMonitorTimeout(); | 3007 host_->StopHangMonitorTimeout(); |
2992 | 3008 |
2993 // Start it again to ensure it still works. | 3009 // Start it again to ensure it still works. |
2994 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 3010 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
2995 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 3011 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
2996 | 3012 |
2997 // Wait long enough for first timeout and see if it fired. | 3013 // Wait long enough for first timeout and see if it fired. |
2998 MessageLoop::current()->PostDelayedTask( | 3014 base::MessageLoop::current()->PostDelayedTask( |
2999 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); | 3015 FROM_HERE, |
3000 MessageLoop::current()->Run(); | 3016 base::MessageLoop::QuitClosure(), |
| 3017 TimeDelta::FromMilliseconds(40)); |
| 3018 base::MessageLoop::current()->Run(); |
3001 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 3019 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
3002 } | 3020 } |
3003 | 3021 |
3004 // Test that the hang monitor timer expires properly if it is started, then | 3022 // Test that the hang monitor timer expires properly if it is started, then |
3005 // updated to a shorter duration. | 3023 // updated to a shorter duration. |
3006 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { | 3024 TEST_F(RenderWidgetHostTest, ShorterDelayHangMonitorTimeout) { |
3007 // Start with a timeout. | 3025 // Start with a timeout. |
3008 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(100)); | 3026 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(100)); |
3009 | 3027 |
3010 // Start it again with shorter delay. | 3028 // Start it again with shorter delay. |
3011 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 3029 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
3012 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20)); | 3030 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(20)); |
3013 | 3031 |
3014 // Wait long enough for the second timeout and see if it fired. | 3032 // Wait long enough for the second timeout and see if it fired. |
3015 MessageLoop::current()->PostDelayedTask( | 3033 base::MessageLoop::current()->PostDelayedTask( |
3016 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(25)); | 3034 FROM_HERE, |
3017 MessageLoop::current()->Run(); | 3035 base::MessageLoop::QuitClosure(), |
| 3036 TimeDelta::FromMilliseconds(25)); |
| 3037 base::MessageLoop::current()->Run(); |
3018 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 3038 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
3019 } | 3039 } |
3020 | 3040 |
3021 // Test that the hang monitor catches two input events but only one ack. | 3041 // Test that the hang monitor catches two input events but only one ack. |
3022 // This can happen if the second input event causes the renderer to hang. | 3042 // This can happen if the second input event causes the renderer to hang. |
3023 // This test will catch a regression of crbug.com/111185. | 3043 // This test will catch a regression of crbug.com/111185. |
3024 TEST_F(RenderWidgetHostTest, MultipleInputEvents) { | 3044 TEST_F(RenderWidgetHostTest, MultipleInputEvents) { |
3025 // Configure the host to wait 10ms before considering | 3045 // Configure the host to wait 10ms before considering |
3026 // the renderer hung. | 3046 // the renderer hung. |
3027 host_->set_hung_renderer_delay_ms(10); | 3047 host_->set_hung_renderer_delay_ms(10); |
3028 | 3048 |
3029 // Send two events but only one ack. | 3049 // Send two events but only one ack. |
3030 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 3050 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
3031 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 3051 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
3032 SendInputEventACK(WebInputEvent::RawKeyDown, | 3052 SendInputEventACK(WebInputEvent::RawKeyDown, |
3033 INPUT_EVENT_ACK_STATE_CONSUMED); | 3053 INPUT_EVENT_ACK_STATE_CONSUMED); |
3034 | 3054 |
3035 // Wait long enough for first timeout and see if it fired. | 3055 // Wait long enough for first timeout and see if it fired. |
3036 MessageLoop::current()->PostDelayedTask( | 3056 base::MessageLoop::current()->PostDelayedTask( |
3037 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(40)); | 3057 FROM_HERE, |
3038 MessageLoop::current()->Run(); | 3058 base::MessageLoop::QuitClosure(), |
| 3059 TimeDelta::FromMilliseconds(40)); |
| 3060 base::MessageLoop::current()->Run(); |
3039 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 3061 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
3040 } | 3062 } |
3041 | 3063 |
3042 // This test is not valid for Windows because getting the shared memory | 3064 // This test is not valid for Windows because getting the shared memory |
3043 // size doesn't work. | 3065 // size doesn't work. |
3044 #if !defined(OS_WIN) | 3066 #if !defined(OS_WIN) |
3045 TEST_F(RenderWidgetHostTest, IncorrectBitmapScaleFactor) { | 3067 TEST_F(RenderWidgetHostTest, IncorrectBitmapScaleFactor) { |
3046 ViewHostMsg_UpdateRect_Params params; | 3068 ViewHostMsg_UpdateRect_Params params; |
3047 process_->InitUpdateRectParams(¶ms); | 3069 process_->InitUpdateRectParams(¶ms); |
3048 params.scale_factor = params.scale_factor * 2; | 3070 params.scale_factor = params.scale_factor * 2; |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3486 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); | 3508 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); |
3487 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 3509 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
3488 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); | 3510 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); |
3489 EXPECT_EQ(0U, process_->sink().message_count()); | 3511 EXPECT_EQ(0U, process_->sink().message_count()); |
3490 | 3512 |
3491 // Let the timer for the debounce queue fire. That should release the queued | 3513 // Let the timer for the debounce queue fire. That should release the queued |
3492 // scroll-end event. Since overscroll has started, but there hasn't been | 3514 // scroll-end event. Since overscroll has started, but there hasn't been |
3493 // enough overscroll to complete the gesture, the overscroll controller | 3515 // enough overscroll to complete the gesture, the overscroll controller |
3494 // will reset the state. The scroll-end should therefore be dispatched to the | 3516 // will reset the state. The scroll-end should therefore be dispatched to the |
3495 // renderer, and the gesture-event-filter should await an ACK for it. | 3517 // renderer, and the gesture-event-filter should await an ACK for it. |
3496 MessageLoop::current()->PostDelayedTask( | 3518 base::MessageLoop::current()->PostDelayedTask( |
3497 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(15)); | 3519 FROM_HERE, |
3498 MessageLoop::current()->Run(); | 3520 base::MessageLoop::QuitClosure(), |
| 3521 TimeDelta::FromMilliseconds(15)); |
| 3522 base::MessageLoop::current()->Run(); |
3499 | 3523 |
3500 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3524 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3501 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 3525 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
3502 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 3526 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
3503 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 3527 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
3504 EXPECT_EQ(1U, process_->sink().message_count()); | 3528 EXPECT_EQ(1U, process_->sink().message_count()); |
3505 } | 3529 } |
3506 | 3530 |
3507 // Tests that when touch-events are dispatched to the renderer, the overscroll | 3531 // Tests that when touch-events are dispatched to the renderer, the overscroll |
3508 // gesture deals with them correctly. | 3532 // gesture deals with them correctly. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3605 EXPECT_EQ(1U, host_->TouchEventQueueSize()); | 3629 EXPECT_EQ(1U, host_->TouchEventQueueSize()); |
3606 process_->sink().ClearMessages(); | 3630 process_->sink().ClearMessages(); |
3607 | 3631 |
3608 SendInputEventACK(WebInputEvent::TouchEnd, | 3632 SendInputEventACK(WebInputEvent::TouchEnd, |
3609 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3633 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3610 EXPECT_EQ(0U, process_->sink().message_count()); | 3634 EXPECT_EQ(0U, process_->sink().message_count()); |
3611 EXPECT_EQ(0U, host_->TouchEventQueueSize()); | 3635 EXPECT_EQ(0U, host_->TouchEventQueueSize()); |
3612 | 3636 |
3613 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, | 3637 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, |
3614 WebGestureEvent::Touchscreen); | 3638 WebGestureEvent::Touchscreen); |
3615 MessageLoop::current()->PostDelayedTask( | 3639 base::MessageLoop::current()->PostDelayedTask( |
3616 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 3640 FROM_HERE, |
3617 MessageLoop::current()->Run(); | 3641 base::MessageLoop::QuitClosure(), |
| 3642 TimeDelta::FromMilliseconds(10)); |
| 3643 base::MessageLoop::current()->Run(); |
3618 EXPECT_EQ(1U, process_->sink().message_count()); | 3644 EXPECT_EQ(1U, process_->sink().message_count()); |
3619 EXPECT_EQ(0U, host_->TouchEventQueueSize()); | 3645 EXPECT_EQ(0U, host_->TouchEventQueueSize()); |
3620 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3646 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3621 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 3647 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
3622 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 3648 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
3623 } | 3649 } |
3624 | 3650 |
3625 // Tests that touch-gesture end is dispatched to the renderer at the end of a | 3651 // Tests that touch-gesture end is dispatched to the renderer at the end of a |
3626 // touch-gesture initiated overscroll. | 3652 // touch-gesture initiated overscroll. |
3627 TEST_F(RenderWidgetHostTest, TouchGestureEndDispatchedAfterOverscrollComplete) { | 3653 TEST_F(RenderWidgetHostTest, TouchGestureEndDispatchedAfterOverscrollComplete) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3667 | 3693 |
3668 // Send end event. | 3694 // Send end event. |
3669 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, | 3695 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, |
3670 WebGestureEvent::Touchscreen); | 3696 WebGestureEvent::Touchscreen); |
3671 EXPECT_EQ(0U, process_->sink().message_count()); | 3697 EXPECT_EQ(0U, process_->sink().message_count()); |
3672 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3698 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3673 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 3699 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
3674 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 3700 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
3675 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 3701 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
3676 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); | 3702 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); |
3677 MessageLoop::current()->PostDelayedTask( | 3703 base::MessageLoop::current()->PostDelayedTask( |
3678 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 3704 FROM_HERE, |
3679 MessageLoop::current()->Run(); | 3705 base::MessageLoop::QuitClosure(), |
| 3706 TimeDelta::FromMilliseconds(10)); |
| 3707 base::MessageLoop::current()->Run(); |
3680 EXPECT_EQ(1U, process_->sink().message_count()); | 3708 EXPECT_EQ(1U, process_->sink().message_count()); |
3681 process_->sink().ClearMessages(); | 3709 process_->sink().ClearMessages(); |
3682 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 3710 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
3683 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 3711 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
3684 | 3712 |
3685 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, | 3713 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, |
3686 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3714 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3687 EXPECT_EQ(0U, process_->sink().message_count()); | 3715 EXPECT_EQ(0U, process_->sink().message_count()); |
3688 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 3716 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
3689 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 3717 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3724 // Send end event. | 3752 // Send end event. |
3725 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, | 3753 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, |
3726 WebGestureEvent::Touchscreen); | 3754 WebGestureEvent::Touchscreen); |
3727 EXPECT_EQ(0U, process_->sink().message_count()); | 3755 EXPECT_EQ(0U, process_->sink().message_count()); |
3728 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3756 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3729 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 3757 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
3730 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 3758 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
3731 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 3759 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
3732 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); | 3760 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); |
3733 | 3761 |
3734 MessageLoop::current()->PostDelayedTask( | 3762 base::MessageLoop::current()->PostDelayedTask( |
3735 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 3763 FROM_HERE, |
3736 MessageLoop::current()->Run(); | 3764 base::MessageLoop::QuitClosure(), |
| 3765 TimeDelta::FromMilliseconds(10)); |
| 3766 base::MessageLoop::current()->Run(); |
3737 EXPECT_EQ(1U, process_->sink().message_count()); | 3767 EXPECT_EQ(1U, process_->sink().message_count()); |
3738 process_->sink().ClearMessages(); | 3768 process_->sink().ClearMessages(); |
3739 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 3769 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
3740 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 3770 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
3741 | 3771 |
3742 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, | 3772 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, |
3743 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3773 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3744 EXPECT_EQ(0U, process_->sink().message_count()); | 3774 EXPECT_EQ(0U, process_->sink().message_count()); |
3745 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 3775 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
3746 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 3776 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3780 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3810 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3781 | 3811 |
3782 // Since the overscroll mode has been reset, the next scroll update events | 3812 // Since the overscroll mode has been reset, the next scroll update events |
3783 // should reach the renderer. | 3813 // should reach the renderer. |
3784 SimulateGestureScrollUpdateEvent(-20, 0, 0); | 3814 SimulateGestureScrollUpdateEvent(-20, 0, 0); |
3785 EXPECT_EQ(1U, process_->sink().message_count()); | 3815 EXPECT_EQ(1U, process_->sink().message_count()); |
3786 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 3816 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
3787 } | 3817 } |
3788 | 3818 |
3789 } // namespace content | 3819 } // namespace content |
OLD | NEW |