Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/browser/renderer_host/input/timeout_monitor.h" | 9 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 10 #include "content/browser/renderer_host/input/touch_event_queue.h" | 10 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 799 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 800 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 800 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 801 | 801 |
| 802 ReleaseTouchPoint(0); | 802 ReleaseTouchPoint(0); |
| 803 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 803 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 804 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 804 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 805 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 805 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 806 } | 806 } |
| 807 | 807 |
| 808 // Tests that no TouchEvents are sent to renderer during scrolling. | 808 // Tests that no TouchEvents are sent to renderer during scrolling. |
| 809 TEST_F(TouchEventQueueTest, NoTouchOnScroll) { | 809 TEST_F(TouchEventQueueTest, TouchCancelOnScroll) { |
| 810 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL); | |
| 810 // Queue a TouchStart. | 811 // Queue a TouchStart. |
| 811 PressTouchPoint(0, 1); | 812 PressTouchPoint(0, 1); |
| 812 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 813 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 813 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 814 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 814 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 815 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 815 | 816 |
| 816 MoveTouchPoint(0, 20, 5); | 817 MoveTouchPoint(0, 20, 5); |
| 817 EXPECT_EQ(1U, queued_event_count()); | 818 EXPECT_EQ(1U, queued_event_count()); |
| 818 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 819 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 819 | 820 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 | 875 |
| 875 ReleaseTouchPoint(0); | 876 ReleaseTouchPoint(0); |
| 876 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 877 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 877 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 878 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 878 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 879 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 879 } | 880 } |
| 880 | 881 |
| 881 // Tests that a scroll event will not insert a synthetic TouchCancel if there | 882 // Tests that a scroll event will not insert a synthetic TouchCancel if there |
| 882 // was no consumer for the current touch sequence. | 883 // was no consumer for the current touch sequence. |
| 883 TEST_F(TouchEventQueueTest, NoTouchCancelOnScrollIfNoConsumer) { | 884 TEST_F(TouchEventQueueTest, NoTouchCancelOnScrollIfNoConsumer) { |
| 885 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL); | |
| 886 | |
| 884 // Queue a TouchStart. | 887 // Queue a TouchStart. |
| 885 PressTouchPoint(0, 1); | 888 PressTouchPoint(0, 1); |
| 886 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 889 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 887 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 890 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
| 888 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 891 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 889 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); | 892 EXPECT_EQ(WebInputEvent::TouchStart, sent_event().type); |
| 890 | 893 |
| 891 // Queue a TouchMove that turns into a GestureScrollBegin. | 894 // Queue a TouchMove that turns into a GestureScrollBegin. |
| 892 WebGestureEvent followup_scroll; | 895 WebGestureEvent followup_scroll; |
| 893 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 896 followup_scroll.type = WebInputEvent::GestureScrollBegin; |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1477 WebGestureEvent followup_scroll; | 1480 WebGestureEvent followup_scroll; |
| 1478 followup_scroll.type = WebInputEvent::GestureScrollBegin; | 1481 followup_scroll.type = WebInputEvent::GestureScrollBegin; |
| 1479 SetFollowupEvent(followup_scroll); | 1482 SetFollowupEvent(followup_scroll); |
| 1480 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1483 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1481 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1484 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1482 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | 1485 EXPECT_EQ(1U, GetAndResetAckedEventCount()); |
| 1483 EXPECT_EQ(0U, queued_event_count()); | 1486 EXPECT_EQ(0U, queued_event_count()); |
| 1484 } | 1487 } |
| 1485 | 1488 |
| 1486 TEST_F(TouchEventQueueTest, TouchAbsorption) { | 1489 TEST_F(TouchEventQueueTest, TouchAbsorption) { |
| 1487 SetTouchScrollingMode( | 1490 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE); |
| 1488 TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE); | |
| 1489 // Queue a TouchStart. | |
| 1490 PressTouchPoint(0, 1); | |
| 1491 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1492 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1493 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1494 | 1491 |
| 1495 for (int i = 0; i < 3; ++i) { | 1492 // Queue a TouchStart. |
| 1493 PressTouchPoint(0, 1); | |
| 1494 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1495 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1496 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1497 | |
| 1498 for (int i = 0; i < 3; ++i) { | |
| 1496 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1499 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
| 1497 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1500 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1498 | 1501 |
| 1499 MoveTouchPoint(0, 20, 5); | 1502 MoveTouchPoint(0, 20, 5); |
| 1500 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1503 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1501 EXPECT_EQ(0U, queued_event_count()); | 1504 EXPECT_EQ(0U, queued_event_count()); |
| 1502 EXPECT_EQ(1U, GetAndResetSentEventCount()); | 1505 EXPECT_EQ(1U, GetAndResetSentEventCount()); |
| 1503 | 1506 |
| 1504 // Consuming a scroll event prevents the next touch moves from being | 1507 // Consuming a scroll event prevents the next touch moves from being |
| 1505 // dispatched. | 1508 // dispatched. |
| 1506 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, | 1509 SendGestureEventAck(WebInputEvent::GestureScrollUpdate, |
| 1507 INPUT_EVENT_ACK_STATE_CONSUMED); | 1510 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1508 MoveTouchPoint(0, 20, 5); | 1511 MoveTouchPoint(0, 20, 5); |
| 1509 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1512 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1510 EXPECT_EQ(0U, queued_event_count()); | 1513 EXPECT_EQ(0U, queued_event_count()); |
| 1511 EXPECT_EQ(0U, GetAndResetSentEventCount()); | 1514 EXPECT_EQ(0U, GetAndResetSentEventCount()); |
| 1512 } | 1515 } |
| 1516 } | |
| 1517 | |
| 1518 TEST_F(TouchEventQueueTest, TouchAbsorptionNoTouchAfterScroll) { | |
| 1519 SetTouchScrollingMode(TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE); | |
| 1520 | |
| 1521 // Process a TouchStart | |
| 1522 PressTouchPoint(0, 1); | |
| 1523 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1524 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1525 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1526 | |
| 1527 // Now send the first touch move and associated GestureScrollBegin, | |
| 1528 // but don't ACK the gesture event yet. | |
| 1529 MoveTouchPoint(0, 0, 5); | |
| 1530 WebGestureEvent followup_scroll; | |
| 1531 followup_scroll.type = WebInputEvent::GestureScrollBegin; | |
| 1532 SetFollowupEvent(followup_scroll); | |
| 1533 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1534 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1535 EXPECT_EQ(1U, GetAndResetAckedEventCount()); | |
| 1536 | |
| 1537 // Now queue a second touchmove and verify it's not dispatched. | |
| 1538 MoveTouchPoint(0, 0, 10); | |
| 1539 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1540 EXPECT_EQ(0U, queued_event_count()); | |
| 1541 EXPECT_EQ(0U, GetAndResetSentEventCount()); | |
| 1542 | |
| 1543 // But a final touchend is sent (even before any gesture events | |
| 1544 // have been ACKed). | |
| 1545 ReleaseTouchPoint(0); | |
| 1546 SendTouchEventAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 1547 EXPECT_EQ(0U, queued_event_count()); | |
| 1548 EXPECT_EQ(1U, GetAndResetSentEventCount()); | |
| 1549 EXPECT_EQ(WebInputEvent::TouchEnd, sent_event().type); | |
| 1513 } | 1550 } |
|
jdduke (slow)
2014/03/07 18:03:16
Could you also test that absorption is reset when
Rick Byers
2014/03/07 20:58:53
Done.
| |
| 1514 | 1551 |
| 1515 } // namespace content | 1552 } // namespace content |
| OLD | NEW |