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