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

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

Issue 227743007: ui::GestureProvider gives GestureEventData the number of touch points. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No more compiler errors. Created 6 years, 8 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
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 6ec8a5bc7f2cd93b658f2bb74b2c8c63325cfd1a..4897d86d324ebc7c5ec256f08cd4ef45db92dd4c 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -174,6 +174,7 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
EXPECT_TRUE(gesture_provider_->IsScrollInProgress());
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
ASSERT_EQ(4U, GetReceivedGestureCount()) << "Only TapDown, TapCancel, "
"ScrollBegin and ScrollBy "
@@ -195,6 +196,7 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
}
static void RunTasksAndWait(base::TimeDelta delay) {
@@ -222,6 +224,7 @@ TEST_F(GestureProviderTest, GestureTapTap) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneMicrosecond,
MotionEvent::ACTION_UP);
@@ -234,6 +237,7 @@ TEST_F(GestureProviderTest, GestureTapTap) {
EXPECT_EQ(10, GetMostRecentGestureEvent().details.bounding_box().height());
EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
}
// Verify that a DOWN followed shortly by an UP will trigger
@@ -251,6 +255,7 @@ TEST_F(GestureProviderTest, GestureTapTapWithDelay) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneMicrosecond,
MotionEvent::ACTION_UP);
@@ -263,6 +268,7 @@ TEST_F(GestureProviderTest, GestureTapTapWithDelay) {
EXPECT_EQ(10, GetMostRecentGestureEvent().details.bounding_box().height());
EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_TAP));
}
@@ -280,6 +286,7 @@ TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + delta_time,
MotionEvent::ACTION_MOVE,
@@ -297,6 +304,7 @@ TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS));
}
@@ -342,6 +350,7 @@ TEST_F(GestureProviderTest, FlingEventSequence) {
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
ASSERT_EQ(4U, GetReceivedGestureCount());
ASSERT_EQ(ET_GESTURE_SCROLL_BEGIN, GetReceivedGesture(2).type);
EXPECT_EQ(motion_event_id, GetReceivedGesture(2).motion_event_id);
@@ -363,6 +372,7 @@ TEST_F(GestureProviderTest, FlingEventSequence) {
EXPECT_FALSE(gesture_provider_->IsScrollInProgress());
EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_SCROLL_END));
EXPECT_EQ(event_time + delta_time * 2, GetMostRecentGestureEvent().time)
<< "FlingStart should have the time of the ACTION_UP";
@@ -375,15 +385,18 @@ TEST_F(GestureProviderTest, TapCancelledWhenWindowFocusLost) {
ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
RunTasksAndWait(GetLongPressTimeout() + GetShowPressTimeout() +
kOneMicrosecond);
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SHOW_PRESS));
EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
// The long press triggers window focus loss by opening a context menu
EXPECT_TRUE(CancelActiveTouchSequence());
EXPECT_EQ(ET_GESTURE_TAP_CANCEL, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
}
TEST_F(GestureProviderTest, TapCancelledWhenScrollBegins) {
@@ -395,6 +408,7 @@ TEST_F(GestureProviderTest, TapCancelledWhenScrollBegins) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneMicrosecond,
MotionEvent::ACTION_MOVE,
kFakeCoordX + 50,
@@ -402,6 +416,7 @@ TEST_F(GestureProviderTest, TapCancelledWhenScrollBegins) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP_CANCEL));
}
@@ -413,6 +428,7 @@ TEST_F(GestureProviderTest, DoubleTap) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneMicrosecond,
MotionEvent::ACTION_UP,
@@ -420,6 +436,7 @@ TEST_F(GestureProviderTest, DoubleTap) {
kFakeCoordY);
gesture_provider_->OnTouchEvent(event);
EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneMicrosecond * 2,
MotionEvent::ACTION_DOWN,
@@ -427,6 +444,7 @@ TEST_F(GestureProviderTest, DoubleTap) {
kFakeCoordY);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
// Moving a very small amount of distance should not trigger the double tap
// drag zoom mode.
@@ -436,6 +454,7 @@ TEST_F(GestureProviderTest, DoubleTap) {
kFakeCoordY + 1);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneMicrosecond * 3,
MotionEvent::ACTION_UP,
@@ -465,11 +484,13 @@ TEST_F(GestureProviderTest, DoubleTapDragZoomBasic) {
kFakeCoordY);
gesture_provider_->OnTouchEvent(event);
EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(
down_time_2, MotionEvent::ACTION_DOWN, kFakeCoordX, kFakeCoordY);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(down_time_2 + kOneMicrosecond,
MotionEvent::ACTION_MOVE,
@@ -537,6 +558,7 @@ TEST_F(GestureProviderTest, ScrollUpdateValues) {
EXPECT_EQ(event_time + kOneMicrosecond * 2, gesture.time);
EXPECT_EQ(kFakeCoordX - delta_x, gesture.x);
EXPECT_EQ(kFakeCoordY - delta_y, gesture.y);
+ EXPECT_EQ(1, gesture.details.touch_points());
// No horizontal delta because of snapping.
EXPECT_EQ(0, gesture.details.scroll_x());
@@ -578,6 +600,7 @@ TEST_F(GestureProviderTest, FractionalScroll) {
GestureEventData gesture = GetMostRecentGestureEvent();
EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type);
EXPECT_EQ(event_time + kOneMicrosecond * i, gesture.time);
+ EXPECT_EQ(1, gesture.details.touch_points());
// Verify that the event co-ordinates are still the precise values we
// supplied.
@@ -667,10 +690,12 @@ TEST_F(GestureProviderTest, GestureLongTap) {
RunTasksAndWait(long_press_timeout);
EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneSecond, MotionEvent::ACTION_UP);
gesture_provider_->OnTouchEvent(event);
EXPECT_EQ(ET_GESTURE_LONG_TAP, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
}
TEST_F(GestureProviderTest, GestureLongPressDoesNotPreventScrolling) {
@@ -685,6 +710,7 @@ TEST_F(GestureProviderTest, GestureLongPressDoesNotPreventScrolling) {
RunTasksAndWait(long_press_timeout);
EXPECT_EQ(ET_GESTURE_LONG_PRESS, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + long_press_timeout,
MotionEvent::ACTION_MOVE,
kFakeCoordX + 100,
@@ -692,6 +718,7 @@ TEST_F(GestureProviderTest, GestureLongPressDoesNotPreventScrolling) {
gesture_provider_->OnTouchEvent(event);
EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_TAP_CANCEL));
@@ -715,6 +742,7 @@ TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {
kFakeCoordY);
gesture_provider_->OnTouchEvent(event);
EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + kOneMicrosecond,
MotionEvent::ACTION_DOWN,
@@ -722,6 +750,7 @@ TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {
kFakeCoordY);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress());
const base::TimeDelta long_press_timeout =
@@ -738,6 +767,7 @@ TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_PINCH_BEGIN, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_TRUE(gesture_provider_->IsDoubleTapInProgress());
event = ObtainMotionEvent(event_time + long_press_timeout + kOneMicrosecond,
@@ -748,6 +778,7 @@ TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_SCROLL_END, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_FALSE(gesture_provider_->IsDoubleTapInProgress());
}
@@ -1008,6 +1039,7 @@ TEST_F(GestureProviderTest, PinchZoom) {
event.SetId(++motion_event_id);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time,
MotionEvent::ACTION_POINTER_DOWN,
@@ -1086,6 +1118,7 @@ TEST_F(GestureProviderTest, GesturesCancelledAfterLongPressCausesLostFocus) {
EXPECT_TRUE(CancelActiveTouchSequence());
EXPECT_EQ(ET_GESTURE_TAP_CANCEL, GetMostRecentGestureEventType());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + long_press_timeout,
MotionEvent::ACTION_UP);
@@ -1136,60 +1169,78 @@ TEST_F(GestureProviderTest, GestureBeginAndEnd) {
EXPECT_EQ(0U, GetReceivedGestureCount());
MockMotionEvent event =
ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ event.pointer_count = 1;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type);
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
EXPECT_EQ(2U, GetReceivedGestureCount());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN);
+ event.pointer_count = 2;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
EXPECT_EQ(3U, GetReceivedGestureCount());
+ EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN);
+ event.pointer_count = 3;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
EXPECT_EQ(4U, GetReceivedGestureCount());
+ EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP);
+ event.pointer_count = 2;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
EXPECT_EQ(5U, GetReceivedGestureCount());
+ EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN);
+ event.pointer_count = 3;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
EXPECT_EQ(6U, GetReceivedGestureCount());
+ EXPECT_EQ(3, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP);
+ event.pointer_count = 2;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
EXPECT_EQ(7U, GetReceivedGestureCount());
+ EXPECT_EQ(2, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP);
+ event.pointer_count = 1;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
EXPECT_EQ(8U, GetReceivedGestureCount());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP);
+ event.pointer_count = 1;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
EXPECT_EQ(9U, GetReceivedGestureCount());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ event.pointer_count = 1;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_CANCEL, GetReceivedGesture(9).type);
EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(10).type);
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
EXPECT_EQ(12U, GetReceivedGestureCount());
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time, MotionEvent::ACTION_CANCEL);
+ event.pointer_count = 1;
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_CANCEL, GetReceivedGesture(12).type);
EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
EXPECT_EQ(14U, GetReceivedGestureCount());
-
-
+ EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
}
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698