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 <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 811 } |
812 | 812 |
813 // Tests that the touch-queue is emptied after a page stops listening for touch | 813 // Tests that the touch-queue is emptied after a page stops listening for touch |
814 // events and the outstanding ack is received. | 814 // events and the outstanding ack is received. |
815 TEST_F(InputRouterImplTest, TouchEventQueueFlush) { | 815 TEST_F(InputRouterImplTest, TouchEventQueueFlush) { |
816 OnHasTouchEventHandlers(true); | 816 OnHasTouchEventHandlers(true); |
817 EXPECT_TRUE(client_->has_touch_handler()); | 817 EXPECT_TRUE(client_->has_touch_handler()); |
818 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 818 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
819 EXPECT_TRUE(TouchEventQueueEmpty()); | 819 EXPECT_TRUE(TouchEventQueueEmpty()); |
820 | 820 |
821 EXPECT_TRUE(input_router_->ShouldForwardTouchEvent()); | |
822 | |
823 // Send a touch-press event. | 821 // Send a touch-press event. |
824 PressTouchPoint(1, 1); | 822 PressTouchPoint(1, 1); |
825 SendTouchEvent(); | 823 SendTouchEvent(); |
826 MoveTouchPoint(0, 2, 2); | 824 MoveTouchPoint(0, 2, 2); |
827 MoveTouchPoint(0, 3, 3); | 825 MoveTouchPoint(0, 3, 3); |
828 EXPECT_FALSE(TouchEventQueueEmpty()); | 826 EXPECT_FALSE(TouchEventQueueEmpty()); |
829 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 827 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
830 | 828 |
831 // The page stops listening for touch-events. Note that flushing is deferred | 829 // The page stops listening for touch-events. Note that flushing is deferred |
832 // until the outstanding ack is received. | 830 // until the outstanding ack is received. |
833 OnHasTouchEventHandlers(false); | 831 OnHasTouchEventHandlers(false); |
834 EXPECT_FALSE(client_->has_touch_handler()); | 832 EXPECT_FALSE(client_->has_touch_handler()); |
835 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 833 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
836 EXPECT_FALSE(TouchEventQueueEmpty()); | 834 EXPECT_FALSE(TouchEventQueueEmpty()); |
837 EXPECT_TRUE(input_router_->ShouldForwardTouchEvent()); | |
838 | 835 |
839 // After the ack, the touch-event queue should be empty, and none of the | 836 // After the ack, the touch-event queue should be empty, and none of the |
840 // flushed touch-events should have been sent to the renderer. | 837 // flushed touch-events should have been sent to the renderer. |
841 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 838 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
842 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 839 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
843 EXPECT_TRUE(TouchEventQueueEmpty()); | 840 EXPECT_TRUE(TouchEventQueueEmpty()); |
844 EXPECT_FALSE(input_router_->ShouldForwardTouchEvent()); | |
845 } | 841 } |
846 | 842 |
847 #if defined(USE_AURA) | 843 #if defined(USE_AURA) |
848 // Tests that the acked events have correct state. (ui::Events are used only on | 844 // Tests that the acked events have correct state. (ui::Events are used only on |
849 // windows and aura) | 845 // windows and aura) |
850 TEST_F(InputRouterImplTest, AckedTouchEventState) { | 846 TEST_F(InputRouterImplTest, AckedTouchEventState) { |
851 input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 847 input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
852 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 848 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
853 EXPECT_TRUE(TouchEventQueueEmpty()); | 849 EXPECT_TRUE(TouchEventQueueEmpty()); |
854 EXPECT_TRUE(input_router_->ShouldForwardTouchEvent()); | |
855 | 850 |
856 // Send a bunch of events, and make sure the ACKed events are correct. | 851 // Send a bunch of events, and make sure the ACKed events are correct. |
857 ScopedVector<ui::TouchEvent> expected_events; | 852 ScopedVector<ui::TouchEvent> expected_events; |
858 | 853 |
859 // Use a custom timestamp for all the events to test that the acked events | 854 // Use a custom timestamp for all the events to test that the acked events |
860 // have the same timestamp; | 855 // have the same timestamp; |
861 base::TimeDelta timestamp = base::Time::NowFromSystemTime() - base::Time(); | 856 base::TimeDelta timestamp = base::Time::NowFromSystemTime() - base::Time(); |
862 timestamp -= base::TimeDelta::FromSeconds(600); | 857 timestamp -= base::TimeDelta::FromSeconds(600); |
863 | 858 |
864 // Press the first finger. | 859 // Press the first finger. |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 client_overscroll = client_->GetAndResetOverscroll(); | 1739 client_overscroll = client_->GetAndResetOverscroll(); |
1745 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, | 1740 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, |
1746 client_overscroll.accumulated_overscroll); | 1741 client_overscroll.accumulated_overscroll); |
1747 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, | 1742 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, |
1748 client_overscroll.latest_overscroll_delta); | 1743 client_overscroll.latest_overscroll_delta); |
1749 EXPECT_EQ(wheel_overscroll.current_fling_velocity, | 1744 EXPECT_EQ(wheel_overscroll.current_fling_velocity, |
1750 client_overscroll.current_fling_velocity); | 1745 client_overscroll.current_fling_velocity); |
1751 } | 1746 } |
1752 | 1747 |
1753 } // namespace content | 1748 } // namespace content |
OLD | NEW |