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/gesture_provider_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
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | ui/events/gesture_detection/motion_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28486cac87a6ffe09c0325c11a5ff3794245b41e..a25a0b545aa1efc59f76b4f55db683c54d55ceeb 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -274,12 +274,15 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
const float scroll_to_x = kFakeCoordX + 100;
const float scroll_to_y = kFakeCoordY + 100;
int motion_event_id = 0;
+ int motion_event_flags = EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN;
MockMotionEvent event =
ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
event = ObtainMotionEvent(event_time + kOneSecond,
MotionEvent::ACTION_MOVE,
@@ -287,11 +290,13 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
scroll_to_y);
event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_TRUE(gesture_provider_->IsScrollInProgress());
EXPECT_TRUE(HasReceivedGesture(ET_GESTURE_SCROLL_BEGIN));
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
EXPECT_EQ(event.GetToolType(0),
GetMostRecentGestureEvent().primary_tool_type);
EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, GetMostRecentGestureEventType());
@@ -411,6 +416,7 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient {
TEST_F(GestureProviderTest, GestureTap) {
base::TimeTicks event_time = base::TimeTicks::Now();
int motion_event_id = 0;
+ int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN;
gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false);
@@ -418,12 +424,14 @@ TEST_F(GestureProviderTest, GestureTap) {
ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_EQ(event.GetToolType(0),
GetMostRecentGestureEvent().primary_tool_type);
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
GetMostRecentGestureEvent().details.bounding_box());
@@ -431,6 +439,7 @@ TEST_F(GestureProviderTest, GestureTap) {
MotionEvent::ACTION_UP);
event.SetToolType(0, MotionEvent::TOOL_TYPE_FINGER);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
@@ -439,6 +448,7 @@ TEST_F(GestureProviderTest, GestureTap) {
EXPECT_EQ(event.GetToolType(0),
GetMostRecentGestureEvent().primary_tool_type);
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
GetMostRecentGestureEvent().details.bounding_box());
@@ -449,16 +459,19 @@ TEST_F(GestureProviderTest, GestureTap) {
TEST_F(GestureProviderTest, GestureTapWithDelay) {
base::TimeTicks event_time = base::TimeTicks::Now();
int motion_event_id = 0;
+ int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN | EF_CAPS_LOCK_DOWN;
gesture_provider_->SetDoubleTapSupportForPlatformEnabled(true);
MockMotionEvent event =
ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
GetMostRecentGestureEvent().details.bounding_box());
@@ -466,12 +479,14 @@ TEST_F(GestureProviderTest, GestureTapWithDelay) {
event = ObtainMotionEvent(event_time + kOneMicrosecond,
MotionEvent::ACTION_UP);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_UNCONFIRMED, GetMostRecentGestureEventType());
// Ensure tap details have been set.
EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_EQ(BoundsForSingleMockTouchAtLocation(kFakeCoordX, kFakeCoordY),
GetMostRecentGestureEvent().details.bounding_box());
@@ -486,14 +501,17 @@ TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {
base::TimeTicks event_time = TimeTicks::Now();
base::TimeDelta delta_time = kDeltaTimeForFlingSequences;
int motion_event_id = 0;
+ int motion_event_flags = EF_ALT_DOWN;
MockMotionEvent event =
ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
event = ObtainMotionEvent(event_time + delta_time,
@@ -501,6 +519,7 @@ TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {
kFakeCoordX * 10,
kFakeCoordY * 10);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
event = ObtainMotionEvent(event_time + delta_time * 2,
@@ -508,10 +527,12 @@ TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {
kFakeCoordX * 10,
kFakeCoordY * 10);
event.set_id(++motion_event_id);
+ event.set_flags(motion_event_flags);
EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
EXPECT_EQ(ET_SCROLL_FLING_START, GetMostRecentGestureEventType());
EXPECT_EQ(motion_event_id, GetMostRecentGestureEvent().motion_event_id);
+ EXPECT_EQ(motion_event_flags, GetMostRecentGestureEvent().flags);
EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_LONG_PRESS));
EXPECT_EQ(
« no previous file with comments | « ui/events/gesture_detection/gesture_provider.cc ('k') | ui/events/gesture_detection/motion_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698