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 8847c8ff01e31aefb4112d1b6d1b8eabb3c19371..cd0915924ba34db00396f00b5044c706a280585b 100644 |
--- a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc |
+++ b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc |
@@ -36,6 +36,8 @@ class TouchDispositionGestureFilterTest |
sent_gestures_.push_back(event.type()); |
last_sent_gesture_location_ = gfx::PointF(event.x, event.y); |
last_sent_gesture_raw_location_ = gfx::PointF(event.raw_x, event.raw_y); |
+ if (event.type() == ET_GESTURE_SHOW_PRESS) |
+ show_press_bounding_box_ = event.details.bounding_box(); |
if (cancel_after_next_gesture_) { |
cancel_after_next_gesture_ = false; |
CancelTouchPoint(); |
@@ -141,6 +143,10 @@ class TouchDispositionGestureFilterTest |
pending_gesture_packet_.Push(CreateGesture(type)); |
} |
+ void PushGesture(EventType type, float x, float y, float diameter) { |
+ pending_gesture_packet_.Push(CreateGesture(type, x, y, diameter)); |
+ } |
+ |
void PressTouchPoint(int x, int y) { |
touch_event_.PressPoint(x, y); |
touch_event_.SetRawOffset(raw_offset_.x(), raw_offset_.y()); |
@@ -195,6 +201,10 @@ class TouchDispositionGestureFilterTest |
return last_sent_gesture_raw_location_; |
} |
+ const gfx::RectF& ShowPressBoundingBox() const { |
+ return show_press_bounding_box_; |
+ } |
+ |
void SetCancelAfterNextGesture(bool cancel_after_next_gesture) { |
cancel_after_next_gesture_ = cancel_after_next_gesture; |
} |
@@ -212,6 +222,23 @@ class TouchDispositionGestureFilterTest |
gfx::RectF(0, 0, 0, 0)); |
} |
+ GestureEventData CreateGesture(EventType type, |
+ float x, |
+ float y, |
+ float diameter) { |
+ return GestureEventData( |
+ GestureEventDetails(type, 0, 0), |
+ 0, |
+ MotionEvent::TOOL_TYPE_FINGER, |
+ base::TimeTicks(), |
+ touch_event_.GetX(0), |
+ touch_event_.GetY(0), |
+ touch_event_.GetRawX(0), |
+ touch_event_.GetRawY(0), |
+ 1, |
+ gfx::RectF(x - diameter / 2, y - diameter / 2, diameter, diameter)); |
+ } |
+ |
private: |
scoped_ptr<TouchDispositionGestureFilter> queue_; |
bool cancel_after_next_gesture_; |
@@ -223,6 +250,7 @@ class TouchDispositionGestureFilterTest |
gfx::Vector2dF raw_offset_; |
gfx::PointF last_sent_gesture_location_; |
gfx::PointF last_sent_gesture_raw_location_; |
+ gfx::RectF show_press_bounding_box_; |
}; |
TEST_F(TouchDispositionGestureFilterTest, BasicNoGestures) { |
@@ -1067,4 +1095,22 @@ TEST_F(TouchDispositionGestureFilterTest, TapCancelOnSecondFingerDown) { |
GetAndResetSentGestures())); |
} |
+TEST_F(TouchDispositionGestureFilterTest, ShowPressBoundingBox) { |
+ int x = 10; |
+ int y = 10; |
+ int diameter = 10; |
+ PushGesture(ET_GESTURE_TAP_DOWN, x, y, diameter); |
tdresser
2014/09/04 13:54:01
You're trying to test that we don't just use the d
lanwei
2014/09/05 20:40:37
Done.
|
+ PressTouchPoint(x, y); |
+ SendTouchNotConsumedAck(); |
+ EXPECT_TRUE( |
+ GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), GetAndResetSentGestures())); |
+ |
+ PushGesture(ET_GESTURE_TAP, x, y, diameter); |
+ ReleaseTouchPoint(); |
+ SendTouchNotConsumedAck(); |
+ EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_SHOW_PRESS, ET_GESTURE_TAP), |
+ GetAndResetSentGestures())); |
+ EXPECT_EQ(gfx::RectF(5, 5, 10, 10), ShowPressBoundingBox()); |
+} |
+ |
} // namespace ui |