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

Side by Side Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 223673006: Support GestureBegin and GestureEnd in ui::GestureProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address jdduke's comments. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2, 1087 event = ObtainMotionEvent(event_time + kOneMicrosecond * 2,
1088 MotionEvent::ACTION_UP); 1088 MotionEvent::ACTION_UP);
1089 EXPECT_FALSE(gesture_provider_->OnTouchEvent(event)); 1089 EXPECT_FALSE(gesture_provider_->OnTouchEvent(event));
1090 1090
1091 event = ObtainMotionEvent(event_time + kOneMicrosecond * 3, 1091 event = ObtainMotionEvent(event_time + kOneMicrosecond * 3,
1092 MotionEvent::ACTION_DOWN); 1092 MotionEvent::ACTION_DOWN);
1093 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1093 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1094 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1094 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1095 } 1095 }
1096 1096
1097 // Verify that gesture begin and gesture end events are dispatched correctly.
1098 TEST_F(GestureProviderTest, GestureBeginAndEnd) {
1099 gesture_provider_->SetBeginEndTypesEnabled(true);
jdduke (slow) 2014/04/03 22:03:28 If possible, I'd prefer not to expose this flag ex
tdresser 2014/04/04 16:39:31 Done.
1100 base::TimeTicks event_time = base::TimeTicks::Now();
1101
1102 EXPECT_EQ(0U, GetReceivedGestureCount());
1103 MockMotionEvent event =
1104 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
1105 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1106 EXPECT_EQ(ET_GESTURE_BEGIN, GetReceivedGesture(0).type);
1107 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1108 EXPECT_EQ(2U, GetReceivedGestureCount());
1109
1110 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN);
1111 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1112 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
1113 EXPECT_EQ(3U, GetReceivedGestureCount());
1114
1115 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN);
1116 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1117 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
1118 EXPECT_EQ(4U, GetReceivedGestureCount());
1119
1120 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP);
1121 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1122 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1123 EXPECT_EQ(5U, GetReceivedGestureCount());
1124
1125 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN);
1126 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1127 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
1128 EXPECT_EQ(6U, GetReceivedGestureCount());
1129
1130 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP);
1131 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1132 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1133 EXPECT_EQ(7U, GetReceivedGestureCount());
1134
1135 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP);
1136 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1137 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1138 EXPECT_EQ(8U, GetReceivedGestureCount());
1139
1140 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_UP);
1141 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1142 EXPECT_EQ(ET_GESTURE_END, GetMostRecentGestureEventType());
1143 EXPECT_EQ(9U, GetReceivedGestureCount());
1144
1145 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_POINTER_DOWN);
1146 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1147 EXPECT_EQ(ET_GESTURE_BEGIN, GetMostRecentGestureEventType());
1148 EXPECT_EQ(10U, GetReceivedGestureCount());
1149
jdduke (slow) 2014/04/03 22:03:28 I guess add an ACTION_CANCEL in here somewhere for
tdresser 2014/04/04 16:39:31 Done.
1150 }
1151
1097 } // namespace ui 1152 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698