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

Unified Diff: content/browser/renderer_host/input/tap_suppression_controller_unittest.cc

Issue 2613533003: Tap suppression controller forwards the next TapCancel when the stashed TapDown is forwarded. (Closed)
Patch Set: Created 3 years, 12 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/tap_suppression_controller_unittest.cc
diff --git a/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc b/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc
index 195a49629f03becb6f6160acb9805b2523c77eb6..b064a5bfb57b56e0d5019336d3997971a1dbd465 100644
--- a/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc
+++ b/content/browser/renderer_host/input/tap_suppression_controller_unittest.cc
@@ -71,8 +71,10 @@ class MockTapSuppressionController : public TapSuppressionController,
}
void SendTapCancel() {
+ bool stashed_tap_down_forwarded =
+ last_actions_ & STASHED_TAP_DOWN_FORWARDED;
last_actions_ = NONE;
- if (ShouldSuppressTapEnd())
+ if (!stashed_tap_down_forwarded && ShouldSuppressTapEnd())
last_actions_ |= TAP_CANCEL_SUPPRESSED;
else
last_actions_ |= TAP_CANCEL_FORWARDED;
@@ -245,7 +247,7 @@ TEST_F(TapSuppressionControllerTest, GFCAckBeforeTapSufficientlyLateTapUp) {
EXPECT_EQ(MockTapSuppressionController::LAST_CANCEL_STOPPED_FLING,
tap_suppression_controller_->state());
- // Send MouseDown. This MouseDown should be suppressed, for now.
+ // Send TapDown. This TapDown should be suppressed, for now.
tap_suppression_controller_->SendTapDown();
EXPECT_EQ(MockTapSuppressionController::TAP_DOWN_DEFERRED,
tap_suppression_controller_->last_actions());
@@ -270,6 +272,49 @@ TEST_F(TapSuppressionControllerTest, GFCAckBeforeTapSufficientlyLateTapUp) {
tap_suppression_controller_->state());
}
+// Test TapSuppressionController for when stashed TapDown gets forwarded.
+// The next TapCancel should be forwarded as well to maintain a valid input
+// stream.
+TEST_F(TapSuppressionControllerTest, GFCAckBeforeTapSufficientlyLateTapCancel) {
+ // Send GestureFlingCancel.
+ tap_suppression_controller_->SendGestureFlingCancel();
+ EXPECT_EQ(MockTapSuppressionController::NONE,
+ tap_suppression_controller_->last_actions());
+ EXPECT_EQ(MockTapSuppressionController::GFC_IN_PROGRESS,
+ tap_suppression_controller_->state());
+
+ // Send processed GestureFlingCancel Ack.
+ tap_suppression_controller_->SendGestureFlingCancelAck(true);
+ EXPECT_EQ(MockTapSuppressionController::NONE,
+ tap_suppression_controller_->last_actions());
+ EXPECT_EQ(MockTapSuppressionController::LAST_CANCEL_STOPPED_FLING,
+ tap_suppression_controller_->state());
+
+ // Send TapDown. This TapDown should be suppressed, for now.
+ tap_suppression_controller_->SendTapDown();
+ EXPECT_EQ(MockTapSuppressionController::TAP_DOWN_DEFERRED,
+ tap_suppression_controller_->last_actions());
+ EXPECT_EQ(MockTapSuppressionController::TAP_DOWN_STASHED,
+ tap_suppression_controller_->state());
+
+ // Wait more than the delay for TapDown timer. This should release the
+ // previously stashed TapDown.
+ tap_suppression_controller_->AdvanceTime(TimeDelta::FromMilliseconds(13));
+ EXPECT_EQ(MockTapSuppressionController::STASHED_TAP_DOWN_FORWARDED,
+ tap_suppression_controller_->last_actions());
+ EXPECT_EQ(MockTapSuppressionController::SUPPRESSING_TAPS,
+ tap_suppression_controller_->state());
+
+ // Send TapCancel. This TapCancel should be forwarded.
+ // When a TapDown is forwarded because of the timer expiration, the next
+ // TapCancel should get forwarded as well to maintain a valid input stream.
+ tap_suppression_controller_->SendTapCancel();
+ EXPECT_EQ(MockTapSuppressionController::TAP_CANCEL_FORWARDED,
+ tap_suppression_controller_->last_actions());
+ EXPECT_EQ(MockTapSuppressionController::SUPPRESSING_TAPS,
+ tap_suppression_controller_->state());
+}
+
// Test TapSuppressionController for when GestureFlingCancel Ack comes before
// TapDown, but there is a small delay between the Ack and TapDown.
TEST_F(TapSuppressionControllerTest, GFCAckBeforeTapInsufficientlyLateTapDown) {
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698