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

Unified Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 178193022: [Android] Always insert a TouchCancel if window or tab focus is lost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 10 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 | « ui/events/gesture_detection/gesture_provider.cc ('k') | ui/events/gesture_detection/mock_motion_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gesture_detection/gesture_provider_unittest.cc
diff --git a/ui/events/gesture_detection/gesture_provider_unittest.cc b/ui/events/gesture_detection/gesture_provider_unittest.cc
index ba518cbbef99bec710fafc52768f093659703679..ddeb191ed250e3c932cd873d3e0d879e9fd593ed 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -72,6 +72,13 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
gestures_.push_back(gesture);
}
+ bool CancelActiveTouchSequence() {
+ if (!gesture_provider_->current_down_event())
+ return false;
+ return gesture_provider_->OnTouchEvent(
+ *gesture_provider_->current_down_event()->Cancel());
+ }
+
bool HasReceivedGesture(EventType type) const {
for (size_t i = 0; i < gestures_.size(); ++i) {
if (gestures_[i].type == type)
@@ -302,7 +309,7 @@ TEST_F(GestureProviderTest, TapCancelledWhenWindowFocusLost) {
EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
// The long press triggers window focus loss by opening a context menu
- gesture_provider_->CancelActiveTouchSequence();
+ EXPECT_TRUE(CancelActiveTouchSequence());
EXPECT_EQ(ET_GESTURE_TAP_CANCEL, GetMostRecentGestureEventType());
}
@@ -971,7 +978,7 @@ TEST_F(GestureProviderTest, GesturesCancelledAfterLongPressCausesLostFocus) {
Wait(long_press_timeout);
EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
- gesture_provider_->CancelActiveTouchSequence();
+ EXPECT_TRUE(CancelActiveTouchSequence());
EXPECT_EQ(ET_GESTURE_TAP_CANCEL, GetMostRecentGestureEventType());
event = ObtainMotionEvent(event_time + long_press_timeout,
@@ -980,12 +987,12 @@ TEST_F(GestureProviderTest, GesturesCancelledAfterLongPressCausesLostFocus) {
EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_TAP));
}
-// Verify that ignoring the remaining touch sequence triggers proper touch and
-// gesture cancellation.
+// Verify that inserting a touch cancel event will trigger proper touch and
+// gesture sequence cancellation.
TEST_F(GestureProviderTest, CancelActiveTouchSequence) {
base::TimeTicks event_time = base::TimeTicks::Now();
- gesture_provider_->CancelActiveTouchSequence();
+ EXPECT_FALSE(CancelActiveTouchSequence());
EXPECT_EQ(0U, GetReceivedGestureCount());
MockMotionEvent event =
@@ -993,7 +1000,7 @@ TEST_F(GestureProviderTest, CancelActiveTouchSequence) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
- gesture_provider_->CancelActiveTouchSequence();
+ ASSERT_TRUE(CancelActiveTouchSequence());
EXPECT_EQ(ET_GESTURE_TAP_CANCEL, GetMostRecentGestureEventType());
// Subsequent MotionEvent's are dropped until ACTION_DOWN.
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | ui/events/gesture_detection/mock_motion_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698