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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 612 |
613 SendInputEventACK(WebInputEvent::TouchMove, | 613 SendInputEventACK(WebInputEvent::TouchMove, |
614 INPUT_EVENT_ACK_STATE_CONSUMED); | 614 INPUT_EVENT_ACK_STATE_CONSUMED); |
615 EXPECT_TRUE(TouchEventQueueEmpty()); | 615 EXPECT_TRUE(TouchEventQueueEmpty()); |
616 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 616 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
617 EXPECT_EQ(WebInputEvent::TouchMove, | 617 EXPECT_EQ(WebInputEvent::TouchMove, |
618 ack_handler_->acked_touch_event().event.type); | 618 ack_handler_->acked_touch_event().event.type); |
619 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 619 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
620 } | 620 } |
621 | 621 |
622 // Tests that the touch-queue is emptied if a page stops listening for touch | 622 // Tests that the touch-queue is emptied after a page stops listening for touch |
623 // events. | 623 // events and the outstanding ack is received. |
624 TEST_F(InputRouterImplTest, TouchEventQueueFlush) { | 624 TEST_F(InputRouterImplTest, TouchEventQueueFlush) { |
625 OnHasTouchEventHandlers(true); | 625 OnHasTouchEventHandlers(true); |
626 EXPECT_TRUE(client_->has_touch_handler()); | 626 EXPECT_TRUE(client_->has_touch_handler()); |
627 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 627 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
628 EXPECT_TRUE(TouchEventQueueEmpty()); | 628 EXPECT_TRUE(TouchEventQueueEmpty()); |
629 | 629 |
630 EXPECT_TRUE(input_router_->ShouldForwardTouchEvent()); | 630 EXPECT_TRUE(input_router_->ShouldForwardTouchEvent()); |
631 | 631 |
632 // Send a touch-press event. | 632 // Send a touch-press event. |
633 PressTouchPoint(1, 1); | 633 PressTouchPoint(1, 1); |
634 SendTouchEvent(); | 634 SendTouchEvent(); |
| 635 MoveTouchPoint(0, 2, 2); |
| 636 MoveTouchPoint(0, 3, 3); |
635 EXPECT_FALSE(TouchEventQueueEmpty()); | 637 EXPECT_FALSE(TouchEventQueueEmpty()); |
636 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 638 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
637 | 639 |
638 // The page stops listening for touch-events. The touch-event queue should now | 640 // The page stops listening for touch-events. Note that flushing is deferred |
639 // be emptied, but none of the queued touch-events should be sent to the | 641 // until the outstanding ack is received. |
640 // renderer. | |
641 OnHasTouchEventHandlers(false); | 642 OnHasTouchEventHandlers(false); |
642 EXPECT_FALSE(client_->has_touch_handler()); | 643 EXPECT_FALSE(client_->has_touch_handler()); |
643 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 644 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 645 EXPECT_FALSE(TouchEventQueueEmpty()); |
| 646 EXPECT_TRUE(input_router_->ShouldForwardTouchEvent()); |
| 647 |
| 648 // After the ack, the touch-event queue should be empty, and none of the |
| 649 // flushed touch-events should have been sent to the renderer. |
| 650 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 651 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
644 EXPECT_TRUE(TouchEventQueueEmpty()); | 652 EXPECT_TRUE(TouchEventQueueEmpty()); |
645 EXPECT_FALSE(input_router_->ShouldForwardTouchEvent()); | 653 EXPECT_FALSE(input_router_->ShouldForwardTouchEvent()); |
646 } | 654 } |
647 | 655 |
648 #if defined(USE_AURA) | 656 #if defined(USE_AURA) |
649 // Tests that the acked events have correct state. (ui::Events are used only on | 657 // Tests that the acked events have correct state. (ui::Events are used only on |
650 // windows and aura) | 658 // windows and aura) |
651 TEST_F(InputRouterImplTest, AckedTouchEventState) { | 659 TEST_F(InputRouterImplTest, AckedTouchEventState) { |
652 input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 660 input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
653 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 661 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 client_overscroll = client_->GetAndResetOverscroll(); | 1724 client_overscroll = client_->GetAndResetOverscroll(); |
1717 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, | 1725 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, |
1718 client_overscroll.accumulated_overscroll); | 1726 client_overscroll.accumulated_overscroll); |
1719 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, | 1727 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, |
1720 client_overscroll.latest_overscroll_delta); | 1728 client_overscroll.latest_overscroll_delta); |
1721 EXPECT_EQ(wheel_overscroll.current_fling_velocity, | 1729 EXPECT_EQ(wheel_overscroll.current_fling_velocity, |
1722 client_overscroll.current_fling_velocity); | 1730 client_overscroll.current_fling_velocity); |
1723 } | 1731 } |
1724 | 1732 |
1725 } // namespace content | 1733 } // namespace content |
OLD | NEW |