| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 base::TimeTicks LeapForward(int time_in_millis) { | 504 base::TimeTicks LeapForward(int time_in_millis) { |
| 505 tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_in_millis)); | 505 tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_in_millis)); |
| 506 return tick_clock_.NowTicks(); | 506 return tick_clock_.NowTicks(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 base::TimeTicks InFuture(int time_in_millis) { | 509 base::TimeTicks InFuture(int time_in_millis) { |
| 510 return tick_clock_.NowTicks() + | 510 return tick_clock_.NowTicks() + |
| 511 base::TimeDelta::FromMilliseconds(time_in_millis); | 511 base::TimeDelta::FromMilliseconds(time_in_millis); |
| 512 } | 512 } |
| 513 | 513 |
| 514 void SendScrollEvents(ui::EventProcessor* dispatcher, | 514 void SendScrollEvents(ui::EventSink* sink, |
| 515 int x_start, | 515 int x_start, |
| 516 int y_start, | 516 int y_start, |
| 517 int dx, | 517 int dx, |
| 518 int dy, | 518 int dy, |
| 519 int touch_id, | 519 int touch_id, |
| 520 int time_step_ms, | 520 int time_step_ms, |
| 521 int num_steps, | 521 int num_steps, |
| 522 GestureEventConsumeDelegate* delegate) { | 522 GestureEventConsumeDelegate* delegate) { |
| 523 float x = x_start; | 523 float x = x_start; |
| 524 float y = y_start; | 524 float y = y_start; |
| 525 | 525 |
| 526 for (int i = 0; i < num_steps; i++) { | 526 for (int i = 0; i < num_steps; i++) { |
| 527 x += dx; | 527 x += dx; |
| 528 y += dy; | 528 y += dy; |
| 529 ui::TouchEvent move( | 529 ui::TouchEvent move( |
| 530 ui::ET_TOUCH_MOVED, gfx::Point(x, y), tick_clock_.NowTicks(), | 530 ui::ET_TOUCH_MOVED, gfx::Point(x, y), tick_clock_.NowTicks(), |
| 531 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, | 531 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, |
| 532 touch_id)); | 532 touch_id)); |
| 533 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 533 ui::EventDispatchDetails details = sink->OnEventFromSource(&move); |
| 534 ASSERT_FALSE(details.dispatcher_destroyed); | 534 ASSERT_FALSE(details.dispatcher_destroyed); |
| 535 tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_step_ms)); | 535 tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_step_ms)); |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 | 538 |
| 539 void SendScrollEvent(ui::EventProcessor* dispatcher, | 539 void SendScrollEvent(ui::EventSink* sink, |
| 540 float x, | 540 float x, |
| 541 float y, | 541 float y, |
| 542 int touch_id, | 542 int touch_id, |
| 543 GestureEventConsumeDelegate* delegate) { | 543 GestureEventConsumeDelegate* delegate) { |
| 544 delegate->Reset(); | 544 delegate->Reset(); |
| 545 ui::TouchEvent move( | 545 ui::TouchEvent move( |
| 546 ui::ET_TOUCH_MOVED, gfx::Point(), Now(), | 546 ui::ET_TOUCH_MOVED, gfx::Point(), Now(), |
| 547 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, touch_id)); | 547 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, touch_id)); |
| 548 move.set_location_f(gfx::PointF(x, y)); | 548 move.set_location_f(gfx::PointF(x, y)); |
| 549 move.set_root_location_f(gfx::PointF(x, y)); | 549 move.set_root_location_f(gfx::PointF(x, y)); |
| 550 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 550 ui::EventDispatchDetails details = sink->OnEventFromSource(&move); |
| 551 ASSERT_FALSE(details.dispatcher_destroyed); | 551 ASSERT_FALSE(details.dispatcher_destroyed); |
| 552 } | 552 } |
| 553 }; | 553 }; |
| 554 | 554 |
| 555 // An event handler to keep track of events. | 555 // An event handler to keep track of events. |
| 556 class TestEventHandler : public ui::EventHandler { | 556 class TestEventHandler : public ui::EventHandler { |
| 557 public: | 557 public: |
| 558 TestEventHandler() | 558 TestEventHandler() |
| 559 : touch_released_count_(0), | 559 : touch_released_count_(0), |
| 560 touch_pressed_count_(0), | 560 touch_pressed_count_(0), |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1045 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1046 DispatchEventUsingWindowDispatcher(&press); | 1046 DispatchEventUsingWindowDispatcher(&press); |
| 1047 EXPECT_2_EVENTS(delegate->events(), | 1047 EXPECT_2_EVENTS(delegate->events(), |
| 1048 ui::ET_GESTURE_BEGIN, | 1048 ui::ET_GESTURE_BEGIN, |
| 1049 ui::ET_GESTURE_TAP_DOWN); | 1049 ui::ET_GESTURE_TAP_DOWN); |
| 1050 | 1050 |
| 1051 // Move the touch-point enough so that it is considered as a scroll. This | 1051 // Move the touch-point enough so that it is considered as a scroll. This |
| 1052 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1052 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1053 // The first movement is diagonal, to ensure that we have a free scroll, | 1053 // The first movement is diagonal, to ensure that we have a free scroll, |
| 1054 // and not a rail scroll. | 1054 // and not a rail scroll. |
| 1055 tes.SendScrollEvent(event_processor(), 111.5, 211.5, kTouchId, | 1055 tes.SendScrollEvent(event_sink(), 111.5, 211.5, kTouchId, delegate.get()); |
| 1056 delegate.get()); | |
| 1057 EXPECT_3_EVENTS(delegate->events(), | 1056 EXPECT_3_EVENTS(delegate->events(), |
| 1058 ui::ET_GESTURE_TAP_CANCEL, | 1057 ui::ET_GESTURE_TAP_CANCEL, |
| 1059 ui::ET_GESTURE_SCROLL_BEGIN, | 1058 ui::ET_GESTURE_SCROLL_BEGIN, |
| 1060 ui::ET_GESTURE_SCROLL_UPDATE); | 1059 ui::ET_GESTURE_SCROLL_UPDATE); |
| 1061 // The slop consumed 5 dips | 1060 // The slop consumed 5 dips |
| 1062 EXPECT_FLOAT_EQ(5.5, delegate->scroll_x()); | 1061 EXPECT_FLOAT_EQ(5.5, delegate->scroll_x()); |
| 1063 EXPECT_FLOAT_EQ(5.5, delegate->scroll_y()); | 1062 EXPECT_FLOAT_EQ(5.5, delegate->scroll_y()); |
| 1064 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 1063 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 1065 delegate->scroll_begin_position().ToString()); | 1064 delegate->scroll_begin_position().ToString()); |
| 1066 | 1065 |
| 1067 // When scrolling with a single finger, the bounding box of the gesture should | 1066 // When scrolling with a single finger, the bounding box of the gesture should |
| 1068 // be empty, since it's a single point and the radius for testing is zero. | 1067 // be empty, since it's a single point and the radius for testing is zero. |
| 1069 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1068 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1070 | 1069 |
| 1071 // Move some more to generate a few more scroll updates. Make sure that we get | 1070 // Move some more to generate a few more scroll updates. Make sure that we get |
| 1072 // out of the snap channel for the unified GR. | 1071 // out of the snap channel for the unified GR. |
| 1073 tes.SendScrollEvent(event_processor(), 20, 120, kTouchId, delegate.get()); | 1072 tes.SendScrollEvent(event_sink(), 20, 120, kTouchId, delegate.get()); |
| 1074 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1073 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 1075 EXPECT_FLOAT_EQ(-91.5, delegate->scroll_x()); | 1074 EXPECT_FLOAT_EQ(-91.5, delegate->scroll_x()); |
| 1076 EXPECT_FLOAT_EQ(-91.5, delegate->scroll_y()); | 1075 EXPECT_FLOAT_EQ(-91.5, delegate->scroll_y()); |
| 1077 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1076 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1078 | 1077 |
| 1079 tes.SendScrollEvent(event_processor(), 50, 124, kTouchId, delegate.get()); | 1078 tes.SendScrollEvent(event_sink(), 50, 124, kTouchId, delegate.get()); |
| 1080 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1079 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 1081 EXPECT_EQ(30, delegate->scroll_x()); | 1080 EXPECT_EQ(30, delegate->scroll_x()); |
| 1082 EXPECT_EQ(4, delegate->scroll_y()); | 1081 EXPECT_EQ(4, delegate->scroll_y()); |
| 1083 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1082 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1084 | 1083 |
| 1085 // Release the touch. This should end the scroll. | 1084 // Release the touch. This should end the scroll. |
| 1086 delegate->Reset(); | 1085 delegate->Reset(); |
| 1087 ui::TouchEvent release( | 1086 ui::TouchEvent release( |
| 1088 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), | 1087 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), |
| 1089 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1088 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 ui::ET_GESTURE_SCROLL_BEGIN, | 1134 ui::ET_GESTURE_SCROLL_BEGIN, |
| 1136 ui::ET_GESTURE_SCROLL_UPDATE); | 1135 ui::ET_GESTURE_SCROLL_UPDATE); |
| 1137 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1136 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
| 1138 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1137 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
| 1139 | 1138 |
| 1140 // Move the touch-point enough so that it is considered as a scroll. This | 1139 // Move the touch-point enough so that it is considered as a scroll. This |
| 1141 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1140 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1142 // The first movement is diagonal, to ensure that we have a free scroll, | 1141 // The first movement is diagonal, to ensure that we have a free scroll, |
| 1143 // and not a rail scroll. | 1142 // and not a rail scroll. |
| 1144 tes.LeapForward(30); | 1143 tes.LeapForward(30); |
| 1145 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 1144 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get()); |
| 1146 EXPECT_1_EVENT(delegate->events(), | 1145 EXPECT_1_EVENT(delegate->events(), |
| 1147 ui::ET_GESTURE_SCROLL_UPDATE); | 1146 ui::ET_GESTURE_SCROLL_UPDATE); |
| 1148 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1147 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
| 1149 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1148 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
| 1150 | 1149 |
| 1151 // Move some more to generate a few more scroll updates. | 1150 // Move some more to generate a few more scroll updates. |
| 1152 tes.LeapForward(30); | 1151 tes.LeapForward(30); |
| 1153 tes.SendScrollEvent(event_processor(), 110, 211, kTouchId, delegate.get()); | 1152 tes.SendScrollEvent(event_sink(), 110, 211, kTouchId, delegate.get()); |
| 1154 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1153 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 1155 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1154 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
| 1156 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1155 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
| 1157 | 1156 |
| 1158 tes.LeapForward(30); | 1157 tes.LeapForward(30); |
| 1159 tes.SendScrollEvent(event_processor(), 140, 215, kTouchId, delegate.get()); | 1158 tes.SendScrollEvent(event_sink(), 140, 215, kTouchId, delegate.get()); |
| 1160 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1159 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 1161 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1160 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
| 1162 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1161 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
| 1163 | 1162 |
| 1164 // Release the touch. This should end the scroll. | 1163 // Release the touch. This should end the scroll. |
| 1165 delegate->Reset(); | 1164 delegate->Reset(); |
| 1166 ui::TouchEvent release( | 1165 ui::TouchEvent release( |
| 1167 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), | 1166 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), |
| 1168 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1167 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1169 DispatchEventUsingWindowDispatcher(&release); | 1168 DispatchEventUsingWindowDispatcher(&release); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1188 delegate->Reset(); | 1187 delegate->Reset(); |
| 1189 ui::TouchEvent press( | 1188 ui::TouchEvent press( |
| 1190 ui::ET_TOUCH_PRESSED, gfx::Point(kPositionX, kPositionY), tes.Now(), | 1189 ui::ET_TOUCH_PRESSED, gfx::Point(kPositionX, kPositionY), tes.Now(), |
| 1191 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1190 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1192 DispatchEventUsingWindowDispatcher(&press); | 1191 DispatchEventUsingWindowDispatcher(&press); |
| 1193 EXPECT_EQ(gfx::Rect(kPositionX - radius, kPositionY - radius, radius * 2, | 1192 EXPECT_EQ(gfx::Rect(kPositionX - radius, kPositionY - radius, radius * 2, |
| 1194 radius * 2), | 1193 radius * 2), |
| 1195 delegate->bounding_box()); | 1194 delegate->bounding_box()); |
| 1196 | 1195 |
| 1197 const int kScrollAmount = 50; | 1196 const int kScrollAmount = 50; |
| 1198 tes.SendScrollEvents(event_processor(), kPositionX, kPositionY, | 1197 tes.SendScrollEvents(event_sink(), kPositionX, kPositionY, 1, 1, kTouchId, |
| 1199 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); | 1198 1, kScrollAmount, delegate.get()); |
| 1200 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 1199 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 1201 delegate->scroll_begin_position().ToString()); | 1200 delegate->scroll_begin_position().ToString()); |
| 1202 EXPECT_EQ( | 1201 EXPECT_EQ( |
| 1203 gfx::Rect(kPositionX + kScrollAmount - radius, | 1202 gfx::Rect(kPositionX + kScrollAmount - radius, |
| 1204 kPositionY + kScrollAmount - radius, radius * 2, radius * 2), | 1203 kPositionY + kScrollAmount - radius, radius * 2, radius * 2), |
| 1205 delegate->bounding_box()); | 1204 delegate->bounding_box()); |
| 1206 | 1205 |
| 1207 // Release the touch. This should end the scroll. | 1206 // Release the touch. This should end the scroll. |
| 1208 delegate->Reset(); | 1207 delegate->Reset(); |
| 1209 ui::TouchEvent release( | 1208 ui::TouchEvent release( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1239 // Get rid of touch slop. | 1238 // Get rid of touch slop. |
| 1240 ui::TouchEvent move( | 1239 ui::TouchEvent move( |
| 1241 ui::ET_TOUCH_MOVED, gfx::Point(10, 0), tes.Now(), | 1240 ui::ET_TOUCH_MOVED, gfx::Point(10, 0), tes.Now(), |
| 1242 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1241 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1243 DispatchEventUsingWindowDispatcher(&move); | 1242 DispatchEventUsingWindowDispatcher(&move); |
| 1244 delegate->Reset(); | 1243 delegate->Reset(); |
| 1245 | 1244 |
| 1246 | 1245 |
| 1247 // Move the touch-point horizontally enough that it is considered a | 1246 // Move the touch-point horizontally enough that it is considered a |
| 1248 // horizontal scroll. | 1247 // horizontal scroll. |
| 1249 tes.SendScrollEvent(event_processor(), 30, 1, kTouchId, delegate.get()); | 1248 tes.SendScrollEvent(event_sink(), 30, 1, kTouchId, delegate.get()); |
| 1250 EXPECT_FLOAT_EQ(0, delegate->scroll_y()); | 1249 EXPECT_FLOAT_EQ(0, delegate->scroll_y()); |
| 1251 EXPECT_FLOAT_EQ(20, delegate->scroll_x()); | 1250 EXPECT_FLOAT_EQ(20, delegate->scroll_x()); |
| 1252 | 1251 |
| 1253 // Get a high x velocity, while still staying on the rail | 1252 // Get a high x velocity, while still staying on the rail |
| 1254 const int kScrollAmount = 8; | 1253 const int kScrollAmount = 8; |
| 1255 tes.SendScrollEvents(event_processor(), | 1254 tes.SendScrollEvents(event_sink(), 1, 1, 100, 10, kTouchId, 1, kScrollAmount, |
| 1256 1, | |
| 1257 1, | |
| 1258 100, | |
| 1259 10, | |
| 1260 kTouchId, | |
| 1261 1, | |
| 1262 kScrollAmount, | |
| 1263 delegate.get()); | 1255 delegate.get()); |
| 1264 | 1256 |
| 1265 delegate->Reset(); | 1257 delegate->Reset(); |
| 1266 ui::TouchEvent release( | 1258 ui::TouchEvent release( |
| 1267 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), | 1259 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), |
| 1268 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1260 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1269 DispatchEventUsingWindowDispatcher(&release); | 1261 DispatchEventUsingWindowDispatcher(&release); |
| 1270 | 1262 |
| 1271 EXPECT_TRUE(delegate->fling()); | 1263 EXPECT_TRUE(delegate->fling()); |
| 1272 EXPECT_FALSE(delegate->scroll_end()); | 1264 EXPECT_FALSE(delegate->scroll_end()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1292 | 1284 |
| 1293 // Get rid of touch slop. | 1285 // Get rid of touch slop. |
| 1294 ui::TouchEvent move( | 1286 ui::TouchEvent move( |
| 1295 ui::ET_TOUCH_MOVED, gfx::Point(0, 10), tes.Now(), | 1287 ui::ET_TOUCH_MOVED, gfx::Point(0, 10), tes.Now(), |
| 1296 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1288 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1297 DispatchEventUsingWindowDispatcher(&move); | 1289 DispatchEventUsingWindowDispatcher(&move); |
| 1298 delegate->Reset(); | 1290 delegate->Reset(); |
| 1299 | 1291 |
| 1300 // Move the touch-point vertically enough that it is considered a | 1292 // Move the touch-point vertically enough that it is considered a |
| 1301 // vertical scroll. | 1293 // vertical scroll. |
| 1302 tes.SendScrollEvent(event_processor(), 1, 30, kTouchId, delegate.get()); | 1294 tes.SendScrollEvent(event_sink(), 1, 30, kTouchId, delegate.get()); |
| 1303 EXPECT_EQ(20, delegate->scroll_y()); | 1295 EXPECT_EQ(20, delegate->scroll_y()); |
| 1304 EXPECT_EQ(0, delegate->scroll_x()); | 1296 EXPECT_EQ(0, delegate->scroll_x()); |
| 1305 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1297 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1306 | 1298 |
| 1307 // Get a high y velocity, while still staying on the rail | 1299 // Get a high y velocity, while still staying on the rail |
| 1308 const int kScrollAmount = 8; | 1300 const int kScrollAmount = 8; |
| 1309 tes.SendScrollEvents(event_processor(), | 1301 tes.SendScrollEvents(event_sink(), 1, 6, 10, 100, kTouchId, 1, kScrollAmount, |
| 1310 1, | |
| 1311 6, | |
| 1312 10, | |
| 1313 100, | |
| 1314 kTouchId, | |
| 1315 1, | |
| 1316 kScrollAmount, | |
| 1317 delegate.get()); | 1302 delegate.get()); |
| 1318 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1303 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1319 | 1304 |
| 1320 delegate->Reset(); | 1305 delegate->Reset(); |
| 1321 ui::TouchEvent release( | 1306 ui::TouchEvent release( |
| 1322 ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), tes.Now(), | 1307 ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), tes.Now(), |
| 1323 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1308 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1324 DispatchEventUsingWindowDispatcher(&release); | 1309 DispatchEventUsingWindowDispatcher(&release); |
| 1325 | 1310 |
| 1326 EXPECT_TRUE(delegate->fling()); | 1311 EXPECT_TRUE(delegate->fling()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1342 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1327 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1343 delegate.get(), -1234, bounds, root_window())); | 1328 delegate.get(), -1234, bounds, root_window())); |
| 1344 | 1329 |
| 1345 ui::TouchEvent press( | 1330 ui::TouchEvent press( |
| 1346 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(), | 1331 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(), |
| 1347 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1332 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1348 DispatchEventUsingWindowDispatcher(&press); | 1333 DispatchEventUsingWindowDispatcher(&press); |
| 1349 | 1334 |
| 1350 // Move the touch-point such that a non-rail scroll begins, and we're outside | 1335 // Move the touch-point such that a non-rail scroll begins, and we're outside |
| 1351 // the snap channel for the unified GR. | 1336 // the snap channel for the unified GR. |
| 1352 tes.SendScrollEvent(event_processor(), 50, 50, kTouchId, delegate.get()); | 1337 tes.SendScrollEvent(event_sink(), 50, 50, kTouchId, delegate.get()); |
| 1353 EXPECT_EQ(50, delegate->scroll_y()); | 1338 EXPECT_EQ(50, delegate->scroll_y()); |
| 1354 EXPECT_EQ(50, delegate->scroll_x()); | 1339 EXPECT_EQ(50, delegate->scroll_x()); |
| 1355 | 1340 |
| 1356 const int kScrollAmount = 8; | 1341 const int kScrollAmount = 8; |
| 1357 tes.SendScrollEvents(event_processor(), | 1342 tes.SendScrollEvents(event_sink(), 1, 1, 10, 100, kTouchId, 1, kScrollAmount, |
| 1358 1, | |
| 1359 1, | |
| 1360 10, | |
| 1361 100, | |
| 1362 kTouchId, | |
| 1363 1, | |
| 1364 kScrollAmount, | |
| 1365 delegate.get()); | 1343 delegate.get()); |
| 1366 | 1344 |
| 1367 delegate->Reset(); | 1345 delegate->Reset(); |
| 1368 ui::TouchEvent release( | 1346 ui::TouchEvent release( |
| 1369 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), | 1347 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), |
| 1370 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1348 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1371 DispatchEventUsingWindowDispatcher(&release); | 1349 DispatchEventUsingWindowDispatcher(&release); |
| 1372 | 1350 |
| 1373 EXPECT_TRUE(delegate->fling()); | 1351 EXPECT_TRUE(delegate->fling()); |
| 1374 EXPECT_FALSE(delegate->scroll_end()); | 1352 EXPECT_FALSE(delegate->scroll_end()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), | 1413 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), |
| 1436 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1414 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1437 DispatchEventUsingWindowDispatcher(&press1); | 1415 DispatchEventUsingWindowDispatcher(&press1); |
| 1438 EXPECT_TRUE(delegate->tap_down()); | 1416 EXPECT_TRUE(delegate->tap_down()); |
| 1439 | 1417 |
| 1440 // We haven't pressed long enough for a long press to occur | 1418 // We haven't pressed long enough for a long press to occur |
| 1441 EXPECT_FALSE(delegate->long_press()); | 1419 EXPECT_FALSE(delegate->long_press()); |
| 1442 EXPECT_FALSE(delegate->tap_cancel()); | 1420 EXPECT_FALSE(delegate->tap_cancel()); |
| 1443 | 1421 |
| 1444 // Scroll around, to cancel the long press | 1422 // Scroll around, to cancel the long press |
| 1445 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 1423 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get()); |
| 1446 | 1424 |
| 1447 // Wait until a long press event would have fired, if it hadn't been | 1425 // Wait until a long press event would have fired, if it hadn't been |
| 1448 // cancelled. | 1426 // cancelled. |
| 1449 DelayByLongPressTimeout(); | 1427 DelayByLongPressTimeout(); |
| 1450 | 1428 |
| 1451 EXPECT_FALSE(delegate->long_press()); | 1429 EXPECT_FALSE(delegate->long_press()); |
| 1452 EXPECT_TRUE(delegate->tap_cancel()); | 1430 EXPECT_TRUE(delegate->tap_cancel()); |
| 1453 | 1431 |
| 1454 delegate->Reset(); | 1432 delegate->Reset(); |
| 1455 ui::TouchEvent release1( | 1433 ui::TouchEvent release1( |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 // Get rid of touch slop. | 1551 // Get rid of touch slop. |
| 1574 ui::TouchEvent move( | 1552 ui::TouchEvent move( |
| 1575 ui::ET_TOUCH_MOVED, gfx::Point(5, 0), tes.Now(), | 1553 ui::ET_TOUCH_MOVED, gfx::Point(5, 0), tes.Now(), |
| 1576 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1554 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1577 | 1555 |
| 1578 DispatchEventUsingWindowDispatcher(&move); | 1556 DispatchEventUsingWindowDispatcher(&move); |
| 1579 delegate->Reset(); | 1557 delegate->Reset(); |
| 1580 | 1558 |
| 1581 // Move the touch-point horizontally enough that it is considered a | 1559 // Move the touch-point horizontally enough that it is considered a |
| 1582 // horizontal scroll. | 1560 // horizontal scroll. |
| 1583 tes.SendScrollEvent(event_processor(), 25, 0, kTouchId, delegate.get()); | 1561 tes.SendScrollEvent(event_sink(), 25, 0, kTouchId, delegate.get()); |
| 1584 EXPECT_EQ(0, delegate->scroll_y()); | 1562 EXPECT_EQ(0, delegate->scroll_y()); |
| 1585 EXPECT_EQ(20, delegate->scroll_x()); | 1563 EXPECT_EQ(20, delegate->scroll_x()); |
| 1586 | 1564 |
| 1587 tes.SendScrollEvent(event_processor(), 30, 6, kTouchId, delegate.get()); | 1565 tes.SendScrollEvent(event_sink(), 30, 6, kTouchId, delegate.get()); |
| 1588 EXPECT_TRUE(delegate->scroll_update()); | 1566 EXPECT_TRUE(delegate->scroll_update()); |
| 1589 EXPECT_EQ(5, delegate->scroll_x()); | 1567 EXPECT_EQ(5, delegate->scroll_x()); |
| 1590 // y shouldn't change, as we're on a horizontal rail. | 1568 // y shouldn't change, as we're on a horizontal rail. |
| 1591 EXPECT_EQ(0, delegate->scroll_y()); | 1569 EXPECT_EQ(0, delegate->scroll_y()); |
| 1592 | 1570 |
| 1593 // Send enough information that a velocity can be calculated for the gesture, | 1571 // Send enough information that a velocity can be calculated for the gesture, |
| 1594 // and we can break the rail | 1572 // and we can break the rail |
| 1595 const int kScrollAmount = 8; | 1573 const int kScrollAmount = 8; |
| 1596 tes.SendScrollEvents(event_processor(), | 1574 tes.SendScrollEvents(event_sink(), 1, 1, 6, 100, kTouchId, 1, kScrollAmount, |
| 1597 1, | |
| 1598 1, | |
| 1599 6, | |
| 1600 100, | |
| 1601 kTouchId, | |
| 1602 1, | |
| 1603 kScrollAmount, | |
| 1604 delegate.get()); | 1575 delegate.get()); |
| 1605 | 1576 |
| 1606 tes.SendScrollEvent(event_processor(), 5, 0, kTouchId, delegate.get()); | 1577 tes.SendScrollEvent(event_sink(), 5, 0, kTouchId, delegate.get()); |
| 1607 tes.SendScrollEvent(event_processor(), 10, 5, kTouchId, delegate.get()); | 1578 tes.SendScrollEvent(event_sink(), 10, 5, kTouchId, delegate.get()); |
| 1608 | 1579 |
| 1609 // The rail should be broken | 1580 // The rail should be broken |
| 1610 EXPECT_TRUE(delegate->scroll_update()); | 1581 EXPECT_TRUE(delegate->scroll_update()); |
| 1611 EXPECT_EQ(5, delegate->scroll_x()); | 1582 EXPECT_EQ(5, delegate->scroll_x()); |
| 1612 EXPECT_EQ(5, delegate->scroll_y()); | 1583 EXPECT_EQ(5, delegate->scroll_y()); |
| 1613 } | 1584 } |
| 1614 | 1585 |
| 1615 // Check that vertical scroll gestures cause scrolls on vertical rails. | 1586 // Check that vertical scroll gestures cause scrolls on vertical rails. |
| 1616 // Also tests that vertical rails can be broken. | 1587 // Also tests that vertical rails can be broken. |
| 1617 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { | 1588 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1630 | 1601 |
| 1631 // Get rid of touch slop. | 1602 // Get rid of touch slop. |
| 1632 ui::TouchEvent move( | 1603 ui::TouchEvent move( |
| 1633 ui::ET_TOUCH_MOVED, gfx::Point(0, 5), tes.Now(), | 1604 ui::ET_TOUCH_MOVED, gfx::Point(0, 5), tes.Now(), |
| 1634 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 1605 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 1635 DispatchEventUsingWindowDispatcher(&move); | 1606 DispatchEventUsingWindowDispatcher(&move); |
| 1636 delegate->Reset(); | 1607 delegate->Reset(); |
| 1637 | 1608 |
| 1638 // Move the touch-point vertically enough that it is considered a | 1609 // Move the touch-point vertically enough that it is considered a |
| 1639 // vertical scroll. | 1610 // vertical scroll. |
| 1640 tes.SendScrollEvent(event_processor(), 0, 25, kTouchId, delegate.get()); | 1611 tes.SendScrollEvent(event_sink(), 0, 25, kTouchId, delegate.get()); |
| 1641 EXPECT_EQ(0, delegate->scroll_x()); | 1612 EXPECT_EQ(0, delegate->scroll_x()); |
| 1642 EXPECT_EQ(20, delegate->scroll_y()); | 1613 EXPECT_EQ(20, delegate->scroll_y()); |
| 1643 | 1614 |
| 1644 tes.SendScrollEvent(event_processor(), 6, 30, kTouchId, delegate.get()); | 1615 tes.SendScrollEvent(event_sink(), 6, 30, kTouchId, delegate.get()); |
| 1645 EXPECT_TRUE(delegate->scroll_update()); | 1616 EXPECT_TRUE(delegate->scroll_update()); |
| 1646 EXPECT_EQ(5, delegate->scroll_y()); | 1617 EXPECT_EQ(5, delegate->scroll_y()); |
| 1647 // x shouldn't change, as we're on a vertical rail. | 1618 // x shouldn't change, as we're on a vertical rail. |
| 1648 EXPECT_EQ(0, delegate->scroll_x()); | 1619 EXPECT_EQ(0, delegate->scroll_x()); |
| 1649 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1620 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1650 | 1621 |
| 1651 // Send enough information that a velocity can be calculated for the gesture, | 1622 // Send enough information that a velocity can be calculated for the gesture, |
| 1652 // and we can break the rail | 1623 // and we can break the rail |
| 1653 const int kScrollAmount = 8; | 1624 const int kScrollAmount = 8; |
| 1654 tes.SendScrollEvents(event_processor(), | 1625 tes.SendScrollEvents(event_sink(), 1, 6, 100, 1, kTouchId, 1, kScrollAmount, |
| 1655 1, | |
| 1656 6, | |
| 1657 100, | |
| 1658 1, | |
| 1659 kTouchId, | |
| 1660 1, | |
| 1661 kScrollAmount, | |
| 1662 delegate.get()); | 1626 delegate.get()); |
| 1663 | 1627 |
| 1664 tes.SendScrollEvent(event_processor(), 0, 5, kTouchId, delegate.get()); | 1628 tes.SendScrollEvent(event_sink(), 0, 5, kTouchId, delegate.get()); |
| 1665 tes.SendScrollEvent(event_processor(), 5, 10, kTouchId, delegate.get()); | 1629 tes.SendScrollEvent(event_sink(), 5, 10, kTouchId, delegate.get()); |
| 1666 | 1630 |
| 1667 // The rail should be broken | 1631 // The rail should be broken |
| 1668 EXPECT_TRUE(delegate->scroll_update()); | 1632 EXPECT_TRUE(delegate->scroll_update()); |
| 1669 EXPECT_EQ(5, delegate->scroll_x()); | 1633 EXPECT_EQ(5, delegate->scroll_x()); |
| 1670 EXPECT_EQ(5, delegate->scroll_y()); | 1634 EXPECT_EQ(5, delegate->scroll_y()); |
| 1671 } | 1635 } |
| 1672 | 1636 |
| 1673 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { | 1637 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { |
| 1674 // We'll start by moving the touch point by (5, 5). We want all of that | 1638 // We'll start by moving the touch point by (5, 5). We want all of that |
| 1675 // distance to be consumed by the slop, so we set the slop radius to | 1639 // distance to be consumed by the slop, so we set the slop radius to |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); | 2080 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); |
| 2117 DispatchEventUsingWindowDispatcher(&press); | 2081 DispatchEventUsingWindowDispatcher(&press); |
| 2118 delegate->Reset(); | 2082 delegate->Reset(); |
| 2119 ui::TouchEvent press2( | 2083 ui::TouchEvent press2( |
| 2120 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(), | 2084 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(), |
| 2121 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); | 2085 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); |
| 2122 DispatchEventUsingWindowDispatcher(&press2); | 2086 DispatchEventUsingWindowDispatcher(&press2); |
| 2123 EXPECT_FALSE(delegate->pinch_begin()); | 2087 EXPECT_FALSE(delegate->pinch_begin()); |
| 2124 | 2088 |
| 2125 // Touch move triggers pinch begin. | 2089 // Touch move triggers pinch begin. |
| 2126 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); | 2090 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId1, delegate.get()); |
| 2127 EXPECT_TRUE(delegate->pinch_begin()); | 2091 EXPECT_TRUE(delegate->pinch_begin()); |
| 2128 EXPECT_FALSE(delegate->pinch_update()); | 2092 EXPECT_FALSE(delegate->pinch_update()); |
| 2129 | 2093 |
| 2130 // Touch move triggers pinch update. | 2094 // Touch move triggers pinch update. |
| 2131 tes.SendScrollEvent(event_processor(), 160, 200, kTouchId1, delegate.get()); | 2095 tes.SendScrollEvent(event_sink(), 160, 200, kTouchId1, delegate.get()); |
| 2132 EXPECT_FALSE(delegate->pinch_begin()); | 2096 EXPECT_FALSE(delegate->pinch_begin()); |
| 2133 EXPECT_TRUE(delegate->pinch_update()); | 2097 EXPECT_TRUE(delegate->pinch_update()); |
| 2134 | 2098 |
| 2135 // Pinch has started, now release the second finger | 2099 // Pinch has started, now release the second finger |
| 2136 delegate->Reset(); | 2100 delegate->Reset(); |
| 2137 ui::TouchEvent release( | 2101 ui::TouchEvent release( |
| 2138 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), | 2102 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), |
| 2139 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); | 2103 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); |
| 2140 DispatchEventUsingWindowDispatcher(&release); | 2104 DispatchEventUsingWindowDispatcher(&release); |
| 2141 EXPECT_TRUE(delegate->pinch_end()); | 2105 EXPECT_TRUE(delegate->pinch_end()); |
| 2142 | 2106 |
| 2143 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId2, delegate.get()); | 2107 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId2, delegate.get()); |
| 2144 EXPECT_TRUE(delegate->scroll_update()); | 2108 EXPECT_TRUE(delegate->scroll_update()); |
| 2145 | 2109 |
| 2146 // Pinch again | 2110 // Pinch again |
| 2147 delegate->Reset(); | 2111 delegate->Reset(); |
| 2148 ui::TouchEvent press3( | 2112 ui::TouchEvent press3( |
| 2149 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(), | 2113 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(), |
| 2150 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); | 2114 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); |
| 2151 DispatchEventUsingWindowDispatcher(&press3); | 2115 DispatchEventUsingWindowDispatcher(&press3); |
| 2152 // Now the touch points are close. So we will go into two finger tap. | 2116 // Now the touch points are close. So we will go into two finger tap. |
| 2153 // Move the touch-point enough to break two-finger-tap and enter pinch. | 2117 // Move the touch-point enough to break two-finger-tap and enter pinch. |
| 2154 ui::TouchEvent move2( | 2118 ui::TouchEvent move2( |
| 2155 ui::ET_TOUCH_MOVED, gfx::Point(101, 50), tes.Now(), | 2119 ui::ET_TOUCH_MOVED, gfx::Point(101, 50), tes.Now(), |
| 2156 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); | 2120 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); |
| 2157 DispatchEventUsingWindowDispatcher(&move2); | 2121 DispatchEventUsingWindowDispatcher(&move2); |
| 2158 EXPECT_TRUE(delegate->pinch_begin()); | 2122 EXPECT_TRUE(delegate->pinch_begin()); |
| 2159 | 2123 |
| 2160 tes.SendScrollEvent(event_processor(), 350, 350, kTouchId1, delegate.get()); | 2124 tes.SendScrollEvent(event_sink(), 350, 350, kTouchId1, delegate.get()); |
| 2161 EXPECT_TRUE(delegate->pinch_update()); | 2125 EXPECT_TRUE(delegate->pinch_update()); |
| 2162 } | 2126 } |
| 2163 | 2127 |
| 2164 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { | 2128 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { |
| 2165 std::unique_ptr<GestureEventConsumeDelegate> delegate( | 2129 std::unique_ptr<GestureEventConsumeDelegate> delegate( |
| 2166 new GestureEventConsumeDelegate()); | 2130 new GestureEventConsumeDelegate()); |
| 2167 TimedEvents tes; | 2131 TimedEvents tes; |
| 2168 const int kWindowWidth = 300; | 2132 const int kWindowWidth = 300; |
| 2169 const int kWindowHeight = 400; | 2133 const int kWindowHeight = 400; |
| 2170 const int kTouchId1 = 3; | 2134 const int kTouchId1 = 3; |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2822 kTouchId1)); | 2786 kTouchId1)); |
| 2823 DispatchEventUsingWindowDispatcher(&press1); | 2787 DispatchEventUsingWindowDispatcher(&press1); |
| 2824 | 2788 |
| 2825 delegate->Reset(); | 2789 delegate->Reset(); |
| 2826 ui::TouchEvent press2( | 2790 ui::TouchEvent press2( |
| 2827 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(), | 2791 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(), |
| 2828 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, | 2792 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, |
| 2829 kTouchId2)); | 2793 kTouchId2)); |
| 2830 DispatchEventUsingWindowDispatcher(&press2); | 2794 DispatchEventUsingWindowDispatcher(&press2); |
| 2831 | 2795 |
| 2832 tes.SendScrollEvent(event_processor(), 230, 330, kTouchId1, delegate.get()); | 2796 tes.SendScrollEvent(event_sink(), 230, 330, kTouchId1, delegate.get()); |
| 2833 EXPECT_FALSE(delegate->two_finger_tap()); | 2797 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2834 EXPECT_TRUE(delegate->pinch_begin()); | 2798 EXPECT_TRUE(delegate->pinch_begin()); |
| 2835 | 2799 |
| 2836 // Make sure there is enough delay before the touch is released so that it | 2800 // Make sure there is enough delay before the touch is released so that it |
| 2837 // is recognized as a tap. | 2801 // is recognized as a tap. |
| 2838 delegate->Reset(); | 2802 delegate->Reset(); |
| 2839 ui::TouchEvent release( | 2803 ui::TouchEvent release( |
| 2840 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), | 2804 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), |
| 2841 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, | 2805 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, |
| 2842 kTouchId2)); | 2806 kTouchId2)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2859 kTouchId1)); | 2823 kTouchId1)); |
| 2860 DispatchEventUsingWindowDispatcher(&press1); | 2824 DispatchEventUsingWindowDispatcher(&press1); |
| 2861 | 2825 |
| 2862 delegate->Reset(); | 2826 delegate->Reset(); |
| 2863 ui::TouchEvent press2( | 2827 ui::TouchEvent press2( |
| 2864 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(), | 2828 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(), |
| 2865 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, | 2829 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, |
| 2866 kTouchId2)); | 2830 kTouchId2)); |
| 2867 DispatchEventUsingWindowDispatcher(&press2); | 2831 DispatchEventUsingWindowDispatcher(&press2); |
| 2868 | 2832 |
| 2869 tes.SendScrollEvent(event_processor(), 301, 230, kTouchId2, delegate.get()); | 2833 tes.SendScrollEvent(event_sink(), 301, 230, kTouchId2, delegate.get()); |
| 2870 EXPECT_FALSE(delegate->two_finger_tap()); | 2834 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2871 EXPECT_TRUE(delegate->pinch_begin()); | 2835 EXPECT_TRUE(delegate->pinch_begin()); |
| 2872 | 2836 |
| 2873 // Make sure there is enough delay before the touch is released so that it | 2837 // Make sure there is enough delay before the touch is released so that it |
| 2874 // is recognized as a tap. | 2838 // is recognized as a tap. |
| 2875 delegate->Reset(); | 2839 delegate->Reset(); |
| 2876 ui::TouchEvent release( | 2840 ui::TouchEvent release( |
| 2877 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), | 2841 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50), |
| 2878 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, | 2842 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, |
| 2879 kTouchId1)); | 2843 kTouchId1)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2895 | 2859 |
| 2896 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2860 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2897 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2861 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2898 delegate.get(), -1234, bounds, root_window())); | 2862 delegate.get(), -1234, bounds, root_window())); |
| 2899 | 2863 |
| 2900 delegate->Reset(); | 2864 delegate->Reset(); |
| 2901 ui::TouchEvent press1( | 2865 ui::TouchEvent press1( |
| 2902 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), | 2866 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), |
| 2903 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); | 2867 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); |
| 2904 DispatchEventUsingWindowDispatcher(&press1); | 2868 DispatchEventUsingWindowDispatcher(&press1); |
| 2905 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); | 2869 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId1, delegate.get()); |
| 2906 | 2870 |
| 2907 delegate->Reset(); | 2871 delegate->Reset(); |
| 2908 ui::TouchEvent press2( | 2872 ui::TouchEvent press2( |
| 2909 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(), | 2873 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(), |
| 2910 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); | 2874 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); |
| 2911 DispatchEventUsingWindowDispatcher(&press2); | 2875 DispatchEventUsingWindowDispatcher(&press2); |
| 2912 | 2876 |
| 2913 EXPECT_FALSE(delegate->pinch_begin()); | 2877 EXPECT_FALSE(delegate->pinch_begin()); |
| 2914 | 2878 |
| 2915 // Make sure there is enough delay before the touch is released so that it | 2879 // Make sure there is enough delay before the touch is released so that it |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3170 delegate.get(), -1234, bounds, root_window())); | 3134 delegate.get(), -1234, bounds, root_window())); |
| 3171 delegate->set_window(window.get()); | 3135 delegate->set_window(window.get()); |
| 3172 TimedEvents tes; | 3136 TimedEvents tes; |
| 3173 | 3137 |
| 3174 delegate->Reset(); | 3138 delegate->Reset(); |
| 3175 ui::TouchEvent press( | 3139 ui::TouchEvent press( |
| 3176 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), | 3140 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), |
| 3177 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 3141 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 3178 DispatchEventUsingWindowDispatcher(&press); | 3142 DispatchEventUsingWindowDispatcher(&press); |
| 3179 // Scroll around, to cancel the long press | 3143 // Scroll around, to cancel the long press |
| 3180 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 3144 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get()); |
| 3181 | 3145 |
| 3182 delegate->Reset(); | 3146 delegate->Reset(); |
| 3183 delegate->ReceivedAck(); | 3147 delegate->ReceivedAck(); |
| 3184 EXPECT_TRUE(delegate->tap_down()); | 3148 EXPECT_TRUE(delegate->tap_down()); |
| 3185 | 3149 |
| 3186 // Wait long enough that long press would have fired if the touchmove hadn't | 3150 // Wait long enough that long press would have fired if the touchmove hadn't |
| 3187 // prevented it. | 3151 // prevented it. |
| 3188 DelayByLongPressTimeout(); | 3152 DelayByLongPressTimeout(); |
| 3189 | 3153 |
| 3190 delegate->Reset(); | 3154 delegate->Reset(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3235 EXPECT_TRUE(delegate->tap_down()); | 3199 EXPECT_TRUE(delegate->tap_down()); |
| 3236 EXPECT_FALSE(delegate->tap_cancel()); | 3200 EXPECT_FALSE(delegate->tap_cancel()); |
| 3237 EXPECT_TRUE(delegate->begin()); | 3201 EXPECT_TRUE(delegate->begin()); |
| 3238 EXPECT_FALSE(delegate->scroll_begin()); | 3202 EXPECT_FALSE(delegate->scroll_begin()); |
| 3239 EXPECT_FALSE(delegate->scroll_update()); | 3203 EXPECT_FALSE(delegate->scroll_update()); |
| 3240 EXPECT_FALSE(delegate->scroll_end()); | 3204 EXPECT_FALSE(delegate->scroll_end()); |
| 3241 | 3205 |
| 3242 // Move the touch-point enough so that it would normally be considered a | 3206 // Move the touch-point enough so that it would normally be considered a |
| 3243 // scroll. But since the touch-moves will be consumed, the scroll should not | 3207 // scroll. But since the touch-moves will be consumed, the scroll should not |
| 3244 // start. | 3208 // start. |
| 3245 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 3209 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get()); |
| 3246 EXPECT_FALSE(delegate->tap()); | 3210 EXPECT_FALSE(delegate->tap()); |
| 3247 EXPECT_FALSE(delegate->tap_down()); | 3211 EXPECT_FALSE(delegate->tap_down()); |
| 3248 EXPECT_TRUE(delegate->tap_cancel()); | 3212 EXPECT_TRUE(delegate->tap_cancel()); |
| 3249 EXPECT_FALSE(delegate->begin()); | 3213 EXPECT_FALSE(delegate->begin()); |
| 3250 EXPECT_FALSE(delegate->scroll_update()); | 3214 EXPECT_FALSE(delegate->scroll_update()); |
| 3251 EXPECT_FALSE(delegate->scroll_end()); | 3215 EXPECT_FALSE(delegate->scroll_end()); |
| 3252 | 3216 |
| 3253 EXPECT_TRUE(delegate->scroll_begin()); | 3217 EXPECT_TRUE(delegate->scroll_begin()); |
| 3254 | 3218 |
| 3255 // Release the touch back at the start point. This should end without causing | 3219 // Release the touch back at the start point. This should end without causing |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3283 | 3247 |
| 3284 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3248 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3285 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3249 std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3286 delegate.get(), -1234, bounds, root_window())); | 3250 delegate.get(), -1234, bounds, root_window())); |
| 3287 | 3251 |
| 3288 delegate->Reset(); | 3252 delegate->Reset(); |
| 3289 ui::TouchEvent press1( | 3253 ui::TouchEvent press1( |
| 3290 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), | 3254 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), |
| 3291 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); | 3255 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); |
| 3292 DispatchEventUsingWindowDispatcher(&press1); | 3256 DispatchEventUsingWindowDispatcher(&press1); |
| 3293 tes.SendScrollEvent(event_processor(), 131, 231, kTouchId1, delegate.get()); | 3257 tes.SendScrollEvent(event_sink(), 131, 231, kTouchId1, delegate.get()); |
| 3294 | 3258 |
| 3295 EXPECT_2_EVENTS(delegate->events(), | 3259 EXPECT_2_EVENTS(delegate->events(), |
| 3296 ui::ET_GESTURE_TAP_CANCEL, | 3260 ui::ET_GESTURE_TAP_CANCEL, |
| 3297 ui::ET_GESTURE_SCROLL_BEGIN); | 3261 ui::ET_GESTURE_SCROLL_BEGIN); |
| 3298 | 3262 |
| 3299 delegate->Reset(); | 3263 delegate->Reset(); |
| 3300 // Second finger touches down and moves. | 3264 // Second finger touches down and moves. |
| 3301 ui::TouchEvent press2( | 3265 ui::TouchEvent press2( |
| 3302 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.LeapForward(50), | 3266 ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.LeapForward(50), |
| 3303 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); | 3267 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); |
| 3304 DispatchEventUsingWindowDispatcher(&press2); | 3268 DispatchEventUsingWindowDispatcher(&press2); |
| 3305 tes.SendScrollEvent(event_processor(), 161, 231, kTouchId2, delegate.get()); | 3269 tes.SendScrollEvent(event_sink(), 161, 231, kTouchId2, delegate.get()); |
| 3306 EXPECT_0_EVENTS(delegate->events()); | 3270 EXPECT_0_EVENTS(delegate->events()); |
| 3307 | 3271 |
| 3308 delegate->Reset(); | 3272 delegate->Reset(); |
| 3309 // Move first finger again, no PinchUpdate & ScrollUpdate. | 3273 // Move first finger again, no PinchUpdate & ScrollUpdate. |
| 3310 tes.SendScrollEvent(event_processor(), 161, 261, kTouchId1, delegate.get()); | 3274 tes.SendScrollEvent(event_sink(), 161, 261, kTouchId1, delegate.get()); |
| 3311 EXPECT_0_EVENTS(delegate->events()); | 3275 EXPECT_0_EVENTS(delegate->events()); |
| 3312 | 3276 |
| 3313 // Stops consuming touch-move. | 3277 // Stops consuming touch-move. |
| 3314 delegate->set_consume_touch_move(false); | 3278 delegate->set_consume_touch_move(false); |
| 3315 | 3279 |
| 3316 delegate->Reset(); | 3280 delegate->Reset(); |
| 3317 // Making a pinch gesture. | 3281 // Making a pinch gesture. |
| 3318 tes.SendScrollEvent(event_processor(), 161, 260, kTouchId1, delegate.get()); | 3282 tes.SendScrollEvent(event_sink(), 161, 260, kTouchId1, delegate.get()); |
| 3319 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 3283 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 3320 | 3284 |
| 3321 delegate->Reset(); | 3285 delegate->Reset(); |
| 3322 tes.SendScrollEvent(event_processor(), 161, 261, kTouchId2, delegate.get()); | 3286 tes.SendScrollEvent(event_sink(), 161, 261, kTouchId2, delegate.get()); |
| 3323 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 3287 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 3324 | 3288 |
| 3325 delegate->Reset(); | 3289 delegate->Reset(); |
| 3326 ui::TouchEvent release1( | 3290 ui::TouchEvent release1( |
| 3327 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), | 3291 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(), |
| 3328 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); | 3292 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1)); |
| 3329 ui::TouchEvent release2( | 3293 ui::TouchEvent release2( |
| 3330 ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), tes.Now(), | 3294 ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), tes.Now(), |
| 3331 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); | 3295 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2)); |
| 3332 DispatchEventUsingWindowDispatcher(&release1); | 3296 DispatchEventUsingWindowDispatcher(&release1); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3361 EXPECT_TRUE(delegate->tap_down()); | 3325 EXPECT_TRUE(delegate->tap_down()); |
| 3362 EXPECT_FALSE(delegate->tap_cancel()); | 3326 EXPECT_FALSE(delegate->tap_cancel()); |
| 3363 EXPECT_TRUE(delegate->begin()); | 3327 EXPECT_TRUE(delegate->begin()); |
| 3364 EXPECT_FALSE(delegate->scroll_begin()); | 3328 EXPECT_FALSE(delegate->scroll_begin()); |
| 3365 EXPECT_FALSE(delegate->scroll_update()); | 3329 EXPECT_FALSE(delegate->scroll_update()); |
| 3366 EXPECT_FALSE(delegate->scroll_end()); | 3330 EXPECT_FALSE(delegate->scroll_end()); |
| 3367 | 3331 |
| 3368 // Move the touch-point enough so that it would normally be considered a | 3332 // Move the touch-point enough so that it would normally be considered a |
| 3369 // scroll. But since the touch-moves will be consumed, the scroll should not | 3333 // scroll. But since the touch-moves will be consumed, the scroll should not |
| 3370 // start. | 3334 // start. |
| 3371 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 3335 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get()); |
| 3372 EXPECT_FALSE(delegate->tap()); | 3336 EXPECT_FALSE(delegate->tap()); |
| 3373 EXPECT_FALSE(delegate->tap_down()); | 3337 EXPECT_FALSE(delegate->tap_down()); |
| 3374 EXPECT_TRUE(delegate->tap_cancel()); | 3338 EXPECT_TRUE(delegate->tap_cancel()); |
| 3375 EXPECT_FALSE(delegate->begin()); | 3339 EXPECT_FALSE(delegate->begin()); |
| 3376 EXPECT_FALSE(delegate->scroll_update()); | 3340 EXPECT_FALSE(delegate->scroll_update()); |
| 3377 EXPECT_FALSE(delegate->scroll_end()); | 3341 EXPECT_FALSE(delegate->scroll_end()); |
| 3378 | 3342 |
| 3379 // Consuming the first touch move event won't prevent all future scrolling. | 3343 // Consuming the first touch move event won't prevent all future scrolling. |
| 3380 EXPECT_TRUE(delegate->scroll_begin()); | 3344 EXPECT_TRUE(delegate->scroll_begin()); |
| 3381 | 3345 |
| 3382 // Now, stop consuming touch-move events, and move the touch-point again. | 3346 // Now, stop consuming touch-move events, and move the touch-point again. |
| 3383 delegate->set_consume_touch_move(false); | 3347 delegate->set_consume_touch_move(false); |
| 3384 tes.SendScrollEvent(event_processor(), 159, 259, kTouchId, delegate.get()); | 3348 tes.SendScrollEvent(event_sink(), 159, 259, kTouchId, delegate.get()); |
| 3385 EXPECT_FALSE(delegate->tap()); | 3349 EXPECT_FALSE(delegate->tap()); |
| 3386 EXPECT_FALSE(delegate->tap_down()); | 3350 EXPECT_FALSE(delegate->tap_down()); |
| 3387 EXPECT_FALSE(delegate->tap_cancel()); | 3351 EXPECT_FALSE(delegate->tap_cancel()); |
| 3388 EXPECT_FALSE(delegate->begin()); | 3352 EXPECT_FALSE(delegate->begin()); |
| 3389 EXPECT_FALSE(delegate->scroll_begin()); | 3353 EXPECT_FALSE(delegate->scroll_begin()); |
| 3390 EXPECT_FALSE(delegate->scroll_end()); | 3354 EXPECT_FALSE(delegate->scroll_end()); |
| 3391 | 3355 |
| 3392 // Scroll not prevented by consumed first touch move. | 3356 // Scroll not prevented by consumed first touch move. |
| 3393 EXPECT_TRUE(delegate->scroll_update()); | 3357 EXPECT_TRUE(delegate->scroll_update()); |
| 3394 EXPECT_EQ(29, delegate->scroll_x()); | 3358 EXPECT_EQ(29, delegate->scroll_x()); |
| 3395 EXPECT_EQ(29, delegate->scroll_y()); | 3359 EXPECT_EQ(29, delegate->scroll_y()); |
| 3396 EXPECT_EQ(gfx::Point(0, 0).ToString(), | 3360 EXPECT_EQ(gfx::Point(0, 0).ToString(), |
| 3397 delegate->scroll_begin_position().ToString()); | 3361 delegate->scroll_begin_position().ToString()); |
| 3398 | 3362 |
| 3399 // Start consuming touch-move events again. | 3363 // Start consuming touch-move events again. |
| 3400 delegate->set_consume_touch_move(true); | 3364 delegate->set_consume_touch_move(true); |
| 3401 | 3365 |
| 3402 // Move some more to generate a few more scroll updates. | 3366 // Move some more to generate a few more scroll updates. |
| 3403 tes.SendScrollEvent(event_processor(), 110, 211, kTouchId, delegate.get()); | 3367 tes.SendScrollEvent(event_sink(), 110, 211, kTouchId, delegate.get()); |
| 3404 EXPECT_FALSE(delegate->tap()); | 3368 EXPECT_FALSE(delegate->tap()); |
| 3405 EXPECT_FALSE(delegate->tap_down()); | 3369 EXPECT_FALSE(delegate->tap_down()); |
| 3406 EXPECT_FALSE(delegate->tap_cancel()); | 3370 EXPECT_FALSE(delegate->tap_cancel()); |
| 3407 EXPECT_FALSE(delegate->begin()); | 3371 EXPECT_FALSE(delegate->begin()); |
| 3408 EXPECT_FALSE(delegate->scroll_begin()); | 3372 EXPECT_FALSE(delegate->scroll_begin()); |
| 3409 EXPECT_FALSE(delegate->scroll_update()); | 3373 EXPECT_FALSE(delegate->scroll_update()); |
| 3410 EXPECT_FALSE(delegate->scroll_end()); | 3374 EXPECT_FALSE(delegate->scroll_end()); |
| 3411 EXPECT_EQ(0, delegate->scroll_x()); | 3375 EXPECT_EQ(0, delegate->scroll_x()); |
| 3412 EXPECT_EQ(0, delegate->scroll_y()); | 3376 EXPECT_EQ(0, delegate->scroll_y()); |
| 3413 | 3377 |
| 3414 tes.SendScrollEvent(event_processor(), 140, 215, kTouchId, delegate.get()); | 3378 tes.SendScrollEvent(event_sink(), 140, 215, kTouchId, delegate.get()); |
| 3415 EXPECT_FALSE(delegate->tap()); | 3379 EXPECT_FALSE(delegate->tap()); |
| 3416 EXPECT_FALSE(delegate->tap_down()); | 3380 EXPECT_FALSE(delegate->tap_down()); |
| 3417 EXPECT_FALSE(delegate->tap_cancel()); | 3381 EXPECT_FALSE(delegate->tap_cancel()); |
| 3418 EXPECT_FALSE(delegate->begin()); | 3382 EXPECT_FALSE(delegate->begin()); |
| 3419 EXPECT_FALSE(delegate->scroll_begin()); | 3383 EXPECT_FALSE(delegate->scroll_begin()); |
| 3420 EXPECT_FALSE(delegate->scroll_update()); | 3384 EXPECT_FALSE(delegate->scroll_update()); |
| 3421 EXPECT_FALSE(delegate->scroll_end()); | 3385 EXPECT_FALSE(delegate->scroll_end()); |
| 3422 EXPECT_EQ(0, delegate->scroll_x()); | 3386 EXPECT_EQ(0, delegate->scroll_x()); |
| 3423 EXPECT_EQ(0, delegate->scroll_y()); | 3387 EXPECT_EQ(0, delegate->scroll_y()); |
| 3424 | 3388 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3786 | 3750 |
| 3787 delegate->set_consume_touch_move(false); | 3751 delegate->set_consume_touch_move(false); |
| 3788 DispatchEventUsingWindowDispatcher(&press); | 3752 DispatchEventUsingWindowDispatcher(&press); |
| 3789 delegate->set_consume_touch_move(true); | 3753 delegate->set_consume_touch_move(true); |
| 3790 delegate->Reset(); | 3754 delegate->Reset(); |
| 3791 // Move the touch-point enough so that it would normally be considered a | 3755 // Move the touch-point enough so that it would normally be considered a |
| 3792 // scroll. But since the touch-moves will be consumed, no scrolling should | 3756 // scroll. But since the touch-moves will be consumed, no scrolling should |
| 3793 // occur. | 3757 // occur. |
| 3794 // With the unified gesture detector, we will receive a scroll begin gesture, | 3758 // With the unified gesture detector, we will receive a scroll begin gesture, |
| 3795 // whereas with the aura gesture recognizer we won't. | 3759 // whereas with the aura gesture recognizer we won't. |
| 3796 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 3760 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get()); |
| 3797 EXPECT_FALSE(delegate->tap()); | 3761 EXPECT_FALSE(delegate->tap()); |
| 3798 EXPECT_FALSE(delegate->tap_down()); | 3762 EXPECT_FALSE(delegate->tap_down()); |
| 3799 EXPECT_TRUE(delegate->tap_cancel()); | 3763 EXPECT_TRUE(delegate->tap_cancel()); |
| 3800 EXPECT_FALSE(delegate->begin()); | 3764 EXPECT_FALSE(delegate->begin()); |
| 3801 EXPECT_FALSE(delegate->scroll_update()); | 3765 EXPECT_FALSE(delegate->scroll_update()); |
| 3802 EXPECT_FALSE(delegate->scroll_end()); | 3766 EXPECT_FALSE(delegate->scroll_end()); |
| 3803 } | 3767 } |
| 3804 | 3768 |
| 3805 TEST_F(GestureRecognizerTest, CancelAllActiveTouches) { | 3769 TEST_F(GestureRecognizerTest, CancelAllActiveTouches) { |
| 3806 std::unique_ptr<GestureEventConsumeDelegate> delegate( | 3770 std::unique_ptr<GestureEventConsumeDelegate> delegate( |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3923 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), | 3887 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(), |
| 3924 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 3888 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 3925 DispatchEventUsingWindowDispatcher(&press1); | 3889 DispatchEventUsingWindowDispatcher(&press1); |
| 3926 EXPECT_TRUE(delegate->tap_down()); | 3890 EXPECT_TRUE(delegate->tap_down()); |
| 3927 | 3891 |
| 3928 // We haven't pressed long enough for a show press to occur | 3892 // We haven't pressed long enough for a show press to occur |
| 3929 EXPECT_FALSE(delegate->show_press()); | 3893 EXPECT_FALSE(delegate->show_press()); |
| 3930 EXPECT_FALSE(delegate->tap_cancel()); | 3894 EXPECT_FALSE(delegate->tap_cancel()); |
| 3931 | 3895 |
| 3932 // Scroll around, to cancel the show press | 3896 // Scroll around, to cancel the show press |
| 3933 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 3897 tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get()); |
| 3934 // Wait until the timer runs out | 3898 // Wait until the timer runs out |
| 3935 DelayByShowPressTimeout(); | 3899 DelayByShowPressTimeout(); |
| 3936 EXPECT_FALSE(delegate->show_press()); | 3900 EXPECT_FALSE(delegate->show_press()); |
| 3937 EXPECT_TRUE(delegate->tap_cancel()); | 3901 EXPECT_TRUE(delegate->tap_cancel()); |
| 3938 | 3902 |
| 3939 delegate->Reset(); | 3903 delegate->Reset(); |
| 3940 ui::TouchEvent release1( | 3904 ui::TouchEvent release1( |
| 3941 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(10), | 3905 ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(10), |
| 3942 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); | 3906 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 3943 DispatchEventUsingWindowDispatcher(&release1); | 3907 DispatchEventUsingWindowDispatcher(&release1); |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4721 EXPECT_FALSE(queued_delegate2->long_press()); | 4685 EXPECT_FALSE(queued_delegate2->long_press()); |
| 4722 | 4686 |
| 4723 queued_delegate->Reset(); | 4687 queued_delegate->Reset(); |
| 4724 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); | 4688 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
| 4725 EXPECT_TRUE(queued_delegate->show_press()); | 4689 EXPECT_TRUE(queued_delegate->show_press()); |
| 4726 EXPECT_FALSE(queued_delegate->tap_down()); | 4690 EXPECT_FALSE(queued_delegate->tap_down()); |
| 4727 } | 4691 } |
| 4728 | 4692 |
| 4729 } // namespace test | 4693 } // namespace test |
| 4730 } // namespace aura | 4694 } // namespace aura |
| OLD | NEW |