OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/renderer_host/input/gesture_event_filter.h" | 8 #include "content/browser/renderer_host/input/gesture_event_filter.h" |
9 #include "content/browser/renderer_host/input/immediate_input_router.h" | 9 #include "content/browser/renderer_host/input/immediate_input_router.h" |
10 #include "content/browser/renderer_host/input/input_router_client.h" | 10 #include "content/browser/renderer_host/input/input_router_client.h" |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 554 |
555 // Check that the second event was sent. | 555 // Check that the second event was sent. |
556 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 556 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
557 InputMsg_HandleInputEvent::ID)); | 557 InputMsg_HandleInputEvent::ID)); |
558 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 558 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
559 | 559 |
560 // Check that the correct unhandled wheel event was received. | 560 // Check that the correct unhandled wheel event was received. |
561 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); | 561 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); |
562 } | 562 } |
563 | 563 |
| 564 TEST_F(ImmediateInputRouterTest, TouchTypesIgnoringAck) { |
| 565 int start_type = static_cast<int>(WebInputEvent::TouchStart); |
| 566 int end_type = static_cast<int>(WebInputEvent::TouchCancel); |
| 567 for (int i = start_type; i <= end_type; ++i) { |
| 568 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); |
| 569 if (!WebInputEventTraits::IgnoresAckDisposition(type)) |
| 570 continue; |
| 571 |
| 572 // The TouchEventQueue requires an initial TouchStart for it to begin |
| 573 // forwarding other touch event types. |
| 574 if (type != WebInputEvent::TouchStart) { |
| 575 SimulateTouchEvent(WebInputEvent::TouchStart); |
| 576 SendInputEventACK(WebInputEvent::TouchStart, |
| 577 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 578 ASSERT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 579 ASSERT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 580 } |
| 581 |
| 582 SimulateTouchEvent(type); |
| 583 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 584 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
| 585 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 586 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 587 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 588 } |
| 589 } |
| 590 |
564 TEST_F(ImmediateInputRouterTest, GestureTypesIgnoringAck) { | 591 TEST_F(ImmediateInputRouterTest, GestureTypesIgnoringAck) { |
565 int start_type = static_cast<int>(WebInputEvent::GestureScrollBegin); | 592 int start_type = static_cast<int>(WebInputEvent::GestureScrollBegin); |
566 int end_type = static_cast<int>(WebInputEvent::GesturePinchUpdate); | 593 int end_type = static_cast<int>(WebInputEvent::GesturePinchUpdate); |
567 for (int i = start_type; i <= end_type; ++i) { | 594 for (int i = start_type; i <= end_type; ++i) { |
568 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); | 595 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); |
569 if (WebInputEventTraits::IgnoresAckDisposition(type)) { | 596 if (!WebInputEventTraits::IgnoresAckDisposition(type)) |
570 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); | 597 continue; |
571 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 598 |
572 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 599 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); |
573 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 600 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
574 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 601 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
575 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 602 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
576 } | 603 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 604 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
577 } | 605 } |
578 } | 606 } |
579 | 607 |
580 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't | 608 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't |
581 // wait for ACKs. | 609 // wait for ACKs. |
582 TEST_F(ImmediateInputRouterTest, GestureTypesIgnoringAckInterleaved) { | 610 TEST_F(ImmediateInputRouterTest, GestureTypesIgnoringAckInterleaved) { |
583 // Interleave a few events that do and do not ignore acks, ensuring that | 611 // Interleave a few events that do and do not ignore acks, ensuring that |
584 // ack-ignoring events aren't dispatched until all prior events which observe | 612 // ack-ignoring events aren't dispatched until all prior events which observe |
585 // their ack disposition have been dispatched. | 613 // their ack disposition have been dispatched. |
586 SimulateGestureEvent(WebInputEvent::GesturePinchUpdate, | 614 SimulateGestureEvent(WebInputEvent::GesturePinchUpdate, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 SendInputEventACK(WebInputEvent::GestureTap, | 705 SendInputEventACK(WebInputEvent::GestureTap, |
678 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 706 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
679 | 707 |
680 // Now that the Tap has been ACKed, the ShowPress events should receive | 708 // Now that the Tap has been ACKed, the ShowPress events should receive |
681 // synthetics acks, and fire immediately. | 709 // synthetics acks, and fire immediately. |
682 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 710 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
683 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); | 711 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); |
684 } | 712 } |
685 | 713 |
686 } // namespace content | 714 } // namespace content |
OLD | NEW |