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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 570 |
571 base::TimeDelta LeapForward(int time_in_millis) { | 571 base::TimeDelta LeapForward(int time_in_millis) { |
572 simulated_now_ += time_in_millis; | 572 simulated_now_ += time_in_millis; |
573 return base::TimeDelta::FromMilliseconds(simulated_now_); | 573 return base::TimeDelta::FromMilliseconds(simulated_now_); |
574 } | 574 } |
575 | 575 |
576 base::TimeDelta InFuture(int time_in_millis) { | 576 base::TimeDelta InFuture(int time_in_millis) { |
577 return base::TimeDelta::FromMilliseconds(simulated_now_ + time_in_millis); | 577 return base::TimeDelta::FromMilliseconds(simulated_now_ + time_in_millis); |
578 } | 578 } |
579 | 579 |
580 void SendScrollEvents(WindowEventDispatcher* dispatcher, | 580 void SendScrollEvents(ui::EventProcessor* dispatcher, |
581 float x_start, | 581 float x_start, |
582 float y_start, | 582 float y_start, |
583 int dx, | 583 int dx, |
584 int dy, | 584 int dy, |
585 int touch_id, | 585 int touch_id, |
586 int time_step, | 586 int time_step, |
587 int num_steps, | 587 int num_steps, |
588 GestureEventConsumeDelegate* delegate) { | 588 GestureEventConsumeDelegate* delegate) { |
589 int x = x_start; | 589 int x = x_start; |
590 int y = y_start; | 590 int y = y_start; |
591 | 591 |
592 for (int i = 0; i < num_steps; i++) { | 592 for (int i = 0; i < num_steps; i++) { |
593 x += dx; | 593 x += dx; |
594 y += dy; | 594 y += dy; |
595 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), | 595 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), |
596 touch_id, | 596 touch_id, |
597 base::TimeDelta::FromMilliseconds(simulated_now_)); | 597 base::TimeDelta::FromMilliseconds(simulated_now_)); |
598 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 598 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
599 ASSERT_FALSE(details.dispatcher_destroyed); | 599 ASSERT_FALSE(details.dispatcher_destroyed); |
600 simulated_now_ += time_step; | 600 simulated_now_ += time_step; |
601 } | 601 } |
602 } | 602 } |
603 | 603 |
604 void SendScrollEvent(WindowEventDispatcher* dispatcher, | 604 void SendScrollEvent(ui::EventProcessor* dispatcher, |
605 float x, | 605 float x, |
606 float y, | 606 float y, |
607 int touch_id, | 607 int touch_id, |
608 GestureEventConsumeDelegate* delegate) { | 608 GestureEventConsumeDelegate* delegate) { |
609 delegate->Reset(); | 609 delegate->Reset(); |
610 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), | 610 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), |
611 touch_id, | 611 touch_id, |
612 base::TimeDelta::FromMilliseconds(simulated_now_)); | 612 base::TimeDelta::FromMilliseconds(simulated_now_)); |
613 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 613 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
614 ASSERT_FALSE(details.dispatcher_destroyed); | 614 ASSERT_FALSE(details.dispatcher_destroyed); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 kTouchId, tes.Now()); | 1023 kTouchId, tes.Now()); |
1024 DispatchEventUsingWindowDispatcher(&press); | 1024 DispatchEventUsingWindowDispatcher(&press); |
1025 EXPECT_2_EVENTS(delegate->events(), | 1025 EXPECT_2_EVENTS(delegate->events(), |
1026 ui::ET_GESTURE_BEGIN, | 1026 ui::ET_GESTURE_BEGIN, |
1027 ui::ET_GESTURE_TAP_DOWN); | 1027 ui::ET_GESTURE_TAP_DOWN); |
1028 | 1028 |
1029 // Move the touch-point enough so that it is considered as a scroll. This | 1029 // Move the touch-point enough so that it is considered as a scroll. This |
1030 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1030 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
1031 // The first movement is diagonal, to ensure that we have a free scroll, | 1031 // The first movement is diagonal, to ensure that we have a free scroll, |
1032 // and not a rail scroll. | 1032 // and not a rail scroll. |
1033 tes.SendScrollEvent(dispatcher(), 111.5, 211.5, kTouchId, delegate.get()); | 1033 tes.SendScrollEvent(event_processor(), 111.5, 211.5, kTouchId, |
| 1034 delegate.get()); |
1034 EXPECT_3_EVENTS(delegate->events(), | 1035 EXPECT_3_EVENTS(delegate->events(), |
1035 ui::ET_GESTURE_TAP_CANCEL, | 1036 ui::ET_GESTURE_TAP_CANCEL, |
1036 ui::ET_GESTURE_SCROLL_BEGIN, | 1037 ui::ET_GESTURE_SCROLL_BEGIN, |
1037 ui::ET_GESTURE_SCROLL_UPDATE); | 1038 ui::ET_GESTURE_SCROLL_UPDATE); |
1038 // The slop consumed 5 dips | 1039 // The slop consumed 5 dips |
1039 EXPECT_FLOAT_EQ(5.5, delegate->scroll_x()); | 1040 EXPECT_FLOAT_EQ(5.5, delegate->scroll_x()); |
1040 EXPECT_FLOAT_EQ(5.5, delegate->scroll_y()); | 1041 EXPECT_FLOAT_EQ(5.5, delegate->scroll_y()); |
1041 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 1042 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
1042 delegate->scroll_begin_position().ToString()); | 1043 delegate->scroll_begin_position().ToString()); |
1043 | 1044 |
1044 // When scrolling with a single finger, the bounding box of the gesture should | 1045 // When scrolling with a single finger, the bounding box of the gesture should |
1045 // be empty, since it's a single point and the radius for testing is zero. | 1046 // be empty, since it's a single point and the radius for testing is zero. |
1046 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1047 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
1047 | 1048 |
1048 // Move some more to generate a few more scroll updates. | 1049 // Move some more to generate a few more scroll updates. |
1049 tes.SendScrollEvent(dispatcher(), 91, 192, kTouchId, delegate.get()); | 1050 tes.SendScrollEvent(event_processor(), 91, 192, kTouchId, delegate.get()); |
1050 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1051 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
1051 EXPECT_FLOAT_EQ(-20.5, delegate->scroll_x()); | 1052 EXPECT_FLOAT_EQ(-20.5, delegate->scroll_x()); |
1052 EXPECT_FLOAT_EQ(-19.5, delegate->scroll_y()); | 1053 EXPECT_FLOAT_EQ(-19.5, delegate->scroll_y()); |
1053 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1054 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
1054 | 1055 |
1055 tes.SendScrollEvent(dispatcher(), 121, 196, kTouchId, delegate.get()); | 1056 tes.SendScrollEvent(event_processor(), 121, 196, kTouchId, delegate.get()); |
1056 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1057 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
1057 EXPECT_EQ(30, delegate->scroll_x()); | 1058 EXPECT_EQ(30, delegate->scroll_x()); |
1058 EXPECT_EQ(4, delegate->scroll_y()); | 1059 EXPECT_EQ(4, delegate->scroll_y()); |
1059 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1060 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
1060 | 1061 |
1061 // Release the touch. This should end the scroll. | 1062 // Release the touch. This should end the scroll. |
1062 delegate->Reset(); | 1063 delegate->Reset(); |
1063 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1064 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
1064 kTouchId, | 1065 kTouchId, |
1065 tes.LeapForward(50)); | 1066 tes.LeapForward(50)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 ui::ET_GESTURE_SCROLL_BEGIN, | 1112 ui::ET_GESTURE_SCROLL_BEGIN, |
1112 ui::ET_GESTURE_SCROLL_UPDATE); | 1113 ui::ET_GESTURE_SCROLL_UPDATE); |
1113 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1114 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
1114 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1115 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
1115 | 1116 |
1116 // Move the touch-point enough so that it is considered as a scroll. This | 1117 // Move the touch-point enough so that it is considered as a scroll. This |
1117 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1118 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
1118 // The first movement is diagonal, to ensure that we have a free scroll, | 1119 // The first movement is diagonal, to ensure that we have a free scroll, |
1119 // and not a rail scroll. | 1120 // and not a rail scroll. |
1120 tes.LeapForward(30); | 1121 tes.LeapForward(30); |
1121 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 1122 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
1122 EXPECT_1_EVENT(delegate->events(), | 1123 EXPECT_1_EVENT(delegate->events(), |
1123 ui::ET_GESTURE_SCROLL_UPDATE); | 1124 ui::ET_GESTURE_SCROLL_UPDATE); |
1124 EXPECT_GT(delegate->scroll_velocity_x(), 0); | 1125 EXPECT_GT(delegate->scroll_velocity_x(), 0); |
1125 EXPECT_GT(delegate->scroll_velocity_y(), 0); | 1126 EXPECT_GT(delegate->scroll_velocity_y(), 0); |
1126 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1127 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
1127 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1128 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
1128 EXPECT_EQ((int)(29 + delegate->scroll_velocity_x() * prediction_interval), | 1129 EXPECT_EQ((int)(29 + delegate->scroll_velocity_x() * prediction_interval), |
1129 (int)(total_scroll.x())); | 1130 (int)(total_scroll.x())); |
1130 EXPECT_EQ((int)(29 + delegate->scroll_velocity_y() * prediction_interval), | 1131 EXPECT_EQ((int)(29 + delegate->scroll_velocity_y() * prediction_interval), |
1131 (int)(total_scroll.y())); | 1132 (int)(total_scroll.y())); |
1132 | 1133 |
1133 // Move some more to generate a few more scroll updates. | 1134 // Move some more to generate a few more scroll updates. |
1134 tes.LeapForward(30); | 1135 tes.LeapForward(30); |
1135 tes.SendScrollEvent(dispatcher(), 110, 211, kTouchId, delegate.get()); | 1136 tes.SendScrollEvent(event_processor(), 110, 211, kTouchId, delegate.get()); |
1136 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1137 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
1137 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1138 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
1138 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1139 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
1139 EXPECT_EQ((int)(9 + delegate->scroll_velocity_x() * prediction_interval), | 1140 EXPECT_EQ((int)(9 + delegate->scroll_velocity_x() * prediction_interval), |
1140 (int)(total_scroll.x())); | 1141 (int)(total_scroll.x())); |
1141 EXPECT_EQ((int)(10 + delegate->scroll_velocity_y() * prediction_interval), | 1142 EXPECT_EQ((int)(10 + delegate->scroll_velocity_y() * prediction_interval), |
1142 (int)(total_scroll.y())); | 1143 (int)(total_scroll.y())); |
1143 | 1144 |
1144 tes.LeapForward(30); | 1145 tes.LeapForward(30); |
1145 tes.SendScrollEvent(dispatcher(), 140, 215, kTouchId, delegate.get()); | 1146 tes.SendScrollEvent(event_processor(), 140, 215, kTouchId, delegate.get()); |
1146 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1147 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
1147 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1148 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
1148 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1149 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
1149 EXPECT_EQ((int)(39 + delegate->scroll_velocity_x() * prediction_interval), | 1150 EXPECT_EQ((int)(39 + delegate->scroll_velocity_x() * prediction_interval), |
1150 (int)(total_scroll.x())); | 1151 (int)(total_scroll.x())); |
1151 EXPECT_EQ((int)(14 + delegate->scroll_velocity_y() * prediction_interval), | 1152 EXPECT_EQ((int)(14 + delegate->scroll_velocity_y() * prediction_interval), |
1152 (int)(total_scroll.y())); | 1153 (int)(total_scroll.y())); |
1153 | 1154 |
1154 // Release the touch. This should end the scroll. | 1155 // Release the touch. This should end the scroll. |
1155 delegate->Reset(); | 1156 delegate->Reset(); |
(...skipping 25 matching lines...) Expand all Loading... |
1181 kTouchId, | 1182 kTouchId, |
1182 tes.Now()); | 1183 tes.Now()); |
1183 DispatchEventUsingWindowDispatcher(&press); | 1184 DispatchEventUsingWindowDispatcher(&press); |
1184 EXPECT_EQ(gfx::Rect(kPositionX - radius, | 1185 EXPECT_EQ(gfx::Rect(kPositionX - radius, |
1185 kPositionY - radius, | 1186 kPositionY - radius, |
1186 radius * 2, | 1187 radius * 2, |
1187 radius * 2).ToString(), | 1188 radius * 2).ToString(), |
1188 delegate->bounding_box().ToString()); | 1189 delegate->bounding_box().ToString()); |
1189 | 1190 |
1190 const int kScrollAmount = 50; | 1191 const int kScrollAmount = 50; |
1191 tes.SendScrollEvents(dispatcher(), kPositionX, kPositionY, | 1192 tes.SendScrollEvents(event_processor(), kPositionX, kPositionY, |
1192 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); | 1193 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); |
1193 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 1194 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
1194 delegate->scroll_begin_position().ToString()); | 1195 delegate->scroll_begin_position().ToString()); |
1195 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, | 1196 EXPECT_EQ(gfx::Rect(kPositionX + kScrollAmount - radius, |
1196 kPositionY + kScrollAmount - radius, | 1197 kPositionY + kScrollAmount - radius, |
1197 radius * 2, | 1198 radius * 2, |
1198 radius * 2).ToString(), | 1199 radius * 2).ToString(), |
1199 delegate->bounding_box().ToString()); | 1200 delegate->bounding_box().ToString()); |
1200 | 1201 |
1201 // Release the touch. This should end the scroll. | 1202 // Release the touch. This should end the scroll. |
(...skipping 30 matching lines...) Expand all Loading... |
1232 | 1233 |
1233 // Get rid of touch slop. | 1234 // Get rid of touch slop. |
1234 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), | 1235 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), |
1235 kTouchId, tes.Now()); | 1236 kTouchId, tes.Now()); |
1236 DispatchEventUsingWindowDispatcher(&move); | 1237 DispatchEventUsingWindowDispatcher(&move); |
1237 delegate->Reset(); | 1238 delegate->Reset(); |
1238 | 1239 |
1239 | 1240 |
1240 // Move the touch-point horizontally enough that it is considered a | 1241 // Move the touch-point horizontally enough that it is considered a |
1241 // horizontal scroll. | 1242 // horizontal scroll. |
1242 tes.SendScrollEvent(dispatcher(), 25, 1, kTouchId, delegate.get()); | 1243 tes.SendScrollEvent(event_processor(), 25, 1, kTouchId, delegate.get()); |
1243 EXPECT_EQ(0, delegate->scroll_y()); | 1244 EXPECT_EQ(0, delegate->scroll_y()); |
1244 EXPECT_EQ(1, delegate->scroll_y_ordinal()); | 1245 EXPECT_EQ(1, delegate->scroll_y_ordinal()); |
1245 EXPECT_EQ(20, delegate->scroll_x()); | 1246 EXPECT_EQ(20, delegate->scroll_x()); |
1246 EXPECT_EQ(20, delegate->scroll_x_ordinal()); | 1247 EXPECT_EQ(20, delegate->scroll_x_ordinal()); |
1247 | 1248 |
1248 // Get a high x velocity, while still staying on the rail | 1249 // Get a high x velocity, while still staying on the rail |
1249 tes.SendScrollEvents(dispatcher(), 1, 1, | 1250 tes.SendScrollEvents(event_processor(), 1, 1, |
1250 100, 10, kTouchId, 1, | 1251 100, 10, kTouchId, 1, |
1251 ui::GestureConfiguration::points_buffered_for_velocity(), | 1252 ui::GestureConfiguration::points_buffered_for_velocity(), |
1252 delegate.get()); | 1253 delegate.get()); |
1253 // The y-velocity during the scroll should be 0 since this is in a horizontal | 1254 // The y-velocity during the scroll should be 0 since this is in a horizontal |
1254 // rail scroll. | 1255 // rail scroll. |
1255 EXPECT_GT(delegate->scroll_velocity_x(), 0); | 1256 EXPECT_GT(delegate->scroll_velocity_x(), 0); |
1256 EXPECT_EQ(0, delegate->scroll_velocity_y()); | 1257 EXPECT_EQ(0, delegate->scroll_velocity_y()); |
1257 | 1258 |
1258 delegate->Reset(); | 1259 delegate->Reset(); |
1259 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1260 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
(...skipping 22 matching lines...) Expand all Loading... |
1282 DispatchEventUsingWindowDispatcher(&press); | 1283 DispatchEventUsingWindowDispatcher(&press); |
1283 | 1284 |
1284 // Get rid of touch slop. | 1285 // Get rid of touch slop. |
1285 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), | 1286 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), |
1286 kTouchId, tes.Now()); | 1287 kTouchId, tes.Now()); |
1287 DispatchEventUsingWindowDispatcher(&move); | 1288 DispatchEventUsingWindowDispatcher(&move); |
1288 delegate->Reset(); | 1289 delegate->Reset(); |
1289 | 1290 |
1290 // Move the touch-point vertically enough that it is considered a | 1291 // Move the touch-point vertically enough that it is considered a |
1291 // vertical scroll. | 1292 // vertical scroll. |
1292 tes.SendScrollEvent(dispatcher(), 1, 25, kTouchId, delegate.get()); | 1293 tes.SendScrollEvent(event_processor(), 1, 25, kTouchId, delegate.get()); |
1293 EXPECT_EQ(20, delegate->scroll_y()); | 1294 EXPECT_EQ(20, delegate->scroll_y()); |
1294 EXPECT_EQ(20, delegate->scroll_y_ordinal()); | 1295 EXPECT_EQ(20, delegate->scroll_y_ordinal()); |
1295 EXPECT_EQ(0, delegate->scroll_x()); | 1296 EXPECT_EQ(0, delegate->scroll_x()); |
1296 EXPECT_EQ(1, delegate->scroll_x_ordinal()); | 1297 EXPECT_EQ(1, delegate->scroll_x_ordinal()); |
1297 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1298 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
1298 EXPECT_GT(delegate->scroll_velocity_x_ordinal(), 0); | 1299 EXPECT_GT(delegate->scroll_velocity_x_ordinal(), 0); |
1299 | 1300 |
1300 // Get a high y velocity, while still staying on the rail | 1301 // Get a high y velocity, while still staying on the rail |
1301 tes.SendScrollEvents(dispatcher(), 1, 6, | 1302 tes.SendScrollEvents(event_processor(), 1, 6, |
1302 10, 100, kTouchId, 1, | 1303 10, 100, kTouchId, 1, |
1303 ui::GestureConfiguration::points_buffered_for_velocity(), | 1304 ui::GestureConfiguration::points_buffered_for_velocity(), |
1304 delegate.get()); | 1305 delegate.get()); |
1305 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1306 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
1306 EXPECT_GT(delegate->scroll_velocity_y(), 0); | 1307 EXPECT_GT(delegate->scroll_velocity_y(), 0); |
1307 | 1308 |
1308 delegate->Reset(); | 1309 delegate->Reset(); |
1309 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), | 1310 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), |
1310 kTouchId, tes.Now()); | 1311 kTouchId, tes.Now()); |
1311 DispatchEventUsingWindowDispatcher(&release); | 1312 DispatchEventUsingWindowDispatcher(&release); |
(...skipping 14 matching lines...) Expand all Loading... |
1326 const int kTouchId = 7; | 1327 const int kTouchId = 7; |
1327 gfx::Rect bounds(0, 0, 1000, 1000); | 1328 gfx::Rect bounds(0, 0, 1000, 1000); |
1328 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1329 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
1329 delegate.get(), -1234, bounds, root_window())); | 1330 delegate.get(), -1234, bounds, root_window())); |
1330 | 1331 |
1331 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1332 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
1332 kTouchId, tes.Now()); | 1333 kTouchId, tes.Now()); |
1333 DispatchEventUsingWindowDispatcher(&press); | 1334 DispatchEventUsingWindowDispatcher(&press); |
1334 | 1335 |
1335 // Move the touch-point such that a non-rail scroll begins | 1336 // Move the touch-point such that a non-rail scroll begins |
1336 tes.SendScrollEvent(dispatcher(), 20, 20, kTouchId, delegate.get()); | 1337 tes.SendScrollEvent(event_processor(), 20, 20, kTouchId, delegate.get()); |
1337 EXPECT_EQ(20, delegate->scroll_y()); | 1338 EXPECT_EQ(20, delegate->scroll_y()); |
1338 EXPECT_EQ(20, delegate->scroll_x()); | 1339 EXPECT_EQ(20, delegate->scroll_x()); |
1339 | 1340 |
1340 tes.SendScrollEvents(dispatcher(), 1, 1, | 1341 tes.SendScrollEvents(event_processor(), 1, 1, |
1341 10, 100, kTouchId, 1, | 1342 10, 100, kTouchId, 1, |
1342 ui::GestureConfiguration::points_buffered_for_velocity(), | 1343 ui::GestureConfiguration::points_buffered_for_velocity(), |
1343 delegate.get()); | 1344 delegate.get()); |
1344 | 1345 |
1345 delegate->Reset(); | 1346 delegate->Reset(); |
1346 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1347 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
1347 kTouchId, tes.Now()); | 1348 kTouchId, tes.Now()); |
1348 DispatchEventUsingWindowDispatcher(&release); | 1349 DispatchEventUsingWindowDispatcher(&release); |
1349 | 1350 |
1350 EXPECT_TRUE(delegate->fling()); | 1351 EXPECT_TRUE(delegate->fling()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1425 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
1425 kTouchId, tes.Now()); | 1426 kTouchId, tes.Now()); |
1426 DispatchEventUsingWindowDispatcher(&press1); | 1427 DispatchEventUsingWindowDispatcher(&press1); |
1427 EXPECT_TRUE(delegate->tap_down()); | 1428 EXPECT_TRUE(delegate->tap_down()); |
1428 | 1429 |
1429 // We haven't pressed long enough for a long press to occur | 1430 // We haven't pressed long enough for a long press to occur |
1430 EXPECT_FALSE(delegate->long_press()); | 1431 EXPECT_FALSE(delegate->long_press()); |
1431 EXPECT_FALSE(delegate->tap_cancel()); | 1432 EXPECT_FALSE(delegate->tap_cancel()); |
1432 | 1433 |
1433 // Scroll around, to cancel the long press | 1434 // Scroll around, to cancel the long press |
1434 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 1435 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
1435 // Wait until the timer runs out | 1436 // Wait until the timer runs out |
1436 gesture_sequence->ForceTimeout(); | 1437 gesture_sequence->ForceTimeout(); |
1437 EXPECT_FALSE(delegate->long_press()); | 1438 EXPECT_FALSE(delegate->long_press()); |
1438 EXPECT_TRUE(delegate->tap_cancel()); | 1439 EXPECT_TRUE(delegate->tap_cancel()); |
1439 | 1440 |
1440 delegate->Reset(); | 1441 delegate->Reset(); |
1441 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1442 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
1442 kTouchId, tes.LeapForward(10)); | 1443 kTouchId, tes.LeapForward(10)); |
1443 DispatchEventUsingWindowDispatcher(&release1); | 1444 DispatchEventUsingWindowDispatcher(&release1); |
1444 EXPECT_FALSE(delegate->long_press()); | 1445 EXPECT_FALSE(delegate->long_press()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 | 1565 |
1565 // Get rid of touch slop. | 1566 // Get rid of touch slop. |
1566 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), | 1567 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), |
1567 kTouchId, tes.Now()); | 1568 kTouchId, tes.Now()); |
1568 | 1569 |
1569 DispatchEventUsingWindowDispatcher(&move); | 1570 DispatchEventUsingWindowDispatcher(&move); |
1570 delegate->Reset(); | 1571 delegate->Reset(); |
1571 | 1572 |
1572 // Move the touch-point horizontally enough that it is considered a | 1573 // Move the touch-point horizontally enough that it is considered a |
1573 // horizontal scroll. | 1574 // horizontal scroll. |
1574 tes.SendScrollEvent(dispatcher(), 25, 1, kTouchId, delegate.get()); | 1575 tes.SendScrollEvent(event_processor(), 25, 1, kTouchId, delegate.get()); |
1575 EXPECT_EQ(0, delegate->scroll_y()); | 1576 EXPECT_EQ(0, delegate->scroll_y()); |
1576 EXPECT_EQ(20, delegate->scroll_x()); | 1577 EXPECT_EQ(20, delegate->scroll_x()); |
1577 | 1578 |
1578 tes.SendScrollEvent(dispatcher(), 30, 6, kTouchId, delegate.get()); | 1579 tes.SendScrollEvent(event_processor(), 30, 6, kTouchId, delegate.get()); |
1579 EXPECT_TRUE(delegate->scroll_update()); | 1580 EXPECT_TRUE(delegate->scroll_update()); |
1580 EXPECT_EQ(5, delegate->scroll_x()); | 1581 EXPECT_EQ(5, delegate->scroll_x()); |
1581 // y shouldn't change, as we're on a horizontal rail. | 1582 // y shouldn't change, as we're on a horizontal rail. |
1582 EXPECT_EQ(0, delegate->scroll_y()); | 1583 EXPECT_EQ(0, delegate->scroll_y()); |
1583 | 1584 |
1584 // Send enough information that a velocity can be calculated for the gesture, | 1585 // Send enough information that a velocity can be calculated for the gesture, |
1585 // and we can break the rail | 1586 // and we can break the rail |
1586 tes.SendScrollEvents(dispatcher(), 1, 1, | 1587 tes.SendScrollEvents(event_processor(), 1, 1, |
1587 6, 100, kTouchId, 1, | 1588 6, 100, kTouchId, 1, |
1588 ui::GestureConfiguration::points_buffered_for_velocity(), | 1589 ui::GestureConfiguration::points_buffered_for_velocity(), |
1589 delegate.get()); | 1590 delegate.get()); |
1590 // Since the scroll is not longer railing, the velocity should be set for both | 1591 // Since the scroll is not longer railing, the velocity should be set for both |
1591 // axis. | 1592 // axis. |
1592 EXPECT_GT(delegate->scroll_velocity_x(), 0); | 1593 EXPECT_GT(delegate->scroll_velocity_x(), 0); |
1593 EXPECT_GT(delegate->scroll_velocity_y(), 0); | 1594 EXPECT_GT(delegate->scroll_velocity_y(), 0); |
1594 | 1595 |
1595 tes.SendScrollEvent(dispatcher(), 5, 0, kTouchId, delegate.get()); | 1596 tes.SendScrollEvent(event_processor(), 5, 0, kTouchId, delegate.get()); |
1596 tes.SendScrollEvent(dispatcher(), 10, 5, kTouchId, delegate.get()); | 1597 tes.SendScrollEvent(event_processor(), 10, 5, kTouchId, delegate.get()); |
1597 | 1598 |
1598 // The rail should be broken | 1599 // The rail should be broken |
1599 EXPECT_TRUE(delegate->scroll_update()); | 1600 EXPECT_TRUE(delegate->scroll_update()); |
1600 EXPECT_EQ(5, delegate->scroll_x()); | 1601 EXPECT_EQ(5, delegate->scroll_x()); |
1601 EXPECT_EQ(5, delegate->scroll_y()); | 1602 EXPECT_EQ(5, delegate->scroll_y()); |
1602 } | 1603 } |
1603 | 1604 |
1604 // Check that vertical scroll gestures cause scrolls on vertical rails. | 1605 // Check that vertical scroll gestures cause scrolls on vertical rails. |
1605 // Also tests that vertical rails can be broken. | 1606 // Also tests that vertical rails can be broken. |
1606 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { | 1607 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { |
(...skipping 10 matching lines...) Expand all Loading... |
1617 DispatchEventUsingWindowDispatcher(&press); | 1618 DispatchEventUsingWindowDispatcher(&press); |
1618 | 1619 |
1619 // Get rid of touch slop. | 1620 // Get rid of touch slop. |
1620 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), | 1621 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), |
1621 kTouchId, tes.Now()); | 1622 kTouchId, tes.Now()); |
1622 DispatchEventUsingWindowDispatcher(&move); | 1623 DispatchEventUsingWindowDispatcher(&move); |
1623 delegate->Reset(); | 1624 delegate->Reset(); |
1624 | 1625 |
1625 // Move the touch-point vertically enough that it is considered a | 1626 // Move the touch-point vertically enough that it is considered a |
1626 // vertical scroll. | 1627 // vertical scroll. |
1627 tes.SendScrollEvent(dispatcher(), 1, 25, kTouchId, delegate.get()); | 1628 tes.SendScrollEvent(event_processor(), 1, 25, kTouchId, delegate.get()); |
1628 EXPECT_EQ(0, delegate->scroll_x()); | 1629 EXPECT_EQ(0, delegate->scroll_x()); |
1629 EXPECT_EQ(20, delegate->scroll_y()); | 1630 EXPECT_EQ(20, delegate->scroll_y()); |
1630 | 1631 |
1631 tes.SendScrollEvent(dispatcher(), 6, 30, kTouchId, delegate.get()); | 1632 tes.SendScrollEvent(event_processor(), 6, 30, kTouchId, delegate.get()); |
1632 EXPECT_TRUE(delegate->scroll_update()); | 1633 EXPECT_TRUE(delegate->scroll_update()); |
1633 EXPECT_EQ(5, delegate->scroll_y()); | 1634 EXPECT_EQ(5, delegate->scroll_y()); |
1634 // x shouldn't change, as we're on a vertical rail. | 1635 // x shouldn't change, as we're on a vertical rail. |
1635 EXPECT_EQ(0, delegate->scroll_x()); | 1636 EXPECT_EQ(0, delegate->scroll_x()); |
1636 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1637 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
1637 | 1638 |
1638 // Send enough information that a velocity can be calculated for the gesture, | 1639 // Send enough information that a velocity can be calculated for the gesture, |
1639 // and we can break the rail | 1640 // and we can break the rail |
1640 tes.SendScrollEvents(dispatcher(), 1, 6, | 1641 tes.SendScrollEvents(event_processor(), 1, 6, |
1641 100, 1, kTouchId, 1, | 1642 100, 1, kTouchId, 1, |
1642 ui::GestureConfiguration::points_buffered_for_velocity(), | 1643 ui::GestureConfiguration::points_buffered_for_velocity(), |
1643 delegate.get()); | 1644 delegate.get()); |
1644 EXPECT_GT(delegate->scroll_velocity_x(), 0); | 1645 EXPECT_GT(delegate->scroll_velocity_x(), 0); |
1645 EXPECT_GT(delegate->scroll_velocity_y(), 0); | 1646 EXPECT_GT(delegate->scroll_velocity_y(), 0); |
1646 | 1647 |
1647 tes.SendScrollEvent(dispatcher(), 0, 5, kTouchId, delegate.get()); | 1648 tes.SendScrollEvent(event_processor(), 0, 5, kTouchId, delegate.get()); |
1648 tes.SendScrollEvent(dispatcher(), 5, 10, kTouchId, delegate.get()); | 1649 tes.SendScrollEvent(event_processor(), 5, 10, kTouchId, delegate.get()); |
1649 | 1650 |
1650 // The rail should be broken | 1651 // The rail should be broken |
1651 EXPECT_TRUE(delegate->scroll_update()); | 1652 EXPECT_TRUE(delegate->scroll_update()); |
1652 EXPECT_EQ(5, delegate->scroll_x()); | 1653 EXPECT_EQ(5, delegate->scroll_x()); |
1653 EXPECT_EQ(5, delegate->scroll_y()); | 1654 EXPECT_EQ(5, delegate->scroll_y()); |
1654 } | 1655 } |
1655 | 1656 |
1656 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { | 1657 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { |
1657 // We'll start by moving the touch point by (5, 5). We want all of that | 1658 // We'll start by moving the touch point by (5, 5). We want all of that |
1658 // distance to be consumed by the slop, so we set the slop radius to | 1659 // distance to be consumed by the slop, so we set the slop radius to |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 EXPECT_FALSE(delegate->tap_down()); | 1776 EXPECT_FALSE(delegate->tap_down()); |
1776 EXPECT_FALSE(delegate->tap_cancel()); | 1777 EXPECT_FALSE(delegate->tap_cancel()); |
1777 EXPECT_FALSE(delegate->scroll_begin()); | 1778 EXPECT_FALSE(delegate->scroll_begin()); |
1778 EXPECT_FALSE(delegate->scroll_update()); | 1779 EXPECT_FALSE(delegate->scroll_update()); |
1779 EXPECT_FALSE(delegate->scroll_end()); | 1780 EXPECT_FALSE(delegate->scroll_end()); |
1780 EXPECT_TRUE(delegate->fling()); | 1781 EXPECT_TRUE(delegate->fling()); |
1781 } | 1782 } |
1782 | 1783 |
1783 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { | 1784 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { |
1784 scoped_ptr<QueueTouchEventDelegate> queued_delegate( | 1785 scoped_ptr<QueueTouchEventDelegate> queued_delegate( |
1785 new QueueTouchEventDelegate(dispatcher())); | 1786 new QueueTouchEventDelegate(host()->dispatcher())); |
1786 const int kWindowWidth = 123; | 1787 const int kWindowWidth = 123; |
1787 const int kWindowHeight = 45; | 1788 const int kWindowHeight = 45; |
1788 const int kTouchId1 = 6; | 1789 const int kTouchId1 = 6; |
1789 const int kTouchId2 = 4; | 1790 const int kTouchId2 = 4; |
1790 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1791 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
1791 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( | 1792 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( |
1792 queued_delegate.get(), -1234, bounds, root_window())); | 1793 queued_delegate.get(), -1234, bounds, root_window())); |
1793 | 1794 |
1794 queued_delegate->set_window(queue.get()); | 1795 queued_delegate->set_window(queue.get()); |
1795 | 1796 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2072 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), | 2073 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), |
2073 kTouchId1, tes.Now()); | 2074 kTouchId1, tes.Now()); |
2074 DispatchEventUsingWindowDispatcher(&press); | 2075 DispatchEventUsingWindowDispatcher(&press); |
2075 delegate->Reset(); | 2076 delegate->Reset(); |
2076 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 2077 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
2077 kTouchId2, tes.Now()); | 2078 kTouchId2, tes.Now()); |
2078 DispatchEventUsingWindowDispatcher(&press2); | 2079 DispatchEventUsingWindowDispatcher(&press2); |
2079 EXPECT_FALSE(delegate->pinch_begin()); | 2080 EXPECT_FALSE(delegate->pinch_begin()); |
2080 | 2081 |
2081 // Touch move triggers pinch begin. | 2082 // Touch move triggers pinch begin. |
2082 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2083 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); |
2083 EXPECT_TRUE(delegate->pinch_begin()); | 2084 EXPECT_TRUE(delegate->pinch_begin()); |
2084 EXPECT_FALSE(delegate->pinch_update()); | 2085 EXPECT_FALSE(delegate->pinch_update()); |
2085 | 2086 |
2086 // Touch move triggers pinch update. | 2087 // Touch move triggers pinch update. |
2087 tes.SendScrollEvent(dispatcher(), 160, 200, kTouchId1, delegate.get()); | 2088 tes.SendScrollEvent(event_processor(), 160, 200, kTouchId1, delegate.get()); |
2088 EXPECT_FALSE(delegate->pinch_begin()); | 2089 EXPECT_FALSE(delegate->pinch_begin()); |
2089 EXPECT_TRUE(delegate->pinch_update()); | 2090 EXPECT_TRUE(delegate->pinch_update()); |
2090 | 2091 |
2091 // Pinch has started, now release the second finger | 2092 // Pinch has started, now release the second finger |
2092 delegate->Reset(); | 2093 delegate->Reset(); |
2093 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2094 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
2094 kTouchId1, tes.Now()); | 2095 kTouchId1, tes.Now()); |
2095 DispatchEventUsingWindowDispatcher(&release); | 2096 DispatchEventUsingWindowDispatcher(&release); |
2096 EXPECT_TRUE(delegate->pinch_end()); | 2097 EXPECT_TRUE(delegate->pinch_end()); |
2097 | 2098 |
2098 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId2, delegate.get()); | 2099 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId2, delegate.get()); |
2099 EXPECT_TRUE(delegate->scroll_update()); | 2100 EXPECT_TRUE(delegate->scroll_update()); |
2100 | 2101 |
2101 // Pinch again | 2102 // Pinch again |
2102 delegate->Reset(); | 2103 delegate->Reset(); |
2103 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 2104 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
2104 kTouchId1, tes.Now()); | 2105 kTouchId1, tes.Now()); |
2105 DispatchEventUsingWindowDispatcher(&press3); | 2106 DispatchEventUsingWindowDispatcher(&press3); |
2106 // Now the touch points are close. So we will go into two finger tap. | 2107 // Now the touch points are close. So we will go into two finger tap. |
2107 // Move the touch-point enough to break two-finger-tap and enter pinch. | 2108 // Move the touch-point enough to break two-finger-tap and enter pinch. |
2108 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202), | 2109 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202), |
2109 kTouchId1, tes.Now()); | 2110 kTouchId1, tes.Now()); |
2110 DispatchEventUsingWindowDispatcher(&move2); | 2111 DispatchEventUsingWindowDispatcher(&move2); |
2111 EXPECT_TRUE(delegate->pinch_begin()); | 2112 EXPECT_TRUE(delegate->pinch_begin()); |
2112 | 2113 |
2113 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2114 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); |
2114 EXPECT_TRUE(delegate->pinch_update()); | 2115 EXPECT_TRUE(delegate->pinch_update()); |
2115 } | 2116 } |
2116 | 2117 |
2117 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { | 2118 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { |
2118 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2119 scoped_ptr<GestureEventConsumeDelegate> delegate( |
2119 new GestureEventConsumeDelegate()); | 2120 new GestureEventConsumeDelegate()); |
2120 TimedEvents tes; | 2121 TimedEvents tes; |
2121 const int kWindowWidth = 300; | 2122 const int kWindowWidth = 300; |
2122 const int kWindowHeight = 400; | 2123 const int kWindowHeight = 400; |
2123 const int kTouchId1 = 3; | 2124 const int kTouchId1 = 3; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 DispatchEventUsingWindowDispatcher(&press2); | 2343 DispatchEventUsingWindowDispatcher(&press2); |
2343 | 2344 |
2344 // As these presses were outside the root window, they should be | 2345 // As these presses were outside the root window, they should be |
2345 // associated with the root window. | 2346 // associated with the root window. |
2346 EXPECT_EQ(0, window_gesture_sequence->point_count()); | 2347 EXPECT_EQ(0, window_gesture_sequence->point_count()); |
2347 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); | 2348 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); |
2348 } | 2349 } |
2349 | 2350 |
2350 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { | 2351 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { |
2351 scoped_ptr<QueueTouchEventDelegate> delegate( | 2352 scoped_ptr<QueueTouchEventDelegate> delegate( |
2352 new QueueTouchEventDelegate(dispatcher())); | 2353 new QueueTouchEventDelegate(host()->dispatcher())); |
2353 TimedEvents tes; | 2354 TimedEvents tes; |
2354 const int kTouchId = 2; | 2355 const int kTouchId = 2; |
2355 gfx::Rect bounds(100, 200, 100, 100); | 2356 gfx::Rect bounds(100, 200, 100, 100); |
2356 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2357 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
2357 delegate.get(), -1234, bounds, root_window())); | 2358 delegate.get(), -1234, bounds, root_window())); |
2358 delegate->set_window(window.get()); | 2359 delegate->set_window(window.get()); |
2359 | 2360 |
2360 delegate->Reset(); | 2361 delegate->Reset(); |
2361 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2362 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
2362 kTouchId, tes.Now()); | 2363 kTouchId, tes.Now()); |
2363 DispatchEventUsingWindowDispatcher(&press); | 2364 DispatchEventUsingWindowDispatcher(&press); |
2364 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2365 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
2365 kTouchId, tes.LeapForward(50)); | 2366 kTouchId, tes.LeapForward(50)); |
2366 DispatchEventUsingWindowDispatcher(&release); | 2367 DispatchEventUsingWindowDispatcher(&release); |
2367 | 2368 |
2368 delegate->Reset(); | 2369 delegate->Reset(); |
2369 delegate->ReceivedAck(); | 2370 delegate->ReceivedAck(); |
2370 EXPECT_TRUE(delegate->tap_down()); | 2371 EXPECT_TRUE(delegate->tap_down()); |
2371 delegate->Reset(); | 2372 delegate->Reset(); |
2372 delegate->ReceivedAckPreventDefaulted(); | 2373 delegate->ReceivedAckPreventDefaulted(); |
2373 EXPECT_FALSE(delegate->tap()); | 2374 EXPECT_FALSE(delegate->tap()); |
2374 EXPECT_TRUE(delegate->tap_cancel()); | 2375 EXPECT_TRUE(delegate->tap_cancel()); |
2375 } | 2376 } |
2376 | 2377 |
2377 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { | 2378 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { |
2378 scoped_ptr<QueueTouchEventDelegate> delegate( | 2379 scoped_ptr<QueueTouchEventDelegate> delegate( |
2379 new QueueTouchEventDelegate(dispatcher())); | 2380 new QueueTouchEventDelegate(host()->dispatcher())); |
2380 TimedEvents tes; | 2381 TimedEvents tes; |
2381 const int kTouchId1 = 7; | 2382 const int kTouchId1 = 7; |
2382 const int kTouchId2 = 5; | 2383 const int kTouchId2 = 5; |
2383 gfx::Rect bounds(10, 20, 100, 100); | 2384 gfx::Rect bounds(10, 20, 100, 100); |
2384 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2385 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
2385 delegate.get(), -1234, bounds, root_window())); | 2386 delegate.get(), -1234, bounds, root_window())); |
2386 delegate->set_window(window.get()); | 2387 delegate->set_window(window.get()); |
2387 | 2388 |
2388 { | 2389 { |
2389 delegate->Reset(); | 2390 delegate->Reset(); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 delegate->Reset(); | 2745 delegate->Reset(); |
2745 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2746 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
2746 kTouchId1, tes.Now()); | 2747 kTouchId1, tes.Now()); |
2747 DispatchEventUsingWindowDispatcher(&press1); | 2748 DispatchEventUsingWindowDispatcher(&press1); |
2748 | 2749 |
2749 delegate->Reset(); | 2750 delegate->Reset(); |
2750 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2751 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
2751 kTouchId2, tes.Now()); | 2752 kTouchId2, tes.Now()); |
2752 DispatchEventUsingWindowDispatcher(&press2); | 2753 DispatchEventUsingWindowDispatcher(&press2); |
2753 | 2754 |
2754 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2755 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); |
2755 EXPECT_FALSE(delegate->two_finger_tap()); | 2756 EXPECT_FALSE(delegate->two_finger_tap()); |
2756 EXPECT_TRUE(delegate->pinch_begin()); | 2757 EXPECT_TRUE(delegate->pinch_begin()); |
2757 | 2758 |
2758 // Make sure there is enough delay before the touch is released so that it | 2759 // Make sure there is enough delay before the touch is released so that it |
2759 // is recognized as a tap. | 2760 // is recognized as a tap. |
2760 delegate->Reset(); | 2761 delegate->Reset(); |
2761 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2762 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
2762 kTouchId2, tes.LeapForward(50)); | 2763 kTouchId2, tes.LeapForward(50)); |
2763 | 2764 |
2764 DispatchEventUsingWindowDispatcher(&release); | 2765 DispatchEventUsingWindowDispatcher(&release); |
(...skipping 10 matching lines...) Expand all Loading... |
2775 delegate->Reset(); | 2776 delegate->Reset(); |
2776 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2777 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
2777 kTouchId1, tes.Now()); | 2778 kTouchId1, tes.Now()); |
2778 DispatchEventUsingWindowDispatcher(&press1); | 2779 DispatchEventUsingWindowDispatcher(&press1); |
2779 | 2780 |
2780 delegate->Reset(); | 2781 delegate->Reset(); |
2781 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2782 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
2782 kTouchId2, tes.Now()); | 2783 kTouchId2, tes.Now()); |
2783 DispatchEventUsingWindowDispatcher(&press2); | 2784 DispatchEventUsingWindowDispatcher(&press2); |
2784 | 2785 |
2785 tes.SendScrollEvent(dispatcher(), 101, 230, kTouchId2, delegate.get()); | 2786 tes.SendScrollEvent(event_processor(), 101, 230, kTouchId2, delegate.get()); |
2786 EXPECT_FALSE(delegate->two_finger_tap()); | 2787 EXPECT_FALSE(delegate->two_finger_tap()); |
2787 EXPECT_TRUE(delegate->pinch_begin()); | 2788 EXPECT_TRUE(delegate->pinch_begin()); |
2788 | 2789 |
2789 // Make sure there is enough delay before the touch is released so that it | 2790 // Make sure there is enough delay before the touch is released so that it |
2790 // is recognized as a tap. | 2791 // is recognized as a tap. |
2791 delegate->Reset(); | 2792 delegate->Reset(); |
2792 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2793 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
2793 kTouchId1, tes.LeapForward(50)); | 2794 kTouchId1, tes.LeapForward(50)); |
2794 | 2795 |
2795 DispatchEventUsingWindowDispatcher(&release); | 2796 DispatchEventUsingWindowDispatcher(&release); |
(...skipping 12 matching lines...) Expand all Loading... |
2808 TimedEvents tes; | 2809 TimedEvents tes; |
2809 | 2810 |
2810 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2811 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
2811 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2812 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
2812 delegate.get(), -1234, bounds, root_window())); | 2813 delegate.get(), -1234, bounds, root_window())); |
2813 | 2814 |
2814 delegate->Reset(); | 2815 delegate->Reset(); |
2815 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2816 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
2816 kTouchId1, tes.Now()); | 2817 kTouchId1, tes.Now()); |
2817 DispatchEventUsingWindowDispatcher(&press1); | 2818 DispatchEventUsingWindowDispatcher(&press1); |
2818 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId1, delegate.get()); | 2819 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); |
2819 | 2820 |
2820 delegate->Reset(); | 2821 delegate->Reset(); |
2821 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2822 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
2822 kTouchId2, tes.Now()); | 2823 kTouchId2, tes.Now()); |
2823 DispatchEventUsingWindowDispatcher(&press2); | 2824 DispatchEventUsingWindowDispatcher(&press2); |
2824 | 2825 |
2825 EXPECT_TRUE(delegate->pinch_begin()); | 2826 EXPECT_TRUE(delegate->pinch_begin()); |
2826 | 2827 |
2827 // Make sure there is enough delay before the touch is released so that it | 2828 // Make sure there is enough delay before the touch is released so that it |
2828 // is recognized as a tap. | 2829 // is recognized as a tap. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 DispatchEventUsingWindowDispatcher(&press2); | 3025 DispatchEventUsingWindowDispatcher(&press2); |
3025 window->Hide(); | 3026 window->Hide(); |
3026 EXPECT_EQ(NULL, | 3027 EXPECT_EQ(NULL, |
3027 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); | 3028 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); |
3028 EXPECT_EQ(NULL, | 3029 EXPECT_EQ(NULL, |
3029 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); | 3030 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); |
3030 } | 3031 } |
3031 | 3032 |
3032 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { | 3033 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { |
3033 scoped_ptr<QueueTouchEventDelegate> delegate( | 3034 scoped_ptr<QueueTouchEventDelegate> delegate( |
3034 new QueueTouchEventDelegate(dispatcher())); | 3035 new QueueTouchEventDelegate(host()->dispatcher())); |
3035 const int kTouchId = 2; | 3036 const int kTouchId = 2; |
3036 gfx::Rect bounds(100, 200, 100, 100); | 3037 gfx::Rect bounds(100, 200, 100, 100); |
3037 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3038 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
3038 delegate.get(), -1234, bounds, root_window())); | 3039 delegate.get(), -1234, bounds, root_window())); |
3039 delegate->set_window(window.get()); | 3040 delegate->set_window(window.get()); |
3040 TimedEvents tes; | 3041 TimedEvents tes; |
3041 | 3042 |
3042 TimerTestGestureRecognizer* gesture_recognizer = | 3043 TimerTestGestureRecognizer* gesture_recognizer = |
3043 new TimerTestGestureRecognizer(); | 3044 new TimerTestGestureRecognizer(); |
3044 TimerTestGestureSequence* gesture_sequence = | 3045 TimerTestGestureSequence* gesture_sequence = |
3045 static_cast<TimerTestGestureSequence*>( | 3046 static_cast<TimerTestGestureSequence*>( |
3046 gesture_recognizer->GetGestureSequenceForTesting(window.get())); | 3047 gesture_recognizer->GetGestureSequenceForTesting(window.get())); |
3047 | 3048 |
3048 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 3049 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
3049 | 3050 |
3050 delegate->Reset(); | 3051 delegate->Reset(); |
3051 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3052 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
3052 kTouchId, tes.Now()); | 3053 kTouchId, tes.Now()); |
3053 DispatchEventUsingWindowDispatcher(&press); | 3054 DispatchEventUsingWindowDispatcher(&press); |
3054 // Scroll around, to cancel the long press | 3055 // Scroll around, to cancel the long press |
3055 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3056 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
3056 | 3057 |
3057 delegate->Reset(); | 3058 delegate->Reset(); |
3058 delegate->ReceivedAck(); | 3059 delegate->ReceivedAck(); |
3059 EXPECT_TRUE(delegate->tap_down()); | 3060 EXPECT_TRUE(delegate->tap_down()); |
3060 EXPECT_TRUE(gesture_sequence->IsTimerRunning()); | 3061 EXPECT_TRUE(gesture_sequence->IsTimerRunning()); |
3061 | 3062 |
3062 delegate->Reset(); | 3063 delegate->Reset(); |
3063 delegate->ReceivedAckPreventDefaulted(); | 3064 delegate->ReceivedAckPreventDefaulted(); |
3064 EXPECT_FALSE(gesture_sequence->IsTimerRunning()); | 3065 EXPECT_FALSE(gesture_sequence->IsTimerRunning()); |
3065 gesture_sequence->ForceTimeout(); | 3066 gesture_sequence->ForceTimeout(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3108 EXPECT_TRUE(delegate->tap_down()); | 3109 EXPECT_TRUE(delegate->tap_down()); |
3109 EXPECT_FALSE(delegate->tap_cancel()); | 3110 EXPECT_FALSE(delegate->tap_cancel()); |
3110 EXPECT_TRUE(delegate->begin()); | 3111 EXPECT_TRUE(delegate->begin()); |
3111 EXPECT_FALSE(delegate->scroll_begin()); | 3112 EXPECT_FALSE(delegate->scroll_begin()); |
3112 EXPECT_FALSE(delegate->scroll_update()); | 3113 EXPECT_FALSE(delegate->scroll_update()); |
3113 EXPECT_FALSE(delegate->scroll_end()); | 3114 EXPECT_FALSE(delegate->scroll_end()); |
3114 | 3115 |
3115 // Move the touch-point enough so that it would normally be considered a | 3116 // Move the touch-point enough so that it would normally be considered a |
3116 // scroll. But since the touch-moves will be consumed, the scroll should not | 3117 // scroll. But since the touch-moves will be consumed, the scroll should not |
3117 // start. | 3118 // start. |
3118 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3119 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
3119 EXPECT_FALSE(delegate->tap()); | 3120 EXPECT_FALSE(delegate->tap()); |
3120 EXPECT_FALSE(delegate->tap_down()); | 3121 EXPECT_FALSE(delegate->tap_down()); |
3121 EXPECT_TRUE(delegate->tap_cancel()); | 3122 EXPECT_TRUE(delegate->tap_cancel()); |
3122 EXPECT_FALSE(delegate->begin()); | 3123 EXPECT_FALSE(delegate->begin()); |
3123 EXPECT_FALSE(delegate->scroll_begin()); | 3124 EXPECT_FALSE(delegate->scroll_begin()); |
3124 EXPECT_FALSE(delegate->scroll_update()); | 3125 EXPECT_FALSE(delegate->scroll_update()); |
3125 EXPECT_FALSE(delegate->scroll_end()); | 3126 EXPECT_FALSE(delegate->scroll_end()); |
3126 | 3127 |
3127 // Release the touch back at the start point. This should end without causing | 3128 // Release the touch back at the start point. This should end without causing |
3128 // a tap. | 3129 // a tap. |
(...skipping 22 matching lines...) Expand all Loading... |
3151 TimedEvents tes; | 3152 TimedEvents tes; |
3152 | 3153 |
3153 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3154 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
3154 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3155 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
3155 delegate.get(), -1234, bounds, root_window())); | 3156 delegate.get(), -1234, bounds, root_window())); |
3156 | 3157 |
3157 delegate->Reset(); | 3158 delegate->Reset(); |
3158 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3159 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
3159 kTouchId1, tes.Now()); | 3160 kTouchId1, tes.Now()); |
3160 DispatchEventUsingWindowDispatcher(&press1); | 3161 DispatchEventUsingWindowDispatcher(&press1); |
3161 tes.SendScrollEvent(dispatcher(), 131, 231, kTouchId1, delegate.get()); | 3162 tes.SendScrollEvent(event_processor(), 131, 231, kTouchId1, delegate.get()); |
3162 | 3163 |
3163 // First finger touches down and moves. | 3164 // First finger touches down and moves. |
3164 EXPECT_FALSE(delegate->tap()); | 3165 EXPECT_FALSE(delegate->tap()); |
3165 EXPECT_FALSE(delegate->scroll_begin()); | 3166 EXPECT_FALSE(delegate->scroll_begin()); |
3166 EXPECT_FALSE(delegate->scroll_update()); | 3167 EXPECT_FALSE(delegate->scroll_update()); |
3167 EXPECT_FALSE(delegate->scroll_end()); | 3168 EXPECT_FALSE(delegate->scroll_end()); |
3168 | 3169 |
3169 delegate->Reset(); | 3170 delegate->Reset(); |
3170 // Second finger touches down and moves. | 3171 // Second finger touches down and moves. |
3171 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 3172 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
3172 kTouchId2, tes.LeapForward(50)); | 3173 kTouchId2, tes.LeapForward(50)); |
3173 DispatchEventUsingWindowDispatcher(&press2); | 3174 DispatchEventUsingWindowDispatcher(&press2); |
3174 tes.SendScrollEvent(dispatcher(), 161, 231, kTouchId2, delegate.get()); | 3175 tes.SendScrollEvent(event_processor(), 161, 231, kTouchId2, delegate.get()); |
3175 | 3176 |
3176 // PinchBegin & ScrollBegin were not sent if the touch-move events were | 3177 // PinchBegin & ScrollBegin were not sent if the touch-move events were |
3177 // consumed. | 3178 // consumed. |
3178 EXPECT_FALSE(delegate->pinch_begin()); | 3179 EXPECT_FALSE(delegate->pinch_begin()); |
3179 EXPECT_FALSE(delegate->scroll_begin()); | 3180 EXPECT_FALSE(delegate->scroll_begin()); |
3180 | 3181 |
3181 EXPECT_FALSE(delegate->tap()); | 3182 EXPECT_FALSE(delegate->tap()); |
3182 EXPECT_FALSE(delegate->two_finger_tap()); | 3183 EXPECT_FALSE(delegate->two_finger_tap()); |
3183 | 3184 |
3184 // Should be no PinchUpdate & ScrollUpdate. | 3185 // Should be no PinchUpdate & ScrollUpdate. |
3185 EXPECT_FALSE(delegate->pinch_update()); | 3186 EXPECT_FALSE(delegate->pinch_update()); |
3186 EXPECT_FALSE(delegate->pinch_end()); | 3187 EXPECT_FALSE(delegate->pinch_end()); |
3187 EXPECT_FALSE(delegate->scroll_update()); | 3188 EXPECT_FALSE(delegate->scroll_update()); |
3188 EXPECT_FALSE(delegate->scroll_end()); | 3189 EXPECT_FALSE(delegate->scroll_end()); |
3189 | 3190 |
3190 delegate->Reset(); | 3191 delegate->Reset(); |
3191 // Moves First finger again, no PinchUpdate & ScrollUpdate. | 3192 // Moves First finger again, no PinchUpdate & ScrollUpdate. |
3192 tes.SendScrollEvent(dispatcher(), 161, 261, kTouchId1, delegate.get()); | 3193 tes.SendScrollEvent(event_processor(), 161, 261, kTouchId1, delegate.get()); |
3193 | 3194 |
3194 EXPECT_FALSE(delegate->pinch_update()); | 3195 EXPECT_FALSE(delegate->pinch_update()); |
3195 EXPECT_FALSE(delegate->pinch_end()); | 3196 EXPECT_FALSE(delegate->pinch_end()); |
3196 EXPECT_FALSE(delegate->scroll_update()); | 3197 EXPECT_FALSE(delegate->scroll_update()); |
3197 EXPECT_FALSE(delegate->scroll_end()); | 3198 EXPECT_FALSE(delegate->scroll_end()); |
3198 | 3199 |
3199 // Stops consuming touch-move. | 3200 // Stops consuming touch-move. |
3200 delegate->set_consume_touch_move(false); | 3201 delegate->set_consume_touch_move(false); |
3201 | 3202 |
3202 delegate->Reset(); | 3203 delegate->Reset(); |
3203 // Making a pinch gesture. | 3204 // Making a pinch gesture. |
3204 tes.SendScrollEvent(dispatcher(), 161, 251, kTouchId1, delegate.get()); | 3205 tes.SendScrollEvent(event_processor(), 161, 251, kTouchId1, delegate.get()); |
3205 // If touch moves are ever consumed, we should not see PinchBegin/Update | 3206 // If touch moves are ever consumed, we should not see PinchBegin/Update |
3206 // even touch moves become not consumed. | 3207 // even touch moves become not consumed. |
3207 EXPECT_FALSE(delegate->scroll_begin()); | 3208 EXPECT_FALSE(delegate->scroll_begin()); |
3208 EXPECT_FALSE(delegate->scroll_update()); | 3209 EXPECT_FALSE(delegate->scroll_update()); |
3209 EXPECT_FALSE(delegate->scroll_end()); | 3210 EXPECT_FALSE(delegate->scroll_end()); |
3210 | 3211 |
3211 EXPECT_FALSE(delegate->pinch_begin()); | 3212 EXPECT_FALSE(delegate->pinch_begin()); |
3212 EXPECT_FALSE(delegate->pinch_update()); | 3213 EXPECT_FALSE(delegate->pinch_update()); |
3213 EXPECT_FALSE(delegate->pinch_end()); | 3214 EXPECT_FALSE(delegate->pinch_end()); |
3214 | 3215 |
3215 delegate->Reset(); | 3216 delegate->Reset(); |
3216 tes.SendScrollEvent(dispatcher(), 161, 241, kTouchId2, delegate.get()); | 3217 tes.SendScrollEvent(event_processor(), 161, 241, kTouchId2, delegate.get()); |
3217 EXPECT_FALSE(delegate->scroll_begin()); | 3218 EXPECT_FALSE(delegate->scroll_begin()); |
3218 EXPECT_FALSE(delegate->scroll_update()); | 3219 EXPECT_FALSE(delegate->scroll_update()); |
3219 EXPECT_FALSE(delegate->scroll_end()); | 3220 EXPECT_FALSE(delegate->scroll_end()); |
3220 | 3221 |
3221 EXPECT_FALSE(delegate->pinch_begin()); | 3222 EXPECT_FALSE(delegate->pinch_begin()); |
3222 EXPECT_FALSE(delegate->pinch_update()); | 3223 EXPECT_FALSE(delegate->pinch_update()); |
3223 EXPECT_FALSE(delegate->pinch_end()); | 3224 EXPECT_FALSE(delegate->pinch_end()); |
3224 | 3225 |
3225 delegate->Reset(); | 3226 delegate->Reset(); |
3226 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3227 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3267 EXPECT_TRUE(delegate->tap_down()); | 3268 EXPECT_TRUE(delegate->tap_down()); |
3268 EXPECT_FALSE(delegate->tap_cancel()); | 3269 EXPECT_FALSE(delegate->tap_cancel()); |
3269 EXPECT_TRUE(delegate->begin()); | 3270 EXPECT_TRUE(delegate->begin()); |
3270 EXPECT_FALSE(delegate->scroll_begin()); | 3271 EXPECT_FALSE(delegate->scroll_begin()); |
3271 EXPECT_FALSE(delegate->scroll_update()); | 3272 EXPECT_FALSE(delegate->scroll_update()); |
3272 EXPECT_FALSE(delegate->scroll_end()); | 3273 EXPECT_FALSE(delegate->scroll_end()); |
3273 | 3274 |
3274 // Move the touch-point enough so that it would normally be considered a | 3275 // Move the touch-point enough so that it would normally be considered a |
3275 // scroll. But since the touch-moves will be consumed, the scroll should not | 3276 // scroll. But since the touch-moves will be consumed, the scroll should not |
3276 // start. | 3277 // start. |
3277 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3278 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
3278 EXPECT_FALSE(delegate->tap()); | 3279 EXPECT_FALSE(delegate->tap()); |
3279 EXPECT_FALSE(delegate->tap_down()); | 3280 EXPECT_FALSE(delegate->tap_down()); |
3280 EXPECT_TRUE(delegate->tap_cancel()); | 3281 EXPECT_TRUE(delegate->tap_cancel()); |
3281 EXPECT_FALSE(delegate->begin()); | 3282 EXPECT_FALSE(delegate->begin()); |
3282 EXPECT_FALSE(delegate->scroll_begin()); | 3283 EXPECT_FALSE(delegate->scroll_begin()); |
3283 EXPECT_FALSE(delegate->scroll_update()); | 3284 EXPECT_FALSE(delegate->scroll_update()); |
3284 EXPECT_FALSE(delegate->scroll_end()); | 3285 EXPECT_FALSE(delegate->scroll_end()); |
3285 | 3286 |
3286 // Now, stop consuming touch-move events, and move the touch-point again. | 3287 // Now, stop consuming touch-move events, and move the touch-point again. |
3287 delegate->set_consume_touch_move(false); | 3288 delegate->set_consume_touch_move(false); |
3288 tes.SendScrollEvent(dispatcher(), 159, 259, kTouchId, delegate.get()); | 3289 tes.SendScrollEvent(event_processor(), 159, 259, kTouchId, delegate.get()); |
3289 EXPECT_FALSE(delegate->tap()); | 3290 EXPECT_FALSE(delegate->tap()); |
3290 EXPECT_FALSE(delegate->tap_down()); | 3291 EXPECT_FALSE(delegate->tap_down()); |
3291 EXPECT_FALSE(delegate->tap_cancel()); | 3292 EXPECT_FALSE(delegate->tap_cancel()); |
3292 EXPECT_FALSE(delegate->begin()); | 3293 EXPECT_FALSE(delegate->begin()); |
3293 EXPECT_FALSE(delegate->scroll_begin()); | 3294 EXPECT_FALSE(delegate->scroll_begin()); |
3294 EXPECT_FALSE(delegate->scroll_update()); | 3295 EXPECT_FALSE(delegate->scroll_update()); |
3295 EXPECT_FALSE(delegate->scroll_end()); | 3296 EXPECT_FALSE(delegate->scroll_end()); |
3296 // No scroll has occurred, because an early touch move was consumed. | 3297 // No scroll has occurred, because an early touch move was consumed. |
3297 EXPECT_EQ(0, delegate->scroll_x()); | 3298 EXPECT_EQ(0, delegate->scroll_x()); |
3298 EXPECT_EQ(0, delegate->scroll_y()); | 3299 EXPECT_EQ(0, delegate->scroll_y()); |
3299 EXPECT_EQ(gfx::Point(0, 0).ToString(), | 3300 EXPECT_EQ(gfx::Point(0, 0).ToString(), |
3300 delegate->scroll_begin_position().ToString()); | 3301 delegate->scroll_begin_position().ToString()); |
3301 | 3302 |
3302 // Start consuming touch-move events again. | 3303 // Start consuming touch-move events again. |
3303 delegate->set_consume_touch_move(true); | 3304 delegate->set_consume_touch_move(true); |
3304 | 3305 |
3305 // Move some more to generate a few more scroll updates. | 3306 // Move some more to generate a few more scroll updates. |
3306 tes.SendScrollEvent(dispatcher(), 110, 211, kTouchId, delegate.get()); | 3307 tes.SendScrollEvent(event_processor(), 110, 211, kTouchId, delegate.get()); |
3307 EXPECT_FALSE(delegate->tap()); | 3308 EXPECT_FALSE(delegate->tap()); |
3308 EXPECT_FALSE(delegate->tap_down()); | 3309 EXPECT_FALSE(delegate->tap_down()); |
3309 EXPECT_FALSE(delegate->tap_cancel()); | 3310 EXPECT_FALSE(delegate->tap_cancel()); |
3310 EXPECT_FALSE(delegate->begin()); | 3311 EXPECT_FALSE(delegate->begin()); |
3311 EXPECT_FALSE(delegate->scroll_begin()); | 3312 EXPECT_FALSE(delegate->scroll_begin()); |
3312 EXPECT_FALSE(delegate->scroll_update()); | 3313 EXPECT_FALSE(delegate->scroll_update()); |
3313 EXPECT_FALSE(delegate->scroll_end()); | 3314 EXPECT_FALSE(delegate->scroll_end()); |
3314 EXPECT_EQ(0, delegate->scroll_x()); | 3315 EXPECT_EQ(0, delegate->scroll_x()); |
3315 EXPECT_EQ(0, delegate->scroll_y()); | 3316 EXPECT_EQ(0, delegate->scroll_y()); |
3316 | 3317 |
3317 tes.SendScrollEvent(dispatcher(), 140, 215, kTouchId, delegate.get()); | 3318 tes.SendScrollEvent(event_processor(), 140, 215, kTouchId, delegate.get()); |
3318 EXPECT_FALSE(delegate->tap()); | 3319 EXPECT_FALSE(delegate->tap()); |
3319 EXPECT_FALSE(delegate->tap_down()); | 3320 EXPECT_FALSE(delegate->tap_down()); |
3320 EXPECT_FALSE(delegate->tap_cancel()); | 3321 EXPECT_FALSE(delegate->tap_cancel()); |
3321 EXPECT_FALSE(delegate->begin()); | 3322 EXPECT_FALSE(delegate->begin()); |
3322 EXPECT_FALSE(delegate->scroll_begin()); | 3323 EXPECT_FALSE(delegate->scroll_begin()); |
3323 EXPECT_FALSE(delegate->scroll_update()); | 3324 EXPECT_FALSE(delegate->scroll_update()); |
3324 EXPECT_FALSE(delegate->scroll_end()); | 3325 EXPECT_FALSE(delegate->scroll_end()); |
3325 EXPECT_EQ(0, delegate->scroll_x()); | 3326 EXPECT_EQ(0, delegate->scroll_x()); |
3326 EXPECT_EQ(0, delegate->scroll_y()); | 3327 EXPECT_EQ(0, delegate->scroll_y()); |
3327 | 3328 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3648 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3649 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
3649 kTouchId, tes.Now()); | 3650 kTouchId, tes.Now()); |
3650 | 3651 |
3651 delegate->set_consume_touch_move(false); | 3652 delegate->set_consume_touch_move(false); |
3652 DispatchEventUsingWindowDispatcher(&press); | 3653 DispatchEventUsingWindowDispatcher(&press); |
3653 delegate->set_consume_touch_move(true); | 3654 delegate->set_consume_touch_move(true); |
3654 delegate->Reset(); | 3655 delegate->Reset(); |
3655 // Move the touch-point enough so that it would normally be considered a | 3656 // Move the touch-point enough so that it would normally be considered a |
3656 // scroll. But since the touch-moves will be consumed, the scroll should not | 3657 // scroll. But since the touch-moves will be consumed, the scroll should not |
3657 // start. | 3658 // start. |
3658 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3659 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
3659 EXPECT_FALSE(delegate->tap()); | 3660 EXPECT_FALSE(delegate->tap()); |
3660 EXPECT_FALSE(delegate->tap_down()); | 3661 EXPECT_FALSE(delegate->tap_down()); |
3661 EXPECT_TRUE(delegate->tap_cancel()); | 3662 EXPECT_TRUE(delegate->tap_cancel()); |
3662 EXPECT_FALSE(delegate->begin()); | 3663 EXPECT_FALSE(delegate->begin()); |
3663 EXPECT_FALSE(delegate->scroll_begin()); | 3664 EXPECT_FALSE(delegate->scroll_begin()); |
3664 EXPECT_FALSE(delegate->scroll_update()); | 3665 EXPECT_FALSE(delegate->scroll_update()); |
3665 EXPECT_FALSE(delegate->scroll_end()); | 3666 EXPECT_FALSE(delegate->scroll_end()); |
3666 } | 3667 } |
3667 | 3668 |
3668 TEST_F(GestureRecognizerTest, | 3669 TEST_F(GestureRecognizerTest, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3777 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3778 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
3778 kTouchId, tes.Now()); | 3779 kTouchId, tes.Now()); |
3779 DispatchEventUsingWindowDispatcher(&press1); | 3780 DispatchEventUsingWindowDispatcher(&press1); |
3780 EXPECT_TRUE(delegate->tap_down()); | 3781 EXPECT_TRUE(delegate->tap_down()); |
3781 | 3782 |
3782 // We haven't pressed long enough for a show press to occur | 3783 // We haven't pressed long enough for a show press to occur |
3783 EXPECT_FALSE(delegate->show_press()); | 3784 EXPECT_FALSE(delegate->show_press()); |
3784 EXPECT_FALSE(delegate->tap_cancel()); | 3785 EXPECT_FALSE(delegate->tap_cancel()); |
3785 | 3786 |
3786 // Scroll around, to cancel the show press | 3787 // Scroll around, to cancel the show press |
3787 tes.SendScrollEvent(dispatcher(), 130, 230, kTouchId, delegate.get()); | 3788 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
3788 // Wait until the timer runs out | 3789 // Wait until the timer runs out |
3789 gesture_sequence->ForceTimeout(); | 3790 gesture_sequence->ForceTimeout(); |
3790 EXPECT_FALSE(delegate->show_press()); | 3791 EXPECT_FALSE(delegate->show_press()); |
3791 EXPECT_TRUE(delegate->tap_cancel()); | 3792 EXPECT_TRUE(delegate->tap_cancel()); |
3792 | 3793 |
3793 delegate->Reset(); | 3794 delegate->Reset(); |
3794 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3795 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
3795 kTouchId, tes.LeapForward(10)); | 3796 kTouchId, tes.LeapForward(10)); |
3796 DispatchEventUsingWindowDispatcher(&release1); | 3797 DispatchEventUsingWindowDispatcher(&release1); |
3797 EXPECT_FALSE(delegate->show_press()); | 3798 EXPECT_FALSE(delegate->show_press()); |
(...skipping 28 matching lines...) Expand all Loading... |
3826 kTouchId, tes.LeapForward(50)); | 3827 kTouchId, tes.LeapForward(50)); |
3827 DispatchEventUsingWindowDispatcher(&release1); | 3828 DispatchEventUsingWindowDispatcher(&release1); |
3828 EXPECT_TRUE(delegate->show_press()); | 3829 EXPECT_TRUE(delegate->show_press()); |
3829 EXPECT_FALSE(delegate->tap_cancel()); | 3830 EXPECT_FALSE(delegate->tap_cancel()); |
3830 EXPECT_TRUE(delegate->tap()); | 3831 EXPECT_TRUE(delegate->tap()); |
3831 } | 3832 } |
3832 | 3833 |
3833 // Test that consuming the first move touch event prevents a scroll. | 3834 // Test that consuming the first move touch event prevents a scroll. |
3834 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { | 3835 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { |
3835 scoped_ptr<QueueTouchEventDelegate> delegate( | 3836 scoped_ptr<QueueTouchEventDelegate> delegate( |
3836 new QueueTouchEventDelegate(dispatcher())); | 3837 new QueueTouchEventDelegate(host()->dispatcher())); |
3837 TimedEvents tes; | 3838 TimedEvents tes; |
3838 const int kTouchId = 7; | 3839 const int kTouchId = 7; |
3839 gfx::Rect bounds(0, 0, 1000, 1000); | 3840 gfx::Rect bounds(0, 0, 1000, 1000); |
3840 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3841 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
3841 delegate.get(), -1234, bounds, root_window())); | 3842 delegate.get(), -1234, bounds, root_window())); |
3842 | 3843 |
3843 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3844 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
3844 kTouchId, tes.Now()); | 3845 kTouchId, tes.Now()); |
3845 DispatchEventUsingWindowDispatcher(&press); | 3846 DispatchEventUsingWindowDispatcher(&press); |
3846 delegate->ReceivedAck(); | 3847 delegate->ReceivedAck(); |
3847 | 3848 |
3848 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | 3849 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
3849 kTouchId, tes.Now()); | 3850 kTouchId, tes.Now()); |
3850 DispatchEventUsingWindowDispatcher(&move1); | 3851 DispatchEventUsingWindowDispatcher(&move1); |
3851 delegate->ReceivedAckPreventDefaulted(); | 3852 delegate->ReceivedAckPreventDefaulted(); |
3852 | 3853 |
3853 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), | 3854 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), |
3854 kTouchId, tes.Now()); | 3855 kTouchId, tes.Now()); |
3855 DispatchEventUsingWindowDispatcher(&move2); | 3856 DispatchEventUsingWindowDispatcher(&move2); |
3856 delegate->ReceivedAck(); | 3857 delegate->ReceivedAck(); |
3857 | 3858 |
3858 EXPECT_FALSE(delegate->scroll_begin()); | 3859 EXPECT_FALSE(delegate->scroll_begin()); |
3859 EXPECT_FALSE(delegate->scroll_update()); | 3860 EXPECT_FALSE(delegate->scroll_update()); |
3860 } | 3861 } |
3861 | 3862 |
3862 // Test that consuming the first touch move event of a touch point doesn't | 3863 // Test that consuming the first touch move event of a touch point doesn't |
3863 // prevent pinching once an additional touch has been pressed. | 3864 // prevent pinching once an additional touch has been pressed. |
3864 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) { | 3865 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) { |
3865 scoped_ptr<QueueTouchEventDelegate> delegate( | 3866 scoped_ptr<QueueTouchEventDelegate> delegate( |
3866 new QueueTouchEventDelegate(dispatcher())); | 3867 new QueueTouchEventDelegate(host()->dispatcher())); |
3867 TimedEvents tes; | 3868 TimedEvents tes; |
3868 const int kTouchId1 = 7; | 3869 const int kTouchId1 = 7; |
3869 const int kTouchId2 = 4; | 3870 const int kTouchId2 = 4; |
3870 gfx::Rect bounds(0, 0, 1000, 1000); | 3871 gfx::Rect bounds(0, 0, 1000, 1000); |
3871 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3872 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
3872 delegate.get(), -1234, bounds, root_window())); | 3873 delegate.get(), -1234, bounds, root_window())); |
3873 | 3874 |
3874 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3875 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
3875 kTouchId1, tes.Now()); | 3876 kTouchId1, tes.Now()); |
3876 DispatchEventUsingWindowDispatcher(&press1); | 3877 DispatchEventUsingWindowDispatcher(&press1); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3913 delegate->ReceivedAck(); | 3914 delegate->ReceivedAck(); |
3914 | 3915 |
3915 EXPECT_TRUE(delegate->pinch_update()); | 3916 EXPECT_TRUE(delegate->pinch_update()); |
3916 EXPECT_EQ(10, delegate->scroll_x()); | 3917 EXPECT_EQ(10, delegate->scroll_x()); |
3917 EXPECT_EQ(10, delegate->scroll_y()); | 3918 EXPECT_EQ(10, delegate->scroll_y()); |
3918 } | 3919 } |
3919 | 3920 |
3920 // Test that consuming the first move touch doesn't prevent a tap. | 3921 // Test that consuming the first move touch doesn't prevent a tap. |
3921 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { | 3922 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { |
3922 scoped_ptr<QueueTouchEventDelegate> delegate( | 3923 scoped_ptr<QueueTouchEventDelegate> delegate( |
3923 new QueueTouchEventDelegate(dispatcher())); | 3924 new QueueTouchEventDelegate(host()->dispatcher())); |
3924 TimedEvents tes; | 3925 TimedEvents tes; |
3925 const int kTouchId = 7; | 3926 const int kTouchId = 7; |
3926 gfx::Rect bounds(0, 0, 1000, 1000); | 3927 gfx::Rect bounds(0, 0, 1000, 1000); |
3927 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3928 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
3928 delegate.get(), -1234, bounds, root_window())); | 3929 delegate.get(), -1234, bounds, root_window())); |
3929 | 3930 |
3930 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3931 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
3931 kTouchId, tes.Now()); | 3932 kTouchId, tes.Now()); |
3932 DispatchEventUsingWindowDispatcher(&press); | 3933 DispatchEventUsingWindowDispatcher(&press); |
3933 delegate->ReceivedAck(); | 3934 delegate->ReceivedAck(); |
3934 | 3935 |
3935 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | 3936 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
3936 kTouchId, tes.Now()); | 3937 kTouchId, tes.Now()); |
3937 DispatchEventUsingWindowDispatcher(&move); | 3938 DispatchEventUsingWindowDispatcher(&move); |
3938 delegate->ReceivedAckPreventDefaulted(); | 3939 delegate->ReceivedAckPreventDefaulted(); |
3939 | 3940 |
3940 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), | 3941 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), |
3941 kTouchId, tes.LeapForward(50)); | 3942 kTouchId, tes.LeapForward(50)); |
3942 DispatchEventUsingWindowDispatcher(&release); | 3943 DispatchEventUsingWindowDispatcher(&release); |
3943 delegate->ReceivedAck(); | 3944 delegate->ReceivedAck(); |
3944 | 3945 |
3945 EXPECT_TRUE(delegate->tap()); | 3946 EXPECT_TRUE(delegate->tap()); |
3946 } | 3947 } |
3947 | 3948 |
3948 // Test that consuming the first move touch doesn't prevent a long press. | 3949 // Test that consuming the first move touch doesn't prevent a long press. |
3949 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { | 3950 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { |
3950 scoped_ptr<QueueTouchEventDelegate> delegate( | 3951 scoped_ptr<QueueTouchEventDelegate> delegate( |
3951 new QueueTouchEventDelegate(dispatcher())); | 3952 new QueueTouchEventDelegate(host()->dispatcher())); |
3952 TimedEvents tes; | 3953 TimedEvents tes; |
3953 const int kWindowWidth = 123; | 3954 const int kWindowWidth = 123; |
3954 const int kWindowHeight = 45; | 3955 const int kWindowHeight = 45; |
3955 const int kTouchId = 2; | 3956 const int kTouchId = 2; |
3956 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3957 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
3957 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3958 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
3958 delegate.get(), -1234, bounds, root_window())); | 3959 delegate.get(), -1234, bounds, root_window())); |
3959 | 3960 |
3960 delegate->Reset(); | 3961 delegate->Reset(); |
3961 | 3962 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4034 EXPECT_FALSE(delegate->scroll_begin()); | 4035 EXPECT_FALSE(delegate->scroll_begin()); |
4035 EXPECT_TRUE(delegate->scroll_update()); | 4036 EXPECT_TRUE(delegate->scroll_update()); |
4036 EXPECT_EQ(1, delegate->scroll_x()); | 4037 EXPECT_EQ(1, delegate->scroll_x()); |
4037 EXPECT_EQ(0, delegate->scroll_x_hint()); | 4038 EXPECT_EQ(0, delegate->scroll_x_hint()); |
4038 delegate->Reset(); | 4039 delegate->Reset(); |
4039 | 4040 |
4040 } | 4041 } |
4041 | 4042 |
4042 TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) { | 4043 TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) { |
4043 scoped_ptr<QueueTouchEventDelegate> delegate( | 4044 scoped_ptr<QueueTouchEventDelegate> delegate( |
4044 new QueueTouchEventDelegate(dispatcher())); | 4045 new QueueTouchEventDelegate(host()->dispatcher())); |
4045 TimedEvents tes; | 4046 TimedEvents tes; |
4046 const int kWindowWidth = 3000; | 4047 const int kWindowWidth = 3000; |
4047 const int kWindowHeight = 3000; | 4048 const int kWindowHeight = 3000; |
4048 const int kTouchId = 2; | 4049 const int kTouchId = 2; |
4049 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 4050 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
4050 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 4051 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
4051 delegate.get(), -1234, bounds, root_window())); | 4052 delegate.get(), -1234, bounds, root_window())); |
4052 | 4053 |
4053 delegate->Reset(); | 4054 delegate->Reset(); |
4054 | 4055 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4091 DispatchEventUsingWindowDispatcher(&move3); | 4092 DispatchEventUsingWindowDispatcher(&move3); |
4092 delegate->ReceivedAckPreventDefaulted(); | 4093 delegate->ReceivedAckPreventDefaulted(); |
4093 EXPECT_FALSE(delegate->scroll_begin()); | 4094 EXPECT_FALSE(delegate->scroll_begin()); |
4094 EXPECT_FALSE(delegate->scroll_update()); | 4095 EXPECT_FALSE(delegate->scroll_update()); |
4095 delegate->Reset(); | 4096 delegate->Reset(); |
4096 } | 4097 } |
4097 } | 4098 } |
4098 | 4099 |
4099 } // namespace test | 4100 } // namespace test |
4100 } // namespace aura | 4101 } // namespace aura |
OLD | NEW |