Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Side by Side Diff: content/browser/renderer_host/input/immediate_input_router_unittest.cc

Issue 44983003: Events ignoring ack disposition receive synthetic acks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jdduke comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 // Check that the second event was sent. 552 // Check that the second event was sent.
553 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( 553 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(
554 InputMsg_HandleInputEvent::ID)); 554 InputMsg_HandleInputEvent::ID));
555 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 555 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
556 556
557 // Check that the correct unhandled wheel event was received. 557 // Check that the correct unhandled wheel event was received.
558 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5); 558 EXPECT_EQ(ack_handler_->acked_wheel_event().deltaY, -5);
559 } 559 }
560 560
561 // Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't
562 // wait for ACKs.
563 TEST_F(ImmediateInputRouterTest, GestureTypesIgnoringAck) {
564 // The show press, tap down and tap cancel events will be acked immediately,
565 // since they ignore ack disposition.
566 SimulateGestureEvent(WebInputEvent::GestureShowPress,
567 WebGestureEvent::Touchscreen);
568 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
569 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
570
571 SimulateGestureEvent(WebInputEvent::GestureTapDown,
572 WebGestureEvent::Touchscreen);
573 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
574 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
575
576 SimulateGestureEvent(WebInputEvent::GestureTapCancel,
577 WebGestureEvent::Touchscreen);
578 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
579 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
580
581 // Interleave a few events that do and do not ignore acks, ensuring that
582 // ack-ignoring events aren't dispatched until all prior events which observe
583 // their ack disposition have been dispatched.
584 SimulateGestureEvent(WebInputEvent::GesturePinchBegin,
585 WebGestureEvent::Touchpad);
586 ASSERT_EQ(1U, GetSentMessageCountAndResetSink());
587 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
588
589 SimulateGestureEvent(WebInputEvent::GestureTapDown,
590 WebGestureEvent::Touchscreen);
591 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
592 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
593
594 SimulateGestureEvent(WebInputEvent::GesturePinchUpdate,
595 WebGestureEvent::Touchpad);
596 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
597 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
598
599 SimulateGestureEvent(WebInputEvent::GestureShowPress,
600 WebGestureEvent::Touchscreen);
601 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
602 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
603
604 SimulateGestureEvent(WebInputEvent::GesturePinchEnd,
605 WebGestureEvent::Touchpad);
606 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
607 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
608
609 SimulateGestureEvent(WebInputEvent::GestureTapCancel,
610 WebGestureEvent::Touchscreen);
611 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
612 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
613
614 // Now ack each event. Ack-ignoring events should not be dispatched until all
615 // prior events which observe ack disposition have been fired, at which
616 // point they should be sent immediately.
617 SendInputEventACK(WebInputEvent::GesturePinchBegin,
618 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
619 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
620 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
621
622 // For events which ignore ack disposition, non-synthetic acks are ignored.
623 SendInputEventACK(WebInputEvent::GestureTapDown,
624 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
625 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
626 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
627
628 SendInputEventACK(WebInputEvent::GesturePinchUpdate,
629 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
630 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
631 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
632
633 // For events which ignore ack disposition, non-synthetic acks are ignored.
634 SendInputEventACK(WebInputEvent::GestureShowPress,
635 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
636 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
637 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
638
639 SendInputEventACK(WebInputEvent::GesturePinchEnd,
640 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
641 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
642 EXPECT_EQ(2U, ack_handler_->GetAndResetAckCount());
643
644 // For events which ignore ack disposition, non-synthetic acks are ignored.
645 SendInputEventACK(WebInputEvent::GestureTapCancel,
646 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
647 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
648 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
649 }
650
651 // Test that GestureShowPress events don't get out of order due to
652 // ignoring their acks.
653 TEST_F(ImmediateInputRouterTest, GestureShowPressIsInOrder) {
654 SimulateGestureEvent(WebInputEvent::GestureTap,
655 WebGestureEvent::Touchscreen);
656
657 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
658 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
659
660 SimulateGestureEvent(WebInputEvent::GestureShowPress,
661 WebGestureEvent::Touchscreen);
662
663 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
664 // The ShowPress, though it ignores ack, is still stuck in the queue
665 // behind the Tap which requires an ack.
666 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
667
668 SimulateGestureEvent(WebInputEvent::GestureShowPress,
669 WebGestureEvent::Touchscreen);
670
671 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
672 // ShowPress has entered the queue.
673 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
674
675 SendInputEventACK(WebInputEvent::GestureTap,
676 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
677
678 // Now that the Tap has been ACKed, the ShowPress events should receive
679 // synthetics acks, and fire immediately.
680 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
681 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount());
682 }
683
561 } // namespace content 684 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/immediate_input_router.cc ('k') | content/common/input/web_input_event_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698