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" |
11 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 11 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
12 #include "content/browser/renderer_host/gesture_event_filter.h" | 12 #include "content/browser/renderer_host/gesture_event_filter.h" |
13 #include "content/browser/renderer_host/overscroll_controller.h" | 13 #include "content/browser/renderer_host/overscroll_controller.h" |
14 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 14 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
| 15 #include "content/browser/renderer_host/tap_suppression_controller.h" |
15 #include "content/browser/renderer_host/test_render_view_host.h" | 16 #include "content/browser/renderer_host/test_render_view_host.h" |
16 #include "content/browser/renderer_host/touch_event_queue.h" | 17 #include "content/browser/renderer_host/touch_event_queue.h" |
17 #include "content/common/view_messages.h" | 18 #include "content/common/view_messages.h" |
18 #include "content/port/browser/render_widget_host_view_port.h" | 19 #include "content/port/browser/render_widget_host_view_port.h" |
19 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
20 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
24 #include "content/public/test/mock_render_process_host.h" | 25 #include "content/public/test/mock_render_process_host.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 using RenderWidgetHostImpl::OnMsgPaintAtSizeAck; | 111 using RenderWidgetHostImpl::OnMsgPaintAtSizeAck; |
111 using RenderWidgetHostImpl::OnMsgUpdateRect; | 112 using RenderWidgetHostImpl::OnMsgUpdateRect; |
112 using RenderWidgetHostImpl::RendererExited; | 113 using RenderWidgetHostImpl::RendererExited; |
113 using RenderWidgetHostImpl::in_flight_size_; | 114 using RenderWidgetHostImpl::in_flight_size_; |
114 using RenderWidgetHostImpl::is_hidden_; | 115 using RenderWidgetHostImpl::is_hidden_; |
115 using RenderWidgetHostImpl::resize_ack_pending_; | 116 using RenderWidgetHostImpl::resize_ack_pending_; |
116 using RenderWidgetHostImpl::gesture_event_filter_; | 117 using RenderWidgetHostImpl::gesture_event_filter_; |
117 using RenderWidgetHostImpl::touch_event_queue_; | 118 using RenderWidgetHostImpl::touch_event_queue_; |
118 using RenderWidgetHostImpl::overscroll_controller_; | 119 using RenderWidgetHostImpl::overscroll_controller_; |
119 | 120 |
| 121 enum TapSuppressionState { |
| 122 TSC_NOTHING = TapSuppressionController::NOTHING, |
| 123 TSC_GFC_IN_PROGRESS = TapSuppressionController::GFC_IN_PROGRESS, |
| 124 TSC_MD_STASHED = TapSuppressionController::MD_STASHED, |
| 125 TSC_LAST_CANCEL_STOPPED_FLING = |
| 126 TapSuppressionController::LAST_CANCEL_STOPPED_FLING, |
| 127 }; |
| 128 |
120 bool unresponsive_timer_fired() const { | 129 bool unresponsive_timer_fired() const { |
121 return unresponsive_timer_fired_; | 130 return unresponsive_timer_fired_; |
122 } | 131 } |
123 | 132 |
124 void set_hung_renderer_delay_ms(int delay_ms) { | 133 void set_hung_renderer_delay_ms(int delay_ms) { |
125 hung_renderer_delay_ms_ = delay_ms; | 134 hung_renderer_delay_ms_ = delay_ms; |
126 } | 135 } |
127 | 136 |
128 WebGestureEvent GestureEventLastQueueEvent() { | 137 WebGestureEvent GestureEventLastQueueEvent() { |
129 return gesture_event_filter_->coalesced_gesture_events_.back(); | 138 return gesture_event_filter_->coalesced_gesture_events_.back(); |
(...skipping 12 matching lines...) Expand all Loading... |
142 } | 151 } |
143 | 152 |
144 bool ScrollingInProgress() { | 153 bool ScrollingInProgress() { |
145 return gesture_event_filter_->scrolling_in_progress_; | 154 return gesture_event_filter_->scrolling_in_progress_; |
146 } | 155 } |
147 | 156 |
148 bool FlingInProgress() { | 157 bool FlingInProgress() { |
149 return gesture_event_filter_->fling_in_progress_; | 158 return gesture_event_filter_->fling_in_progress_; |
150 } | 159 } |
151 | 160 |
| 161 TapSuppressionState TapSuppressionControllerState() { |
| 162 return static_cast<TapSuppressionState>( |
| 163 gesture_event_filter_->tap_suppression_controller_->state_); |
| 164 } |
| 165 |
152 void SetupForOverscrollControllerTest() { | 166 void SetupForOverscrollControllerTest() { |
153 InitializeOverscrollController(); | 167 InitializeOverscrollController(); |
154 overscroll_delegate_.reset(new TestOverscrollDelegate); | 168 overscroll_delegate_.reset(new TestOverscrollDelegate); |
155 overscroll_controller_->set_delegate(overscroll_delegate_.get()); | 169 overscroll_controller_->set_delegate(overscroll_delegate_.get()); |
156 } | 170 } |
157 | 171 |
158 void set_maximum_tap_gap_time_ms(int delay_ms) { | 172 void set_maximum_tap_gap_time_ms(int delay_ms) { |
159 gesture_event_filter_->maximum_tap_gap_time_ms_ = delay_ms; | 173 gesture_event_filter_->maximum_tap_gap_time_ms_ = delay_ms; |
160 } | 174 } |
161 | 175 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 host_->OnMessageReceived(*response); | 512 host_->OnMessageReceived(*response); |
499 } | 513 } |
500 | 514 |
501 void SimulateKeyboardEvent(WebInputEvent::Type type) { | 515 void SimulateKeyboardEvent(WebInputEvent::Type type) { |
502 NativeWebKeyboardEvent key_event; | 516 NativeWebKeyboardEvent key_event; |
503 key_event.type = type; | 517 key_event.type = type; |
504 key_event.windowsKeyCode = ui::VKEY_L; // non-null made up value. | 518 key_event.windowsKeyCode = ui::VKEY_L; // non-null made up value. |
505 host_->ForwardKeyboardEvent(key_event); | 519 host_->ForwardKeyboardEvent(key_event); |
506 } | 520 } |
507 | 521 |
| 522 void SimulateMouseEvent(WebInputEvent::Type type) { |
| 523 WebMouseWheelEvent mouse_event; |
| 524 mouse_event.type = type; |
| 525 host_->ForwardMouseEvent(mouse_event); |
| 526 } |
| 527 |
508 void SimulateWheelEvent(float dX, float dY, int modifiers) { | 528 void SimulateWheelEvent(float dX, float dY, int modifiers) { |
509 WebMouseWheelEvent wheel_event; | 529 WebMouseWheelEvent wheel_event; |
510 wheel_event.type = WebInputEvent::MouseWheel; | 530 wheel_event.type = WebInputEvent::MouseWheel; |
511 wheel_event.deltaX = dX; | 531 wheel_event.deltaX = dX; |
512 wheel_event.deltaY = dY; | 532 wheel_event.deltaY = dY; |
513 wheel_event.modifiers = modifiers; | 533 wheel_event.modifiers = modifiers; |
514 host_->ForwardWheelEvent(wheel_event); | 534 host_->ForwardWheelEvent(wheel_event); |
515 } | 535 } |
516 | 536 |
517 void SimulateMouseMove(int x, int y, int modifiers) { | 537 void SimulateMouseMove(int x, int y, int modifiers) { |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 WebInputEvent::GestureScrollUpdate, | 1514 WebInputEvent::GestureScrollUpdate, |
1495 WebInputEvent::GestureScrollUpdate}; | 1515 WebInputEvent::GestureScrollUpdate}; |
1496 | 1516 |
1497 for (unsigned i = 0; i < sizeof(expected) / sizeof(WebInputEvent::Type); | 1517 for (unsigned i = 0; i < sizeof(expected) / sizeof(WebInputEvent::Type); |
1498 i++) { | 1518 i++) { |
1499 WebGestureEvent merged_event = host_->GestureEventQueueEventAt(i); | 1519 WebGestureEvent merged_event = host_->GestureEventQueueEventAt(i); |
1500 EXPECT_EQ(expected[i], merged_event.type); | 1520 EXPECT_EQ(expected[i], merged_event.type); |
1501 } | 1521 } |
1502 } | 1522 } |
1503 | 1523 |
| 1524 #if defined(USE_AURA) |
| 1525 // Test TapSuppressionController for when GestureFlingCancel Ack comes before |
| 1526 // MouseDown and everything happens without any delays. |
| 1527 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseFast) { |
| 1528 process_->sink().ClearMessages(); |
| 1529 |
| 1530 // Send GestureFlingStart. |
| 1531 SimulateGestureFlingStartEvent(0, -10); |
| 1532 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1533 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1534 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 1535 host_->GestureEventLastQueueEvent().type); |
| 1536 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1537 host_->TapSuppressionControllerState()); |
| 1538 EXPECT_TRUE(host_->FlingInProgress()); |
| 1539 |
| 1540 // Send GestureFlingStart Ack. |
| 1541 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 1542 MessageLoop::current()->RunUntilIdle(); |
| 1543 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1544 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1545 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1546 host_->TapSuppressionControllerState()); |
| 1547 EXPECT_TRUE(host_->FlingInProgress()); |
| 1548 |
| 1549 // Send GestureFlingCancel. |
| 1550 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 1551 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1552 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1553 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1554 host_->GestureEventLastQueueEvent().type); |
| 1555 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 1556 host_->TapSuppressionControllerState()); |
| 1557 EXPECT_FALSE(host_->FlingInProgress()); |
| 1558 |
| 1559 // Send GestureFlingCancel Ack. |
| 1560 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 1561 MessageLoop::current()->RunUntilIdle(); |
| 1562 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1563 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1564 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
| 1565 host_->TapSuppressionControllerState()); |
| 1566 EXPECT_FALSE(host_->FlingInProgress()); |
| 1567 |
| 1568 // Send MouseDown. This MouseDown should be suppressed. |
| 1569 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 1570 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1571 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1572 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1573 host_->GestureEventLastQueueEvent().type); |
| 1574 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 1575 host_->TapSuppressionControllerState()); |
| 1576 EXPECT_FALSE(host_->FlingInProgress()); |
| 1577 |
| 1578 // Send MouseUp. This MouseUp should be suppressed. |
| 1579 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 1580 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1581 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1582 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1583 host_->GestureEventLastQueueEvent().type); |
| 1584 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1585 host_->TapSuppressionControllerState()); |
| 1586 EXPECT_FALSE(host_->FlingInProgress()); |
| 1587 } |
| 1588 #endif // defined(USE_AURA) |
| 1589 |
| 1590 #if defined(USE_AURA) |
| 1591 // Test TapSuppressionController for when GestureFlingCancel Ack comes before |
| 1592 // MouseDown, but there is a small delay between MouseDown and MouseUp. |
| 1593 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseInsufficientlyLateMouseUp) { |
| 1594 process_->sink().ClearMessages(); |
| 1595 |
| 1596 // Send GestureFlingStart. |
| 1597 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 1598 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1599 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1600 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 1601 host_->GestureEventLastQueueEvent().type); |
| 1602 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1603 host_->TapSuppressionControllerState()); |
| 1604 EXPECT_TRUE(host_->FlingInProgress()); |
| 1605 |
| 1606 // Send GestureFlingStart Ack. |
| 1607 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 1608 MessageLoop::current()->RunUntilIdle(); |
| 1609 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1610 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1611 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1612 host_->TapSuppressionControllerState()); |
| 1613 EXPECT_TRUE(host_->FlingInProgress()); |
| 1614 |
| 1615 // Send GestureFlingCancel. |
| 1616 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 1617 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1618 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1619 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1620 host_->GestureEventLastQueueEvent().type); |
| 1621 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 1622 host_->TapSuppressionControllerState()); |
| 1623 EXPECT_FALSE(host_->FlingInProgress()); |
| 1624 |
| 1625 // Send GestureFlingCancel Ack. |
| 1626 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 1627 MessageLoop::current()->RunUntilIdle(); |
| 1628 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1629 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1630 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
| 1631 host_->TapSuppressionControllerState()); |
| 1632 EXPECT_FALSE(host_->FlingInProgress()); |
| 1633 |
| 1634 // Send MouseDown. This MouseDown should be suppressed. |
| 1635 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 1636 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1637 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1638 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 1639 host_->TapSuppressionControllerState()); |
| 1640 EXPECT_FALSE(host_->FlingInProgress()); |
| 1641 |
| 1642 // Wait less than allowed delay between MouseDown and MouseUp, so they are |
| 1643 // still considered a tap. |
| 1644 // TODO(mohsen): The amounts used for delays are too much and will slow down |
| 1645 // the tests. A better way is to reduce the allowed delays in TSC before each |
| 1646 // test. So, they should be made accessible and configurable. |
| 1647 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1648 MessageLoop::QuitClosure(), |
| 1649 TimeDelta::FromMilliseconds(100)); |
| 1650 MessageLoop::current()->Run(); |
| 1651 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1652 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1653 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 1654 host_->TapSuppressionControllerState()); |
| 1655 EXPECT_FALSE(host_->FlingInProgress()); |
| 1656 |
| 1657 // Send MouseUp. This MouseUp should be suppressed. |
| 1658 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 1659 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1660 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1661 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1662 host_->TapSuppressionControllerState()); |
| 1663 EXPECT_FALSE(host_->FlingInProgress()); |
| 1664 } |
| 1665 #endif // defined(USE_AURA) |
| 1666 |
| 1667 #if defined(USE_AURA) |
| 1668 // Test TapSuppressionController for when GestureFlingCancel Ack comes before |
| 1669 // MouseDown, but there is a long delay between MouseDown and MouseUp. |
| 1670 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseSufficientlyLateMouseUp) { |
| 1671 process_->sink().ClearMessages(); |
| 1672 |
| 1673 // Send GestureFlingStart. |
| 1674 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 1675 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1676 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1677 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 1678 host_->GestureEventLastQueueEvent().type); |
| 1679 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1680 host_->TapSuppressionControllerState()); |
| 1681 EXPECT_TRUE(host_->FlingInProgress()); |
| 1682 |
| 1683 // Send GestureFlingStart Ack. |
| 1684 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 1685 MessageLoop::current()->RunUntilIdle(); |
| 1686 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1687 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1688 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1689 host_->TapSuppressionControllerState()); |
| 1690 EXPECT_TRUE(host_->FlingInProgress()); |
| 1691 |
| 1692 // Send GestureFlingCancel. |
| 1693 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 1694 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1695 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1696 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1697 host_->GestureEventLastQueueEvent().type); |
| 1698 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 1699 host_->TapSuppressionControllerState()); |
| 1700 EXPECT_FALSE(host_->FlingInProgress()); |
| 1701 |
| 1702 // Send processed GestureFlingCancel Ack. |
| 1703 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 1704 MessageLoop::current()->RunUntilIdle(); |
| 1705 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1706 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1707 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
| 1708 host_->TapSuppressionControllerState()); |
| 1709 EXPECT_FALSE(host_->FlingInProgress()); |
| 1710 |
| 1711 // Send MouseDown. This MouseDown should be suppressed, for now. |
| 1712 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 1713 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1714 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1715 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 1716 host_->TapSuppressionControllerState()); |
| 1717 EXPECT_FALSE(host_->FlingInProgress()); |
| 1718 |
| 1719 // Wait more than allowed delay between MosueDown and MouseUp, so they are |
| 1720 // not considered a tap. This should release the previously suppressed |
| 1721 // MouseDown. |
| 1722 // TODO(mohsen): The amounts used for delays are too much and will slow down |
| 1723 // the tests. A better way is to reduce the allowed delays in TSC before each |
| 1724 // test. So, they should be made configurable and accessible here. |
| 1725 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1726 MessageLoop::QuitClosure(), |
| 1727 TimeDelta::FromMilliseconds(300)); |
| 1728 MessageLoop::current()->Run(); |
| 1729 EXPECT_EQ(3U, process_->sink().message_count()); |
| 1730 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1731 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1732 host_->TapSuppressionControllerState()); |
| 1733 EXPECT_FALSE(host_->FlingInProgress()); |
| 1734 |
| 1735 // Send MouseUp. This MouseUp should not be suppressed. |
| 1736 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 1737 EXPECT_EQ(4U, process_->sink().message_count()); |
| 1738 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1739 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1740 host_->TapSuppressionControllerState()); |
| 1741 EXPECT_FALSE(host_->FlingInProgress()); |
| 1742 } |
| 1743 #endif // defined(USE_AURA) |
| 1744 |
| 1745 #if defined(USE_AURA) |
| 1746 // Test TapSuppressionController for when GestureFlingCancel Ack comes before |
| 1747 // MouseDown, but there is a small delay between the Ack and MouseDown. |
| 1748 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseInsufficientlyLateMouseDown) { |
| 1749 process_->sink().ClearMessages(); |
| 1750 |
| 1751 // Send GestureFlingStart. |
| 1752 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 1753 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1754 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1755 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 1756 host_->GestureEventLastQueueEvent().type); |
| 1757 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1758 host_->TapSuppressionControllerState()); |
| 1759 EXPECT_TRUE(host_->FlingInProgress()); |
| 1760 |
| 1761 // Send GestureFlingStart Ack. |
| 1762 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 1763 MessageLoop::current()->RunUntilIdle(); |
| 1764 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1765 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1766 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1767 host_->TapSuppressionControllerState()); |
| 1768 EXPECT_TRUE(host_->FlingInProgress()); |
| 1769 |
| 1770 // Send GestureFlingCancel. |
| 1771 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 1772 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1773 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1774 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1775 host_->GestureEventLastQueueEvent().type); |
| 1776 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 1777 host_->TapSuppressionControllerState()); |
| 1778 EXPECT_FALSE(host_->FlingInProgress()); |
| 1779 |
| 1780 // Send GestureFlingCancel Ack. |
| 1781 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 1782 MessageLoop::current()->RunUntilIdle(); |
| 1783 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1784 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1785 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
| 1786 host_->TapSuppressionControllerState()); |
| 1787 EXPECT_FALSE(host_->FlingInProgress()); |
| 1788 |
| 1789 // Wait less than allowed delay between GestureFlingCancel and MouseDown, |
| 1790 // so the MouseDown is still considered associated with the |
| 1791 // GestureFlingCancel. |
| 1792 // TODO(mohsen): The amounts used for delays are too much and will slow down |
| 1793 // the tests. A better way is to reduce the allowed delays in TSC before each |
| 1794 // test. So, they should be made configurable and accessible here. |
| 1795 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1796 MessageLoop::QuitClosure(), |
| 1797 TimeDelta::FromMilliseconds(300)); |
| 1798 MessageLoop::current()->Run(); |
| 1799 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1800 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1801 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
| 1802 host_->TapSuppressionControllerState()); |
| 1803 EXPECT_FALSE(host_->FlingInProgress()); |
| 1804 |
| 1805 // Send MouseDown. This MouseDown should be suppressed. |
| 1806 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 1807 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1808 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1809 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 1810 host_->TapSuppressionControllerState()); |
| 1811 EXPECT_FALSE(host_->FlingInProgress()); |
| 1812 |
| 1813 // Send MouseUp. This MouseUp should be suppressed. |
| 1814 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 1815 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1816 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1817 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1818 host_->TapSuppressionControllerState()); |
| 1819 EXPECT_FALSE(host_->FlingInProgress()); |
| 1820 } |
| 1821 #endif // defined(USE_AURA) |
| 1822 |
| 1823 #if defined(USE_AURA) |
| 1824 // Test TapSuppressionController for when GestureFlingCancel Ack comes before |
| 1825 // MouseDown, but there is a long delay between the Ack and MouseDown. |
| 1826 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseSufficientlyLateMouseDown) { |
| 1827 process_->sink().ClearMessages(); |
| 1828 |
| 1829 // Send GestureFlingStart. |
| 1830 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 1831 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1832 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1833 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 1834 host_->GestureEventLastQueueEvent().type); |
| 1835 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1836 host_->TapSuppressionControllerState()); |
| 1837 EXPECT_TRUE(host_->FlingInProgress()); |
| 1838 |
| 1839 // Send GestureFlingStart Ack. |
| 1840 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 1841 MessageLoop::current()->RunUntilIdle(); |
| 1842 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1843 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1844 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1845 host_->TapSuppressionControllerState()); |
| 1846 EXPECT_TRUE(host_->FlingInProgress()); |
| 1847 |
| 1848 // Send GestureFlingCancel. |
| 1849 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 1850 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1851 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1852 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1853 host_->GestureEventLastQueueEvent().type); |
| 1854 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 1855 host_->TapSuppressionControllerState()); |
| 1856 EXPECT_FALSE(host_->FlingInProgress()); |
| 1857 |
| 1858 // Send GestureFlingCancel Ack. |
| 1859 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 1860 MessageLoop::current()->RunUntilIdle(); |
| 1861 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1862 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1863 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
| 1864 host_->TapSuppressionControllerState()); |
| 1865 EXPECT_FALSE(host_->FlingInProgress()); |
| 1866 |
| 1867 // Wait more than allowed delay between GestureFlingCancel and MouseDown, |
| 1868 // so the MouseDown is not considered associated with the GestureFlingCancel. |
| 1869 // TODO(mohsen): The amounts used for delays are too much and will slow down |
| 1870 // the tests. A better way is to reduce the allowed delays in TSC before each |
| 1871 // test. So, they should be made configurable and accessible here. |
| 1872 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1873 MessageLoop::QuitClosure(), |
| 1874 TimeDelta::FromMilliseconds(500)); |
| 1875 MessageLoop::current()->Run(); |
| 1876 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1877 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1878 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, |
| 1879 host_->TapSuppressionControllerState()); |
| 1880 EXPECT_FALSE(host_->FlingInProgress()); |
| 1881 |
| 1882 // Send MouseDown. This MouseDown should not be suppressed. |
| 1883 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 1884 EXPECT_EQ(3U, process_->sink().message_count()); |
| 1885 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1886 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1887 host_->TapSuppressionControllerState()); |
| 1888 EXPECT_FALSE(host_->FlingInProgress()); |
| 1889 |
| 1890 // Send MouseUp. This MouseUp should not be suppressed. |
| 1891 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 1892 EXPECT_EQ(4U, process_->sink().message_count()); |
| 1893 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1894 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1895 host_->TapSuppressionControllerState()); |
| 1896 EXPECT_FALSE(host_->FlingInProgress()); |
| 1897 } |
| 1898 #endif // defined(USE_AURA) |
| 1899 |
| 1900 #if defined(USE_AURA) |
| 1901 // Test TapSuppressionController for when unprocessed GestureFlingCancel Ack |
| 1902 // comes after MouseDown and everything happens without any delay. |
| 1903 TEST_F(RenderWidgetHostTest, GFCAckUnprocessedAfterMouseFast) { |
| 1904 process_->sink().ClearMessages(); |
| 1905 |
| 1906 // Send GestureFlingStart. |
| 1907 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 1908 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1909 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1910 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 1911 host_->GestureEventLastQueueEvent().type); |
| 1912 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1913 host_->TapSuppressionControllerState()); |
| 1914 EXPECT_TRUE(host_->FlingInProgress()); |
| 1915 |
| 1916 // Send GestureFlingStart Ack. |
| 1917 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 1918 MessageLoop::current()->RunUntilIdle(); |
| 1919 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1920 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1921 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1922 host_->TapSuppressionControllerState()); |
| 1923 EXPECT_TRUE(host_->FlingInProgress()); |
| 1924 |
| 1925 // Send GestureFlingCancel. |
| 1926 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 1927 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1928 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1929 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1930 host_->GestureEventLastQueueEvent().type); |
| 1931 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 1932 host_->TapSuppressionControllerState()); |
| 1933 EXPECT_FALSE(host_->FlingInProgress()); |
| 1934 |
| 1935 // Send MouseDown. This MouseDown should be suppressed, for now. |
| 1936 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 1937 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1938 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1939 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1940 host_->GestureEventLastQueueEvent().type); |
| 1941 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 1942 host_->TapSuppressionControllerState()); |
| 1943 EXPECT_FALSE(host_->FlingInProgress()); |
| 1944 |
| 1945 // Send unprocessed GestureFlingCancel Ack. This should release the |
| 1946 // previously suppressed MouseDown. |
| 1947 SendInputEventACK(WebInputEvent::GestureFlingCancel, false); |
| 1948 MessageLoop::current()->RunUntilIdle(); |
| 1949 EXPECT_EQ(3U, process_->sink().message_count()); |
| 1950 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1951 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1952 host_->TapSuppressionControllerState()); |
| 1953 EXPECT_FALSE(host_->FlingInProgress()); |
| 1954 |
| 1955 // Send MouseUp. This MouseUp should not be suppressed. |
| 1956 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 1957 EXPECT_EQ(4U, process_->sink().message_count()); |
| 1958 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1959 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1960 host_->TapSuppressionControllerState()); |
| 1961 EXPECT_FALSE(host_->FlingInProgress()); |
| 1962 } |
| 1963 #endif // defined(USE_AURA) |
| 1964 |
| 1965 #if defined(USE_AURA) |
| 1966 // Test TapSuppressionController for when processed GestureFlingCancel Ack |
| 1967 // comes after MouseDown and everything happens without any delay. |
| 1968 TEST_F(RenderWidgetHostTest, GFCAckProcessedAfterMouseFast) { |
| 1969 process_->sink().ClearMessages(); |
| 1970 |
| 1971 // Send GestureFlingStart. |
| 1972 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 1973 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1974 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1975 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 1976 host_->GestureEventLastQueueEvent().type); |
| 1977 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1978 host_->TapSuppressionControllerState()); |
| 1979 EXPECT_TRUE(host_->FlingInProgress()); |
| 1980 |
| 1981 // Send GestureFlingStart Ack. |
| 1982 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 1983 MessageLoop::current()->RunUntilIdle(); |
| 1984 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1985 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1986 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 1987 host_->TapSuppressionControllerState()); |
| 1988 EXPECT_TRUE(host_->FlingInProgress()); |
| 1989 |
| 1990 // Send GestureFlingCancel. |
| 1991 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 1992 EXPECT_EQ(2U, process_->sink().message_count()); |
| 1993 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1994 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 1995 host_->GestureEventLastQueueEvent().type); |
| 1996 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 1997 host_->TapSuppressionControllerState()); |
| 1998 EXPECT_FALSE(host_->FlingInProgress()); |
| 1999 |
| 2000 // Send MouseDown. This MouseDown should be suppressed. |
| 2001 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 2002 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2003 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2004 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 2005 host_->GestureEventLastQueueEvent().type); |
| 2006 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 2007 host_->TapSuppressionControllerState()); |
| 2008 EXPECT_FALSE(host_->FlingInProgress()); |
| 2009 |
| 2010 // Send GestureFlingCancel Ack. |
| 2011 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 2012 MessageLoop::current()->RunUntilIdle(); |
| 2013 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2014 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2015 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 2016 host_->TapSuppressionControllerState()); |
| 2017 EXPECT_FALSE(host_->FlingInProgress()); |
| 2018 |
| 2019 // Send MouseUp. This MouseUp should be suppressed. |
| 2020 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 2021 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2022 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2023 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2024 host_->TapSuppressionControllerState()); |
| 2025 EXPECT_FALSE(host_->FlingInProgress()); |
| 2026 } |
| 2027 #endif // defined(USE_AURA) |
| 2028 |
| 2029 #if defined(USE_AURA) |
| 2030 // Test TapSuppressionController for when GestureFlingCancel Ack comes after |
| 2031 // MouseDown and there is a small delay between the Ack and MouseUp. |
| 2032 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseInsufficientlyLateMouseUp) { |
| 2033 process_->sink().ClearMessages(); |
| 2034 |
| 2035 // Send GestureFlingStart. |
| 2036 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 2037 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2038 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2039 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 2040 host_->GestureEventLastQueueEvent().type); |
| 2041 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2042 host_->TapSuppressionControllerState()); |
| 2043 EXPECT_TRUE(host_->FlingInProgress()); |
| 2044 |
| 2045 // Send GestureFlingStart Ack. |
| 2046 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 2047 MessageLoop::current()->RunUntilIdle(); |
| 2048 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2049 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2050 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2051 host_->TapSuppressionControllerState()); |
| 2052 EXPECT_TRUE(host_->FlingInProgress()); |
| 2053 |
| 2054 // Send GestureFlingCancel. |
| 2055 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 2056 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2057 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2058 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 2059 host_->GestureEventLastQueueEvent().type); |
| 2060 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 2061 host_->TapSuppressionControllerState()); |
| 2062 EXPECT_FALSE(host_->FlingInProgress()); |
| 2063 |
| 2064 // Send MouseDown. This MouseDown should be suppressed. |
| 2065 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 2066 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2067 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2068 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 2069 host_->GestureEventLastQueueEvent().type); |
| 2070 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 2071 host_->TapSuppressionControllerState()); |
| 2072 EXPECT_FALSE(host_->FlingInProgress()); |
| 2073 |
| 2074 // Send GestureFlingCancel Ack. |
| 2075 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 2076 MessageLoop::current()->RunUntilIdle(); |
| 2077 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2078 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2079 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 2080 host_->TapSuppressionControllerState()); |
| 2081 EXPECT_FALSE(host_->FlingInProgress()); |
| 2082 |
| 2083 // Wait less than allowed delay between MouseDown and MouseUp, so they are |
| 2084 // still considered as a tap. |
| 2085 // TODO(mohsen): The amounts used for delays are too much and will slow down |
| 2086 // the tests. A better way is to reduce the allowed delays in TSC before each |
| 2087 // test. So, they should be made configurable and accessible here. |
| 2088 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 2089 MessageLoop::QuitClosure(), |
| 2090 TimeDelta::FromMilliseconds(100)); |
| 2091 MessageLoop::current()->Run(); |
| 2092 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2093 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2094 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 2095 host_->TapSuppressionControllerState()); |
| 2096 EXPECT_FALSE(host_->FlingInProgress()); |
| 2097 |
| 2098 // Send MouseUp. This MouseUp should be suppressed. |
| 2099 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 2100 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2101 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2102 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2103 host_->TapSuppressionControllerState()); |
| 2104 EXPECT_FALSE(host_->FlingInProgress()); |
| 2105 } |
| 2106 #endif // defined(USE_AURA) |
| 2107 |
| 2108 #if defined(USE_AURA) |
| 2109 // Test TapSuppressionController for when GestureFlingCancel Ack comes after |
| 2110 // MouseDown and there is a long delay between the Ack and MouseUp. |
| 2111 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseSufficientlyLateMouseUp) { |
| 2112 process_->sink().ClearMessages(); |
| 2113 |
| 2114 // Send GestureFlingStart. |
| 2115 SimulateGestureEvent(WebInputEvent::GestureFlingStart); |
| 2116 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2117 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2118 EXPECT_EQ(WebInputEvent::GestureFlingStart, |
| 2119 host_->GestureEventLastQueueEvent().type); |
| 2120 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2121 host_->TapSuppressionControllerState()); |
| 2122 EXPECT_TRUE(host_->FlingInProgress()); |
| 2123 |
| 2124 // Send GestureFlingStart Ack. |
| 2125 SendInputEventACK(WebInputEvent::GestureFlingStart, true); |
| 2126 MessageLoop::current()->RunUntilIdle(); |
| 2127 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2128 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2129 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2130 host_->TapSuppressionControllerState()); |
| 2131 EXPECT_TRUE(host_->FlingInProgress()); |
| 2132 |
| 2133 // Send GestureFlingCancel. |
| 2134 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); |
| 2135 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2136 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2137 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 2138 host_->GestureEventLastQueueEvent().type); |
| 2139 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, |
| 2140 host_->TapSuppressionControllerState()); |
| 2141 EXPECT_FALSE(host_->FlingInProgress()); |
| 2142 |
| 2143 // Send MouseDown. This MouseDown should be suppressed, for now. |
| 2144 SimulateMouseEvent(WebInputEvent::MouseDown); |
| 2145 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2146 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2147 EXPECT_EQ(WebInputEvent::GestureFlingCancel, |
| 2148 host_->GestureEventLastQueueEvent().type); |
| 2149 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 2150 host_->TapSuppressionControllerState()); |
| 2151 EXPECT_FALSE(host_->FlingInProgress()); |
| 2152 |
| 2153 // Send GestureFlingCancel Ack. |
| 2154 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); |
| 2155 MessageLoop::current()->RunUntilIdle(); |
| 2156 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2157 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2158 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, |
| 2159 host_->TapSuppressionControllerState()); |
| 2160 EXPECT_FALSE(host_->FlingInProgress()); |
| 2161 |
| 2162 // Wait more than allowed delay between MouseDown and MouseUp, so they are |
| 2163 // not considered as a tap. This should release the previously suppressed |
| 2164 // MouseDown. |
| 2165 // TODO(mohsen): The amounts used for delays are too much and will slow down |
| 2166 // the tests. A better way is to reduce the allowed delays in TSC before each |
| 2167 // test. So, they should be made configurable and accessible here. |
| 2168 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 2169 MessageLoop::QuitClosure(), |
| 2170 TimeDelta::FromMilliseconds(300)); |
| 2171 MessageLoop::current()->Run(); |
| 2172 EXPECT_EQ(3U, process_->sink().message_count()); |
| 2173 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2174 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2175 host_->TapSuppressionControllerState()); |
| 2176 EXPECT_FALSE(host_->FlingInProgress()); |
| 2177 |
| 2178 // Send MouseUp. This MouseUp should not be suppressed. |
| 2179 SimulateMouseEvent(WebInputEvent::MouseUp); |
| 2180 EXPECT_EQ(4U, process_->sink().message_count()); |
| 2181 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2182 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, |
| 2183 host_->TapSuppressionControllerState()); |
| 2184 EXPECT_FALSE(host_->FlingInProgress()); |
| 2185 } |
| 2186 #endif // defined(USE_AURA) |
| 2187 |
1504 // Tests that touch-events are queued properly. | 2188 // Tests that touch-events are queued properly. |
1505 TEST_F(RenderWidgetHostTest, TouchEventQueue) { | 2189 TEST_F(RenderWidgetHostTest, TouchEventQueue) { |
1506 process_->sink().ClearMessages(); | 2190 process_->sink().ClearMessages(); |
1507 | 2191 |
1508 PressTouchPoint(1, 1); | 2192 PressTouchPoint(1, 1); |
1509 SendTouchEvent(); | 2193 SendTouchEvent(); |
1510 EXPECT_EQ(1U, process_->sink().message_count()); | 2194 EXPECT_EQ(1U, process_->sink().message_count()); |
1511 process_->sink().ClearMessages(); | 2195 process_->sink().ClearMessages(); |
1512 | 2196 |
1513 // The second touch should not be sent since one is already in queue. | 2197 // The second touch should not be sent since one is already in queue. |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 3112 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
2429 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 3113 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
2430 | 3114 |
2431 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, false); | 3115 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, false); |
2432 EXPECT_EQ(0U, process_->sink().message_count()); | 3116 EXPECT_EQ(0U, process_->sink().message_count()); |
2433 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 3117 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
2434 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 3118 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
2435 } | 3119 } |
2436 | 3120 |
2437 } // namespace content | 3121 } // namespace content |
OLD | NEW |