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

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

Issue 567783002: Add modifier flags to MotionEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove MotionEvent modifiers Created 6 years, 3 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/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 07cfb1754a3e4b09c9ab6c637faa504e9b883d95..2e37efb976b084e0e04558ecf6338b6ba3ee96c2 100644
--- a/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
+++ b/ui/events/gesture_detection/touch_disposition_gesture_filter_unittest.cc
@@ -11,6 +11,11 @@
using ui::test::MockMotionEvent;
namespace ui {
+namespace {
+
+const int kDefaultEventFlags = EF_ALT_DOWN | EF_SHIFT_DOWN;
+
+} // namespace
class TouchDispositionGestureFilterTest
: public testing::Test,
@@ -23,6 +28,7 @@ class TouchDispositionGestureFilterTest
// testing::Test
virtual void SetUp() OVERRIDE {
queue_.reset(new TouchDispositionGestureFilter(this));
+ touch_event_.set_flags(kDefaultEventFlags);
}
virtual void TearDown() OVERRIDE {
@@ -32,10 +38,8 @@ class TouchDispositionGestureFilterTest
// TouchDispositionGestureFilterClient
virtual void ForwardGestureEvent(const GestureEventData& event) OVERRIDE {
++sent_gesture_count_;
- last_sent_gesture_time_ = event.time;
+ last_sent_gesture_.reset(new GestureEventData(event));
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_) {
@@ -178,7 +182,8 @@ class TouchDispositionGestureFilterTest
bool GesturesSent() const { return !sent_gestures_.empty(); }
base::TimeTicks LastSentGestureTime() const {
- return last_sent_gesture_time_;
+ CHECK(last_sent_gesture_);
+ return last_sent_gesture_->time;
}
base::TimeTicks CurrentTouchTime() const {
@@ -193,12 +198,19 @@ class TouchDispositionGestureFilterTest
return sent_gestures;
}
- const gfx::PointF& LastSentGestureLocation() const {
- return last_sent_gesture_location_;
+ gfx::PointF LastSentGestureLocation() const {
+ CHECK(last_sent_gesture_);
+ 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);
}
- const gfx::PointF& LastSentGestureRawLocation() const {
- return last_sent_gesture_raw_location_;
+ int LastSentGestureFlags() const {
+ CHECK(last_sent_gesture_);
+ return last_sent_gesture_->flags;
}
const gfx::RectF& ShowPressBoundingBox() const {
@@ -227,7 +239,8 @@ class TouchDispositionGestureFilterTest
touch_event_.GetRawX(0),
touch_event_.GetRawY(0),
1,
- gfx::RectF(x - diameter / 2, y - diameter / 2, diameter, diameter));
+ gfx::RectF(x - diameter / 2, y - diameter / 2, diameter, diameter),
+ kDefaultEventFlags);
}
private:
@@ -236,11 +249,9 @@ class TouchDispositionGestureFilterTest
MockMotionEvent touch_event_;
GestureEventDataPacket pending_gesture_packet_;
size_t sent_gesture_count_;
- base::TimeTicks last_sent_gesture_time_;
GestureList sent_gestures_;
gfx::Vector2dF raw_offset_;
- gfx::PointF last_sent_gesture_location_;
- gfx::PointF last_sent_gesture_raw_location_;
+ scoped_ptr<GestureEventData> last_sent_gesture_;
gfx::RectF show_press_bounding_box_;
};
@@ -1122,4 +1133,21 @@ TEST_F(TouchDispositionGestureFilterTest, TapCancelledBeforeGestureEnd) {
GetAndResetSentGestures()));
}
+TEST_F(TouchDispositionGestureFilterTest, EventFlagPropagation) {
+ // Real gestures should propagate flags from their causal touches.
+ PushGesture(ET_GESTURE_TAP_DOWN);
+ PressTouchPoint(1, 1);
+ SendTouchNotConsumedAck();
+ EXPECT_TRUE(
+ GesturesMatch(Gestures(ET_GESTURE_TAP_DOWN), GetAndResetSentGestures()));
+ EXPECT_EQ(kDefaultEventFlags, LastSentGestureFlags());
+
+ // Synthetic gestures lack flags.
+ PressTouchPoint(1, 1);
+ SendTouchNotConsumedAck();
+ EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL),
+ GetAndResetSentGestures()));
+ EXPECT_EQ(0, LastSentGestureFlags());
+}
+
} // namespace ui
« no previous file with comments | « ui/events/gesture_detection/touch_disposition_gesture_filter.cc ('k') | ui/events/gestures/gesture_provider_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698