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)) { |
tdresser
2013/11/21 13:54:31
Can you reverse this condition as you have above?
jdduke (slow)
2013/11/21 16:55:29
Done.
| |
570 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); | 597 SimulateGestureEvent(type, WebGestureEvent::Touchscreen); |
571 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 598 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
572 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 599 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
573 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 600 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
574 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 601 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
575 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 602 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
576 } | 603 } |
577 } | 604 } |
578 } | 605 } |
579 | 606 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 SendInputEventACK(WebInputEvent::GestureTap, | 704 SendInputEventACK(WebInputEvent::GestureTap, |
678 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 705 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
679 | 706 |
680 // Now that the Tap has been ACKed, the ShowPress events should receive | 707 // Now that the Tap has been ACKed, the ShowPress events should receive |
681 // synthetics acks, and fire immediately. | 708 // synthetics acks, and fire immediately. |
682 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); | 709 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); |
683 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); | 710 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); |
684 } | 711 } |
685 | 712 |
686 } // namespace content | 713 } // namespace content |
OLD | NEW |