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

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

Issue 349463002: [Android] Map raw touch coordinates to global gesture locations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win compilation Created 6 years, 6 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/touch_disposition_gesture_filter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c46b83c54856c3f1e7cb8e153d5839cc05913417..a5471f73cfff8ceb3b52875727d3fb9674e3b534 100644
--- a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
+++ b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
@@ -33,6 +33,7 @@ class TouchDispositionGestureFilterTest
last_sent_gesture_time_ = event.time;
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 (cancel_after_next_gesture_) {
CancelTouchPoint();
SendTouchNotConsumedAck();
@@ -158,6 +159,10 @@ class TouchDispositionGestureFilterTest
SendTouchGestures();
}
+ void SetRawTouchOffset(const gfx::Vector2dF& raw_offset) {
+ touch_event_.SetRawOffset(raw_offset.x(), raw_offset.y());
+ }
+
void ResetTouchPoints() { touch_event_ = MockMotionEvent(); }
bool GesturesSent() const { return !sent_gestures_.empty(); }
@@ -178,20 +183,26 @@ class TouchDispositionGestureFilterTest
return sent_gestures;
}
- gfx::PointF LastSentGestureLocation() {
+ const gfx::PointF& LastSentGestureLocation() const {
return last_sent_gesture_location_;
}
+ const gfx::PointF& LastSentGestureRawLocation() const {
+ return last_sent_gesture_raw_location_;
+ }
+
void SetCancelAfterNextGesture(bool cancel_after_next_gesture) {
cancel_after_next_gesture_ = cancel_after_next_gesture;
}
GestureEventData CreateGesture(EventType type) {
- return GestureEventData(type,
+ return GestureEventData(GestureEventDetails(type, 0, 0),
0,
base::TimeTicks(),
touch_event_.GetX(0),
touch_event_.GetY(0),
+ touch_event_.GetRawX(0),
+ touch_event_.GetRawY(0),
1,
gfx::RectF(0, 0, 0, 0));
}
@@ -205,6 +216,7 @@ class TouchDispositionGestureFilterTest
base::TimeTicks last_sent_gesture_time_;
GestureList sent_gestures_;
gfx::PointF last_sent_gesture_location_;
+ gfx::PointF last_sent_gesture_raw_location_;
};
TEST_F(TouchDispositionGestureFilterTest, BasicNoGestures) {
@@ -559,6 +571,8 @@ TEST_F(TouchDispositionGestureFilterTest, MultipleTouchSequences) {
}
TEST_F(TouchDispositionGestureFilterTest, FlingCancelledOnNewTouchSequence) {
+ const gfx::Vector2dF raw_offset(1.3f, 3.7f);
+ SetRawTouchOffset(raw_offset);
// Simulate a fling.
PushGesture(ET_GESTURE_TAP_DOWN);
PushGesture(ET_GESTURE_SCROLL_BEGIN);
@@ -581,6 +595,7 @@ TEST_F(TouchDispositionGestureFilterTest, FlingCancelledOnNewTouchSequence) {
GetAndResetSentGestures()));
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime());
EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1));
+ EXPECT_EQ(LastSentGestureRawLocation(), gfx::PointF(1, 1) + raw_offset);
ReleaseTouchPoint();
SendTouchNotConsumedAck();
EXPECT_FALSE(GesturesSent());
@@ -889,6 +904,8 @@ TEST_F(TouchDispositionGestureFilterTest, ShowPressNotInsertedIfAlreadySent) {
}
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();
@@ -902,6 +919,7 @@ TEST_F(TouchDispositionGestureFilterTest, TapAndScrollCancelledOnTouchCancel) {
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);
@@ -917,6 +935,7 @@ TEST_F(TouchDispositionGestureFilterTest, TapAndScrollCancelledOnTouchCancel) {
GetAndResetSentGestures()));
EXPECT_EQ(CurrentTouchTime(), LastSentGestureTime());
EXPECT_EQ(LastSentGestureLocation(), gfx::PointF(1, 1));
+ EXPECT_EQ(LastSentGestureRawLocation(), gfx::PointF(1, 1) + raw_offset);
}
TEST_F(TouchDispositionGestureFilterTest,
« no previous file with comments | « ui/events/gesture_detection/touch_disposition_gesture_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698