Chromium Code Reviews| 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 <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 base::TimeDelta LeapForward(int time_in_millis) { | 495 base::TimeDelta LeapForward(int time_in_millis) { |
| 496 simulated_now_ += time_in_millis; | 496 simulated_now_ += time_in_millis; |
| 497 return base::TimeDelta::FromMilliseconds(simulated_now_); | 497 return base::TimeDelta::FromMilliseconds(simulated_now_); |
| 498 } | 498 } |
| 499 | 499 |
| 500 base::TimeDelta InFuture(int time_in_millis) { | 500 base::TimeDelta InFuture(int time_in_millis) { |
| 501 return base::TimeDelta::FromMilliseconds(simulated_now_ + time_in_millis); | 501 return base::TimeDelta::FromMilliseconds(simulated_now_ + time_in_millis); |
| 502 } | 502 } |
| 503 | 503 |
| 504 void SendScrollEvents(ui::EventProcessor* dispatcher, | 504 void SendScrollEvents(ui::EventProcessor* dispatcher, |
| 505 float x_start, | 505 float x_start, |
|
sky
2015/10/30 22:20:44
AFAICT x_start and y_start is always supplied inte
danakj
2015/10/30 22:39:45
Done.
| |
| 506 float y_start, | 506 float y_start, |
| 507 int dx, | 507 int dx, |
| 508 int dy, | 508 int dy, |
| 509 int touch_id, | 509 int touch_id, |
| 510 int time_step, | 510 int time_step, |
| 511 int num_steps, | 511 int num_steps, |
| 512 GestureEventConsumeDelegate* delegate) { | 512 GestureEventConsumeDelegate* delegate) { |
| 513 float x = x_start; | 513 float x = x_start; |
| 514 float y = y_start; | 514 float y = y_start; |
| 515 | 515 |
| 516 for (int i = 0; i < num_steps; i++) { | 516 for (int i = 0; i < num_steps; i++) { |
| 517 x += dx; | 517 x += dx; |
| 518 y += dy; | 518 y += dy; |
| 519 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), | 519 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), touch_id, |
| 520 touch_id, | |
| 521 base::TimeDelta::FromMilliseconds(simulated_now_)); | 520 base::TimeDelta::FromMilliseconds(simulated_now_)); |
| 521 move.set_location_f(gfx::PointF(x, y)); | |
| 522 move.set_root_location_f(gfx::PointF(x, y)); | |
| 522 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 523 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
| 523 ASSERT_FALSE(details.dispatcher_destroyed); | 524 ASSERT_FALSE(details.dispatcher_destroyed); |
| 524 simulated_now_ += time_step; | 525 simulated_now_ += time_step; |
| 525 } | 526 } |
| 526 } | 527 } |
| 527 | 528 |
| 528 void SendScrollEvent(ui::EventProcessor* dispatcher, | 529 void SendScrollEvent(ui::EventProcessor* dispatcher, |
| 529 float x, | 530 float x, |
| 530 float y, | 531 float y, |
| 531 int touch_id, | 532 int touch_id, |
| 532 GestureEventConsumeDelegate* delegate) { | 533 GestureEventConsumeDelegate* delegate) { |
| 533 delegate->Reset(); | 534 delegate->Reset(); |
| 534 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(x, y), | 535 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), touch_id, |
| 535 touch_id, | |
| 536 base::TimeDelta::FromMilliseconds(simulated_now_)); | 536 base::TimeDelta::FromMilliseconds(simulated_now_)); |
| 537 move.set_location_f(gfx::PointF(x, y)); | |
| 538 move.set_root_location_f(gfx::PointF(x, y)); | |
| 537 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 539 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
| 538 ASSERT_FALSE(details.dispatcher_destroyed); | 540 ASSERT_FALSE(details.dispatcher_destroyed); |
| 539 simulated_now_++; | 541 simulated_now_++; |
| 540 } | 542 } |
| 541 }; | 543 }; |
| 542 | 544 |
| 543 // An event handler to keep track of events. | 545 // An event handler to keep track of events. |
| 544 class TestEventHandler : public ui::EventHandler { | 546 class TestEventHandler : public ui::EventHandler { |
| 545 public: | 547 public: |
| 546 TestEventHandler() | 548 TestEventHandler() |
| 547 : touch_released_count_(0), | 549 : touch_released_count_(0), |
| 548 touch_pressed_count_(0), | 550 touch_pressed_count_(0), |
| 549 touch_moved_count_(0) {} | 551 touch_moved_count_(0) {} |
| 550 | 552 |
| 551 ~TestEventHandler() override {} | 553 ~TestEventHandler() override {} |
| 552 | 554 |
| 553 void OnTouchEvent(ui::TouchEvent* event) override { | 555 void OnTouchEvent(ui::TouchEvent* event) override { |
| 554 switch (event->type()) { | 556 switch (event->type()) { |
| 555 case ui::ET_TOUCH_RELEASED: | 557 case ui::ET_TOUCH_RELEASED: |
| 556 touch_released_count_++; | 558 touch_released_count_++; |
| 557 break; | 559 break; |
| 558 case ui::ET_TOUCH_PRESSED: | 560 case ui::ET_TOUCH_PRESSED: |
| 559 touch_pressed_count_++; | 561 touch_pressed_count_++; |
| 560 break; | 562 break; |
| 561 case ui::ET_TOUCH_MOVED: | 563 case ui::ET_TOUCH_MOVED: |
| 562 touch_moved_count_++; | 564 touch_moved_count_++; |
| 563 break; | 565 break; |
| 564 case ui::ET_TOUCH_CANCELLED: | 566 case ui::ET_TOUCH_CANCELLED: |
| 565 cancelled_touch_points_.push_back(event->location()); | 567 cancelled_touch_points_.push_back(event->location_f()); |
| 566 break; | 568 break; |
| 567 default: | 569 default: |
| 568 break; | 570 break; |
| 569 } | 571 } |
| 570 } | 572 } |
| 571 | 573 |
| 572 void Reset() { | 574 void Reset() { |
| 573 touch_released_count_ = 0; | 575 touch_released_count_ = 0; |
| 574 touch_pressed_count_ = 0; | 576 touch_pressed_count_ = 0; |
| 575 touch_moved_count_ = 0; | 577 touch_moved_count_ = 0; |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 ui::GestureConfiguration::GetInstance()->set_default_radius(radius); | 1111 ui::GestureConfiguration::GetInstance()->set_default_radius(radius); |
| 1110 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1112 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1111 new GestureEventConsumeDelegate()); | 1113 new GestureEventConsumeDelegate()); |
| 1112 const int kWindowWidth = 123; | 1114 const int kWindowWidth = 123; |
| 1113 const int kWindowHeight = 45; | 1115 const int kWindowHeight = 45; |
| 1114 const int kTouchId = 5; | 1116 const int kTouchId = 5; |
| 1115 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1117 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1116 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1118 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1117 delegate.get(), -1234, bounds, root_window())); | 1119 delegate.get(), -1234, bounds, root_window())); |
| 1118 | 1120 |
| 1119 const float kPositionX = 101; | 1121 const int kPositionX = 101; |
| 1120 const float kPositionY = 201; | 1122 const int kPositionY = 201; |
| 1121 delegate->Reset(); | 1123 delegate->Reset(); |
| 1122 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 1124 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
| 1123 gfx::PointF(kPositionX, kPositionY), | 1125 gfx::Point(kPositionX, kPositionY), kTouchId, |
| 1124 kTouchId, | |
| 1125 tes.Now()); | 1126 tes.Now()); |
| 1126 DispatchEventUsingWindowDispatcher(&press); | 1127 DispatchEventUsingWindowDispatcher(&press); |
| 1127 EXPECT_EQ(gfx::Rect(kPositionX - radius, kPositionY - radius, radius * 2, | 1128 EXPECT_EQ(gfx::Rect(kPositionX - radius, kPositionY - radius, radius * 2, |
| 1128 radius * 2), | 1129 radius * 2), |
| 1129 delegate->bounding_box()); | 1130 delegate->bounding_box()); |
| 1130 | 1131 |
| 1131 const int kScrollAmount = 50; | 1132 const int kScrollAmount = 50; |
| 1132 tes.SendScrollEvents(event_processor(), kPositionX, kPositionY, | 1133 tes.SendScrollEvents(event_processor(), kPositionX, kPositionY, |
| 1133 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); | 1134 1, 1, kTouchId, 1, kScrollAmount, delegate.get()); |
| 1134 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 1135 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 1135 delegate->scroll_begin_position().ToString()); | 1136 delegate->scroll_begin_position().ToString()); |
| 1136 EXPECT_EQ( | 1137 EXPECT_EQ( |
| 1137 gfx::Rect(kPositionX + kScrollAmount - radius, | 1138 gfx::Rect(kPositionX + kScrollAmount - radius, |
| 1138 kPositionY + kScrollAmount - radius, radius * 2, radius * 2), | 1139 kPositionY + kScrollAmount - radius, radius * 2, radius * 2), |
| 1139 delegate->bounding_box()); | 1140 delegate->bounding_box()); |
| 1140 | 1141 |
| 1141 // Release the touch. This should end the scroll. | 1142 // Release the touch. This should end the scroll. |
| 1142 delegate->Reset(); | 1143 delegate->Reset(); |
| 1143 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, | 1144 ui::TouchEvent release( |
| 1144 gfx::PointF(kPositionX + kScrollAmount, | 1145 ui::ET_TOUCH_RELEASED, |
| 1145 kPositionY + kScrollAmount), | 1146 gfx::Point(kPositionX + kScrollAmount, kPositionY + kScrollAmount), |
| 1146 kTouchId, press.time_stamp() + | 1147 kTouchId, press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); |
| 1147 base::TimeDelta::FromMilliseconds(50)); | |
| 1148 DispatchEventUsingWindowDispatcher(&release); | 1148 DispatchEventUsingWindowDispatcher(&release); |
| 1149 EXPECT_EQ( | 1149 EXPECT_EQ( |
| 1150 gfx::Rect(kPositionX + kScrollAmount - radius, | 1150 gfx::Rect(kPositionX + kScrollAmount - radius, |
| 1151 kPositionY + kScrollAmount - radius, radius * 2, radius * 2), | 1151 kPositionY + kScrollAmount - radius, radius * 2, radius * 2), |
| 1152 delegate->bounding_box()); | 1152 delegate->bounding_box()); |
| 1153 } | 1153 } |
| 1154 ui::GestureConfiguration::GetInstance()->set_default_radius(0); | 1154 ui::GestureConfiguration::GetInstance()->set_default_radius(0); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 // Check Scroll End Events report correct velocities | 1157 // Check Scroll End Events report correct velocities |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1846 EXPECT_FALSE(queued_delegate->begin()); | 1846 EXPECT_FALSE(queued_delegate->begin()); |
| 1847 EXPECT_FALSE(queued_delegate->end()); | 1847 EXPECT_FALSE(queued_delegate->end()); |
| 1848 EXPECT_FALSE(queued_delegate->scroll_begin()); | 1848 EXPECT_FALSE(queued_delegate->scroll_begin()); |
| 1849 EXPECT_FALSE(queued_delegate->scroll_update()); | 1849 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1850 EXPECT_FALSE(queued_delegate->scroll_end()); | 1850 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1851 | 1851 |
| 1852 // Move the second touch-point enough so that it is considered a pinch. This | 1852 // Move the second touch-point enough so that it is considered a pinch. This |
| 1853 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. | 1853 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. |
| 1854 queued_delegate->Reset(); | 1854 queued_delegate->Reset(); |
| 1855 delegate->Reset(); | 1855 delegate->Reset(); |
| 1856 ui::TouchEvent move( | 1856 ui::TouchEvent move(ui::ET_TOUCH_MOVED, |
| 1857 ui::ET_TOUCH_MOVED, | 1857 gfx::Point(203 + |
| 1858 gfx::PointF(203 + | 1858 ui::GestureConfiguration::GetInstance() |
| 1859 ui::GestureConfiguration::GetInstance() | 1859 ->max_touch_move_in_pixels_for_click(), |
| 1860 ->max_touch_move_in_pixels_for_click(), | 1860 303), |
| 1861 303), | 1861 kTouchId2, tes.Now()); |
| 1862 kTouchId2, | |
| 1863 tes.Now()); | |
| 1864 DispatchEventUsingWindowDispatcher(&move); | 1862 DispatchEventUsingWindowDispatcher(&move); |
| 1865 EXPECT_FALSE(delegate->tap()); | 1863 EXPECT_FALSE(delegate->tap()); |
| 1866 EXPECT_FALSE(delegate->tap_down()); | 1864 EXPECT_FALSE(delegate->tap_down()); |
| 1867 EXPECT_FALSE(delegate->tap_cancel()); | 1865 EXPECT_FALSE(delegate->tap_cancel()); |
| 1868 EXPECT_FALSE(delegate->begin()); | 1866 EXPECT_FALSE(delegate->begin()); |
| 1869 EXPECT_FALSE(delegate->scroll_begin()); | 1867 EXPECT_FALSE(delegate->scroll_begin()); |
| 1870 EXPECT_FALSE(delegate->scroll_update()); | 1868 EXPECT_FALSE(delegate->scroll_update()); |
| 1871 EXPECT_FALSE(delegate->scroll_end()); | 1869 EXPECT_FALSE(delegate->scroll_end()); |
| 1872 EXPECT_FALSE(queued_delegate->tap()); | 1870 EXPECT_FALSE(queued_delegate->tap()); |
| 1873 EXPECT_FALSE(queued_delegate->tap_down()); | 1871 EXPECT_FALSE(queued_delegate->tap_down()); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2177 windows[i] = CreateTestWindowWithDelegate( | 2175 windows[i] = CreateTestWindowWithDelegate( |
| 2178 delegates[i], i, window_bounds[i], root_window()); | 2176 delegates[i], i, window_bounds[i], root_window()); |
| 2179 windows[i]->set_id(i); | 2177 windows[i]->set_id(i); |
| 2180 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), | 2178 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), |
| 2181 i, tes.Now()); | 2179 i, tes.Now()); |
| 2182 DispatchEventUsingWindowDispatcher(&press); | 2180 DispatchEventUsingWindowDispatcher(&press); |
| 2183 } | 2181 } |
| 2184 | 2182 |
| 2185 // Touches should now be associated with the closest touch within | 2183 // Touches should now be associated with the closest touch within |
| 2186 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels | 2184 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels |
| 2187 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11), -1); | 2185 target = |
| 2186 gesture_recognizer->GetTargetForLocation(gfx::PointF(11.f, 11.f), -1); | |
| 2188 EXPECT_EQ("0", WindowIDAsString(target)); | 2187 EXPECT_EQ("0", WindowIDAsString(target)); |
| 2189 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11), -1); | 2188 target = |
| 2189 gesture_recognizer->GetTargetForLocation(gfx::PointF(511.f, 11.f), -1); | |
| 2190 EXPECT_EQ("1", WindowIDAsString(target)); | 2190 EXPECT_EQ("1", WindowIDAsString(target)); |
| 2191 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 511), -1); | 2191 target = |
| 2192 gesture_recognizer->GetTargetForLocation(gfx::PointF(11.f, 511.f), -1); | |
| 2192 EXPECT_EQ("2", WindowIDAsString(target)); | 2193 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2193 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 511), -1); | 2194 target = |
| 2195 gesture_recognizer->GetTargetForLocation(gfx::PointF(511.f, 511.f), -1); | |
| 2194 EXPECT_EQ("3", WindowIDAsString(target)); | 2196 EXPECT_EQ("3", WindowIDAsString(target)); |
| 2195 | 2197 |
| 2196 // Add a touch in the middle associated with windows[2] | 2198 // Add a touch in the middle associated with windows[2] |
| 2197 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500), | 2199 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 500), |
| 2198 kNumWindows, tes.Now()); | 2200 kNumWindows, tes.Now()); |
| 2199 DispatchEventUsingWindowDispatcher(&press); | 2201 DispatchEventUsingWindowDispatcher(&press); |
| 2200 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(250, 250), | 2202 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(250, 250), |
| 2201 kNumWindows, tes.Now()); | 2203 kNumWindows, tes.Now()); |
| 2202 DispatchEventUsingWindowDispatcher(&move); | 2204 DispatchEventUsingWindowDispatcher(&move); |
| 2203 | 2205 |
| 2204 target = gesture_recognizer->GetTargetForLocation(gfx::Point(250, 250), -1); | 2206 target = |
| 2207 gesture_recognizer->GetTargetForLocation(gfx::PointF(250.f, 250.f), -1); | |
| 2205 EXPECT_EQ("2", WindowIDAsString(target)); | 2208 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2206 | 2209 |
| 2207 // Make sure that ties are broken by distance to a current touch | 2210 // Make sure that ties are broken by distance to a current touch |
| 2208 // Closer to the point in the bottom right. | 2211 // Closer to the point in the bottom right. |
| 2209 target = gesture_recognizer->GetTargetForLocation(gfx::Point(380, 380), -1); | 2212 target = |
| 2213 gesture_recognizer->GetTargetForLocation(gfx::PointF(380.f, 380.f), -1); | |
| 2210 EXPECT_EQ("3", WindowIDAsString(target)); | 2214 EXPECT_EQ("3", WindowIDAsString(target)); |
| 2211 | 2215 |
| 2212 // This touch is closer to the point in the middle | 2216 // This touch is closer to the point in the middle |
| 2213 target = gesture_recognizer->GetTargetForLocation(gfx::Point(300, 300), -1); | 2217 target = |
| 2218 gesture_recognizer->GetTargetForLocation(gfx::PointF(300.f, 300.f), -1); | |
| 2214 EXPECT_EQ("2", WindowIDAsString(target)); | 2219 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2215 | 2220 |
| 2216 // A touch too far from other touches won't be locked to anything | 2221 // A touch too far from other touches won't be locked to anything |
| 2217 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); | 2222 target = |
| 2223 gesture_recognizer->GetTargetForLocation(gfx::PointF(1000.f, 1000.f), -1); | |
| 2218 EXPECT_TRUE(target == NULL); | 2224 EXPECT_TRUE(target == NULL); |
| 2219 | 2225 |
| 2220 // Move a touch associated with windows[2] to 1000, 1000 | 2226 // Move a touch associated with windows[2] to 1000, 1000 |
| 2221 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), | 2227 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), |
| 2222 kNumWindows, tes.Now()); | 2228 kNumWindows, tes.Now()); |
| 2223 DispatchEventUsingWindowDispatcher(&move2); | 2229 DispatchEventUsingWindowDispatcher(&move2); |
| 2224 | 2230 |
| 2225 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000), -1); | 2231 target = |
| 2232 gesture_recognizer->GetTargetForLocation(gfx::PointF(1000.f, 1000.f), -1); | |
| 2226 EXPECT_EQ("2", WindowIDAsString(target)); | 2233 EXPECT_EQ("2", WindowIDAsString(target)); |
| 2227 | 2234 |
| 2228 for (int i = 0; i < kNumWindows; ++i) { | 2235 for (int i = 0; i < kNumWindows; ++i) { |
| 2229 // Delete windows before deleting delegates. | 2236 // Delete windows before deleting delegates. |
| 2230 delete windows[i]; | 2237 delete windows[i]; |
| 2231 delete delegates[i]; | 2238 delete delegates[i]; |
| 2232 } | 2239 } |
| 2233 } | 2240 } |
| 2234 | 2241 |
| 2235 // Check that a touch's target will not be effected by a touch on a different | 2242 // Check that a touch's target will not be effected by a touch on a different |
| (...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3623 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr); | 3630 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr); |
| 3624 | 3631 |
| 3625 EXPECT_EQ(NULL, gesture_recognizer->GetTouchLockedTarget(press)); | 3632 EXPECT_EQ(NULL, gesture_recognizer->GetTouchLockedTarget(press)); |
| 3626 EXPECT_4_EVENTS(delegate->events(), | 3633 EXPECT_4_EVENTS(delegate->events(), |
| 3627 ui::ET_GESTURE_PINCH_END, | 3634 ui::ET_GESTURE_PINCH_END, |
| 3628 ui::ET_GESTURE_SCROLL_END, | 3635 ui::ET_GESTURE_SCROLL_END, |
| 3629 ui::ET_GESTURE_END, | 3636 ui::ET_GESTURE_END, |
| 3630 ui::ET_GESTURE_END); | 3637 ui::ET_GESTURE_END); |
| 3631 const std::vector<gfx::PointF>& points = handler->cancelled_touch_points(); | 3638 const std::vector<gfx::PointF>& points = handler->cancelled_touch_points(); |
| 3632 EXPECT_EQ(2U, points.size()); | 3639 EXPECT_EQ(2U, points.size()); |
| 3633 EXPECT_EQ(gfx::Point(101, 201), points[0]); | 3640 EXPECT_EQ(gfx::PointF(101.f, 201.f), points[0]); |
| 3634 EXPECT_EQ(gfx::Point(350, 300), points[1]); | 3641 EXPECT_EQ(gfx::PointF(350.f, 300.f), points[1]); |
| 3635 } | 3642 } |
| 3636 | 3643 |
| 3637 // Check that appropriate touch events generate show press events | 3644 // Check that appropriate touch events generate show press events |
| 3638 TEST_F(GestureRecognizerTest, GestureEventShowPress) { | 3645 TEST_F(GestureRecognizerTest, GestureEventShowPress) { |
| 3639 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3646 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3640 new GestureEventConsumeDelegate()); | 3647 new GestureEventConsumeDelegate()); |
| 3641 TimedEvents tes; | 3648 TimedEvents tes; |
| 3642 const int kWindowWidth = 123; | 3649 const int kWindowWidth = 123; |
| 3643 const int kWindowHeight = 45; | 3650 const int kWindowHeight = 45; |
| 3644 const int kTouchId = 2; | 3651 const int kTouchId = 2; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3870 | 3877 |
| 3871 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(12, 10), kTouchId, | 3878 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(12, 10), kTouchId, |
| 3872 tes.LeapForward(40)); | 3879 tes.LeapForward(40)); |
| 3873 DispatchEventUsingWindowDispatcher(&move2); | 3880 DispatchEventUsingWindowDispatcher(&move2); |
| 3874 EXPECT_FALSE(delegate->scroll_begin()); | 3881 EXPECT_FALSE(delegate->scroll_begin()); |
| 3875 EXPECT_FALSE(delegate->scroll_update()); | 3882 EXPECT_FALSE(delegate->scroll_update()); |
| 3876 EXPECT_EQ(0, delegate->scroll_x()); | 3883 EXPECT_EQ(0, delegate->scroll_x()); |
| 3877 EXPECT_EQ(0, delegate->scroll_x_hint()); | 3884 EXPECT_EQ(0, delegate->scroll_x_hint()); |
| 3878 delegate->Reset(); | 3885 delegate->Reset(); |
| 3879 | 3886 |
| 3880 | 3887 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(), kTouchId, |
| 3881 ui::TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::PointF(13.1f, 10.f), kTouchId, | |
| 3882 tes.LeapForward(40)); | 3888 tes.LeapForward(40)); |
| 3889 move3.set_location_f(gfx::PointF(13.1f, 10.f)); | |
| 3890 move3.set_root_location_f(gfx::PointF(13.1f, 10.f)); | |
| 3883 DispatchEventUsingWindowDispatcher(&move3); | 3891 DispatchEventUsingWindowDispatcher(&move3); |
| 3884 EXPECT_TRUE(delegate->scroll_begin()); | 3892 EXPECT_TRUE(delegate->scroll_begin()); |
| 3885 EXPECT_TRUE(delegate->scroll_update()); | 3893 EXPECT_TRUE(delegate->scroll_update()); |
| 3886 EXPECT_NEAR(0.1, delegate->scroll_x(), 0.0001); | 3894 EXPECT_NEAR(0.1, delegate->scroll_x(), 0.0001); |
| 3887 EXPECT_FLOAT_EQ(3.1f, delegate->scroll_x_hint()); | 3895 EXPECT_FLOAT_EQ(3.1f, delegate->scroll_x_hint()); |
| 3888 delegate->Reset(); | 3896 delegate->Reset(); |
| 3889 | 3897 |
| 3890 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(14, 10), kTouchId, | 3898 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(14, 10), kTouchId, |
| 3891 tes.LeapForward(40)); | 3899 tes.LeapForward(40)); |
| 3892 DispatchEventUsingWindowDispatcher(&move4); | 3900 DispatchEventUsingWindowDispatcher(&move4); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4355 // The synchronous ack is stuck behind the pending touch move. | 4363 // The synchronous ack is stuck behind the pending touch move. |
| 4356 EXPECT_0_EVENTS(delegate->events()); | 4364 EXPECT_0_EVENTS(delegate->events()); |
| 4357 | 4365 |
| 4358 delegate->ReceivedAck(); | 4366 delegate->ReceivedAck(); |
| 4359 EXPECT_2_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE, | 4367 EXPECT_2_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE, |
| 4360 ui::ET_GESTURE_SCROLL_UPDATE); | 4368 ui::ET_GESTURE_SCROLL_UPDATE); |
| 4361 } | 4369 } |
| 4362 | 4370 |
| 4363 } // namespace test | 4371 } // namespace test |
| 4364 } // namespace aura | 4372 } // namespace aura |
| OLD | NEW |