Index: ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc |
diff --git a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc |
index fa310568200ad21c48124ec55594f2bb7d6a4704..43a4e24ab4cebf2bc712766aa8e5a87941624668 100644 |
--- a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc |
+++ b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc |
@@ -6,7 +6,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" |
-#include "ui/events/test/mock_motion_event.h" |
+#include "ui/events/test/motion_event_test_utils.h" |
using ui::test::MockMotionEvent; |
@@ -31,9 +31,7 @@ class TouchDispositionGestureFilterTest |
touch_event_.set_flags(kDefaultEventFlags); |
} |
- void TearDown() override { |
- queue_.reset(); |
- } |
+ void TearDown() override { queue_.reset(); } |
// TouchDispositionGestureFilterClient |
void ForwardGestureEvent(const GestureEventData& event) override { |
@@ -44,8 +42,8 @@ class TouchDispositionGestureFilterTest |
show_press_bounding_box_ = event.details.bounding_box(); |
if (cancel_after_next_gesture_) { |
cancel_after_next_gesture_ = false; |
- CancelTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(CancelTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
} |
} |
@@ -73,6 +71,8 @@ class TouchDispositionGestureFilterTest |
return ::testing::AssertionSuccess(); |
} |
+ GestureList NoGestures() { return GestureList(0); } |
+ |
GestureList Gestures(EventType type) { |
return GestureList(1, type); |
} |
@@ -106,17 +106,9 @@ class TouchDispositionGestureFilterTest |
return gestures; |
} |
- void SendTouchGestures() { |
- touch_event_.set_event_time(base::TimeTicks::Now()); |
- EXPECT_EQ(TouchDispositionGestureFilter::SUCCESS, |
- SendTouchGestures(touch_event_, pending_gesture_packet_)); |
- GestureEventDataPacket gesture_packet; |
- std::swap(gesture_packet, pending_gesture_packet_); |
- } |
- |
- TouchDispositionGestureFilter::PacketResult |
- SendTouchGestures(const MotionEvent& touch, |
- const GestureEventDataPacket& packet) { |
+ TouchDispositionGestureFilter::PacketResult SendTouchGesturesWithResult( |
+ const MotionEvent& touch, |
+ const GestureEventDataPacket& packet) { |
GestureEventDataPacket touch_packet = |
GestureEventDataPacket::FromTouch(touch); |
for (size_t i = 0; i < packet.gesture_count(); ++i) |
@@ -124,6 +116,13 @@ class TouchDispositionGestureFilterTest |
return queue_->OnGesturePacket(touch_packet); |
} |
+ uint32 SendTouchGestures(const MotionEvent& touch, |
+ const GestureEventDataPacket& packet) { |
+ SendTouchGesturesWithResult(touch, packet); |
+ last_sent_touch_event_id_ = touch.GetUniqueEventId(); |
+ return touch.GetUniqueEventId(); |
+ } |
+ |
TouchDispositionGestureFilter::PacketResult |
SendTimeoutGesture(EventType type) { |
return queue_->OnGesturePacket( |
@@ -135,13 +134,25 @@ class TouchDispositionGestureFilterTest |
return queue_->OnGesturePacket(packet); |
} |
- void SendTouchEventAck(bool event_consumed) { |
- queue_->OnTouchEventAck(event_consumed); |
+ void SendTouchEventAck(uint32 touch_event_id, bool event_consumed) { |
+ queue_->OnTouchEventAck(touch_event_id, event_consumed); |
+ } |
+ |
+ void SendTouchConsumedAck(uint32 touch_event_id) { |
+ SendTouchEventAck(touch_event_id, true); |
+ } |
+ |
+ void SendTouchNotConsumedAck(uint32 touch_event_id) { |
+ SendTouchEventAck(touch_event_id, false); |
} |
- void SendTouchConsumedAck() { SendTouchEventAck(true); } |
+ void SendTouchConsumedAckForLastTouch() { |
+ SendTouchEventAck(last_sent_touch_event_id_, true); |
+ } |
- void SendTouchNotConsumedAck() { SendTouchEventAck(false); } |
+ void SendTouchNotConsumedAckForLastTouch() { |
+ SendTouchEventAck(last_sent_touch_event_id_, false); |
+ } |
void PushGesture(EventType type) { |
pending_gesture_packet_.Push(CreateGesture(type)); |
@@ -151,39 +162,61 @@ class TouchDispositionGestureFilterTest |
pending_gesture_packet_.Push(CreateGesture(type, x, y, diameter)); |
} |
- void PressTouchPoint(int x, int y) { |
+ const MockMotionEvent& PressTouchPoint(float x, float y) { |
touch_event_.PressPoint(x, y); |
touch_event_.SetRawOffset(raw_offset_.x(), raw_offset_.y()); |
- SendTouchGestures(); |
+ return touch_event_; |
} |
- void MoveTouchPoint(size_t index, int x, int y) { |
- touch_event_.MovePoint(index, x, y); |
- touch_event_.SetRawOffset(raw_offset_.x(), raw_offset_.y()); |
- SendTouchGestures(); |
+ const MockMotionEvent& PressTouchPoint() { return PressTouchPoint(0, 0); } |
+ |
+ const MockMotionEvent& MoveTouchPoint() { |
+ touch_event_.MovePoint(0, 0, 0); |
+ touch_event_.set_event_time(base::TimeTicks::Now()); |
+ return touch_event_; |
} |
- void ReleaseTouchPoint() { |
+ const MockMotionEvent& ReleaseTouchPoint() { |
touch_event_.ReleasePoint(); |
- SendTouchGestures(); |
+ touch_event_.set_event_time(base::TimeTicks::Now()); |
+ return touch_event_; |
} |
- void CancelTouchPoint() { |
+ const MockMotionEvent& CancelTouchPoint() { |
touch_event_.CancelPoint(); |
- SendTouchGestures(); |
+ touch_event_.set_event_time(base::TimeTicks::Now()); |
+ return touch_event_; |
+ } |
+ |
+ uint32 SendPacket(const MockMotionEvent& touch_event, |
+ GestureList gesture_list) { |
+ GestureEventDataPacket gesture_packet; |
+ for (EventType type : gesture_list) |
+ gesture_packet.Push(CreateGesture(type)); |
+ last_sent_touch_event_id_ = touch_event.GetUniqueEventId(); |
+ EXPECT_EQ(TouchDispositionGestureFilter::SUCCESS, |
+ SendTouchGesturesWithResult(touch_event, gesture_packet)); |
+ return touch_event.GetUniqueEventId(); |
} |
void SetRawTouchOffset(const gfx::Vector2dF& raw_offset) { |
raw_offset_ = raw_offset; |
} |
- void ResetTouchPoints() { touch_event_ = MockMotionEvent(); } |
+ const MockMotionEvent& ResetTouchPoints() { |
+ touch_event_ = MockMotionEvent(); |
+ return touch_event_; |
+ } |
bool GesturesSent() const { return !sent_gestures_.empty(); } |
- base::TimeTicks LastSentGestureTime() const { |
+ const GestureEventData& last_sent_gesture() const { |
CHECK(last_sent_gesture_); |
- return last_sent_gesture_->time; |
+ return *last_sent_gesture_; |
+ } |
+ |
+ base::TimeTicks LastSentGestureTime() const { |
+ return last_sent_gesture().time; |
} |
base::TimeTicks CurrentTouchTime() const { |
@@ -199,18 +232,15 @@ class TouchDispositionGestureFilterTest |
} |
gfx::PointF LastSentGestureLocation() const { |
- CHECK(last_sent_gesture_); |
- return gfx::PointF(last_sent_gesture_->x, last_sent_gesture_->y); |
+ return gfx::PointF(last_sent_gesture().x, last_sent_gesture().y); |
} |
gfx::PointF LastSentGestureRawLocation() const { |
- CHECK(last_sent_gesture_); |
- return gfx::PointF(last_sent_gesture_->raw_x, last_sent_gesture_->raw_y); |
+ return gfx::PointF(last_sent_gesture().raw_x, last_sent_gesture().raw_y); |
} |
int LastSentGestureFlags() const { |
- CHECK(last_sent_gesture_); |
- return last_sent_gesture_->flags; |
+ return last_sent_gesture().flags; |
} |
const gfx::RectF& ShowPressBoundingBox() const { |
@@ -230,15 +260,8 @@ class TouchDispositionGestureFilterTest |
float y, |
float diameter) { |
return GestureEventData( |
- GestureEventDetails(type), |
- 0, |
- MotionEvent::TOOL_TYPE_FINGER, |
- base::TimeTicks(), |
- touch_event_.GetX(0), |
- touch_event_.GetY(0), |
- touch_event_.GetRawX(0), |
- touch_event_.GetRawY(0), |
- 1, |
+ GestureEventDetails(type), 0, MotionEvent::TOOL_TYPE_FINGER, |
+ base::TimeTicks(), x, y, 0, 0, 1, |
gfx::RectF(x - diameter / 2, y - diameter / 2, diameter, diameter), |
kDefaultEventFlags); |
} |
@@ -253,354 +276,307 @@ class TouchDispositionGestureFilterTest |
gfx::Vector2dF raw_offset_; |
scoped_ptr<GestureEventData> last_sent_gesture_; |
gfx::RectF show_press_bounding_box_; |
+ uint32 last_sent_touch_event_id_; |
}; |
TEST_F(TouchDispositionGestureFilterTest, BasicNoGestures) { |
- PressTouchPoint(1, 1); |
+ uint32 touch_press_event_id = PressTouchPoint().GetUniqueEventId(); |
EXPECT_FALSE(GesturesSent()); |
- MoveTouchPoint(0, 2, 2); |
+ uint32 touch_move_event_id = MoveTouchPoint().GetUniqueEventId(); |
EXPECT_FALSE(GesturesSent()); |
// No gestures should be dispatched by the ack, as the queued packets |
// contained no gestures. |
- SendTouchConsumedAck(); |
+ SendTouchConsumedAck(touch_press_event_id); |
EXPECT_FALSE(GesturesSent()); |
// Release the touch gesture. |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
- SendTouchConsumedAck(); |
+ uint32 touch_release_event_id = ReleaseTouchPoint().GetUniqueEventId(); |
+ SendTouchConsumedAck(touch_move_event_id); |
+ SendTouchConsumedAck(touch_release_event_id); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, BasicGestures) { |
+ GestureList press_gestures = |
+ Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN); |
// An unconsumed touch's gesture should be sent. |
- PushGesture(ET_GESTURE_BEGIN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
+ SendPacket(PressTouchPoint(), press_gestures); |
EXPECT_FALSE(GesturesSent()); |
- SendTouchNotConsumedAck(); |
- EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN), |
- GetAndResetSentGestures())); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ EXPECT_TRUE(GesturesMatch(press_gestures, GetAndResetSentGestures())); |
// Multiple gestures can be queued for a single event. |
- PushGesture(ET_SCROLL_FLING_START); |
- PushGesture(ET_SCROLL_FLING_CANCEL); |
- PushGesture(ET_GESTURE_END); |
- ReleaseTouchPoint(); |
+ GestureList release_gestures = |
+ Gestures(ET_SCROLL_FLING_START, ET_SCROLL_FLING_CANCEL, ET_GESTURE_END); |
+ SendPacket(ReleaseTouchPoint(), release_gestures); |
EXPECT_FALSE(GesturesSent()); |
- SendTouchNotConsumedAck(); |
- EXPECT_TRUE(GesturesMatch(Gestures(ET_SCROLL_FLING_START, |
- ET_SCROLL_FLING_CANCEL, |
- ET_GESTURE_END), |
- GetAndResetSentGestures())); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ EXPECT_TRUE(GesturesMatch(release_gestures, GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, BasicGesturesConsumed) { |
// A consumed touch's gesture should not be sent. |
- PushGesture(ET_GESTURE_BEGIN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), |
+ Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_SCROLL_FLING_START); |
- PushGesture(ET_SCROLL_FLING_CANCEL); |
- PushGesture(ET_GESTURE_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket( |
+ ReleaseTouchPoint(), |
+ Gestures(ET_SCROLL_FLING_START, ET_SCROLL_FLING_CANCEL, ET_GESTURE_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, ConsumedThenNotConsumed) { |
// A consumed touch's gesture should not be sent. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
// Even if the subsequent touch is not consumed, continue dropping gestures. |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
// Even if the subsequent touch had no consumer, continue dropping gestures. |
- PushGesture(ET_SCROLL_FLING_START); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_SCROLL_FLING_START)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, NotConsumedThenConsumed) { |
// A not consumed touch's gesture should be sent. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
// A newly consumed gesture should not be sent. |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(10, 10); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
// And subsequent non-consumed pinch updates should not be sent. |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- PushGesture(ET_GESTURE_PINCH_UPDATE); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(MoveTouchPoint(), |
+ Gestures(ET_GESTURE_SCROLL_UPDATE, ET_GESTURE_PINCH_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_UPDATE), |
GetAndResetSentGestures())); |
// End events dispatched only when their start events were. |
- PushGesture(ET_GESTURE_PINCH_END); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_PINCH_END)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_SCROLL_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, ScrollAlternatelyConsumed) { |
// A consumed touch's gesture should not be sent. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
for (size_t i = 0; i < 3; ++i) { |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 3, 3); |
- SendTouchNotConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_UPDATE), |
GetAndResetSentGestures())); |
} |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_SCROLL_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, NotConsumedThenNoConsumer) { |
// An unconsumed touch's gesture should be sent. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
// If the subsequent touch has no consumer (e.g., a secondary pointer is |
// pressed but not on a touch handling rect), send the gesture. |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_BEGIN), |
GetAndResetSentGestures())); |
// End events should be dispatched when their start events were, independent |
// of the ack state. |
- PushGesture(ET_GESTURE_PINCH_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_PINCH_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_END), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_SCROLL_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, EndingEventsSent) { |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_BEGIN), |
GetAndResetSentGestures())); |
// Consuming the touchend event can't suppress the match end gesture. |
- PushGesture(ET_GESTURE_PINCH_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_PINCH_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_END), |
GetAndResetSentGestures())); |
// But other events in the same packet are still suppressed. |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), |
+ Gestures(ET_GESTURE_SCROLL_UPDATE, ET_GESTURE_SCROLL_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
// ET_GESTURE_SCROLL_END and ET_SCROLL_FLING_START behave the same in this |
// regard. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_SCROLL_FLING_START); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_SCROLL_FLING_START)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_SCROLL_FLING_START), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, EndingEventsNotSent) { |
// Consuming a begin event ensures no end events are sent. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_PINCH_END); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_PINCH_END)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_SCROLL_END)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, UpdateEventsSuppressedPerEvent) { |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
// Consuming a single scroll or pinch update should suppress only that event. |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_PINCH_UPDATE); |
- MoveTouchPoint(1, 2, 3); |
- SendTouchConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_PINCH_UPDATE)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
// Subsequent updates should not be affected. |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 4, 4); |
- SendTouchNotConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_UPDATE), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_PINCH_UPDATE); |
- MoveTouchPoint(0, 4, 5); |
- SendTouchNotConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_PINCH_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_UPDATE), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_PINCH_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_PINCH_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_END), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_SCROLL_END)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, UpdateEventsDependOnBeginEvents) { |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
// Scroll and pinch gestures depend on the scroll begin gesture being |
// dispatched. |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_PINCH_UPDATE); |
- MoveTouchPoint(1, 2, 3); |
- SendTouchConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_PINCH_UPDATE)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_PINCH_END); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_PINCH_END)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_SCROLL_END)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, MultipleTouchSequences) { |
// Queue two touch-to-gestures sequences. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- PushGesture(ET_GESTURE_TAP); |
- ReleaseTouchPoint(); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- ReleaseTouchPoint(); |
+ uint32 touch_press_event_id1 = |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ uint32 touch_release_event_id1 = |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_TAP)); |
+ uint32 touch_press_event_id2 = |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ uint32 touch_release_event_id2 = |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_SCROLL_END)); |
// The first gesture sequence should not be allowed. |
- SendTouchConsumedAck(); |
- SendTouchNotConsumedAck(); |
+ SendTouchConsumedAck(touch_press_event_id1); |
+ SendTouchNotConsumedAck(touch_release_event_id1); |
EXPECT_FALSE(GesturesSent()); |
// The subsequent sequence should "reset" allowance. |
- SendTouchNotConsumedAck(); |
- SendTouchNotConsumedAck(); |
+ SendTouchNotConsumedAck(touch_press_event_id2); |
+ SendTouchNotConsumedAck(touch_release_event_id2); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN, |
ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
@@ -611,57 +587,54 @@ TEST_F(TouchDispositionGestureFilterTest, FlingCancelledOnNewTouchSequence) { |
SetRawTouchOffset(raw_offset); |
// Simulate a fling. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), |
+ Gestures(ET_GESTURE_TAP_DOWN, ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch( |
Gestures( |
ET_GESTURE_TAP_DOWN, ET_GESTURE_TAP_CANCEL, ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_SCROLL_FLING_START); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_SCROLL_FLING_START)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_SCROLL_FLING_START), |
GetAndResetSentGestures())); |
// A new touch sequence should cancel the outstanding fling. |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(1, 1), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_SCROLL_FLING_CANCEL), |
GetAndResetSentGestures())); |
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime()); |
EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1)); |
EXPECT_EQ(LastSentGestureRawLocation(), gfx::PointF(1, 1) + raw_offset); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, ScrollEndedOnTouchReleaseIfNoFling) { |
// Simulate a scroll. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ // Touch position will be used for synthesized scroll end gesture. |
+ SendPacket(PressTouchPoint(2, 3), |
+ Gestures(ET_GESTURE_TAP_DOWN, ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch( |
Gestures( |
ET_GESTURE_TAP_DOWN, ET_GESTURE_TAP_CANCEL, ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime()); |
- EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1)); |
+ EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(2, 3)); |
} |
TEST_F(TouchDispositionGestureFilterTest, ScrollEndedOnNewTouchSequence) { |
// Simulate a scroll. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), |
+ Gestures(ET_GESTURE_TAP_DOWN, ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch( |
Gestures( |
ET_GESTURE_TAP_DOWN, ET_GESTURE_TAP_CANCEL, ET_GESTURE_SCROLL_BEGIN), |
@@ -669,8 +642,10 @@ TEST_F(TouchDispositionGestureFilterTest, ScrollEndedOnNewTouchSequence) { |
// A new touch sequence should end the outstanding scroll. |
ResetTouchPoints(); |
- PressTouchPoint(2, 3); |
- SendTouchConsumedAck(); |
+ |
+ // Touch position will be used for synthesized scroll end gesture. |
+ SendPacket(PressTouchPoint(2, 3), NoGestures()); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime()); |
@@ -679,11 +654,10 @@ TEST_F(TouchDispositionGestureFilterTest, ScrollEndedOnNewTouchSequence) { |
TEST_F(TouchDispositionGestureFilterTest, FlingCancelledOnScrollBegin) { |
// Simulate a fling sequence. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PushGesture(ET_SCROLL_FLING_START); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), |
+ Gestures(ET_GESTURE_TAP_DOWN, ET_GESTURE_SCROLL_BEGIN, |
+ ET_SCROLL_FLING_START)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN, |
ET_GESTURE_TAP_CANCEL, |
ET_GESTURE_SCROLL_BEGIN, |
@@ -691,10 +665,9 @@ TEST_F(TouchDispositionGestureFilterTest, FlingCancelledOnScrollBegin) { |
GetAndResetSentGestures())); |
// The new fling should cancel the preceding one. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PushGesture(ET_SCROLL_FLING_START); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), |
+ Gestures(ET_GESTURE_SCROLL_BEGIN, ET_SCROLL_FLING_START)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_SCROLL_FLING_CANCEL, |
ET_GESTURE_SCROLL_BEGIN, |
ET_SCROLL_FLING_START), |
@@ -703,15 +676,14 @@ TEST_F(TouchDispositionGestureFilterTest, FlingCancelledOnScrollBegin) { |
TEST_F(TouchDispositionGestureFilterTest, FlingNotCancelledIfGFCEventReceived) { |
// Simulate a fling that is started then cancelled. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
- PushGesture(ET_SCROLL_FLING_START); |
- MoveTouchPoint(0, 2, 3); |
- SendTouchNotConsumedAck(); |
- PushGesture(ET_SCROLL_FLING_CANCEL); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_SCROLL_FLING_START)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ GestureEventDataPacket packet; |
+ packet.Push(CreateGesture(ET_SCROLL_FLING_CANCEL, 2, 3, 0)); |
+ SendTouchGestures(ReleaseTouchPoint(), packet); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN, |
ET_SCROLL_FLING_START, |
ET_SCROLL_FLING_CANCEL), |
@@ -720,72 +692,68 @@ TEST_F(TouchDispositionGestureFilterTest, FlingNotCancelledIfGFCEventReceived) { |
// A new touch sequence will not inject a ET_SCROLL_FLING_CANCEL, as the fling |
// has already been cancelled. |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ SendPacket(ReleaseTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, TapCancelledWhenScrollBegins) { |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
// If the subsequent touch turns into a scroll, the tap should be cancelled. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchNotConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL, |
ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, TapCancelledWhenTouchConsumed) { |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
// If the subsequent touch is consumed, the tap should be cancelled. |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchConsumedAck(); |
+ GestureEventDataPacket packet; |
+ packet.Push(CreateGesture(ET_GESTURE_SCROLL_BEGIN, 2, 3, 0)); |
+ SendTouchGestures(MoveTouchPoint(), packet); |
+ |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE( |
GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL, ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1)); |
+ EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(2, 3)); |
} |
TEST_F(TouchDispositionGestureFilterTest, |
TapNotCancelledIfTapEndingEventReceived) { |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE( |
GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_TAP); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_TAP)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SHOW_PRESS, ET_GESTURE_TAP), |
GetAndResetSentGestures())); |
// The tap should not be cancelled as it was terminated by a |ET_GESTURE_TAP|. |
- PressTouchPoint(2, 2); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), NoGestures()); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, TimeoutGestures) { |
// If the sequence is allowed, and there are no preceding gestures, the |
// timeout gestures should be forwarded immediately. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
@@ -797,35 +765,32 @@ TEST_F(TouchDispositionGestureFilterTest, TimeoutGestures) { |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_LONG_PRESS), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_LONG_TAP); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_LONG_TAP)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL, |
ET_GESTURE_LONG_TAP), |
GetAndResetSentGestures())); |
// If the sequence is disallowed, and there are no preceding gestures, the |
// timeout gestures should be dropped immediately. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
SendTimeoutGesture(ET_GESTURE_SHOW_PRESS); |
EXPECT_FALSE(GesturesSent()); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
// If the sequence has a pending ack, the timeout gestures should |
// remain queued until the ack is received. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
EXPECT_FALSE(GesturesSent()); |
SendTimeoutGesture(ET_GESTURE_LONG_PRESS); |
EXPECT_FALSE(GesturesSent()); |
- SendTouchNotConsumedAck(); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN, |
ET_GESTURE_LONG_PRESS), |
GetAndResetSentGestures())); |
@@ -834,15 +799,15 @@ TEST_F(TouchDispositionGestureFilterTest, TimeoutGestures) { |
TEST_F(TouchDispositionGestureFilterTest, SpuriousAcksIgnored) { |
// Acks received when the queue is empty will be safely ignored. |
ASSERT_TRUE(IsEmpty()); |
- SendTouchConsumedAck(); |
+ SendTouchConsumedAck(0); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 3,3); |
- SendTouchNotConsumedAck(); |
- SendTouchNotConsumedAck(); |
+ uint32 touch_press_event_id = |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ uint32 touch_move_event_id = |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAck(touch_press_event_id); |
+ SendTouchNotConsumedAck(touch_move_event_id); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN, |
ET_GESTURE_SCROLL_UPDATE), |
GetAndResetSentGestures())); |
@@ -851,7 +816,7 @@ TEST_F(TouchDispositionGestureFilterTest, SpuriousAcksIgnored) { |
// there could be follow-up timeout events. Spurious acks in such cases |
// should also be safely ignored. |
ASSERT_FALSE(IsEmpty()); |
- SendTouchConsumedAck(); |
+ SendTouchConsumedAck(0); |
EXPECT_FALSE(GesturesSent()); |
} |
@@ -870,31 +835,28 @@ TEST_F(TouchDispositionGestureFilterTest, PacketsWithInvalidOrderIgnored) { |
TEST_F(TouchDispositionGestureFilterTest, ConsumedTouchCancel) { |
// An unconsumed touch's gesture should be sent. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
EXPECT_FALSE(GesturesSent()); |
- SendTouchNotConsumedAck(); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_TAP_CANCEL); |
- PushGesture(ET_GESTURE_SCROLL_END); |
- CancelTouchPoint(); |
+ SendPacket(CancelTouchPoint(), |
+ Gestures(ET_GESTURE_TAP_CANCEL, ET_GESTURE_SCROLL_END)); |
EXPECT_FALSE(GesturesSent()); |
- SendTouchConsumedAck(); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL, |
ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, TimeoutEventAfterRelease) { |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PushGesture(ET_GESTURE_TAP_UNCONFIRMED); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), |
+ Gestures(ET_GESTURE_TAP_DOWN, ET_GESTURE_TAP_UNCONFIRMED)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE( |
GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN, ET_GESTURE_TAP_UNCONFIRMED), |
GetAndResetSentGestures())); |
@@ -905,9 +867,8 @@ TEST_F(TouchDispositionGestureFilterTest, TimeoutEventAfterRelease) { |
} |
TEST_F(TouchDispositionGestureFilterTest, ShowPressInsertedBeforeTap) { |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
@@ -915,18 +876,16 @@ TEST_F(TouchDispositionGestureFilterTest, ShowPressInsertedBeforeTap) { |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_UNCONFIRMED), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_TAP); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_TAP)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SHOW_PRESS, |
ET_GESTURE_TAP), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, ShowPressNotInsertedIfAlreadySent) { |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
@@ -934,9 +893,8 @@ TEST_F(TouchDispositionGestureFilterTest, ShowPressNotInsertedIfAlreadySent) { |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SHOW_PRESS), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_TAP); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_TAP)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP), |
GetAndResetSentGestures())); |
} |
@@ -945,31 +903,29 @@ TEST_F(TouchDispositionGestureFilterTest, TapAndScrollCancelledOnTouchCancel) { |
const gfx::Vector2dF raw_offset(1.3f, 3.7f); |
SetRawTouchOffset(raw_offset); |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(1, 1), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
// A cancellation motion event should cancel the tap. |
- CancelTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(CancelTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL), |
GetAndResetSentGestures())); |
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime()); |
EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1)); |
EXPECT_EQ(LastSentGestureRawLocation(), gfx::PointF(1, 1) + raw_offset); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(1, 1), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
// A cancellation motion event should end the scroll, even if the touch was |
// consumed. |
- CancelTouchPoint(); |
- SendTouchConsumedAck(); |
+ SendPacket(CancelTouchPoint(), NoGestures()); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END), |
GetAndResetSentGestures())); |
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime()); |
@@ -980,60 +936,59 @@ TEST_F(TouchDispositionGestureFilterTest, TapAndScrollCancelledOnTouchCancel) { |
TEST_F(TouchDispositionGestureFilterTest, |
ConsumedScrollUpdateMakesFlingScrollEnd) { |
// A consumed touch's gesture should not be sent. |
- PushGesture(ET_GESTURE_BEGIN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), |
+ Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE( |
GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_SCROLL_UPDATE); |
- MoveTouchPoint(0, 2, 2); |
- SendTouchConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
- PushGesture(ET_SCROLL_FLING_START); |
- PushGesture(ET_SCROLL_FLING_CANCEL); |
- PushGesture(ET_GESTURE_END); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ GestureEventDataPacket packet; |
+ packet.Push(CreateGesture(ET_SCROLL_FLING_START)); |
+ packet.Push(CreateGesture(ET_SCROLL_FLING_CANCEL)); |
+ packet.Push(CreateGesture(ET_GESTURE_END, 2, 3, 0)); |
+ SendTouchGestures(ReleaseTouchPoint(), packet); |
+ |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_END, ET_GESTURE_END), |
GetAndResetSentGestures())); |
- EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(2, 2)); |
+ EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(2, 3)); |
- PushGesture(ET_GESTURE_BEGIN); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), |
+ Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, TapCancelledOnTouchCancel) { |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ // Touch position is used for synthesized tap cancel. |
+ SendPacket(PressTouchPoint(2, 3), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
// A cancellation motion event should cancel the tap. |
- CancelTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(CancelTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL), |
GetAndResetSentGestures())); |
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime()); |
- EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1)); |
+ EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(2, 3)); |
} |
// Test that a GestureEvent whose dispatch causes a cancel event to be fired |
// won't cause a crash. |
TEST_F(TouchDispositionGestureFilterTest, TestCancelMidGesture) { |
SetCancelAfterNextGesture(true); |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ // Synthesized tap cancel uses touch position. |
+ SendPacket(PressTouchPoint(1, 1), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN, |
ET_GESTURE_TAP_CANCEL), |
GetAndResetSentGestures())); |
@@ -1042,81 +997,77 @@ TEST_F(TouchDispositionGestureFilterTest, TestCancelMidGesture) { |
// Test that a MultiFingerSwipe event is dispatched when appropriate. |
TEST_F(TouchDispositionGestureFilterTest, TestAllowedMultiFingerSwipe) { |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_SWIPE); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SWIPE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SWIPE), |
GetAndResetSentGestures())); |
} |
// Test that a MultiFingerSwipe event is dispatched when appropriate. |
TEST_F(TouchDispositionGestureFilterTest, TestDisallowedMultiFingerSwipe) { |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
- PushGesture(ET_GESTURE_SCROLL_BEGIN); |
- MoveTouchPoint(0, 0, 0); |
- SendTouchConsumedAck(); |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SCROLL_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_PINCH_BEGIN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_PINCH_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_PINCH_BEGIN), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_SWIPE); |
- PressTouchPoint(1, 1); |
- SendTouchConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_SWIPE)); |
+ SendTouchConsumedAckForLastTouch(); |
EXPECT_FALSE(GesturesSent()); |
} |
TEST_F(TouchDispositionGestureFilterTest, TapCancelOnSecondFingerDown) { |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, ShowPressBoundingBox) { |
- PushGesture(ET_GESTURE_TAP_DOWN, 9, 9, 8); |
- PressTouchPoint(9, 9); |
- SendTouchNotConsumedAck(); |
+ GestureEventDataPacket press_packet; |
+ press_packet.Push(CreateGesture(ET_GESTURE_TAP_DOWN, 9, 9, 8)); |
+ SendTouchGestures(PressTouchPoint(), press_packet); |
+ |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE( |
GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_TAP, 10, 10, 10); |
- ReleaseTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ GestureEventDataPacket release_packet; |
+ release_packet.Push(CreateGesture(ET_GESTURE_TAP, 10, 10, 10)); |
+ SendTouchGestures(ReleaseTouchPoint(), release_packet); |
+ |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SHOW_PRESS, ET_GESTURE_TAP), |
GetAndResetSentGestures())); |
EXPECT_EQ(gfx::RectF(5, 5, 10, 10), ShowPressBoundingBox()); |
} |
TEST_F(TouchDispositionGestureFilterTest, TapCancelledBeforeGestureEnd) { |
- PushGesture(ET_GESTURE_BEGIN); |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), |
+ Gestures(ET_GESTURE_BEGIN, ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_TAP_DOWN), |
GetAndResetSentGestures())); |
SendTimeoutGesture(ET_GESTURE_SHOW_PRESS); |
@@ -1126,28 +1077,179 @@ TEST_F(TouchDispositionGestureFilterTest, TapCancelledBeforeGestureEnd) { |
SendTimeoutGesture(ET_GESTURE_LONG_PRESS); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_LONG_PRESS), |
GetAndResetSentGestures())); |
- PushGesture(ET_GESTURE_END); |
- CancelTouchPoint(); |
- SendTouchNotConsumedAck(); |
+ SendPacket(CancelTouchPoint(), Gestures(ET_GESTURE_END)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL, ET_GESTURE_END), |
GetAndResetSentGestures())); |
} |
TEST_F(TouchDispositionGestureFilterTest, EventFlagPropagation) { |
// Real gestures should propagate flags from their causal touches. |
- PushGesture(ET_GESTURE_TAP_DOWN); |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_TAP_DOWN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE( |
GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), GetAndResetSentGestures())); |
EXPECT_EQ(kDefaultEventFlags, LastSentGestureFlags()); |
// Synthetic gestures lack flags. |
- PressTouchPoint(1, 1); |
- SendTouchNotConsumedAck(); |
+ SendPacket(PressTouchPoint(), NoGestures()); |
+ SendTouchNotConsumedAckForLastTouch(); |
EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL), |
GetAndResetSentGestures())); |
EXPECT_EQ(0, LastSentGestureFlags()); |
} |
+ |
+TEST_F(TouchDispositionGestureFilterTest, PreviousScrollPrevented) { |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_BEGIN)); |
+ EXPECT_FALSE(GesturesSent()); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ EXPECT_TRUE( |
+ GesturesMatch(Gestures(ET_GESTURE_BEGIN), GetAndResetSentGestures())); |
+ |
+ // The sent scroll update should always reflect whether any preceding scroll |
+ // update has been dropped. |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ ASSERT_TRUE(GesturesSent()); |
+ EXPECT_FALSE(last_sent_gesture() |
+ .details.previous_scroll_update_in_sequence_prevented()); |
+ GetAndResetSentGestures(); |
+ |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchConsumedAckForLastTouch(); |
+ EXPECT_FALSE(GesturesSent()); |
+ |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ ASSERT_TRUE(GesturesSent()); |
+ EXPECT_TRUE(last_sent_gesture() |
+ .details.previous_scroll_update_in_sequence_prevented()); |
+ GetAndResetSentGestures(); |
+ |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ ASSERT_TRUE(GesturesSent()); |
+ EXPECT_TRUE(last_sent_gesture() |
+ .details.previous_scroll_update_in_sequence_prevented()); |
+} |
+ |
+TEST_F(TouchDispositionGestureFilterTest, AckQueueBack) { |
+ SendPacket(PressTouchPoint(1, 1), Gestures(ET_GESTURE_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ GetAndResetSentGestures(); |
+ |
+ // Pending touch move. |
+ GestureEventDataPacket packet1; |
+ packet1.Push(CreateGesture(ET_GESTURE_SCROLL_UPDATE, 2, 3, 0)); |
+ uint32 touch_event_id = SendTouchGestures(MoveTouchPoint(), packet1); |
+ EXPECT_FALSE(GesturesSent()); |
+ |
+ // Additional pending touch move. |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ |
+ // Ack back of the queue consumed. |
+ SendTouchConsumedAckForLastTouch(); |
+ |
+ // Ack the pending touch. |
+ GetAndResetSentGestures(); |
+ SendTouchNotConsumedAck(touch_event_id); |
+ |
+ // The consumed touch doesn't produce a gesture. |
+ EXPECT_TRUE(GesturesMatch( |
+ Gestures(ET_GESTURE_SCROLL_UPDATE), |
+ GetAndResetSentGestures())); |
+ EXPECT_EQ(gfx::PointF(2, 3), LastSentGestureLocation()); |
+ |
+ // Pending touch move. |
+ touch_event_id = |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ EXPECT_FALSE(GesturesSent()); |
+ |
+ // Ack back of the queue unconsumed (twice). |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ |
+ GestureEventDataPacket packet2; |
+ packet2.Push(CreateGesture(ET_GESTURE_SCROLL_UPDATE, 7, 8, 0)); |
+ SendTouchGestures(MoveTouchPoint(), packet2); |
+ EXPECT_FALSE(GesturesSent()); |
+ |
+ SendTouchNotConsumedAckForLastTouch(); |
+ |
+ // Ack the pending touch. |
+ GetAndResetSentGestures(); |
+ SendTouchNotConsumedAck(touch_event_id); |
+ |
+ // Both touches have now been acked. |
+ EXPECT_TRUE( |
+ GesturesMatch(Gestures(ET_GESTURE_SCROLL_UPDATE, ET_GESTURE_SCROLL_UPDATE, |
+ ET_GESTURE_SCROLL_UPDATE), |
+ GetAndResetSentGestures())); |
+ EXPECT_EQ(gfx::PointF(7, 8), LastSentGestureLocation()); |
+} |
+ |
+TEST_F(TouchDispositionGestureFilterTest, AckQueueGestureAtBack) { |
+ // Send gesture sequence |
+ uint32 touch_press_event_id1 = |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_BEGIN)); |
+ uint32 touch_release_event_id1 = |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_END)); |
+ |
+ // Send second gesture sequence, and synchronously ack it. |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_BEGIN)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ |
+ GestureEventDataPacket packet; |
+ packet.Push(CreateGesture(ET_GESTURE_END, 2, 3, 0)); |
+ SendTouchGestures(ReleaseTouchPoint(), packet); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ |
+ // The second gesture sequence is blocked on the first. |
+ EXPECT_FALSE(GesturesSent()); |
+ |
+ SendTouchNotConsumedAck(touch_press_event_id1); |
+ SendTouchNotConsumedAck(touch_release_event_id1); |
+ |
+ // Both gestures have now been acked. |
+ EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_END, |
+ ET_GESTURE_BEGIN, ET_GESTURE_END), |
+ GetAndResetSentGestures())); |
+ EXPECT_EQ(gfx::PointF(2, 3), LastSentGestureLocation()); |
+} |
+ |
+TEST_F(TouchDispositionGestureFilterTest, |
+ SyncAcksOnlyTriggerAppropriateGestures) { |
+ // Queue a touch press. |
+ uint32 touch_press_event_id = |
+ SendPacket(PressTouchPoint(), Gestures(ET_GESTURE_BEGIN)); |
+ |
+ // Send and synchronously ack two touch moves. |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ |
+ SendPacket(MoveTouchPoint(), Gestures(ET_GESTURE_SCROLL_UPDATE)); |
+ SendTouchNotConsumedAckForLastTouch(); |
+ |
+ // Queue a touch release. |
+ uint32 touch_release_event_id = |
+ SendPacket(ReleaseTouchPoint(), Gestures(ET_GESTURE_END)); |
+ |
+ EXPECT_FALSE(GesturesSent()); |
+ |
+ // Ack the touch press. All events but the release should be acked. |
+ SendTouchNotConsumedAck(touch_press_event_id); |
+ EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_BEGIN, ET_GESTURE_SCROLL_UPDATE, |
+ ET_GESTURE_SCROLL_UPDATE), |
+ GetAndResetSentGestures())); |
+ |
+ // The touch release still requires an ack. |
+ SendTouchNotConsumedAck(touch_release_event_id); |
+ EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_END), |
+ GetAndResetSentGestures())); |
+} |
+ |
} // namespace ui |