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 "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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 velocity_y_(0), | 95 velocity_y_(0), |
| 96 scroll_x_ordinal_(0), | 96 scroll_x_ordinal_(0), |
| 97 scroll_y_ordinal_(0), | 97 scroll_y_ordinal_(0), |
| 98 scroll_velocity_x_ordinal_(0), | 98 scroll_velocity_x_ordinal_(0), |
| 99 scroll_velocity_y_ordinal_(0), | 99 scroll_velocity_y_ordinal_(0), |
| 100 velocity_x_ordinal_(0), | 100 velocity_x_ordinal_(0), |
| 101 velocity_y_ordinal_(0), | 101 velocity_y_ordinal_(0), |
| 102 scroll_x_hint_(0), | 102 scroll_x_hint_(0), |
| 103 scroll_y_hint_(0), | 103 scroll_y_hint_(0), |
| 104 tap_count_(0), | 104 tap_count_(0), |
| 105 wait_until_event_(ui::ET_UNKNOWN) { | 105 wait_until_event_(ui::ET_UNKNOWN), |
| 106 } | 106 flags_(0) {} |
| 107 | 107 |
| 108 virtual ~GestureEventConsumeDelegate() {} | 108 virtual ~GestureEventConsumeDelegate() {} |
| 109 | 109 |
| 110 void Reset() { | 110 void Reset() { |
| 111 events_.clear(); | 111 events_.clear(); |
| 112 tap_ = false; | 112 tap_ = false; |
| 113 tap_down_ = false; | 113 tap_down_ = false; |
| 114 tap_cancel_ = false; | 114 tap_cancel_ = false; |
| 115 begin_ = false; | 115 begin_ = false; |
| 116 end_ = false; | 116 end_ = false; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 142 scroll_x_ordinal_ = 0; | 142 scroll_x_ordinal_ = 0; |
| 143 scroll_y_ordinal_ = 0; | 143 scroll_y_ordinal_ = 0; |
| 144 scroll_velocity_x_ordinal_ = 0; | 144 scroll_velocity_x_ordinal_ = 0; |
| 145 scroll_velocity_y_ordinal_ = 0; | 145 scroll_velocity_y_ordinal_ = 0; |
| 146 velocity_x_ordinal_ = 0; | 146 velocity_x_ordinal_ = 0; |
| 147 velocity_y_ordinal_ = 0; | 147 velocity_y_ordinal_ = 0; |
| 148 scroll_x_hint_ = 0; | 148 scroll_x_hint_ = 0; |
| 149 scroll_y_hint_ = 0; | 149 scroll_y_hint_ = 0; |
| 150 tap_count_ = 0; | 150 tap_count_ = 0; |
| 151 scale_ = 0; | 151 scale_ = 0; |
| 152 flags_ = 0; | |
| 152 } | 153 } |
| 153 | 154 |
| 154 const std::vector<ui::EventType>& events() const { return events_; }; | 155 const std::vector<ui::EventType>& events() const { return events_; }; |
| 155 | 156 |
| 156 bool tap() const { return tap_; } | 157 bool tap() const { return tap_; } |
| 157 bool tap_down() const { return tap_down_; } | 158 bool tap_down() const { return tap_down_; } |
| 158 bool tap_cancel() const { return tap_cancel_; } | 159 bool tap_cancel() const { return tap_cancel_; } |
| 159 bool begin() const { return begin_; } | 160 bool begin() const { return begin_; } |
| 160 bool end() const { return end_; } | 161 bool end() const { return end_; } |
| 161 bool scroll_begin() const { return scroll_begin_; } | 162 bool scroll_begin() const { return scroll_begin_; } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 float scroll_y_ordinal() const { return scroll_y_ordinal_; } | 197 float scroll_y_ordinal() const { return scroll_y_ordinal_; } |
| 197 float scroll_velocity_x_ordinal() const { return scroll_velocity_x_ordinal_; } | 198 float scroll_velocity_x_ordinal() const { return scroll_velocity_x_ordinal_; } |
| 198 float scroll_velocity_y_ordinal() const { return scroll_velocity_y_ordinal_; } | 199 float scroll_velocity_y_ordinal() const { return scroll_velocity_y_ordinal_; } |
| 199 float velocity_x_ordinal() const { return velocity_x_ordinal_; } | 200 float velocity_x_ordinal() const { return velocity_x_ordinal_; } |
| 200 float velocity_y_ordinal() const { return velocity_y_ordinal_; } | 201 float velocity_y_ordinal() const { return velocity_y_ordinal_; } |
| 201 float scroll_x_hint() const { return scroll_x_hint_; } | 202 float scroll_x_hint() const { return scroll_x_hint_; } |
| 202 float scroll_y_hint() const { return scroll_y_hint_; } | 203 float scroll_y_hint() const { return scroll_y_hint_; } |
| 203 float scale() const { return scale_; } | 204 float scale() const { return scale_; } |
| 204 const gfx::Rect& bounding_box() const { return bounding_box_; } | 205 const gfx::Rect& bounding_box() const { return bounding_box_; } |
| 205 int tap_count() const { return tap_count_; } | 206 int tap_count() const { return tap_count_; } |
| 207 int flags() const { return flags_; } | |
| 206 | 208 |
| 207 void WaitUntilReceivedGesture(ui::EventType type) { | 209 void WaitUntilReceivedGesture(ui::EventType type) { |
| 208 wait_until_event_ = type; | 210 wait_until_event_ = type; |
| 209 run_loop_.reset(new base::RunLoop()); | 211 run_loop_.reset(new base::RunLoop()); |
| 210 run_loop_->Run(); | 212 run_loop_->Run(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE { | 215 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE { |
| 214 events_.push_back(gesture->type()); | 216 events_.push_back(gesture->type()); |
| 215 bounding_box_ = gesture->details().bounding_box(); | 217 bounding_box_ = gesture->details().bounding_box(); |
| 218 flags_ = gesture->flags(); | |
| 216 switch (gesture->type()) { | 219 switch (gesture->type()) { |
| 217 case ui::ET_GESTURE_TAP: | 220 case ui::ET_GESTURE_TAP: |
| 218 tap_location_ = gesture->location(); | 221 tap_location_ = gesture->location(); |
| 219 tap_count_ = gesture->details().tap_count(); | 222 tap_count_ = gesture->details().tap_count(); |
| 220 tap_ = true; | 223 tap_ = true; |
| 221 break; | 224 break; |
| 222 case ui::ET_GESTURE_TAP_DOWN: | 225 case ui::ET_GESTURE_TAP_DOWN: |
| 223 tap_down_ = true; | 226 tap_down_ = true; |
| 224 break; | 227 break; |
| 225 case ui::ET_GESTURE_TAP_CANCEL: | 228 case ui::ET_GESTURE_TAP_CANCEL: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 break; | 283 break; |
| 281 case ui::ET_GESTURE_SHOW_PRESS: | 284 case ui::ET_GESTURE_SHOW_PRESS: |
| 282 show_press_ = true; | 285 show_press_ = true; |
| 283 break; | 286 break; |
| 284 case ui::ET_GESTURE_MULTIFINGER_SWIPE: | 287 case ui::ET_GESTURE_MULTIFINGER_SWIPE: |
| 285 swipe_left_ = gesture->details().swipe_left(); | 288 swipe_left_ = gesture->details().swipe_left(); |
| 286 swipe_right_ = gesture->details().swipe_right(); | 289 swipe_right_ = gesture->details().swipe_right(); |
| 287 swipe_up_ = gesture->details().swipe_up(); | 290 swipe_up_ = gesture->details().swipe_up(); |
| 288 swipe_down_ = gesture->details().swipe_down(); | 291 swipe_down_ = gesture->details().swipe_down(); |
| 289 break; | 292 break; |
| 293 case ui::ET_SCROLL_FLING_CANCEL: | |
| 294 // Only used in unified gesture detection. | |
| 295 break; | |
| 290 default: | 296 default: |
| 291 NOTREACHED(); | 297 NOTREACHED(); |
| 292 } | 298 } |
| 293 if (wait_until_event_ == gesture->type() && run_loop_) { | 299 if (wait_until_event_ == gesture->type() && run_loop_) { |
| 294 run_loop_->Quit(); | 300 run_loop_->Quit(); |
| 295 wait_until_event_ = ui::ET_UNKNOWN; | 301 wait_until_event_ = ui::ET_UNKNOWN; |
| 296 } | 302 } |
| 297 gesture->StopPropagation(); | 303 gesture->StopPropagation(); |
| 298 } | 304 } |
| 299 | 305 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 float scroll_y_ordinal_; | 342 float scroll_y_ordinal_; |
| 337 float scroll_velocity_x_ordinal_; | 343 float scroll_velocity_x_ordinal_; |
| 338 float scroll_velocity_y_ordinal_; | 344 float scroll_velocity_y_ordinal_; |
| 339 float velocity_x_ordinal_; | 345 float velocity_x_ordinal_; |
| 340 float velocity_y_ordinal_; | 346 float velocity_y_ordinal_; |
| 341 float scroll_x_hint_; | 347 float scroll_x_hint_; |
| 342 float scroll_y_hint_; | 348 float scroll_y_hint_; |
| 343 float scale_; | 349 float scale_; |
| 344 gfx::Rect bounding_box_; | 350 gfx::Rect bounding_box_; |
| 345 int tap_count_; | 351 int tap_count_; |
| 352 int flags_; | |
| 346 | 353 |
| 347 ui::EventType wait_until_event_; | 354 ui::EventType wait_until_event_; |
| 348 | 355 |
| 349 DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate); | 356 DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate); |
| 350 }; | 357 }; |
| 351 | 358 |
| 352 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { | 359 class QueueTouchEventDelegate : public GestureEventConsumeDelegate { |
| 353 public: | 360 public: |
| 354 explicit QueueTouchEventDelegate(WindowEventDispatcher* dispatcher) | 361 explicit QueueTouchEventDelegate(WindowEventDispatcher* dispatcher) |
| 355 : window_(NULL), | 362 : window_(NULL), |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 scoped_ptr<ui::GestureRecognizer> new_gr_; | 556 scoped_ptr<ui::GestureRecognizer> new_gr_; |
| 550 | 557 |
| 551 DISALLOW_COPY_AND_ASSIGN(ScopedGestureRecognizerSetter); | 558 DISALLOW_COPY_AND_ASSIGN(ScopedGestureRecognizerSetter); |
| 552 }; | 559 }; |
| 553 | 560 |
| 554 class TimedEvents { | 561 class TimedEvents { |
| 555 private: | 562 private: |
| 556 int simulated_now_; | 563 int simulated_now_; |
| 557 | 564 |
| 558 public: | 565 public: |
| 559 TimedEvents() : simulated_now_(0) { | 566 // Use a non-zero start time to pass DCHECKs which ensure events have had a |
| 567 // time assigned. | |
| 568 TimedEvents() : simulated_now_(1) { | |
| 560 } | 569 } |
| 561 | 570 |
| 562 base::TimeDelta Now() { | 571 base::TimeDelta Now() { |
| 563 base::TimeDelta t = base::TimeDelta::FromMilliseconds(simulated_now_); | 572 base::TimeDelta t = base::TimeDelta::FromMilliseconds(simulated_now_); |
| 564 simulated_now_++; | 573 simulated_now_++; |
| 565 return t; | 574 return t; |
| 566 } | 575 } |
| 567 | 576 |
| 568 base::TimeDelta LeapForward(int time_in_millis) { | 577 base::TimeDelta LeapForward(int time_in_millis) { |
| 569 simulated_now_ += time_in_millis; | 578 simulated_now_ += time_in_millis; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 target->RemovePreTargetHandler(this); | 696 target->RemovePreTargetHandler(this); |
| 688 target->parent()->RemoveChild(target); | 697 target->parent()->RemoveChild(target); |
| 689 } | 698 } |
| 690 } | 699 } |
| 691 | 700 |
| 692 DISALLOW_COPY_AND_ASSIGN(RemoveOnTouchCancelHandler); | 701 DISALLOW_COPY_AND_ASSIGN(RemoveOnTouchCancelHandler); |
| 693 }; | 702 }; |
| 694 | 703 |
| 695 } // namespace | 704 } // namespace |
| 696 | 705 |
| 697 class GestureRecognizerTest : public AuraTestBase { | 706 class GestureRecognizerTest : public AuraTestBase, |
| 707 public ::testing::WithParamInterface<bool> { | |
| 698 public: | 708 public: |
| 699 GestureRecognizerTest() {} | 709 GestureRecognizerTest() {} |
| 700 | 710 |
| 711 bool UsingUnifiedGR() { | |
| 712 return GetParam(); | |
| 713 } | |
| 714 | |
| 701 virtual void SetUp() OVERRIDE { | 715 virtual void SetUp() OVERRIDE { |
| 702 CommandLine::ForCurrentProcess()->AppendSwitch( | 716 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 703 switches::kEnableScrollPrediction); | 717 switches::kEnableScrollPrediction); |
|
sadrul
2014/04/25 13:44:12
Aside: We don't enable this flag by default, right
tdresser
2014/04/25 16:46:34
Doesn't look like any tests rely on the flag being
| |
| 718 // TODO(tdresser): Once unified GR has landed, only run these tests once. | |
| 719 if (UsingUnifiedGR()) { | |
| 720 // TODO(tdresser): | |
| 721 // CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 722 // switches::kUseUnifiedGestureDetector); | |
| 723 } | |
| 724 | |
| 704 AuraTestBase::SetUp(); | 725 AuraTestBase::SetUp(); |
| 705 } | 726 } |
| 706 | 727 |
| 707 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest); | 728 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest); |
| 708 }; | 729 }; |
| 709 | 730 |
| 710 // Check that appropriate touch events generate tap gesture events. | 731 // Check that appropriate touch events generate tap gesture events. |
| 711 TEST_F(GestureRecognizerTest, GestureEventTap) { | 732 TEST_P(GestureRecognizerTest, GestureEventTap) { |
| 712 scoped_ptr<GestureEventConsumeDelegate> delegate( | 733 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 713 new GestureEventConsumeDelegate()); | 734 new GestureEventConsumeDelegate()); |
| 714 TimedEvents tes; | 735 TimedEvents tes; |
| 715 const int kWindowWidth = 123; | 736 const int kWindowWidth = 123; |
| 716 const int kWindowHeight = 45; | 737 const int kWindowHeight = 45; |
| 717 const int kTouchId = 2; | 738 const int kTouchId = 2; |
| 718 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 739 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 719 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 740 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 720 delegate.get(), -1234, bounds, root_window())); | 741 delegate.get(), -1234, bounds, root_window())); |
| 721 | 742 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 752 EXPECT_TRUE(delegate->end()); | 773 EXPECT_TRUE(delegate->end()); |
| 753 EXPECT_FALSE(delegate->scroll_begin()); | 774 EXPECT_FALSE(delegate->scroll_begin()); |
| 754 EXPECT_FALSE(delegate->scroll_update()); | 775 EXPECT_FALSE(delegate->scroll_update()); |
| 755 EXPECT_FALSE(delegate->scroll_end()); | 776 EXPECT_FALSE(delegate->scroll_end()); |
| 756 | 777 |
| 757 EXPECT_EQ(1, delegate->tap_count()); | 778 EXPECT_EQ(1, delegate->tap_count()); |
| 758 } | 779 } |
| 759 | 780 |
| 760 // Check that appropriate touch events generate tap gesture events | 781 // Check that appropriate touch events generate tap gesture events |
| 761 // when information about the touch radii are provided. | 782 // when information about the touch radii are provided. |
| 762 TEST_F(GestureRecognizerTest, GestureEventTapRegion) { | 783 TEST_P(GestureRecognizerTest, GestureEventTapRegion) { |
| 763 scoped_ptr<GestureEventConsumeDelegate> delegate( | 784 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 764 new GestureEventConsumeDelegate()); | 785 new GestureEventConsumeDelegate()); |
| 765 TimedEvents tes; | 786 TimedEvents tes; |
| 766 const int kWindowWidth = 800; | 787 const int kWindowWidth = 800; |
| 767 const int kWindowHeight = 600; | 788 const int kWindowHeight = 600; |
| 768 const int kTouchId = 2; | 789 const int kTouchId = 2; |
| 769 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 790 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 770 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 791 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 771 delegate.get(), -1234, bounds, root_window())); | 792 delegate.get(), -1234, bounds, root_window())); |
| 772 | 793 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 EXPECT_EQ(1, delegate->tap_count()); | 1013 EXPECT_EQ(1, delegate->tap_count()); |
| 993 gfx::Point actual_point(delegate->tap_location()); | 1014 gfx::Point actual_point(delegate->tap_location()); |
| 994 EXPECT_EQ(33, delegate->bounding_box().width()); | 1015 EXPECT_EQ(33, delegate->bounding_box().width()); |
| 995 EXPECT_EQ(32, delegate->bounding_box().height()); | 1016 EXPECT_EQ(32, delegate->bounding_box().height()); |
| 996 EXPECT_EQ(397, actual_point.x()); | 1017 EXPECT_EQ(397, actual_point.x()); |
| 997 EXPECT_EQ(149, actual_point.y()); | 1018 EXPECT_EQ(149, actual_point.y()); |
| 998 } | 1019 } |
| 999 } | 1020 } |
| 1000 | 1021 |
| 1001 // Check that appropriate touch events generate scroll gesture events. | 1022 // Check that appropriate touch events generate scroll gesture events. |
| 1002 TEST_F(GestureRecognizerTest, GestureEventScroll) { | 1023 TEST_P(GestureRecognizerTest, GestureEventScroll) { |
| 1003 // We'll start by moving the touch point by (10.5, 10.5). We want 5 dips of | 1024 // We'll start by moving the touch point by (10.5, 10.5). We want 5 dips of |
| 1004 // that distance to be consumed by the slop, so we set the slop radius to | 1025 // that distance to be consumed by the slop, so we set the slop radius to |
| 1005 // sqrt(5 * 5 + 5 * 5). | 1026 // sqrt(5 * 5 + 5 * 5). |
| 1006 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( | 1027 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( |
| 1007 sqrt(static_cast<double>(5 * 5 + 5 * 5))); | 1028 sqrt(static_cast<double>(5 * 5 + 5 * 5))); |
| 1008 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1029 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1009 new GestureEventConsumeDelegate()); | 1030 new GestureEventConsumeDelegate()); |
| 1010 TimedEvents tes; | 1031 TimedEvents tes; |
| 1011 const int kWindowWidth = 123; | 1032 const int kWindowWidth = 123; |
| 1012 const int kWindowHeight = 45; | 1033 const int kWindowHeight = 45; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1036 // The slop consumed 5 dips | 1057 // The slop consumed 5 dips |
| 1037 EXPECT_FLOAT_EQ(5.5, delegate->scroll_x()); | 1058 EXPECT_FLOAT_EQ(5.5, delegate->scroll_x()); |
| 1038 EXPECT_FLOAT_EQ(5.5, delegate->scroll_y()); | 1059 EXPECT_FLOAT_EQ(5.5, delegate->scroll_y()); |
| 1039 EXPECT_EQ(gfx::Point(1, 1).ToString(), | 1060 EXPECT_EQ(gfx::Point(1, 1).ToString(), |
| 1040 delegate->scroll_begin_position().ToString()); | 1061 delegate->scroll_begin_position().ToString()); |
| 1041 | 1062 |
| 1042 // When scrolling with a single finger, the bounding box of the gesture should | 1063 // When scrolling with a single finger, the bounding box of the gesture should |
| 1043 // be empty, since it's a single point and the radius for testing is zero. | 1064 // be empty, since it's a single point and the radius for testing is zero. |
| 1044 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1065 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1045 | 1066 |
| 1046 // Move some more to generate a few more scroll updates. | 1067 // Move some more to generate a few more scroll updates. Make sure that we get |
| 1047 tes.SendScrollEvent(event_processor(), 91, 192, kTouchId, delegate.get()); | 1068 // out of the snap channel for the unified GR. |
| 1069 tes.SendScrollEvent(event_processor(), 20, 120, kTouchId, delegate.get()); | |
| 1048 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1070 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 1049 EXPECT_FLOAT_EQ(-20.5, delegate->scroll_x()); | 1071 EXPECT_FLOAT_EQ(-91.5, delegate->scroll_x()); |
| 1050 EXPECT_FLOAT_EQ(-19.5, delegate->scroll_y()); | 1072 EXPECT_FLOAT_EQ(-91.5, delegate->scroll_y()); |
| 1051 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1073 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1052 | 1074 |
| 1053 tes.SendScrollEvent(event_processor(), 121, 196, kTouchId, delegate.get()); | 1075 tes.SendScrollEvent(event_processor(), 50, 124, kTouchId, delegate.get()); |
| 1054 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 1076 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 1055 EXPECT_EQ(30, delegate->scroll_x()); | 1077 EXPECT_EQ(30, delegate->scroll_x()); |
| 1056 EXPECT_EQ(4, delegate->scroll_y()); | 1078 EXPECT_EQ(4, delegate->scroll_y()); |
| 1057 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1079 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1058 | 1080 |
| 1059 // Release the touch. This should end the scroll. | 1081 // Release the touch. This should end the scroll. |
| 1060 delegate->Reset(); | 1082 delegate->Reset(); |
| 1061 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1083 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1062 kTouchId, | 1084 kTouchId, |
| 1063 tes.LeapForward(50)); | 1085 tes.LeapForward(50)); |
| 1064 DispatchEventUsingWindowDispatcher(&release); | 1086 DispatchEventUsingWindowDispatcher(&release); |
| 1065 EXPECT_2_EVENTS(delegate->events(), | 1087 EXPECT_2_EVENTS(delegate->events(), |
| 1066 ui::ET_SCROLL_FLING_START, | 1088 ui::ET_SCROLL_FLING_START, |
| 1067 ui::ET_GESTURE_END); | 1089 ui::ET_GESTURE_END); |
| 1068 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 1090 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 1069 } | 1091 } |
| 1070 | 1092 |
| 1071 // Check that predicted scroll update positions are correct. | 1093 // Check that predicted scroll update positions are correct. |
| 1072 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { | 1094 TEST_P(GestureRecognizerTest, GestureEventScrollPrediction) { |
| 1073 const double prediction_interval = 0.03; | 1095 const double prediction_interval = 0.03; |
| 1074 ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval); | 1096 ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval); |
| 1075 // We'll start by moving the touch point by (5, 5). We want all of that | 1097 // We'll start by moving the touch point by (5, 5). We want all of that |
| 1076 // distance to be consumed by the slop, so we set the slop radius to | 1098 // distance to be consumed by the slop, so we set the slop radius to |
| 1077 // sqrt(5 * 5 + 5 * 5). | 1099 // sqrt(5 * 5 + 5 * 5). |
| 1078 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( | 1100 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( |
| 1079 sqrt(static_cast<double>(5 * 5 + 5 * 5))); | 1101 sqrt(static_cast<double>(5 * 5 + 5 * 5))); |
| 1080 | 1102 |
| 1081 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1103 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1082 new GestureEventConsumeDelegate()); | 1104 new GestureEventConsumeDelegate()); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1094 gfx::Vector2dF total_scroll; | 1116 gfx::Vector2dF total_scroll; |
| 1095 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(96, 196), | 1117 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(96, 196), |
| 1096 kTouchId, tes.Now()); | 1118 kTouchId, tes.Now()); |
| 1097 DispatchEventUsingWindowDispatcher(&press); | 1119 DispatchEventUsingWindowDispatcher(&press); |
| 1098 EXPECT_2_EVENTS(delegate->events(), | 1120 EXPECT_2_EVENTS(delegate->events(), |
| 1099 ui::ET_GESTURE_BEGIN, | 1121 ui::ET_GESTURE_BEGIN, |
| 1100 ui::ET_GESTURE_TAP_DOWN); | 1122 ui::ET_GESTURE_TAP_DOWN); |
| 1101 delegate->Reset(); | 1123 delegate->Reset(); |
| 1102 | 1124 |
| 1103 // Get rid of touch slop. | 1125 // Get rid of touch slop. |
| 1104 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), | 1126 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(111, 211), |
| 1105 kTouchId, tes.Now()); | 1127 kTouchId, tes.Now()); |
| 1106 DispatchEventUsingWindowDispatcher(&move); | 1128 DispatchEventUsingWindowDispatcher(&move); |
| 1107 EXPECT_3_EVENTS(delegate->events(), | 1129 EXPECT_3_EVENTS(delegate->events(), |
| 1108 ui::ET_GESTURE_TAP_CANCEL, | 1130 ui::ET_GESTURE_TAP_CANCEL, |
| 1109 ui::ET_GESTURE_SCROLL_BEGIN, | 1131 ui::ET_GESTURE_SCROLL_BEGIN, |
| 1110 ui::ET_GESTURE_SCROLL_UPDATE); | 1132 ui::ET_GESTURE_SCROLL_UPDATE); |
| 1111 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); | 1133 total_scroll.set_x(total_scroll.x() + delegate->scroll_x()); |
| 1112 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); | 1134 total_scroll.set_y(total_scroll.y() + delegate->scroll_y()); |
| 1113 | 1135 |
| 1114 // Move the touch-point enough so that it is considered as a scroll. This | 1136 // Move the touch-point enough so that it is considered as a scroll. This |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1137 | 1159 |
| 1138 // Release the touch. This should end the scroll. | 1160 // Release the touch. This should end the scroll. |
| 1139 delegate->Reset(); | 1161 delegate->Reset(); |
| 1140 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1162 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1141 kTouchId, | 1163 kTouchId, |
| 1142 tes.LeapForward(50)); | 1164 tes.LeapForward(50)); |
| 1143 DispatchEventUsingWindowDispatcher(&release); | 1165 DispatchEventUsingWindowDispatcher(&release); |
| 1144 } | 1166 } |
| 1145 | 1167 |
| 1146 // Check that the bounding box during a scroll event is correct. | 1168 // Check that the bounding box during a scroll event is correct. |
| 1147 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { | 1169 TEST_P(GestureRecognizerTest, GestureEventScrollBoundingBox) { |
| 1148 TimedEvents tes; | 1170 TimedEvents tes; |
| 1149 for (int radius = 1; radius <= 10; ++radius) { | 1171 for (int radius = 1; radius <= 10; ++radius) { |
| 1150 ui::GestureConfiguration::set_default_radius(radius); | 1172 ui::GestureConfiguration::set_default_radius(radius); |
| 1151 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1173 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1152 new GestureEventConsumeDelegate()); | 1174 new GestureEventConsumeDelegate()); |
| 1153 const int kWindowWidth = 123; | 1175 const int kWindowWidth = 123; |
| 1154 const int kWindowHeight = 45; | 1176 const int kWindowHeight = 45; |
| 1155 const int kTouchId = 5; | 1177 const int kTouchId = 5; |
| 1156 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1178 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1157 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1179 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 kPositionY + kScrollAmount - radius, | 1216 kPositionY + kScrollAmount - radius, |
| 1195 radius * 2, | 1217 radius * 2, |
| 1196 radius * 2).ToString(), | 1218 radius * 2).ToString(), |
| 1197 delegate->bounding_box().ToString()); | 1219 delegate->bounding_box().ToString()); |
| 1198 } | 1220 } |
| 1199 ui::GestureConfiguration::set_default_radius(0); | 1221 ui::GestureConfiguration::set_default_radius(0); |
| 1200 } | 1222 } |
| 1201 | 1223 |
| 1202 // Check Scroll End Events report correct velocities | 1224 // Check Scroll End Events report correct velocities |
| 1203 // if the user was on a horizontal rail | 1225 // if the user was on a horizontal rail |
| 1204 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { | 1226 TEST_P(GestureRecognizerTest, GestureEventHorizontalRailFling) { |
| 1205 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1227 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1206 new GestureEventConsumeDelegate()); | 1228 new GestureEventConsumeDelegate()); |
| 1207 TimedEvents tes; | 1229 TimedEvents tes; |
| 1208 const int kTouchId = 7; | 1230 const int kTouchId = 7; |
| 1209 gfx::Rect bounds(0, 0, 1000, 1000); | 1231 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1210 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1232 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1211 delegate.get(), -1234, bounds, root_window())); | 1233 delegate.get(), -1234, bounds, root_window())); |
| 1212 | 1234 |
| 1213 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1235 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1214 kTouchId, tes.Now()); | 1236 kTouchId, tes.Now()); |
| 1215 DispatchEventUsingWindowDispatcher(&press); | 1237 DispatchEventUsingWindowDispatcher(&press); |
| 1216 | 1238 |
| 1217 // Get rid of touch slop. | 1239 // Get rid of touch slop. |
| 1218 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), | 1240 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 0), |
| 1219 kTouchId, tes.Now()); | 1241 kTouchId, tes.Now()); |
| 1220 DispatchEventUsingWindowDispatcher(&move); | 1242 DispatchEventUsingWindowDispatcher(&move); |
| 1221 delegate->Reset(); | 1243 delegate->Reset(); |
| 1222 | 1244 |
| 1223 | 1245 |
| 1224 // Move the touch-point horizontally enough that it is considered a | 1246 // Move the touch-point horizontally enough that it is considered a |
| 1225 // horizontal scroll. | 1247 // horizontal scroll. |
| 1226 tes.SendScrollEvent(event_processor(), 25, 1, kTouchId, delegate.get()); | 1248 tes.SendScrollEvent(event_processor(), 30, 1, kTouchId, delegate.get()); |
| 1227 EXPECT_EQ(0, delegate->scroll_y()); | 1249 EXPECT_FLOAT_EQ(0, delegate->scroll_y()); |
| 1228 EXPECT_EQ(1, delegate->scroll_y_ordinal()); | 1250 EXPECT_FLOAT_EQ(1, delegate->scroll_y_ordinal()); |
| 1229 EXPECT_EQ(20, delegate->scroll_x()); | 1251 EXPECT_FLOAT_EQ(20, delegate->scroll_x()); |
| 1230 EXPECT_EQ(20, delegate->scroll_x_ordinal()); | 1252 EXPECT_FLOAT_EQ(20, delegate->scroll_x_ordinal()); |
| 1231 | 1253 |
| 1232 // Get a high x velocity, while still staying on the rail | 1254 // Get a high x velocity, while still staying on the rail |
| 1233 tes.SendScrollEvents(event_processor(), 1, 1, | 1255 tes.SendScrollEvents(event_processor(), 1, 1, |
| 1234 100, 10, kTouchId, 1, | 1256 100, 10, kTouchId, 1, |
| 1235 ui::GestureConfiguration::points_buffered_for_velocity(), | 1257 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1236 delegate.get()); | 1258 delegate.get()); |
| 1237 | 1259 |
| 1238 delegate->Reset(); | 1260 delegate->Reset(); |
| 1239 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1261 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1240 kTouchId, tes.Now()); | 1262 kTouchId, tes.Now()); |
| 1241 DispatchEventUsingWindowDispatcher(&release); | 1263 DispatchEventUsingWindowDispatcher(&release); |
| 1242 | 1264 |
| 1243 EXPECT_TRUE(delegate->fling()); | 1265 EXPECT_TRUE(delegate->fling()); |
| 1244 EXPECT_FALSE(delegate->scroll_end()); | 1266 EXPECT_FALSE(delegate->scroll_end()); |
| 1245 EXPECT_GT(delegate->velocity_x(), 0); | 1267 EXPECT_GT(delegate->velocity_x(), 0); |
| 1246 EXPECT_EQ(0, delegate->velocity_y()); | 1268 EXPECT_EQ(0, delegate->velocity_y()); |
| 1247 } | 1269 } |
| 1248 | 1270 |
| 1249 // Check Scroll End Events report correct velocities | 1271 // Check Scroll End Events report correct velocities |
| 1250 // if the user was on a vertical rail | 1272 // if the user was on a vertical rail |
| 1251 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { | 1273 TEST_P(GestureRecognizerTest, GestureEventVerticalRailFling) { |
| 1252 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1274 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1253 new GestureEventConsumeDelegate()); | 1275 new GestureEventConsumeDelegate()); |
| 1254 TimedEvents tes; | 1276 TimedEvents tes; |
| 1255 const int kTouchId = 7; | 1277 const int kTouchId = 7; |
| 1256 gfx::Rect bounds(0, 0, 1000, 1000); | 1278 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1257 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1279 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1258 delegate.get(), -1234, bounds, root_window())); | 1280 delegate.get(), -1234, bounds, root_window())); |
| 1259 | 1281 |
| 1260 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1282 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1261 kTouchId, tes.Now()); | 1283 kTouchId, tes.Now()); |
| 1262 DispatchEventUsingWindowDispatcher(&press); | 1284 DispatchEventUsingWindowDispatcher(&press); |
| 1263 | 1285 |
| 1264 // Get rid of touch slop. | 1286 // Get rid of touch slop. |
| 1265 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), | 1287 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 10), |
| 1266 kTouchId, tes.Now()); | 1288 kTouchId, tes.Now()); |
| 1267 DispatchEventUsingWindowDispatcher(&move); | 1289 DispatchEventUsingWindowDispatcher(&move); |
| 1268 delegate->Reset(); | 1290 delegate->Reset(); |
| 1269 | 1291 |
| 1270 // Move the touch-point vertically enough that it is considered a | 1292 // Move the touch-point vertically enough that it is considered a |
| 1271 // vertical scroll. | 1293 // vertical scroll. |
| 1272 tes.SendScrollEvent(event_processor(), 1, 25, kTouchId, delegate.get()); | 1294 tes.SendScrollEvent(event_processor(), 1, 30, kTouchId, delegate.get()); |
| 1273 EXPECT_EQ(20, delegate->scroll_y()); | 1295 EXPECT_EQ(20, delegate->scroll_y()); |
| 1274 EXPECT_EQ(20, delegate->scroll_y_ordinal()); | 1296 EXPECT_EQ(20, delegate->scroll_y_ordinal()); |
| 1275 EXPECT_EQ(0, delegate->scroll_x()); | 1297 EXPECT_EQ(0, delegate->scroll_x()); |
| 1276 EXPECT_EQ(1, delegate->scroll_x_ordinal()); | 1298 EXPECT_EQ(1, delegate->scroll_x_ordinal()); |
| 1277 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1299 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1278 | 1300 |
| 1279 // Get a high y velocity, while still staying on the rail | 1301 // Get a high y velocity, while still staying on the rail |
| 1280 tes.SendScrollEvents(event_processor(), 1, 6, | 1302 tes.SendScrollEvents(event_processor(), 1, 6, |
| 1281 10, 100, kTouchId, 1, | 1303 10, 100, kTouchId, 1, |
| 1282 ui::GestureConfiguration::points_buffered_for_velocity(), | 1304 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1283 delegate.get()); | 1305 delegate.get()); |
| 1284 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1306 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1285 | 1307 |
| 1286 delegate->Reset(); | 1308 delegate->Reset(); |
| 1287 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), | 1309 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), |
| 1288 kTouchId, tes.Now()); | 1310 kTouchId, tes.Now()); |
| 1289 DispatchEventUsingWindowDispatcher(&release); | 1311 DispatchEventUsingWindowDispatcher(&release); |
| 1290 | 1312 |
| 1291 EXPECT_TRUE(delegate->fling()); | 1313 EXPECT_TRUE(delegate->fling()); |
| 1292 EXPECT_FALSE(delegate->scroll_end()); | 1314 EXPECT_FALSE(delegate->scroll_end()); |
| 1293 EXPECT_EQ(0, delegate->velocity_x()); | 1315 EXPECT_EQ(0, delegate->velocity_x()); |
| 1294 EXPECT_GT(delegate->velocity_y(), 0); | 1316 EXPECT_GT(delegate->velocity_y(), 0); |
| 1295 } | 1317 } |
| 1296 | 1318 |
| 1297 // Check Scroll End Events reports zero velocities | 1319 // Check Scroll End Events report non-zero velocities if the user is not on a |
| 1298 // if the user is not on a rail | 1320 // rail |
| 1299 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { | 1321 TEST_P(GestureRecognizerTest, GestureEventNonRailFling) { |
| 1300 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0); | 1322 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0); |
| 1301 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1323 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1302 new GestureEventConsumeDelegate()); | 1324 new GestureEventConsumeDelegate()); |
| 1303 TimedEvents tes; | 1325 TimedEvents tes; |
| 1304 const int kTouchId = 7; | 1326 const int kTouchId = 7; |
| 1305 gfx::Rect bounds(0, 0, 1000, 1000); | 1327 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1306 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1328 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1307 delegate.get(), -1234, bounds, root_window())); | 1329 delegate.get(), -1234, bounds, root_window())); |
| 1308 | 1330 |
| 1309 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1331 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1310 kTouchId, tes.Now()); | 1332 kTouchId, tes.Now()); |
| 1311 DispatchEventUsingWindowDispatcher(&press); | 1333 DispatchEventUsingWindowDispatcher(&press); |
| 1312 | 1334 |
| 1313 // Move the touch-point such that a non-rail scroll begins | 1335 // Move the touch-point such that a non-rail scroll begins, and we're outside |
| 1314 tes.SendScrollEvent(event_processor(), 20, 20, kTouchId, delegate.get()); | 1336 // the snap channel for the unified GR. |
| 1315 EXPECT_EQ(20, delegate->scroll_y()); | 1337 tes.SendScrollEvent(event_processor(), 50, 50, kTouchId, delegate.get()); |
| 1316 EXPECT_EQ(20, delegate->scroll_x()); | 1338 EXPECT_EQ(50, delegate->scroll_y()); |
| 1339 EXPECT_EQ(50, delegate->scroll_x()); | |
| 1317 | 1340 |
| 1318 tes.SendScrollEvents(event_processor(), 1, 1, | 1341 tes.SendScrollEvents(event_processor(), 1, 1, |
| 1319 10, 100, kTouchId, 1, | 1342 10, 100, kTouchId, 1, |
| 1320 ui::GestureConfiguration::points_buffered_for_velocity(), | 1343 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1321 delegate.get()); | 1344 delegate.get()); |
| 1322 | 1345 |
| 1323 delegate->Reset(); | 1346 delegate->Reset(); |
| 1324 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1347 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1325 kTouchId, tes.Now()); | 1348 kTouchId, tes.Now()); |
| 1326 DispatchEventUsingWindowDispatcher(&release); | 1349 DispatchEventUsingWindowDispatcher(&release); |
| 1327 | 1350 |
| 1328 EXPECT_TRUE(delegate->fling()); | 1351 EXPECT_TRUE(delegate->fling()); |
| 1329 EXPECT_FALSE(delegate->scroll_end()); | 1352 EXPECT_FALSE(delegate->scroll_end()); |
| 1330 EXPECT_GT(delegate->velocity_x(), 0); | 1353 EXPECT_GT(delegate->velocity_x(), 0); |
| 1331 EXPECT_GT(delegate->velocity_y(), 0); | 1354 EXPECT_GT(delegate->velocity_y(), 0); |
| 1332 } | 1355 } |
| 1333 | 1356 |
| 1334 // Check that appropriate touch events generate long press events | 1357 // Check that appropriate touch events generate long press events |
| 1335 TEST_F(GestureRecognizerTest, GestureEventLongPress) { | 1358 TEST_P(GestureRecognizerTest, GestureEventLongPress) { |
| 1336 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1359 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1337 new GestureEventConsumeDelegate()); | 1360 new GestureEventConsumeDelegate()); |
| 1338 TimedEvents tes; | |
| 1339 const int kWindowWidth = 123; | 1361 const int kWindowWidth = 123; |
| 1340 const int kWindowHeight = 45; | 1362 const int kWindowHeight = 45; |
| 1341 const int kTouchId = 2; | 1363 const int kTouchId = 2; |
| 1342 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1364 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1343 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1365 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1344 delegate.get(), -1234, bounds, root_window())); | 1366 delegate.get(), -1234, bounds, root_window())); |
| 1345 | 1367 |
| 1346 delegate->Reset(); | 1368 delegate->Reset(); |
| 1347 | 1369 |
| 1348 TimerTestGestureRecognizer* gesture_recognizer = | 1370 TimerTestGestureRecognizer* gesture_recognizer = |
| 1349 new TimerTestGestureRecognizer(); | 1371 new TimerTestGestureRecognizer(); |
| 1350 | 1372 |
| 1351 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 1373 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 1352 | 1374 |
| 1353 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1375 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1354 kTouchId, tes.Now()); | 1376 kTouchId, base::TimeTicks::Now() - base::TimeTicks()); |
|
sadrul
2014/04/25 13:44:12
Can we use ui::EventTimeForNow() instead?
tdresser
2014/04/25 16:46:34
Wonderful, done.
| |
| 1355 DispatchEventUsingWindowDispatcher(&press1); | 1377 DispatchEventUsingWindowDispatcher(&press1); |
| 1356 EXPECT_TRUE(delegate->tap_down()); | 1378 EXPECT_TRUE(delegate->tap_down()); |
| 1357 EXPECT_TRUE(delegate->begin()); | 1379 EXPECT_TRUE(delegate->begin()); |
| 1358 EXPECT_FALSE(delegate->tap_cancel()); | 1380 EXPECT_FALSE(delegate->tap_cancel()); |
| 1359 | 1381 |
| 1360 // We haven't pressed long enough for a long press to occur | 1382 // We haven't pressed long enough for a long press to occur |
| 1361 EXPECT_FALSE(delegate->long_press()); | 1383 EXPECT_FALSE(delegate->long_press()); |
| 1362 | 1384 |
| 1363 // Wait until the timer runs out | 1385 // Wait until the timer runs out |
| 1364 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); | 1386 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); |
| 1365 EXPECT_TRUE(delegate->long_press()); | 1387 EXPECT_TRUE(delegate->long_press()); |
| 1366 EXPECT_FALSE(delegate->tap_cancel()); | 1388 EXPECT_FALSE(delegate->tap_cancel()); |
| 1367 | 1389 |
| 1368 delegate->Reset(); | 1390 delegate->Reset(); |
| 1369 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1391 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1370 kTouchId, tes.Now()); | 1392 kTouchId, base::TimeTicks::Now() - base::TimeTicks()); |
| 1371 DispatchEventUsingWindowDispatcher(&release1); | 1393 DispatchEventUsingWindowDispatcher(&release1); |
| 1372 EXPECT_FALSE(delegate->long_press()); | 1394 EXPECT_FALSE(delegate->long_press()); |
| 1373 | 1395 |
| 1374 // Note the tap down isn't cancelled until the release | 1396 // Note the tap cancel isn't dispatched until the release |
| 1375 EXPECT_TRUE(delegate->tap_cancel()); | 1397 EXPECT_TRUE(delegate->tap_cancel()); |
| 1398 EXPECT_FALSE(delegate->tap()); | |
| 1376 } | 1399 } |
| 1377 | 1400 |
| 1378 // Check that scrolling cancels a long press | 1401 // Check that scrolling cancels a long press |
| 1379 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { | 1402 TEST_P(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { |
| 1380 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1403 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1381 new GestureEventConsumeDelegate()); | 1404 new GestureEventConsumeDelegate()); |
| 1382 TimedEvents tes; | 1405 TimedEvents tes; |
| 1383 ui::GestureConfiguration::set_long_press_time_in_seconds(.01); | 1406 ui::GestureConfiguration::set_long_press_time_in_seconds(.01); |
| 1384 const int kWindowWidth = 123; | 1407 const int kWindowWidth = 123; |
| 1385 const int kWindowHeight = 45; | 1408 const int kWindowHeight = 45; |
| 1386 const int kTouchId = 6; | 1409 const int kTouchId = 6; |
| 1387 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1410 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1388 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1411 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1389 delegate.get(), -1234, bounds, root_window())); | 1412 delegate.get(), -1234, bounds, root_window())); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1416 | 1439 |
| 1417 delegate->Reset(); | 1440 delegate->Reset(); |
| 1418 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1441 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1419 kTouchId, tes.LeapForward(10)); | 1442 kTouchId, tes.LeapForward(10)); |
| 1420 DispatchEventUsingWindowDispatcher(&release1); | 1443 DispatchEventUsingWindowDispatcher(&release1); |
| 1421 EXPECT_FALSE(delegate->long_press()); | 1444 EXPECT_FALSE(delegate->long_press()); |
| 1422 EXPECT_FALSE(delegate->tap_cancel()); | 1445 EXPECT_FALSE(delegate->tap_cancel()); |
| 1423 } | 1446 } |
| 1424 | 1447 |
| 1425 // Check that appropriate touch events generate long tap events | 1448 // Check that appropriate touch events generate long tap events |
| 1426 TEST_F(GestureRecognizerTest, GestureEventLongTap) { | 1449 TEST_P(GestureRecognizerTest, GestureEventLongTap) { |
| 1427 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1450 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1428 new GestureEventConsumeDelegate()); | 1451 new GestureEventConsumeDelegate()); |
| 1429 TimedEvents tes; | |
| 1430 const int kWindowWidth = 123; | 1452 const int kWindowWidth = 123; |
| 1431 const int kWindowHeight = 45; | 1453 const int kWindowHeight = 45; |
| 1432 const int kTouchId = 2; | 1454 const int kTouchId = 2; |
| 1433 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1455 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1434 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1456 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1435 delegate.get(), -1234, bounds, root_window())); | 1457 delegate.get(), -1234, bounds, root_window())); |
| 1436 | 1458 |
| 1437 delegate->Reset(); | 1459 delegate->Reset(); |
| 1438 | 1460 |
| 1439 TimerTestGestureRecognizer* gesture_recognizer = | 1461 TimerTestGestureRecognizer* gesture_recognizer = |
| 1440 new TimerTestGestureRecognizer(); | 1462 new TimerTestGestureRecognizer(); |
| 1441 | 1463 |
| 1442 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 1464 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 1443 | 1465 |
| 1444 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 1466 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 1445 kTouchId, tes.Now()); | 1467 kTouchId, base::TimeTicks::Now() - base::TimeTicks()); |
| 1446 DispatchEventUsingWindowDispatcher(&press1); | 1468 DispatchEventUsingWindowDispatcher(&press1); |
| 1447 EXPECT_TRUE(delegate->tap_down()); | 1469 EXPECT_TRUE(delegate->tap_down()); |
| 1448 EXPECT_TRUE(delegate->begin()); | 1470 EXPECT_TRUE(delegate->begin()); |
| 1449 EXPECT_FALSE(delegate->tap_cancel()); | 1471 EXPECT_FALSE(delegate->tap_cancel()); |
| 1450 | 1472 |
| 1451 // We haven't pressed long enough for a long press to occur | 1473 // We haven't pressed long enough for a long press to occur |
| 1452 EXPECT_FALSE(delegate->long_press()); | 1474 EXPECT_FALSE(delegate->long_press()); |
| 1453 | 1475 |
| 1454 // Wait until the timer runs out | 1476 // Wait until the timer runs out |
| 1455 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); | 1477 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); |
| 1456 EXPECT_TRUE(delegate->long_press()); | 1478 EXPECT_TRUE(delegate->long_press()); |
| 1457 EXPECT_FALSE(delegate->tap_cancel()); | 1479 EXPECT_FALSE(delegate->tap_cancel()); |
| 1458 | 1480 |
| 1459 delegate->Reset(); | 1481 delegate->Reset(); |
| 1460 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1482 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1461 kTouchId, tes.Now()); | 1483 kTouchId, base::TimeTicks::Now() - base::TimeTicks()); |
| 1462 DispatchEventUsingWindowDispatcher(&release1); | 1484 DispatchEventUsingWindowDispatcher(&release1); |
| 1463 EXPECT_FALSE(delegate->long_press()); | 1485 EXPECT_FALSE(delegate->long_press()); |
| 1464 EXPECT_TRUE(delegate->long_tap()); | 1486 EXPECT_TRUE(delegate->long_tap()); |
| 1465 | 1487 |
| 1466 // Note the tap down isn't cancelled until the release | 1488 // Note the tap cancel isn't dispatched until the release |
| 1467 EXPECT_TRUE(delegate->tap_cancel()); | 1489 EXPECT_TRUE(delegate->tap_cancel()); |
| 1490 EXPECT_FALSE(delegate->tap()); | |
| 1491 | |
|
sadrul
2014/04/25 13:44:12
Remove blank line
tdresser
2014/04/25 16:46:34
Done.
| |
| 1468 } | 1492 } |
| 1469 | 1493 |
| 1470 // Check that second tap cancels a long press | 1494 // Check that second tap cancels a long press |
| 1471 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { | 1495 TEST_P(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { |
| 1496 // TODO(tdresser): enable this test with unified GR once two finger tap is | |
| 1497 // supported. See crbug.com/354396. | |
| 1498 if (UsingUnifiedGR()) | |
| 1499 return; | |
| 1500 | |
| 1472 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1501 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1473 new GestureEventConsumeDelegate()); | 1502 new GestureEventConsumeDelegate()); |
| 1474 TimedEvents tes; | 1503 TimedEvents tes; |
| 1475 ui::GestureConfiguration::set_long_press_time_in_seconds(.01); | 1504 ui::GestureConfiguration::set_long_press_time_in_seconds(.01); |
| 1476 const int kWindowWidth = 300; | 1505 const int kWindowWidth = 300; |
| 1477 const int kWindowHeight = 400; | 1506 const int kWindowHeight = 400; |
| 1478 const int kTouchId1 = 8; | 1507 const int kTouchId1 = 8; |
| 1479 const int kTouchId2 = 2; | 1508 const int kTouchId2 = 2; |
| 1480 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 1509 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
| 1481 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1510 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1518 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 1547 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 1519 kTouchId1, tes.Now()); | 1548 kTouchId1, tes.Now()); |
| 1520 DispatchEventUsingWindowDispatcher(&release1); | 1549 DispatchEventUsingWindowDispatcher(&release1); |
| 1521 EXPECT_FALSE(delegate->long_press()); | 1550 EXPECT_FALSE(delegate->long_press()); |
| 1522 EXPECT_TRUE(delegate->two_finger_tap()); | 1551 EXPECT_TRUE(delegate->two_finger_tap()); |
| 1523 EXPECT_FALSE(delegate->tap_cancel()); | 1552 EXPECT_FALSE(delegate->tap_cancel()); |
| 1524 } | 1553 } |
| 1525 | 1554 |
| 1526 // Check that horizontal scroll gestures cause scrolls on horizontal rails. | 1555 // Check that horizontal scroll gestures cause scrolls on horizontal rails. |
| 1527 // Also tests that horizontal rails can be broken. | 1556 // Also tests that horizontal rails can be broken. |
| 1528 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { | 1557 TEST_P(GestureRecognizerTest, GestureEventHorizontalRailScroll) { |
| 1529 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1558 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1530 new GestureEventConsumeDelegate()); | 1559 new GestureEventConsumeDelegate()); |
| 1531 TimedEvents tes; | 1560 TimedEvents tes; |
| 1532 const int kTouchId = 7; | 1561 const int kTouchId = 7; |
| 1533 gfx::Rect bounds(0, 0, 1000, 1000); | 1562 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1534 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1563 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1535 delegate.get(), -1234, bounds, root_window())); | 1564 delegate.get(), -1234, bounds, root_window())); |
| 1536 | 1565 |
| 1537 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1566 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1538 kTouchId, tes.Now()); | 1567 kTouchId, tes.Now()); |
| 1539 DispatchEventUsingWindowDispatcher(&press); | 1568 DispatchEventUsingWindowDispatcher(&press); |
| 1540 | 1569 |
| 1541 // Get rid of touch slop. | 1570 // Get rid of touch slop. |
| 1542 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), | 1571 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0), |
| 1543 kTouchId, tes.Now()); | 1572 kTouchId, tes.Now()); |
| 1544 | 1573 |
| 1545 DispatchEventUsingWindowDispatcher(&move); | 1574 DispatchEventUsingWindowDispatcher(&move); |
| 1546 delegate->Reset(); | 1575 delegate->Reset(); |
| 1547 | 1576 |
| 1548 // Move the touch-point horizontally enough that it is considered a | 1577 // Move the touch-point horizontally enough that it is considered a |
| 1549 // horizontal scroll. | 1578 // horizontal scroll. |
| 1550 tes.SendScrollEvent(event_processor(), 25, 1, kTouchId, delegate.get()); | 1579 tes.SendScrollEvent(event_processor(), 25, 0, kTouchId, delegate.get()); |
| 1551 EXPECT_EQ(0, delegate->scroll_y()); | 1580 EXPECT_EQ(0, delegate->scroll_y()); |
| 1552 EXPECT_EQ(20, delegate->scroll_x()); | 1581 EXPECT_EQ(20, delegate->scroll_x()); |
| 1553 | 1582 |
| 1554 tes.SendScrollEvent(event_processor(), 30, 6, kTouchId, delegate.get()); | 1583 tes.SendScrollEvent(event_processor(), 30, 6, kTouchId, delegate.get()); |
| 1555 EXPECT_TRUE(delegate->scroll_update()); | 1584 EXPECT_TRUE(delegate->scroll_update()); |
| 1556 EXPECT_EQ(5, delegate->scroll_x()); | 1585 EXPECT_EQ(5, delegate->scroll_x()); |
| 1557 // y shouldn't change, as we're on a horizontal rail. | 1586 // y shouldn't change, as we're on a horizontal rail. |
| 1558 EXPECT_EQ(0, delegate->scroll_y()); | 1587 EXPECT_EQ(0, delegate->scroll_y()); |
| 1559 | 1588 |
| 1560 // Send enough information that a velocity can be calculated for the gesture, | 1589 // Send enough information that a velocity can be calculated for the gesture, |
| 1561 // and we can break the rail | 1590 // and we can break the rail |
| 1562 tes.SendScrollEvents(event_processor(), 1, 1, | 1591 tes.SendScrollEvents(event_processor(), 1, 1, |
| 1563 6, 100, kTouchId, 1, | 1592 6, 100, kTouchId, 1, |
| 1564 ui::GestureConfiguration::points_buffered_for_velocity(), | 1593 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1565 delegate.get()); | 1594 delegate.get()); |
| 1566 | 1595 |
| 1567 tes.SendScrollEvent(event_processor(), 5, 0, kTouchId, delegate.get()); | 1596 tes.SendScrollEvent(event_processor(), 5, 0, kTouchId, delegate.get()); |
| 1568 tes.SendScrollEvent(event_processor(), 10, 5, kTouchId, delegate.get()); | 1597 tes.SendScrollEvent(event_processor(), 10, 5, kTouchId, delegate.get()); |
| 1569 | 1598 |
| 1570 // The rail should be broken | 1599 // The rail should be broken |
| 1571 EXPECT_TRUE(delegate->scroll_update()); | 1600 EXPECT_TRUE(delegate->scroll_update()); |
| 1572 EXPECT_EQ(5, delegate->scroll_x()); | 1601 EXPECT_EQ(5, delegate->scroll_x()); |
| 1573 EXPECT_EQ(5, delegate->scroll_y()); | 1602 EXPECT_EQ(5, delegate->scroll_y()); |
| 1574 } | 1603 } |
| 1575 | 1604 |
| 1576 // Check that vertical scroll gestures cause scrolls on vertical rails. | 1605 // Check that vertical scroll gestures cause scrolls on vertical rails. |
| 1577 // Also tests that vertical rails can be broken. | 1606 // Also tests that vertical rails can be broken. |
| 1578 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { | 1607 TEST_P(GestureRecognizerTest, GestureEventVerticalRailScroll) { |
| 1579 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1608 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1580 new GestureEventConsumeDelegate()); | 1609 new GestureEventConsumeDelegate()); |
| 1581 TimedEvents tes; | 1610 TimedEvents tes; |
| 1582 const int kTouchId = 7; | 1611 const int kTouchId = 7; |
| 1583 gfx::Rect bounds(0, 0, 1000, 1000); | 1612 gfx::Rect bounds(0, 0, 1000, 1000); |
| 1584 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1613 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1585 delegate.get(), -1234, bounds, root_window())); | 1614 delegate.get(), -1234, bounds, root_window())); |
| 1586 | 1615 |
| 1587 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 1616 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 1588 kTouchId, tes.Now()); | 1617 kTouchId, tes.Now()); |
| 1589 DispatchEventUsingWindowDispatcher(&press); | 1618 DispatchEventUsingWindowDispatcher(&press); |
| 1590 | 1619 |
| 1591 // Get rid of touch slop. | 1620 // Get rid of touch slop. |
| 1592 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), | 1621 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5), |
| 1593 kTouchId, tes.Now()); | 1622 kTouchId, tes.Now()); |
| 1594 DispatchEventUsingWindowDispatcher(&move); | 1623 DispatchEventUsingWindowDispatcher(&move); |
| 1595 delegate->Reset(); | 1624 delegate->Reset(); |
| 1596 | 1625 |
| 1597 // Move the touch-point vertically enough that it is considered a | 1626 // Move the touch-point vertically enough that it is considered a |
| 1598 // vertical scroll. | 1627 // vertical scroll. |
| 1599 tes.SendScrollEvent(event_processor(), 1, 25, kTouchId, delegate.get()); | 1628 tes.SendScrollEvent(event_processor(), 0, 25, kTouchId, delegate.get()); |
| 1600 EXPECT_EQ(0, delegate->scroll_x()); | 1629 EXPECT_EQ(0, delegate->scroll_x()); |
| 1601 EXPECT_EQ(20, delegate->scroll_y()); | 1630 EXPECT_EQ(20, delegate->scroll_y()); |
| 1602 | 1631 |
| 1603 tes.SendScrollEvent(event_processor(), 6, 30, kTouchId, delegate.get()); | 1632 tes.SendScrollEvent(event_processor(), 6, 30, kTouchId, delegate.get()); |
| 1604 EXPECT_TRUE(delegate->scroll_update()); | 1633 EXPECT_TRUE(delegate->scroll_update()); |
| 1605 EXPECT_EQ(5, delegate->scroll_y()); | 1634 EXPECT_EQ(5, delegate->scroll_y()); |
| 1606 // x shouldn't change, as we're on a vertical rail. | 1635 // x shouldn't change, as we're on a vertical rail. |
| 1607 EXPECT_EQ(0, delegate->scroll_x()); | 1636 EXPECT_EQ(0, delegate->scroll_x()); |
| 1608 EXPECT_EQ(0, delegate->scroll_velocity_x()); | 1637 EXPECT_EQ(0, delegate->scroll_velocity_x()); |
| 1609 | 1638 |
| 1610 // 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, |
| 1611 // and we can break the rail | 1640 // and we can break the rail |
| 1612 tes.SendScrollEvents(event_processor(), 1, 6, | 1641 tes.SendScrollEvents(event_processor(), 1, 6, |
| 1613 100, 1, kTouchId, 1, | 1642 100, 1, kTouchId, 1, |
| 1614 ui::GestureConfiguration::points_buffered_for_velocity(), | 1643 ui::GestureConfiguration::points_buffered_for_velocity(), |
| 1615 delegate.get()); | 1644 delegate.get()); |
| 1616 | 1645 |
| 1617 tes.SendScrollEvent(event_processor(), 0, 5, kTouchId, delegate.get()); | 1646 tes.SendScrollEvent(event_processor(), 0, 5, kTouchId, delegate.get()); |
| 1618 tes.SendScrollEvent(event_processor(), 5, 10, kTouchId, delegate.get()); | 1647 tes.SendScrollEvent(event_processor(), 5, 10, kTouchId, delegate.get()); |
| 1619 | 1648 |
| 1620 // The rail should be broken | 1649 // The rail should be broken |
| 1621 EXPECT_TRUE(delegate->scroll_update()); | 1650 EXPECT_TRUE(delegate->scroll_update()); |
| 1622 EXPECT_EQ(5, delegate->scroll_x()); | 1651 EXPECT_EQ(5, delegate->scroll_x()); |
| 1623 EXPECT_EQ(5, delegate->scroll_y()); | 1652 EXPECT_EQ(5, delegate->scroll_y()); |
| 1624 } | 1653 } |
| 1625 | 1654 |
| 1626 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { | 1655 TEST_P(GestureRecognizerTest, GestureTapFollowedByScroll) { |
| 1627 // We'll start by moving the touch point by (5, 5). We want all of that | 1656 // We'll start by moving the touch point by (5, 5). We want all of that |
| 1628 // distance to be consumed by the slop, so we set the slop radius to | 1657 // distance to be consumed by the slop, so we set the slop radius to |
| 1629 // sqrt(5 * 5 + 5 * 5). | 1658 // sqrt(5 * 5 + 5 * 5). |
| 1630 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( | 1659 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( |
| 1631 sqrt(static_cast<double>(5 * 5 + 5 * 5))); | 1660 sqrt(static_cast<double>(5 * 5 + 5 * 5))); |
| 1632 | 1661 |
| 1633 // First, tap. Then, do a scroll using the same touch-id. | 1662 // First, tap. Then, do a scroll using the same touch-id. |
| 1634 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1663 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1635 new GestureEventConsumeDelegate()); | 1664 new GestureEventConsumeDelegate()); |
| 1636 TimedEvents tes; | 1665 TimedEvents tes; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1672 kTouchId, tes.LeapForward(1000)); | 1701 kTouchId, tes.LeapForward(1000)); |
| 1673 DispatchEventUsingWindowDispatcher(&press1); | 1702 DispatchEventUsingWindowDispatcher(&press1); |
| 1674 EXPECT_FALSE(delegate->tap()); | 1703 EXPECT_FALSE(delegate->tap()); |
| 1675 EXPECT_TRUE(delegate->tap_down()); | 1704 EXPECT_TRUE(delegate->tap_down()); |
| 1676 EXPECT_FALSE(delegate->tap_cancel()); | 1705 EXPECT_FALSE(delegate->tap_cancel()); |
| 1677 EXPECT_FALSE(delegate->scroll_begin()); | 1706 EXPECT_FALSE(delegate->scroll_begin()); |
| 1678 EXPECT_FALSE(delegate->scroll_update()); | 1707 EXPECT_FALSE(delegate->scroll_update()); |
| 1679 EXPECT_FALSE(delegate->scroll_end()); | 1708 EXPECT_FALSE(delegate->scroll_end()); |
| 1680 | 1709 |
| 1681 // Get rid of touch slop. | 1710 // Get rid of touch slop. |
| 1682 ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::Point(106, 206), | 1711 ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::Point(116, 216), |
| 1683 kTouchId, tes.Now()); | 1712 kTouchId, tes.Now()); |
| 1684 DispatchEventUsingWindowDispatcher(&move_remove_slop); | 1713 DispatchEventUsingWindowDispatcher(&move_remove_slop); |
| 1685 EXPECT_TRUE(delegate->tap_cancel()); | 1714 EXPECT_TRUE(delegate->tap_cancel()); |
| 1686 EXPECT_TRUE(delegate->scroll_begin()); | 1715 EXPECT_TRUE(delegate->scroll_begin()); |
| 1687 EXPECT_FALSE(delegate->scroll_update()); | 1716 EXPECT_TRUE(delegate->scroll_update()); |
|
sadrul
2014/04/25 13:44:12
This expectation change is because we changed the
tdresser
2014/04/25 16:46:34
Correct. Trying to get rid of the touch slop exact
| |
| 1688 EXPECT_EQ(5, delegate->scroll_x_hint()); | 1717 EXPECT_EQ(15, delegate->scroll_x_hint()); |
| 1689 EXPECT_EQ(5, delegate->scroll_y_hint()); | 1718 EXPECT_EQ(15, delegate->scroll_y_hint()); |
| 1690 | 1719 |
| 1691 delegate->Reset(); | 1720 delegate->Reset(); |
| 1692 | 1721 |
| 1693 // Move the touch-point enough so that it is considered as a scroll. This | 1722 // Move the touch-point enough so that it is considered as a scroll. This |
| 1694 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. | 1723 // should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures. |
| 1695 // The first movement is diagonal, to ensure that we have a free scroll, | 1724 // The first movement is diagonal, to ensure that we have a free scroll, |
| 1696 // and not a rail scroll. | 1725 // and not a rail scroll. |
| 1697 delegate->Reset(); | 1726 delegate->Reset(); |
| 1698 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(135, 235), | 1727 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(135, 235), |
| 1699 kTouchId, tes.Now()); | 1728 kTouchId, tes.Now()); |
| 1700 DispatchEventUsingWindowDispatcher(&move); | 1729 DispatchEventUsingWindowDispatcher(&move); |
| 1701 EXPECT_FALSE(delegate->tap()); | 1730 EXPECT_FALSE(delegate->tap()); |
| 1702 EXPECT_FALSE(delegate->tap_down()); | 1731 EXPECT_FALSE(delegate->tap_down()); |
| 1703 EXPECT_FALSE(delegate->tap_cancel()); | 1732 EXPECT_FALSE(delegate->tap_cancel()); |
| 1704 EXPECT_FALSE(delegate->scroll_begin()); | 1733 EXPECT_FALSE(delegate->scroll_begin()); |
| 1705 EXPECT_TRUE(delegate->scroll_update()); | 1734 EXPECT_TRUE(delegate->scroll_update()); |
| 1706 EXPECT_FALSE(delegate->scroll_end()); | 1735 EXPECT_FALSE(delegate->scroll_end()); |
| 1707 EXPECT_EQ(29, delegate->scroll_x()); | 1736 EXPECT_EQ(19, delegate->scroll_x()); |
| 1708 EXPECT_EQ(29, delegate->scroll_y()); | 1737 EXPECT_EQ(19, delegate->scroll_y()); |
| 1709 | 1738 |
| 1710 // Move some more to generate a few more scroll updates. | 1739 // Move some more to generate a few more scroll updates. |
| 1711 delegate->Reset(); | 1740 delegate->Reset(); |
| 1712 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(115, 216), | 1741 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(115, 216), |
| 1713 kTouchId, tes.Now()); | 1742 kTouchId, tes.Now()); |
| 1714 DispatchEventUsingWindowDispatcher(&move1); | 1743 DispatchEventUsingWindowDispatcher(&move1); |
| 1715 EXPECT_FALSE(delegate->tap()); | 1744 EXPECT_FALSE(delegate->tap()); |
| 1716 EXPECT_FALSE(delegate->tap_down()); | 1745 EXPECT_FALSE(delegate->tap_down()); |
| 1717 EXPECT_FALSE(delegate->tap_cancel()); | 1746 EXPECT_FALSE(delegate->tap_cancel()); |
| 1718 EXPECT_FALSE(delegate->scroll_begin()); | 1747 EXPECT_FALSE(delegate->scroll_begin()); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1743 DispatchEventUsingWindowDispatcher(&release1); | 1772 DispatchEventUsingWindowDispatcher(&release1); |
| 1744 EXPECT_FALSE(delegate->tap()); | 1773 EXPECT_FALSE(delegate->tap()); |
| 1745 EXPECT_FALSE(delegate->tap_down()); | 1774 EXPECT_FALSE(delegate->tap_down()); |
| 1746 EXPECT_FALSE(delegate->tap_cancel()); | 1775 EXPECT_FALSE(delegate->tap_cancel()); |
| 1747 EXPECT_FALSE(delegate->scroll_begin()); | 1776 EXPECT_FALSE(delegate->scroll_begin()); |
| 1748 EXPECT_FALSE(delegate->scroll_update()); | 1777 EXPECT_FALSE(delegate->scroll_update()); |
| 1749 EXPECT_FALSE(delegate->scroll_end()); | 1778 EXPECT_FALSE(delegate->scroll_end()); |
| 1750 EXPECT_TRUE(delegate->fling()); | 1779 EXPECT_TRUE(delegate->fling()); |
| 1751 } | 1780 } |
| 1752 | 1781 |
| 1753 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { | 1782 TEST_P(GestureRecognizerTest, AsynchronousGestureRecognition) { |
| 1783 // TODO(tdresser): enable this test with unified GR once two finger tap is | |
| 1784 // supported. See crbug.com/354396. | |
| 1785 if (UsingUnifiedGR()) | |
| 1786 return; | |
| 1754 scoped_ptr<QueueTouchEventDelegate> queued_delegate( | 1787 scoped_ptr<QueueTouchEventDelegate> queued_delegate( |
| 1755 new QueueTouchEventDelegate(host()->dispatcher())); | 1788 new QueueTouchEventDelegate(host()->dispatcher())); |
| 1756 const int kWindowWidth = 123; | 1789 const int kWindowWidth = 123; |
| 1757 const int kWindowHeight = 45; | 1790 const int kWindowHeight = 45; |
| 1758 const int kTouchId1 = 6; | 1791 const int kTouchId1 = 6; |
| 1759 const int kTouchId2 = 4; | 1792 const int kTouchId2 = 4; |
| 1760 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 1793 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 1761 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( | 1794 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( |
| 1762 queued_delegate.get(), -1234, bounds, root_window())); | 1795 queued_delegate.get(), -1234, bounds, root_window())); |
| 1763 | 1796 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1935 EXPECT_FALSE(queued_delegate->end()); | 1968 EXPECT_FALSE(queued_delegate->end()); |
| 1936 EXPECT_TRUE(queued_delegate->scroll_begin()); | 1969 EXPECT_TRUE(queued_delegate->scroll_begin()); |
| 1937 EXPECT_FALSE(queued_delegate->scroll_update()); | 1970 EXPECT_FALSE(queued_delegate->scroll_update()); |
| 1938 EXPECT_FALSE(queued_delegate->scroll_end()); | 1971 EXPECT_FALSE(queued_delegate->scroll_end()); |
| 1939 EXPECT_TRUE(queued_delegate->pinch_begin()); | 1972 EXPECT_TRUE(queued_delegate->pinch_begin()); |
| 1940 EXPECT_FALSE(queued_delegate->pinch_update()); | 1973 EXPECT_FALSE(queued_delegate->pinch_update()); |
| 1941 EXPECT_FALSE(queued_delegate->pinch_end()); | 1974 EXPECT_FALSE(queued_delegate->pinch_end()); |
| 1942 } | 1975 } |
| 1943 | 1976 |
| 1944 // Check that appropriate touch events generate pinch gesture events. | 1977 // Check that appropriate touch events generate pinch gesture events. |
| 1945 TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) { | 1978 TEST_P(GestureRecognizerTest, GestureEventPinchFromScroll) { |
| 1979 // Disabled for unified GR due to differences in when pinch begin is sent. The | |
| 1980 // Aura GR sends it earlier than is necessary. | |
| 1981 if (UsingUnifiedGR()) | |
| 1982 return; | |
| 1983 | |
| 1946 scoped_ptr<GestureEventConsumeDelegate> delegate( | 1984 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 1947 new GestureEventConsumeDelegate()); | 1985 new GestureEventConsumeDelegate()); |
| 1948 TimedEvents tes; | 1986 TimedEvents tes; |
| 1949 const int kWindowWidth = 300; | 1987 const int kWindowWidth = 300; |
| 1950 const int kWindowHeight = 400; | 1988 const int kWindowHeight = 400; |
| 1951 const int kTouchId1 = 5; | 1989 const int kTouchId1 = 5; |
| 1952 const int kTouchId2 = 3; | 1990 const int kTouchId2 = 3; |
| 1953 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 1991 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
| 1954 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 1992 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 1955 delegate.get(), -1234, bounds, root_window())); | 1993 delegate.get(), -1234, bounds, root_window())); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2020 | 2058 |
| 2021 // Move the second finger. This should still generate a scroll. | 2059 // Move the second finger. This should still generate a scroll. |
| 2022 delegate->Reset(); | 2060 delegate->Reset(); |
| 2023 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 2061 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
| 2024 kTouchId2, tes.Now()); | 2062 kTouchId2, tes.Now()); |
| 2025 DispatchEventUsingWindowDispatcher(&move5); | 2063 DispatchEventUsingWindowDispatcher(&move5); |
| 2026 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 2064 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 2027 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 2065 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 2028 } | 2066 } |
| 2029 | 2067 |
| 2030 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { | 2068 TEST_P(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { |
| 2031 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2069 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2032 new GestureEventConsumeDelegate()); | 2070 new GestureEventConsumeDelegate()); |
| 2033 TimedEvents tes; | 2071 TimedEvents tes; |
| 2034 const int kWindowWidth = 300; | 2072 const int kWindowWidth = 300; |
| 2035 const int kWindowHeight = 400; | 2073 const int kWindowHeight = 400; |
| 2036 const int kTouchId1 = 5; | 2074 const int kTouchId1 = 5; |
| 2037 const int kTouchId2 = 3; | 2075 const int kTouchId2 = 3; |
| 2038 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 2076 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
| 2039 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2077 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2040 delegate.get(), -1234, bounds, root_window())); | 2078 delegate.get(), -1234, bounds, root_window())); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2068 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId2, delegate.get()); | 2106 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId2, delegate.get()); |
| 2069 EXPECT_TRUE(delegate->scroll_update()); | 2107 EXPECT_TRUE(delegate->scroll_update()); |
| 2070 | 2108 |
| 2071 // Pinch again | 2109 // Pinch again |
| 2072 delegate->Reset(); | 2110 delegate->Reset(); |
| 2073 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 2111 ui::TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 2074 kTouchId1, tes.Now()); | 2112 kTouchId1, tes.Now()); |
| 2075 DispatchEventUsingWindowDispatcher(&press3); | 2113 DispatchEventUsingWindowDispatcher(&press3); |
| 2076 // Now the touch points are close. So we will go into two finger tap. | 2114 // Now the touch points are close. So we will go into two finger tap. |
| 2077 // Move the touch-point enough to break two-finger-tap and enter pinch. | 2115 // Move the touch-point enough to break two-finger-tap and enter pinch. |
| 2078 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202), | 2116 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 50), |
| 2079 kTouchId1, tes.Now()); | 2117 kTouchId1, tes.Now()); |
| 2080 DispatchEventUsingWindowDispatcher(&move2); | 2118 DispatchEventUsingWindowDispatcher(&move2); |
| 2081 EXPECT_TRUE(delegate->pinch_begin()); | 2119 EXPECT_TRUE(delegate->pinch_begin()); |
| 2082 | 2120 |
| 2083 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get()); | 2121 tes.SendScrollEvent(event_processor(), 230, 280, kTouchId1, delegate.get()); |
| 2084 EXPECT_TRUE(delegate->pinch_update()); | 2122 EXPECT_TRUE(delegate->pinch_update()); |
| 2085 } | 2123 } |
| 2086 | 2124 |
| 2087 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { | 2125 TEST_P(GestureRecognizerTest, GestureEventPinchFromTap) { |
| 2126 // TODO(tdresser): enable this test with unified GR once two finger tap. | |
| 2127 if (UsingUnifiedGR()) | |
| 2128 return; | |
| 2129 | |
| 2088 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2130 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2089 new GestureEventConsumeDelegate()); | 2131 new GestureEventConsumeDelegate()); |
| 2090 TimedEvents tes; | 2132 TimedEvents tes; |
| 2091 const int kWindowWidth = 300; | 2133 const int kWindowWidth = 300; |
| 2092 const int kWindowHeight = 400; | 2134 const int kWindowHeight = 400; |
| 2093 const int kTouchId1 = 3; | 2135 const int kTouchId1 = 3; |
| 2094 const int kTouchId2 = 5; | 2136 const int kTouchId2 = 5; |
| 2095 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); | 2137 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); |
| 2096 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2138 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2097 delegate.get(), -1234, bounds, root_window())); | 2139 delegate.get(), -1234, bounds, root_window())); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2151 | 2193 |
| 2152 // Move the second finger. This should still generate a scroll. | 2194 // Move the second finger. This should still generate a scroll. |
| 2153 delegate->Reset(); | 2195 delegate->Reset(); |
| 2154 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), | 2196 ui::TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), |
| 2155 kTouchId2, tes.Now()); | 2197 kTouchId2, tes.Now()); |
| 2156 DispatchEventUsingWindowDispatcher(&move5); | 2198 DispatchEventUsingWindowDispatcher(&move5); |
| 2157 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); | 2199 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); |
| 2158 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); | 2200 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 2159 } | 2201 } |
| 2160 | 2202 |
| 2161 TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { | 2203 TEST_P(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) { |
| 2162 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2204 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2163 new GestureEventConsumeDelegate()); | 2205 new GestureEventConsumeDelegate()); |
| 2164 TimedEvents tes; | 2206 TimedEvents tes; |
| 2165 | 2207 |
| 2166 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2208 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2167 6, tes.Now()); | 2209 6, tes.Now()); |
| 2168 DispatchEventUsingWindowDispatcher(&release1); | 2210 DispatchEventUsingWindowDispatcher(&release1); |
| 2169 EXPECT_FALSE(delegate->tap()); | 2211 EXPECT_FALSE(delegate->tap()); |
| 2170 EXPECT_FALSE(delegate->tap_down()); | 2212 EXPECT_FALSE(delegate->tap_down()); |
| 2171 } | 2213 } |
| 2172 | 2214 |
| 2173 // Check that a touch is locked to the window of the closest current touch | 2215 // Check that a touch is locked to the window of the closest current touch |
| 2174 // within max_separation_for_gesture_touches_in_pixels | 2216 // within max_separation_for_gesture_touches_in_pixels |
| 2175 TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { | 2217 TEST_P(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) { |
| 2176 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl(); | 2218 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl(); |
| 2177 TimedEvents tes; | 2219 TimedEvents tes; |
| 2178 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 2220 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 2179 | 2221 |
| 2180 ui::GestureConsumer* target; | 2222 ui::GestureConsumer* target; |
| 2181 const int kNumWindows = 4; | 2223 const int kNumWindows = 4; |
| 2182 | 2224 |
| 2183 scoped_ptr<GestureEventConsumeDelegate*[]> delegates( | 2225 scoped_ptr<GestureEventConsumeDelegate*[]> delegates( |
| 2184 new GestureEventConsumeDelegate*[kNumWindows]); | 2226 new GestureEventConsumeDelegate*[kNumWindows]); |
| 2185 | 2227 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2251 | 2293 |
| 2252 for (int i = 0; i < kNumWindows; ++i) { | 2294 for (int i = 0; i < kNumWindows; ++i) { |
| 2253 // Delete windows before deleting delegates. | 2295 // Delete windows before deleting delegates. |
| 2254 delete windows[i]; | 2296 delete windows[i]; |
| 2255 delete delegates[i]; | 2297 delete delegates[i]; |
| 2256 } | 2298 } |
| 2257 } | 2299 } |
| 2258 | 2300 |
| 2259 // Check that a touch's target will not be effected by a touch on a different | 2301 // Check that a touch's target will not be effected by a touch on a different |
| 2260 // screen. | 2302 // screen. |
| 2261 TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) { | 2303 TEST_P(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) { |
| 2262 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2304 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2263 new GestureEventConsumeDelegate()); | 2305 new GestureEventConsumeDelegate()); |
| 2264 gfx::Rect bounds(0, 0, 10, 10); | 2306 gfx::Rect bounds(0, 0, 10, 10); |
| 2265 scoped_ptr<aura::Window> window( | 2307 scoped_ptr<aura::Window> window( |
| 2266 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); | 2308 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); |
| 2267 | 2309 |
| 2268 const int kTouchId1 = 8; | 2310 const int kTouchId1 = 8; |
| 2269 const int kTouchId2 = 2; | 2311 const int kTouchId2 = 2; |
| 2270 TimedEvents tes; | 2312 TimedEvents tes; |
| 2271 | 2313 |
| 2272 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(5, 5), | 2314 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(5, 5), |
| 2273 kTouchId1, tes.Now()); | 2315 kTouchId1, tes.Now()); |
| 2274 press1.set_source_device_id(1); | 2316 press1.set_source_device_id(1); |
| 2275 DispatchEventUsingWindowDispatcher(&press1); | 2317 DispatchEventUsingWindowDispatcher(&press1); |
| 2276 | 2318 |
| 2277 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), | 2319 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), |
| 2278 kTouchId2, tes.Now()); | 2320 kTouchId2, tes.Now()); |
| 2279 press2.set_source_device_id(2); | 2321 press2.set_source_device_id(2); |
| 2280 DispatchEventUsingWindowDispatcher(&press2); | 2322 DispatchEventUsingWindowDispatcher(&press2); |
| 2281 | 2323 |
| 2282 // The second press should not have been locked to the same target as the | 2324 // The second press should not have been locked to the same target as the |
| 2283 // first, as they occured on different displays. | 2325 // first, as they occured on different displays. |
| 2284 EXPECT_NE( | 2326 EXPECT_NE( |
| 2285 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1), | 2327 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1), |
| 2286 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); | 2328 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); |
| 2287 } | 2329 } |
| 2288 | 2330 |
| 2289 // Check that touch events outside the root window are still handled | 2331 // Check that touch events outside the root window are still handled |
| 2290 // by the root window's gesture sequence. | 2332 // by the root window's gesture sequence. |
| 2291 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { | 2333 TEST_P(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { |
| 2334 // TODO(tdresser): write a version of this test for the unified GR. | |
| 2335 if (UsingUnifiedGR()) | |
| 2336 return; | |
| 2337 | |
| 2292 TestGestureRecognizer* gesture_recognizer = | 2338 TestGestureRecognizer* gesture_recognizer = |
| 2293 new TestGestureRecognizer(); | 2339 new TestGestureRecognizer(); |
| 2294 TimedEvents tes; | 2340 TimedEvents tes; |
| 2295 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 2341 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 2296 | 2342 |
| 2297 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( | 2343 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( |
| 2298 gfx::Rect(-100, -100, 2000, 2000), root_window())); | 2344 gfx::Rect(-100, -100, 2000, 2000), root_window())); |
| 2299 | 2345 |
| 2300 ui::GestureSequence* window_gesture_sequence = | 2346 ui::GestureSequence* window_gesture_sequence = |
| 2301 gesture_recognizer->GetGestureSequenceForTesting(window.get()); | 2347 gesture_recognizer->GetGestureSequenceForTesting(window.get()); |
| 2302 | 2348 |
| 2303 ui::GestureSequence* root_window_gesture_sequence = | 2349 ui::GestureSequence* root_window_gesture_sequence = |
| 2304 gesture_recognizer->GetGestureSequenceForTesting(root_window()); | 2350 gesture_recognizer->GetGestureSequenceForTesting(root_window()); |
| 2305 | 2351 |
| 2306 gfx::Point pos1(-10, -10); | 2352 gfx::Point pos1(-10, -10); |
| 2307 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now()); | 2353 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, tes.Now()); |
| 2308 DispatchEventUsingWindowDispatcher(&press1); | 2354 DispatchEventUsingWindowDispatcher(&press1); |
| 2309 | 2355 |
| 2310 gfx::Point pos2(1000, 1000); | 2356 gfx::Point pos2(1000, 1000); |
| 2311 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now()); | 2357 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, tes.Now()); |
| 2312 DispatchEventUsingWindowDispatcher(&press2); | 2358 DispatchEventUsingWindowDispatcher(&press2); |
| 2313 | 2359 |
| 2314 // As these presses were outside the root window, they should be | 2360 // As these presses were outside the root window, they should be |
| 2315 // associated with the root window. | 2361 // associated with the root window. |
| 2316 EXPECT_EQ(0, window_gesture_sequence->point_count()); | 2362 EXPECT_EQ(0, window_gesture_sequence->point_count()); |
| 2317 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); | 2363 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); |
| 2318 } | 2364 } |
| 2319 | 2365 |
| 2320 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { | 2366 TEST_P(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { |
| 2321 scoped_ptr<QueueTouchEventDelegate> delegate( | 2367 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 2322 new QueueTouchEventDelegate(host()->dispatcher())); | 2368 new QueueTouchEventDelegate(host()->dispatcher())); |
| 2323 TimedEvents tes; | 2369 TimedEvents tes; |
| 2324 const int kTouchId = 2; | 2370 const int kTouchId = 2; |
| 2325 gfx::Rect bounds(100, 200, 100, 100); | 2371 gfx::Rect bounds(100, 200, 100, 100); |
| 2326 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2372 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2327 delegate.get(), -1234, bounds, root_window())); | 2373 delegate.get(), -1234, bounds, root_window())); |
| 2328 delegate->set_window(window.get()); | 2374 delegate->set_window(window.get()); |
| 2329 | 2375 |
| 2330 delegate->Reset(); | 2376 delegate->Reset(); |
| 2331 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 2377 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 2332 kTouchId, tes.Now()); | 2378 kTouchId, tes.Now()); |
| 2333 DispatchEventUsingWindowDispatcher(&press); | 2379 DispatchEventUsingWindowDispatcher(&press); |
| 2334 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2380 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2335 kTouchId, tes.LeapForward(50)); | 2381 kTouchId, tes.LeapForward(50)); |
| 2336 DispatchEventUsingWindowDispatcher(&release); | 2382 DispatchEventUsingWindowDispatcher(&release); |
| 2337 | 2383 |
| 2338 delegate->Reset(); | 2384 delegate->Reset(); |
| 2339 delegate->ReceivedAck(); | 2385 delegate->ReceivedAck(); |
| 2340 EXPECT_TRUE(delegate->tap_down()); | 2386 EXPECT_TRUE(delegate->tap_down()); |
| 2341 delegate->Reset(); | 2387 delegate->Reset(); |
| 2342 delegate->ReceivedAckPreventDefaulted(); | 2388 delegate->ReceivedAckPreventDefaulted(); |
| 2343 EXPECT_FALSE(delegate->tap()); | 2389 EXPECT_FALSE(delegate->tap()); |
| 2344 EXPECT_TRUE(delegate->tap_cancel()); | 2390 EXPECT_TRUE(delegate->tap_cancel()); |
| 2345 } | 2391 } |
| 2346 | 2392 |
| 2347 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { | 2393 TEST_P(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { |
| 2394 // Disabled for unified GR due to differences in when pinch begin is sent. The | |
| 2395 // Aura GR sends it earlier than is necessary. | |
| 2396 if (UsingUnifiedGR()) | |
| 2397 return; | |
| 2398 | |
| 2348 scoped_ptr<QueueTouchEventDelegate> delegate( | 2399 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 2349 new QueueTouchEventDelegate(host()->dispatcher())); | 2400 new QueueTouchEventDelegate(host()->dispatcher())); |
| 2350 TimedEvents tes; | 2401 TimedEvents tes; |
| 2351 const int kTouchId1 = 7; | 2402 const int kTouchId1 = 7; |
| 2352 const int kTouchId2 = 5; | 2403 const int kTouchId2 = 5; |
| 2353 gfx::Rect bounds(10, 20, 100, 100); | 2404 gfx::Rect bounds(10, 20, 100, 100); |
| 2354 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2405 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2355 delegate.get(), -1234, bounds, root_window())); | 2406 delegate.get(), -1234, bounds, root_window())); |
| 2356 delegate->set_window(window.get()); | 2407 delegate->set_window(window.get()); |
| 2357 | 2408 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2431 delegate->ReceivedAckPreventDefaulted(); | 2482 delegate->ReceivedAckPreventDefaulted(); |
| 2432 EXPECT_TRUE(delegate->pinch_end()); | 2483 EXPECT_TRUE(delegate->pinch_end()); |
| 2433 EXPECT_TRUE(delegate->end()); | 2484 EXPECT_TRUE(delegate->end()); |
| 2434 | 2485 |
| 2435 delegate->Reset(); | 2486 delegate->Reset(); |
| 2436 delegate->ReceivedAckPreventDefaulted(); | 2487 delegate->ReceivedAckPreventDefaulted(); |
| 2437 EXPECT_TRUE(delegate->scroll_end()); | 2488 EXPECT_TRUE(delegate->scroll_end()); |
| 2438 EXPECT_TRUE(delegate->end()); | 2489 EXPECT_TRUE(delegate->end()); |
| 2439 } | 2490 } |
| 2440 | 2491 |
| 2441 TEST_F(GestureRecognizerTest, GestureEndLocation) { | 2492 TEST_P(GestureRecognizerTest, GestureEndLocation) { |
| 2442 GestureEventConsumeDelegate delegate; | 2493 GestureEventConsumeDelegate delegate; |
| 2443 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2494 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2444 &delegate, -1234, gfx::Rect(10, 10, 300, 300), root_window())); | 2495 &delegate, -1234, gfx::Rect(10, 10, 300, 300), root_window())); |
| 2445 EventGenerator generator(root_window(), window.get()); | 2496 EventGenerator generator(root_window(), window.get()); |
| 2446 const gfx::Point begin(20, 20); | 2497 const gfx::Point begin(20, 20); |
| 2447 const gfx::Point end(150, 150); | 2498 const gfx::Point end(150, 150); |
| 2448 const gfx::Vector2d window_offset = | 2499 const gfx::Vector2d window_offset = |
| 2449 window->bounds().origin().OffsetFromOrigin(); | 2500 window->bounds().origin().OffsetFromOrigin(); |
| 2450 generator.GestureScrollSequence(begin, end, | 2501 generator.GestureScrollSequence(begin, end, |
| 2451 base::TimeDelta::FromMilliseconds(20), | 2502 base::TimeDelta::FromMilliseconds(20), |
| 2452 10); | 2503 10); |
| 2453 EXPECT_EQ((begin - window_offset).ToString(), | 2504 EXPECT_EQ((begin - window_offset).ToString(), |
| 2454 delegate.scroll_begin_position().ToString()); | 2505 delegate.scroll_begin_position().ToString()); |
| 2455 EXPECT_EQ((end - window_offset).ToString(), | 2506 EXPECT_EQ((end - window_offset).ToString(), |
| 2456 delegate.gesture_end_location().ToString()); | 2507 delegate.gesture_end_location().ToString()); |
| 2457 } | 2508 } |
| 2458 | 2509 |
| 2459 TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) { | 2510 TEST_P(GestureRecognizerTest, CaptureSendsGestureEnd) { |
| 2460 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2511 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2461 new GestureEventConsumeDelegate()); | 2512 new GestureEventConsumeDelegate()); |
| 2462 TestGestureRecognizer* gesture_recognizer = | 2513 TestGestureRecognizer* gesture_recognizer = |
| 2463 new TestGestureRecognizer(); | 2514 new TestGestureRecognizer(); |
| 2464 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 2515 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 2465 | 2516 |
| 2466 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2517 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2467 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); | 2518 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); |
| 2468 EventGenerator generator(root_window()); | 2519 EventGenerator generator(root_window()); |
| 2469 | 2520 |
| 2470 generator.MoveMouseRelativeTo(window.get(), gfx::Point(10, 10)); | 2521 generator.MoveMouseRelativeTo(window.get(), gfx::Point(10, 10)); |
| 2471 generator.PressTouch(); | 2522 generator.PressTouch(); |
| 2472 RunAllPendingInMessageLoop(); | 2523 RunAllPendingInMessageLoop(); |
| 2473 | 2524 |
| 2474 EXPECT_TRUE(delegate->tap_down()); | 2525 EXPECT_TRUE(delegate->tap_down()); |
| 2475 | 2526 |
| 2476 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds( | 2527 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds( |
| 2477 gfx::Rect(10, 10, 200, 200), root_window())); | 2528 gfx::Rect(10, 10, 200, 200), root_window())); |
| 2478 capture->SetCapture(); | 2529 capture->SetCapture(); |
| 2479 RunAllPendingInMessageLoop(); | 2530 RunAllPendingInMessageLoop(); |
| 2480 | 2531 |
| 2481 EXPECT_TRUE(delegate->end()); | 2532 EXPECT_TRUE(delegate->end()); |
| 2482 EXPECT_TRUE(delegate->tap_cancel()); | 2533 EXPECT_TRUE(delegate->tap_cancel()); |
| 2483 } | 2534 } |
| 2484 | 2535 |
| 2485 // Check that previous touch actions that are completely finished (either | 2536 // Check that previous touch actions that are completely finished (either |
| 2486 // released or cancelled), do not receive extra synthetic cancels upon change of | 2537 // released or cancelled), do not receive extra synthetic cancels upon change of |
| 2487 // capture. | 2538 // capture. |
| 2488 TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) { | 2539 TEST_P(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) { |
| 2489 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2540 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2490 new GestureEventConsumeDelegate()); | 2541 new GestureEventConsumeDelegate()); |
| 2491 scoped_ptr<TestEventHandler> handler(new TestEventHandler); | 2542 scoped_ptr<TestEventHandler> handler(new TestEventHandler); |
| 2492 root_window()->AddPreTargetHandler(handler.get()); | 2543 root_window()->AddPreTargetHandler(handler.get()); |
| 2493 | 2544 |
| 2494 // Create a window and set it as the capture window. | 2545 // Create a window and set it as the capture window. |
| 2495 scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate(delegate.get(), | 2546 scoped_ptr<aura::Window> window1(CreateTestWindowWithDelegate(delegate.get(), |
| 2496 -1234, gfx::Rect(10, 10, 300, 300), root_window())); | 2547 -1234, gfx::Rect(10, 10, 300, 300), root_window())); |
| 2497 window1->SetCapture(); | 2548 window1->SetCapture(); |
| 2498 | 2549 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2531 gfx::Rect(100, 100, 300, 300), root_window())); | 2582 gfx::Rect(100, 100, 300, 300), root_window())); |
| 2532 window2->SetCapture(); | 2583 window2->SetCapture(); |
| 2533 RunAllPendingInMessageLoop(); | 2584 RunAllPendingInMessageLoop(); |
| 2534 // Check that setting capture does not generate any synthetic touch-cancels | 2585 // Check that setting capture does not generate any synthetic touch-cancels |
| 2535 // for the two previously finished touch actions. | 2586 // for the two previously finished touch actions. |
| 2536 EXPECT_EQ(1, handler->touch_cancelled_count()); | 2587 EXPECT_EQ(1, handler->touch_cancelled_count()); |
| 2537 | 2588 |
| 2538 root_window()->RemovePreTargetHandler(handler.get()); | 2589 root_window()->RemovePreTargetHandler(handler.get()); |
| 2539 } | 2590 } |
| 2540 | 2591 |
| 2541 TEST_F(GestureRecognizerTest, PressDoesNotCrash) { | 2592 // Tests that a press with the same touch id as an existing touch is ignored. |
| 2593 TEST_P(GestureRecognizerTest, PressDoesNotCrash) { | |
| 2542 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2594 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2543 new GestureEventConsumeDelegate()); | 2595 new GestureEventConsumeDelegate()); |
| 2544 TestGestureRecognizer* gesture_recognizer = | 2596 TestGestureRecognizer* gesture_recognizer = |
| 2545 new TestGestureRecognizer(); | 2597 new TestGestureRecognizer(); |
| 2546 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); | 2598 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); |
| 2547 TimedEvents tes; | 2599 TimedEvents tes; |
| 2548 | 2600 |
| 2549 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2601 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2550 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); | 2602 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window())); |
| 2551 | 2603 |
| 2552 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now()); | 2604 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, tes.Now()); |
| 2553 press.set_radius_x(40); | 2605 press.set_radius_x(40); |
| 2554 DispatchEventUsingWindowDispatcher(&press); | 2606 DispatchEventUsingWindowDispatcher(&press); |
| 2555 EXPECT_TRUE(delegate->tap_down()); | 2607 EXPECT_TRUE(delegate->tap_down()); |
| 2556 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), | 2608 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), |
| 2557 delegate->bounding_box().ToString()); | 2609 delegate->bounding_box().ToString()); |
| 2558 delegate->Reset(); | 2610 delegate->Reset(); |
| 2559 | 2611 |
| 2560 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, tes.Now()); | 2612 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, tes.Now()); |
| 2561 DispatchEventUsingWindowDispatcher(&press2); | 2613 DispatchEventUsingWindowDispatcher(&press2); |
| 2562 | 2614 |
| 2563 // This new press should not generate a tap-down. | 2615 // This new press should not generate a tap-down. |
| 2564 EXPECT_FALSE(delegate->begin()); | 2616 EXPECT_FALSE(delegate->begin()); |
| 2565 EXPECT_FALSE(delegate->tap_down()); | 2617 EXPECT_FALSE(delegate->tap_down()); |
| 2566 EXPECT_FALSE(delegate->tap_cancel()); | 2618 EXPECT_FALSE(delegate->tap_cancel()); |
| 2567 EXPECT_FALSE(delegate->scroll_begin()); | 2619 EXPECT_FALSE(delegate->scroll_begin()); |
| 2568 } | 2620 } |
| 2569 | 2621 |
| 2570 TEST_F(GestureRecognizerTest, TwoFingerTap) { | 2622 TEST_P(GestureRecognizerTest, TwoFingerTap) { |
| 2623 // TODO(tdresser): enable this test with unified GR once two finger tap is | |
| 2624 // supported. See crbug.com/354396. | |
| 2625 if (UsingUnifiedGR()) | |
| 2626 return; | |
| 2627 | |
| 2571 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2628 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2572 new GestureEventConsumeDelegate()); | 2629 new GestureEventConsumeDelegate()); |
| 2573 const int kWindowWidth = 123; | 2630 const int kWindowWidth = 123; |
| 2574 const int kWindowHeight = 45; | 2631 const int kWindowHeight = 45; |
| 2575 const int kTouchId1 = 2; | 2632 const int kTouchId1 = 2; |
| 2576 const int kTouchId2 = 3; | 2633 const int kTouchId2 = 3; |
| 2577 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2634 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2578 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2635 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2579 delegate.get(), -1234, bounds, root_window())); | 2636 delegate.get(), -1234, bounds, root_window())); |
| 2580 TimedEvents tes; | 2637 TimedEvents tes; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2648 EXPECT_FALSE(delegate->tap()); | 2705 EXPECT_FALSE(delegate->tap()); |
| 2649 EXPECT_FALSE(delegate->tap_down()); | 2706 EXPECT_FALSE(delegate->tap_down()); |
| 2650 EXPECT_FALSE(delegate->tap_cancel()); | 2707 EXPECT_FALSE(delegate->tap_cancel()); |
| 2651 EXPECT_FALSE(delegate->scroll_begin()); | 2708 EXPECT_FALSE(delegate->scroll_begin()); |
| 2652 EXPECT_FALSE(delegate->scroll_update()); | 2709 EXPECT_FALSE(delegate->scroll_update()); |
| 2653 EXPECT_FALSE(delegate->scroll_end()); | 2710 EXPECT_FALSE(delegate->scroll_end()); |
| 2654 EXPECT_TRUE(delegate->fling()); | 2711 EXPECT_TRUE(delegate->fling()); |
| 2655 EXPECT_FALSE(delegate->two_finger_tap()); | 2712 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2656 } | 2713 } |
| 2657 | 2714 |
| 2658 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { | 2715 TEST_P(GestureRecognizerTest, TwoFingerTapExpired) { |
| 2659 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2716 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2660 new GestureEventConsumeDelegate()); | 2717 new GestureEventConsumeDelegate()); |
| 2661 const int kWindowWidth = 123; | 2718 const int kWindowWidth = 123; |
| 2662 const int kWindowHeight = 45; | 2719 const int kWindowHeight = 45; |
| 2663 const int kTouchId1 = 2; | 2720 const int kTouchId1 = 2; |
| 2664 const int kTouchId2 = 3; | 2721 const int kTouchId2 = 3; |
| 2665 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2722 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2666 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2723 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2667 delegate.get(), -1234, bounds, root_window())); | 2724 delegate.get(), -1234, bounds, root_window())); |
| 2668 TimedEvents tes; | 2725 TimedEvents tes; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2689 // Make sure there is enough delay before the touch is released so that it is | 2746 // Make sure there is enough delay before the touch is released so that it is |
| 2690 // recognized as a tap. | 2747 // recognized as a tap. |
| 2691 delegate->Reset(); | 2748 delegate->Reset(); |
| 2692 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), | 2749 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), |
| 2693 kTouchId2, tes.LeapForward(50)); | 2750 kTouchId2, tes.LeapForward(50)); |
| 2694 | 2751 |
| 2695 DispatchEventUsingWindowDispatcher(&release2); | 2752 DispatchEventUsingWindowDispatcher(&release2); |
| 2696 EXPECT_FALSE(delegate->two_finger_tap()); | 2753 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2697 } | 2754 } |
| 2698 | 2755 |
| 2699 TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) { | 2756 TEST_P(GestureRecognizerTest, TwoFingerTapChangesToPinch) { |
| 2757 // TODO(tdresser): enable this test with unified GR once two finger tap is | |
| 2758 // supported. See crbug.com/354396. | |
| 2759 if (UsingUnifiedGR()) | |
| 2760 return; | |
| 2761 | |
| 2700 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2762 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2701 new GestureEventConsumeDelegate()); | 2763 new GestureEventConsumeDelegate()); |
| 2702 const int kWindowWidth = 123; | 2764 const int kWindowWidth = 123; |
| 2703 const int kWindowHeight = 45; | 2765 const int kWindowHeight = 45; |
| 2704 const int kTouchId1 = 2; | 2766 const int kTouchId1 = 2; |
| 2705 const int kTouchId2 = 3; | 2767 const int kTouchId2 = 3; |
| 2706 TimedEvents tes; | 2768 TimedEvents tes; |
| 2707 | 2769 |
| 2708 // Test moving first finger | 2770 // Test moving first finger |
| 2709 { | 2771 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2761 delegate->Reset(); | 2823 delegate->Reset(); |
| 2762 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2824 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2763 kTouchId1, tes.LeapForward(50)); | 2825 kTouchId1, tes.LeapForward(50)); |
| 2764 | 2826 |
| 2765 DispatchEventUsingWindowDispatcher(&release); | 2827 DispatchEventUsingWindowDispatcher(&release); |
| 2766 EXPECT_FALSE(delegate->two_finger_tap()); | 2828 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2767 EXPECT_TRUE(delegate->pinch_end()); | 2829 EXPECT_TRUE(delegate->pinch_end()); |
| 2768 } | 2830 } |
| 2769 } | 2831 } |
| 2770 | 2832 |
| 2771 TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { | 2833 TEST_P(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) { |
| 2834 // Disabled for unified GR due to differences in when pinch begin is sent. The | |
| 2835 // Aura GR sends it earlier than is necessary. | |
| 2836 if (UsingUnifiedGR()) | |
| 2837 return; | |
| 2838 | |
| 2772 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2839 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2773 new GestureEventConsumeDelegate()); | 2840 new GestureEventConsumeDelegate()); |
| 2774 const int kWindowWidth = 123; | 2841 const int kWindowWidth = 123; |
| 2775 const int kWindowHeight = 45; | 2842 const int kWindowHeight = 45; |
| 2776 const int kTouchId1 = 2; | 2843 const int kTouchId1 = 2; |
| 2777 const int kTouchId2 = 3; | 2844 const int kTouchId2 = 3; |
| 2778 TimedEvents tes; | 2845 TimedEvents tes; |
| 2779 | 2846 |
| 2780 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2847 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2781 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2848 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2798 // is recognized as a tap. | 2865 // is recognized as a tap. |
| 2799 delegate->Reset(); | 2866 delegate->Reset(); |
| 2800 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2867 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2801 kTouchId2, tes.LeapForward(50)); | 2868 kTouchId2, tes.LeapForward(50)); |
| 2802 | 2869 |
| 2803 DispatchEventUsingWindowDispatcher(&release); | 2870 DispatchEventUsingWindowDispatcher(&release); |
| 2804 EXPECT_FALSE(delegate->two_finger_tap()); | 2871 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2805 EXPECT_TRUE(delegate->pinch_end()); | 2872 EXPECT_TRUE(delegate->pinch_end()); |
| 2806 } | 2873 } |
| 2807 | 2874 |
| 2808 TEST_F(GestureRecognizerTest, MultiFingerSwipe) { | 2875 TEST_P(GestureRecognizerTest, MultiFingerSwipe) { |
| 2809 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2876 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2810 new GestureEventConsumeDelegate()); | 2877 new GestureEventConsumeDelegate()); |
| 2811 const int kWindowWidth = 123; | 2878 const int kWindowWidth = 123; |
| 2812 const int kWindowHeight = 45; | 2879 const int kWindowHeight = 45; |
| 2813 | 2880 |
| 2814 gfx::Rect bounds(5, 10, kWindowWidth, kWindowHeight); | 2881 gfx::Rect bounds(5, 10, kWindowWidth, kWindowHeight); |
| 2815 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 2882 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2816 delegate.get(), -1234, bounds, root_window())); | 2883 delegate.get(), -1234, bounds, root_window())); |
| 2817 | 2884 |
| 2818 const int kSteps = 15; | 2885 const int kSteps = 15; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2842 EXPECT_TRUE(delegate->swipe_left()); | 2909 EXPECT_TRUE(delegate->swipe_left()); |
| 2843 delegate->Reset(); | 2910 delegate->Reset(); |
| 2844 | 2911 |
| 2845 generator.GestureMultiFingerScroll( | 2912 generator.GestureMultiFingerScroll( |
| 2846 count, points, 1000, kSteps, 11 * kSteps, 0); | 2913 count, points, 1000, kSteps, 11 * kSteps, 0); |
| 2847 EXPECT_TRUE(delegate->swipe_right()); | 2914 EXPECT_TRUE(delegate->swipe_right()); |
| 2848 delegate->Reset(); | 2915 delegate->Reset(); |
| 2849 } | 2916 } |
| 2850 } | 2917 } |
| 2851 | 2918 |
| 2852 TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) { | 2919 TEST_P(GestureRecognizerTest, TwoFingerTapCancelled) { |
| 2853 scoped_ptr<GestureEventConsumeDelegate> delegate( | 2920 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2854 new GestureEventConsumeDelegate()); | 2921 new GestureEventConsumeDelegate()); |
| 2855 const int kWindowWidth = 123; | 2922 const int kWindowWidth = 123; |
| 2856 const int kWindowHeight = 45; | 2923 const int kWindowHeight = 45; |
| 2857 const int kTouchId1 = 2; | 2924 const int kTouchId1 = 2; |
| 2858 const int kTouchId2 = 3; | 2925 const int kTouchId2 = 3; |
| 2859 TimedEvents tes; | 2926 TimedEvents tes; |
| 2860 | 2927 |
| 2861 // Test canceling first finger. | 2928 // Test canceling first finger. |
| 2862 { | 2929 { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2916 // is recognized as a tap. | 2983 // is recognized as a tap. |
| 2917 delegate->Reset(); | 2984 delegate->Reset(); |
| 2918 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2985 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 2919 kTouchId1, tes.LeapForward(50)); | 2986 kTouchId1, tes.LeapForward(50)); |
| 2920 | 2987 |
| 2921 DispatchEventUsingWindowDispatcher(&release); | 2988 DispatchEventUsingWindowDispatcher(&release); |
| 2922 EXPECT_FALSE(delegate->two_finger_tap()); | 2989 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2923 } | 2990 } |
| 2924 } | 2991 } |
| 2925 | 2992 |
| 2926 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { | 2993 TEST_P(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { |
| 2994 // Disabled for unified GR due to differences in when scroll update is | |
| 2995 // sent. The Aura GR will never send a ScrollUpdate with a ScrollBegin, but | |
| 2996 // the unified GR will. | |
| 2997 if (UsingUnifiedGR()) | |
| 2998 return; | |
| 2999 | |
| 2927 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3000 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2928 new GestureEventConsumeDelegate()); | 3001 new GestureEventConsumeDelegate()); |
| 2929 const int kWindowWidth = 523; | 3002 const int kWindowWidth = 523; |
| 2930 const int kWindowHeight = 45; | 3003 const int kWindowHeight = 45; |
| 2931 const int kTouchId1 = 2; | 3004 const int kTouchId1 = 2; |
| 2932 const int kTouchId2 = 3; | 3005 const int kTouchId2 = 3; |
| 2933 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3006 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2934 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3007 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2935 delegate.get(), -1234, bounds, root_window())); | 3008 delegate.get(), -1234, bounds, root_window())); |
| 2936 TimedEvents tes; | 3009 TimedEvents tes; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2973 EXPECT_TRUE(delegate->scroll_begin()); | 3046 EXPECT_TRUE(delegate->scroll_begin()); |
| 2974 EXPECT_FALSE(delegate->scroll_update()); | 3047 EXPECT_FALSE(delegate->scroll_update()); |
| 2975 EXPECT_FALSE(delegate->scroll_end()); | 3048 EXPECT_FALSE(delegate->scroll_end()); |
| 2976 EXPECT_FALSE(delegate->long_press()); | 3049 EXPECT_FALSE(delegate->long_press()); |
| 2977 EXPECT_FALSE(delegate->two_finger_tap()); | 3050 EXPECT_FALSE(delegate->two_finger_tap()); |
| 2978 EXPECT_TRUE(delegate->pinch_begin()); | 3051 EXPECT_TRUE(delegate->pinch_begin()); |
| 2979 } | 3052 } |
| 2980 | 3053 |
| 2981 // Verifies if a window is the target of multiple touch-ids and we hide the | 3054 // Verifies if a window is the target of multiple touch-ids and we hide the |
| 2982 // window everything is cleaned up correctly. | 3055 // window everything is cleaned up correctly. |
| 2983 TEST_F(GestureRecognizerTest, FlushAllOnHide) { | 3056 TEST_P(GestureRecognizerTest, FlushAllOnHide) { |
| 2984 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3057 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2985 new GestureEventConsumeDelegate()); | 3058 new GestureEventConsumeDelegate()); |
| 2986 gfx::Rect bounds(0, 0, 200, 200); | 3059 gfx::Rect bounds(0, 0, 200, 200); |
| 2987 scoped_ptr<aura::Window> window( | 3060 scoped_ptr<aura::Window> window( |
| 2988 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); | 3061 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window())); |
| 2989 const int kTouchId1 = 8; | 3062 const int kTouchId1 = 8; |
| 2990 const int kTouchId2 = 2; | 3063 const int kTouchId2 = 2; |
| 2991 TimedEvents tes; | 3064 TimedEvents tes; |
| 2992 | 3065 |
| 2993 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), | 3066 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), |
| 2994 kTouchId1, tes.Now()); | 3067 kTouchId1, tes.Now()); |
| 2995 DispatchEventUsingWindowDispatcher(&press1); | 3068 DispatchEventUsingWindowDispatcher(&press1); |
| 2996 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), | 3069 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), |
| 2997 kTouchId2, tes.Now()); | 3070 kTouchId2, tes.Now()); |
| 2998 DispatchEventUsingWindowDispatcher(&press2); | 3071 DispatchEventUsingWindowDispatcher(&press2); |
| 2999 window->Hide(); | 3072 window->Hide(); |
| 3000 EXPECT_EQ(NULL, | 3073 EXPECT_EQ(NULL, |
| 3001 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); | 3074 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press1)); |
| 3002 EXPECT_EQ(NULL, | 3075 EXPECT_EQ(NULL, |
| 3003 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); | 3076 ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2)); |
| 3004 } | 3077 } |
| 3005 | 3078 |
| 3006 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { | 3079 TEST_P(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { |
| 3080 // TODO(tdresser): write a version of this test for the unified GR. | |
| 3081 if (UsingUnifiedGR()) | |
| 3082 return; | |
| 3083 | |
| 3007 scoped_ptr<QueueTouchEventDelegate> delegate( | 3084 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3008 new QueueTouchEventDelegate(host()->dispatcher())); | 3085 new QueueTouchEventDelegate(host()->dispatcher())); |
| 3009 const int kTouchId = 2; | 3086 const int kTouchId = 2; |
| 3010 gfx::Rect bounds(100, 200, 100, 100); | 3087 gfx::Rect bounds(100, 200, 100, 100); |
| 3011 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3088 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3012 delegate.get(), -1234, bounds, root_window())); | 3089 delegate.get(), -1234, bounds, root_window())); |
| 3013 delegate->set_window(window.get()); | 3090 delegate->set_window(window.get()); |
| 3014 TimedEvents tes; | 3091 TimedEvents tes; |
| 3015 | 3092 |
| 3016 TimerTestGestureRecognizer* gesture_recognizer = | 3093 TimerTestGestureRecognizer* gesture_recognizer = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3056 GestureEventConsumeDelegate::OnTouchEvent(touch); | 3133 GestureEventConsumeDelegate::OnTouchEvent(touch); |
| 3057 } | 3134 } |
| 3058 | 3135 |
| 3059 bool consume_touch_move_; | 3136 bool consume_touch_move_; |
| 3060 | 3137 |
| 3061 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); | 3138 DISALLOW_COPY_AND_ASSIGN(ConsumesTouchMovesDelegate); |
| 3062 }; | 3139 }; |
| 3063 | 3140 |
| 3064 // Same as GestureEventScroll, but tests that the behavior is the same | 3141 // Same as GestureEventScroll, but tests that the behavior is the same |
| 3065 // even if all the touch-move events are consumed. | 3142 // even if all the touch-move events are consumed. |
| 3066 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) { | 3143 TEST_P(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) { |
| 3067 scoped_ptr<ConsumesTouchMovesDelegate> delegate( | 3144 scoped_ptr<ConsumesTouchMovesDelegate> delegate( |
| 3068 new ConsumesTouchMovesDelegate()); | 3145 new ConsumesTouchMovesDelegate()); |
| 3069 const int kWindowWidth = 123; | 3146 const int kWindowWidth = 123; |
| 3070 const int kWindowHeight = 45; | 3147 const int kWindowHeight = 45; |
| 3071 const int kTouchId = 5; | 3148 const int kTouchId = 5; |
| 3072 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3149 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3073 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3150 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3074 delegate.get(), -1234, bounds, root_window())); | 3151 delegate.get(), -1234, bounds, root_window())); |
| 3075 TimedEvents tes; | 3152 TimedEvents tes; |
| 3076 | 3153 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3108 EXPECT_FALSE(delegate->tap_down()); | 3185 EXPECT_FALSE(delegate->tap_down()); |
| 3109 EXPECT_FALSE(delegate->tap_cancel()); | 3186 EXPECT_FALSE(delegate->tap_cancel()); |
| 3110 EXPECT_FALSE(delegate->begin()); | 3187 EXPECT_FALSE(delegate->begin()); |
| 3111 EXPECT_TRUE(delegate->end()); | 3188 EXPECT_TRUE(delegate->end()); |
| 3112 EXPECT_FALSE(delegate->scroll_begin()); | 3189 EXPECT_FALSE(delegate->scroll_begin()); |
| 3113 EXPECT_FALSE(delegate->scroll_update()); | 3190 EXPECT_FALSE(delegate->scroll_update()); |
| 3114 EXPECT_FALSE(delegate->scroll_end()); | 3191 EXPECT_FALSE(delegate->scroll_end()); |
| 3115 } | 3192 } |
| 3116 | 3193 |
| 3117 // Tests the behavior of 2F scroll when all the touch-move events are consumed. | 3194 // Tests the behavior of 2F scroll when all the touch-move events are consumed. |
| 3118 TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { | 3195 TEST_P(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) { |
| 3196 // TODO(tdresser): enable this test with unified GR once two finger tap is | |
| 3197 // supported. See crbug.com/354396. | |
| 3198 if (UsingUnifiedGR()) | |
| 3199 return; | |
| 3200 | |
| 3119 scoped_ptr<ConsumesTouchMovesDelegate> delegate( | 3201 scoped_ptr<ConsumesTouchMovesDelegate> delegate( |
| 3120 new ConsumesTouchMovesDelegate()); | 3202 new ConsumesTouchMovesDelegate()); |
| 3121 const int kWindowWidth = 123; | 3203 const int kWindowWidth = 123; |
| 3122 const int kWindowHeight = 100; | 3204 const int kWindowHeight = 100; |
| 3123 const int kTouchId1 = 2; | 3205 const int kTouchId1 = 2; |
| 3124 const int kTouchId2 = 3; | 3206 const int kTouchId2 = 3; |
| 3125 TimedEvents tes; | 3207 TimedEvents tes; |
| 3126 | 3208 |
| 3127 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3209 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3128 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3210 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3215 EXPECT_TRUE(delegate->fling()); | 3297 EXPECT_TRUE(delegate->fling()); |
| 3216 | 3298 |
| 3217 EXPECT_FALSE(delegate->pinch_begin()); | 3299 EXPECT_FALSE(delegate->pinch_begin()); |
| 3218 EXPECT_FALSE(delegate->pinch_update()); | 3300 EXPECT_FALSE(delegate->pinch_update()); |
| 3219 EXPECT_FALSE(delegate->pinch_end()); | 3301 EXPECT_FALSE(delegate->pinch_end()); |
| 3220 } | 3302 } |
| 3221 | 3303 |
| 3222 // Like as GestureEventTouchMoveConsumed but tests the different behavior | 3304 // Like as GestureEventTouchMoveConsumed but tests the different behavior |
| 3223 // depending on whether the events were consumed before or after the scroll | 3305 // depending on whether the events were consumed before or after the scroll |
| 3224 // started. | 3306 // started. |
| 3225 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) { | 3307 TEST_P(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) { |
| 3226 scoped_ptr<ConsumesTouchMovesDelegate> delegate( | 3308 scoped_ptr<ConsumesTouchMovesDelegate> delegate( |
| 3227 new ConsumesTouchMovesDelegate()); | 3309 new ConsumesTouchMovesDelegate()); |
| 3228 const int kWindowWidth = 123; | 3310 const int kWindowWidth = 123; |
| 3229 const int kWindowHeight = 45; | 3311 const int kWindowHeight = 45; |
| 3230 const int kTouchId = 5; | 3312 const int kTouchId = 5; |
| 3231 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3313 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3232 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3314 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3233 delegate.get(), -1234, bounds, root_window())); | 3315 delegate.get(), -1234, bounds, root_window())); |
| 3234 TimedEvents tes; | 3316 TimedEvents tes; |
| 3235 | 3317 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3309 EXPECT_FALSE(delegate->tap_cancel()); | 3391 EXPECT_FALSE(delegate->tap_cancel()); |
| 3310 EXPECT_FALSE(delegate->begin()); | 3392 EXPECT_FALSE(delegate->begin()); |
| 3311 EXPECT_TRUE(delegate->end()); | 3393 EXPECT_TRUE(delegate->end()); |
| 3312 EXPECT_FALSE(delegate->scroll_begin()); | 3394 EXPECT_FALSE(delegate->scroll_begin()); |
| 3313 EXPECT_FALSE(delegate->scroll_update()); | 3395 EXPECT_FALSE(delegate->scroll_update()); |
| 3314 EXPECT_FALSE(delegate->scroll_end()); | 3396 EXPECT_FALSE(delegate->scroll_end()); |
| 3315 EXPECT_FALSE(delegate->fling()); | 3397 EXPECT_FALSE(delegate->fling()); |
| 3316 } | 3398 } |
| 3317 | 3399 |
| 3318 // Check that appropriate touch events generate double tap gesture events. | 3400 // Check that appropriate touch events generate double tap gesture events. |
| 3319 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { | 3401 TEST_P(GestureRecognizerTest, GestureEventDoubleTap) { |
| 3402 // TODO(tdresser): enable this test with unified GR once double / triple tap | |
| 3403 // gestures work. See crbug.com/357270. | |
| 3404 if (UsingUnifiedGR()) | |
| 3405 return; | |
| 3406 | |
| 3320 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3407 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3321 new GestureEventConsumeDelegate()); | 3408 new GestureEventConsumeDelegate()); |
| 3322 const int kWindowWidth = 123; | 3409 const int kWindowWidth = 123; |
| 3323 const int kWindowHeight = 45; | 3410 const int kWindowHeight = 45; |
| 3324 const int kTouchId = 2; | 3411 const int kTouchId = 2; |
| 3325 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3412 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3326 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3413 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3327 delegate.get(), -1234, bounds, root_window())); | 3414 delegate.get(), -1234, bounds, root_window())); |
| 3328 TimedEvents tes; | 3415 TimedEvents tes; |
| 3329 | 3416 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 3350 EXPECT_TRUE(delegate->begin()); | 3437 EXPECT_TRUE(delegate->begin()); |
| 3351 EXPECT_TRUE(delegate->end()); | 3438 EXPECT_TRUE(delegate->end()); |
| 3352 EXPECT_FALSE(delegate->scroll_begin()); | 3439 EXPECT_FALSE(delegate->scroll_begin()); |
| 3353 EXPECT_FALSE(delegate->scroll_update()); | 3440 EXPECT_FALSE(delegate->scroll_update()); |
| 3354 EXPECT_FALSE(delegate->scroll_end()); | 3441 EXPECT_FALSE(delegate->scroll_end()); |
| 3355 | 3442 |
| 3356 EXPECT_EQ(2, delegate->tap_count()); | 3443 EXPECT_EQ(2, delegate->tap_count()); |
| 3357 } | 3444 } |
| 3358 | 3445 |
| 3359 // Check that appropriate touch events generate triple tap gesture events. | 3446 // Check that appropriate touch events generate triple tap gesture events. |
| 3360 TEST_F(GestureRecognizerTest, GestureEventTripleTap) { | 3447 TEST_P(GestureRecognizerTest, GestureEventTripleTap) { |
| 3448 // TODO(tdresser): enable this test with unified GR once double / triple tap | |
| 3449 // gestures work. See crbug.com/357270. | |
| 3450 if (UsingUnifiedGR()) | |
| 3451 return; | |
| 3452 | |
| 3361 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3453 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3362 new GestureEventConsumeDelegate()); | 3454 new GestureEventConsumeDelegate()); |
| 3363 const int kWindowWidth = 123; | 3455 const int kWindowWidth = 123; |
| 3364 const int kWindowHeight = 45; | 3456 const int kWindowHeight = 45; |
| 3365 const int kTouchId = 2; | 3457 const int kTouchId = 2; |
| 3366 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3458 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3367 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3459 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3368 delegate.get(), -1234, bounds, root_window())); | 3460 delegate.get(), -1234, bounds, root_window())); |
| 3369 TimedEvents tes; | 3461 TimedEvents tes; |
| 3370 | 3462 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3405 EXPECT_TRUE(delegate->begin()); | 3497 EXPECT_TRUE(delegate->begin()); |
| 3406 EXPECT_TRUE(delegate->end()); | 3498 EXPECT_TRUE(delegate->end()); |
| 3407 EXPECT_FALSE(delegate->scroll_begin()); | 3499 EXPECT_FALSE(delegate->scroll_begin()); |
| 3408 EXPECT_FALSE(delegate->scroll_update()); | 3500 EXPECT_FALSE(delegate->scroll_update()); |
| 3409 EXPECT_FALSE(delegate->scroll_end()); | 3501 EXPECT_FALSE(delegate->scroll_end()); |
| 3410 | 3502 |
| 3411 EXPECT_EQ(3, delegate->tap_count()); | 3503 EXPECT_EQ(3, delegate->tap_count()); |
| 3412 } | 3504 } |
| 3413 | 3505 |
| 3414 // Check that we don't get a double tap when the two taps are far apart. | 3506 // Check that we don't get a double tap when the two taps are far apart. |
| 3415 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { | 3507 TEST_P(GestureRecognizerTest, TwoTapsFarApart) { |
| 3416 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3508 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3417 new GestureEventConsumeDelegate()); | 3509 new GestureEventConsumeDelegate()); |
| 3418 const int kWindowWidth = 123; | 3510 const int kWindowWidth = 123; |
| 3419 const int kWindowHeight = 45; | 3511 const int kWindowHeight = 45; |
| 3420 const int kTouchId = 2; | 3512 const int kTouchId = 2; |
| 3421 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3513 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3422 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3514 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3423 delegate.get(), -1234, bounds, root_window())); | 3515 delegate.get(), -1234, bounds, root_window())); |
| 3424 TimedEvents tes; | 3516 TimedEvents tes; |
| 3425 | 3517 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 3447 EXPECT_TRUE(delegate->end()); | 3539 EXPECT_TRUE(delegate->end()); |
| 3448 EXPECT_FALSE(delegate->scroll_begin()); | 3540 EXPECT_FALSE(delegate->scroll_begin()); |
| 3449 EXPECT_FALSE(delegate->scroll_update()); | 3541 EXPECT_FALSE(delegate->scroll_update()); |
| 3450 EXPECT_FALSE(delegate->scroll_end()); | 3542 EXPECT_FALSE(delegate->scroll_end()); |
| 3451 | 3543 |
| 3452 EXPECT_EQ(1, delegate->tap_count()); | 3544 EXPECT_EQ(1, delegate->tap_count()); |
| 3453 } | 3545 } |
| 3454 | 3546 |
| 3455 // Check that we don't get a double tap when the two taps have a long enough | 3547 // Check that we don't get a double tap when the two taps have a long enough |
| 3456 // delay in between. | 3548 // delay in between. |
| 3457 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { | 3549 TEST_P(GestureRecognizerTest, TwoTapsWithDelayBetween) { |
| 3458 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3550 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3459 new GestureEventConsumeDelegate()); | 3551 new GestureEventConsumeDelegate()); |
| 3460 const int kWindowWidth = 123; | 3552 const int kWindowWidth = 123; |
| 3461 const int kWindowHeight = 45; | 3553 const int kWindowHeight = 45; |
| 3462 const int kTouchId = 2; | 3554 const int kTouchId = 2; |
| 3463 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3555 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3464 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3556 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3465 delegate.get(), -1234, bounds, root_window())); | 3557 delegate.get(), -1234, bounds, root_window())); |
| 3466 TimedEvents tes; | 3558 TimedEvents tes; |
| 3467 | 3559 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 3490 EXPECT_FALSE(delegate->scroll_begin()); | 3582 EXPECT_FALSE(delegate->scroll_begin()); |
| 3491 EXPECT_FALSE(delegate->scroll_update()); | 3583 EXPECT_FALSE(delegate->scroll_update()); |
| 3492 EXPECT_FALSE(delegate->scroll_end()); | 3584 EXPECT_FALSE(delegate->scroll_end()); |
| 3493 | 3585 |
| 3494 EXPECT_EQ(1, delegate->tap_count()); | 3586 EXPECT_EQ(1, delegate->tap_count()); |
| 3495 } | 3587 } |
| 3496 | 3588 |
| 3497 // Checks that if the bounding-box of a gesture changes because of change in | 3589 // Checks that if the bounding-box of a gesture changes because of change in |
| 3498 // radius of a touch-point, and not because of change in position, then there | 3590 // radius of a touch-point, and not because of change in position, then there |
| 3499 // are not gesture events from that. | 3591 // are not gesture events from that. |
| 3500 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { | 3592 TEST_P(GestureRecognizerTest, BoundingBoxRadiusChange) { |
| 3593 // TODO(tdresser): enable this test with unified GR when (if?) bounding box | |
| 3594 // behavior is unified. | |
| 3595 if (UsingUnifiedGR()) | |
| 3596 return; | |
| 3597 | |
| 3501 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3598 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3502 new GestureEventConsumeDelegate()); | 3599 new GestureEventConsumeDelegate()); |
| 3503 const int kWindowWidth = 234; | 3600 const int kWindowWidth = 234; |
| 3504 const int kWindowHeight = 345; | 3601 const int kWindowHeight = 345; |
| 3505 const int kTouchId = 5, kTouchId2 = 7; | 3602 const int kTouchId = 5, kTouchId2 = 7; |
| 3506 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3603 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3507 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3604 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3508 delegate.get(), -1234, bounds, root_window())); | 3605 delegate.get(), -1234, bounds, root_window())); |
| 3509 TimedEvents tes; | 3606 TimedEvents tes; |
| 3510 | 3607 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3544 EXPECT_FALSE(delegate->tap()); | 3641 EXPECT_FALSE(delegate->tap()); |
| 3545 EXPECT_FALSE(delegate->tap_cancel()); | 3642 EXPECT_FALSE(delegate->tap_cancel()); |
| 3546 EXPECT_FALSE(delegate->scroll_update()); | 3643 EXPECT_FALSE(delegate->scroll_update()); |
| 3547 EXPECT_FALSE(delegate->pinch_update()); | 3644 EXPECT_FALSE(delegate->pinch_update()); |
| 3548 | 3645 |
| 3549 delegate->Reset(); | 3646 delegate->Reset(); |
| 3550 } | 3647 } |
| 3551 | 3648 |
| 3552 // Checks that slow scrolls deliver the correct deltas. | 3649 // Checks that slow scrolls deliver the correct deltas. |
| 3553 // In particular, fix for http;//crbug.com/150573. | 3650 // In particular, fix for http;//crbug.com/150573. |
| 3554 TEST_F(GestureRecognizerTest, NoDriftInScroll) { | 3651 TEST_P(GestureRecognizerTest, NoDriftInScroll) { |
| 3555 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); | 3652 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); |
| 3556 ui::GestureConfiguration::set_min_scroll_delta_squared(9); | 3653 ui::GestureConfiguration::set_min_scroll_delta_squared(9); |
| 3557 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3654 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3558 new GestureEventConsumeDelegate()); | 3655 new GestureEventConsumeDelegate()); |
| 3559 const int kWindowWidth = 234; | 3656 const int kWindowWidth = 234; |
| 3560 const int kWindowHeight = 345; | 3657 const int kWindowHeight = 345; |
| 3561 const int kTouchId = 5; | 3658 const int kTouchId = 5; |
| 3562 TimedEvents tes; | 3659 TimedEvents tes; |
| 3563 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3660 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3564 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3661 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3602 DispatchEventUsingWindowDispatcher(&move4); | 3699 DispatchEventUsingWindowDispatcher(&move4); |
| 3603 EXPECT_TRUE(delegate->scroll_update()); | 3700 EXPECT_TRUE(delegate->scroll_update()); |
| 3604 EXPECT_EQ(-1, delegate->scroll_y()); | 3701 EXPECT_EQ(-1, delegate->scroll_y()); |
| 3605 | 3702 |
| 3606 delegate->Reset(); | 3703 delegate->Reset(); |
| 3607 } | 3704 } |
| 3608 | 3705 |
| 3609 // Ensure that move events which are preventDefaulted will cause a tap | 3706 // Ensure that move events which are preventDefaulted will cause a tap |
| 3610 // cancel gesture event to be fired if the move would normally cause a | 3707 // cancel gesture event to be fired if the move would normally cause a |
| 3611 // scroll. See bug http://crbug.com/146397. | 3708 // scroll. See bug http://crbug.com/146397. |
| 3612 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { | 3709 TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) { |
| 3613 scoped_ptr<ConsumesTouchMovesDelegate> delegate( | 3710 scoped_ptr<ConsumesTouchMovesDelegate> delegate( |
| 3614 new ConsumesTouchMovesDelegate()); | 3711 new ConsumesTouchMovesDelegate()); |
| 3615 const int kTouchId = 5; | 3712 const int kTouchId = 5; |
| 3616 gfx::Rect bounds(100, 200, 123, 45); | 3713 gfx::Rect bounds(100, 200, 123, 45); |
| 3617 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3714 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3618 delegate.get(), -1234, bounds, root_window())); | 3715 delegate.get(), -1234, bounds, root_window())); |
| 3619 TimedEvents tes; | 3716 TimedEvents tes; |
| 3620 | 3717 |
| 3621 delegate->Reset(); | 3718 delegate->Reset(); |
| 3622 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | 3719 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), |
| 3623 kTouchId, tes.Now()); | 3720 kTouchId, tes.Now()); |
| 3624 | 3721 |
| 3625 delegate->set_consume_touch_move(false); | 3722 delegate->set_consume_touch_move(false); |
| 3626 DispatchEventUsingWindowDispatcher(&press); | 3723 DispatchEventUsingWindowDispatcher(&press); |
| 3627 delegate->set_consume_touch_move(true); | 3724 delegate->set_consume_touch_move(true); |
| 3628 delegate->Reset(); | 3725 delegate->Reset(); |
| 3629 // Move the touch-point enough so that it would normally be considered a | 3726 // Move the touch-point enough so that it would normally be considered a |
| 3630 // scroll. But since the touch-moves will be consumed, the scroll should not | 3727 // scroll. But since the touch-moves will be consumed, the scroll should not |
| 3631 // start. | 3728 // start. |
| 3632 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); | 3729 tes.SendScrollEvent(event_processor(), 130, 230, kTouchId, delegate.get()); |
| 3633 EXPECT_FALSE(delegate->tap()); | 3730 EXPECT_FALSE(delegate->tap()); |
| 3634 EXPECT_FALSE(delegate->tap_down()); | 3731 EXPECT_FALSE(delegate->tap_down()); |
| 3635 EXPECT_TRUE(delegate->tap_cancel()); | 3732 EXPECT_TRUE(delegate->tap_cancel()); |
| 3636 EXPECT_FALSE(delegate->begin()); | 3733 EXPECT_FALSE(delegate->begin()); |
| 3637 EXPECT_FALSE(delegate->scroll_begin()); | 3734 EXPECT_FALSE(delegate->scroll_begin()); |
| 3638 EXPECT_FALSE(delegate->scroll_update()); | 3735 EXPECT_FALSE(delegate->scroll_update()); |
| 3639 EXPECT_FALSE(delegate->scroll_end()); | 3736 EXPECT_FALSE(delegate->scroll_end()); |
| 3640 } | 3737 } |
| 3641 | 3738 |
| 3642 TEST_F(GestureRecognizerTest, | 3739 TEST_P(GestureRecognizerTest, |
| 3643 TransferEventDispatchesTouchCancel) { | 3740 TransferEventDispatchesTouchCancel) { |
| 3644 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3741 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3645 new GestureEventConsumeDelegate()); | 3742 new GestureEventConsumeDelegate()); |
| 3646 TimedEvents tes; | 3743 TimedEvents tes; |
| 3647 const int kWindowWidth = 800; | 3744 const int kWindowWidth = 800; |
| 3648 const int kWindowHeight = 600; | 3745 const int kWindowHeight = 600; |
| 3649 const int kTouchId = 2; | 3746 const int kTouchId = 2; |
| 3650 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 3747 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 3651 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3748 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3652 delegate.get(), -1234, bounds, root_window())); | 3749 delegate.get(), -1234, bounds, root_window())); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 3675 gesture_recognizer->GetTouchLockedTarget(press)); | 3772 gesture_recognizer->GetTouchLockedTarget(press)); |
| 3676 gesture_recognizer->TransferEventsTo(window.get(), NULL); | 3773 gesture_recognizer->TransferEventsTo(window.get(), NULL); |
| 3677 EXPECT_EQ(NULL, | 3774 EXPECT_EQ(NULL, |
| 3678 gesture_recognizer->GetTouchLockedTarget(press)); | 3775 gesture_recognizer->GetTouchLockedTarget(press)); |
| 3679 // The event-handler removes |window| from its parent on the first | 3776 // The event-handler removes |window| from its parent on the first |
| 3680 // touch-cancel event, so it won't receive the second touch-cancel event. | 3777 // touch-cancel event, so it won't receive the second touch-cancel event. |
| 3681 EXPECT_EQ(1, handler->touch_cancelled_count()); | 3778 EXPECT_EQ(1, handler->touch_cancelled_count()); |
| 3682 } | 3779 } |
| 3683 | 3780 |
| 3684 // Check that appropriate touch events generate show press events | 3781 // Check that appropriate touch events generate show press events |
| 3685 TEST_F(GestureRecognizerTest, GestureEventShowPress) { | 3782 TEST_P(GestureRecognizerTest, GestureEventShowPress) { |
| 3686 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3783 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3687 new GestureEventConsumeDelegate()); | 3784 new GestureEventConsumeDelegate()); |
| 3688 TimedEvents tes; | 3785 TimedEvents tes; |
| 3689 const int kWindowWidth = 123; | 3786 const int kWindowWidth = 123; |
| 3690 const int kWindowHeight = 45; | 3787 const int kWindowHeight = 45; |
| 3691 const int kTouchId = 2; | 3788 const int kTouchId = 2; |
| 3692 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3789 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3693 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3790 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3694 delegate.get(), -1234, bounds, root_window())); | 3791 delegate.get(), -1234, bounds, root_window())); |
| 3695 | 3792 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 3714 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); | 3811 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
| 3715 EXPECT_TRUE(delegate->show_press()); | 3812 EXPECT_TRUE(delegate->show_press()); |
| 3716 EXPECT_FALSE(delegate->tap_cancel()); | 3813 EXPECT_FALSE(delegate->tap_cancel()); |
| 3717 | 3814 |
| 3718 delegate->Reset(); | 3815 delegate->Reset(); |
| 3719 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3816 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3720 kTouchId, tes.Now()); | 3817 kTouchId, tes.Now()); |
| 3721 DispatchEventUsingWindowDispatcher(&release1); | 3818 DispatchEventUsingWindowDispatcher(&release1); |
| 3722 EXPECT_FALSE(delegate->long_press()); | 3819 EXPECT_FALSE(delegate->long_press()); |
| 3723 | 3820 |
| 3724 // Note the tap down isn't cancelled until the release | 3821 // Note the tap isn't dispatched until the release |
| 3725 EXPECT_TRUE(delegate->tap_cancel()); | 3822 EXPECT_FALSE(delegate->tap_cancel()); |
| 3823 EXPECT_TRUE(delegate->tap()); | |
| 3726 } | 3824 } |
| 3727 | 3825 |
| 3728 // Check that scrolling cancels a show press | 3826 // Check that scrolling cancels a show press |
| 3729 TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { | 3827 TEST_P(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) { |
| 3730 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3828 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3731 new GestureEventConsumeDelegate()); | 3829 new GestureEventConsumeDelegate()); |
| 3732 TimedEvents tes; | 3830 TimedEvents tes; |
| 3733 const int kWindowWidth = 123; | 3831 const int kWindowWidth = 123; |
| 3734 const int kWindowHeight = 45; | 3832 const int kWindowHeight = 45; |
| 3735 const int kTouchId = 6; | 3833 const int kTouchId = 6; |
| 3736 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3834 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3737 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3835 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3738 delegate.get(), -1234, bounds, root_window())); | 3836 delegate.get(), -1234, bounds, root_window())); |
| 3739 | 3837 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 3766 | 3864 |
| 3767 delegate->Reset(); | 3865 delegate->Reset(); |
| 3768 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3866 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3769 kTouchId, tes.LeapForward(10)); | 3867 kTouchId, tes.LeapForward(10)); |
| 3770 DispatchEventUsingWindowDispatcher(&release1); | 3868 DispatchEventUsingWindowDispatcher(&release1); |
| 3771 EXPECT_FALSE(delegate->show_press()); | 3869 EXPECT_FALSE(delegate->show_press()); |
| 3772 EXPECT_FALSE(delegate->tap_cancel()); | 3870 EXPECT_FALSE(delegate->tap_cancel()); |
| 3773 } | 3871 } |
| 3774 | 3872 |
| 3775 // Test that show press events are sent immediately on tap | 3873 // Test that show press events are sent immediately on tap |
| 3776 TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) { | 3874 TEST_P(GestureRecognizerTest, GestureEventShowPressSentOnTap) { |
| 3777 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3875 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3778 new GestureEventConsumeDelegate()); | 3876 new GestureEventConsumeDelegate()); |
| 3779 TimedEvents tes; | 3877 TimedEvents tes; |
| 3780 const int kWindowWidth = 123; | 3878 const int kWindowWidth = 123; |
| 3781 const int kWindowHeight = 45; | 3879 const int kWindowHeight = 45; |
| 3782 const int kTouchId = 6; | 3880 const int kTouchId = 6; |
| 3783 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 3881 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3784 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3882 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3785 delegate.get(), -1234, bounds, root_window())); | 3883 delegate.get(), -1234, bounds, root_window())); |
| 3786 | 3884 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 3798 delegate->Reset(); | 3896 delegate->Reset(); |
| 3799 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 3897 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
| 3800 kTouchId, tes.LeapForward(50)); | 3898 kTouchId, tes.LeapForward(50)); |
| 3801 DispatchEventUsingWindowDispatcher(&release1); | 3899 DispatchEventUsingWindowDispatcher(&release1); |
| 3802 EXPECT_TRUE(delegate->show_press()); | 3900 EXPECT_TRUE(delegate->show_press()); |
| 3803 EXPECT_FALSE(delegate->tap_cancel()); | 3901 EXPECT_FALSE(delegate->tap_cancel()); |
| 3804 EXPECT_TRUE(delegate->tap()); | 3902 EXPECT_TRUE(delegate->tap()); |
| 3805 } | 3903 } |
| 3806 | 3904 |
| 3807 // Test that consuming the first move touch event prevents a scroll. | 3905 // Test that consuming the first move touch event prevents a scroll. |
| 3808 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { | 3906 TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) { |
| 3809 scoped_ptr<QueueTouchEventDelegate> delegate( | 3907 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3810 new QueueTouchEventDelegate(host()->dispatcher())); | 3908 new QueueTouchEventDelegate(host()->dispatcher())); |
| 3811 TimedEvents tes; | 3909 TimedEvents tes; |
| 3812 const int kTouchId = 7; | 3910 const int kTouchId = 7; |
| 3813 gfx::Rect bounds(0, 0, 1000, 1000); | 3911 gfx::Rect bounds(0, 0, 1000, 1000); |
| 3814 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3912 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3815 delegate.get(), -1234, bounds, root_window())); | 3913 delegate.get(), -1234, bounds, root_window())); |
| 3816 | 3914 |
| 3817 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3915 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 3818 kTouchId, tes.Now()); | 3916 kTouchId, tes.Now()); |
| 3819 DispatchEventUsingWindowDispatcher(&press); | 3917 DispatchEventUsingWindowDispatcher(&press); |
| 3820 delegate->ReceivedAck(); | 3918 delegate->ReceivedAck(); |
| 3821 | 3919 |
| 3822 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | 3920 // A touch move within the slop region is never consumed in web contents. The |
| 3921 // unified GR won't prevent scroll if a touch move within the slop region is | |
| 3922 // consumed, so make sure this touch move exceeds the slop region. | |
| 3923 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), | |
| 3823 kTouchId, tes.Now()); | 3924 kTouchId, tes.Now()); |
| 3824 DispatchEventUsingWindowDispatcher(&move1); | 3925 DispatchEventUsingWindowDispatcher(&move1); |
| 3825 delegate->ReceivedAckPreventDefaulted(); | 3926 delegate->ReceivedAckPreventDefaulted(); |
| 3826 | 3927 |
| 3827 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), | 3928 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), |
| 3828 kTouchId, tes.Now()); | 3929 kTouchId, tes.Now()); |
| 3829 DispatchEventUsingWindowDispatcher(&move2); | 3930 DispatchEventUsingWindowDispatcher(&move2); |
| 3830 delegate->ReceivedAck(); | 3931 delegate->ReceivedAck(); |
| 3831 | 3932 |
| 3832 EXPECT_FALSE(delegate->scroll_begin()); | 3933 EXPECT_FALSE(delegate->scroll_begin()); |
| 3833 EXPECT_FALSE(delegate->scroll_update()); | 3934 EXPECT_FALSE(delegate->scroll_update()); |
| 3834 } | 3935 } |
| 3835 | 3936 |
| 3836 // Test that consuming the first touch move event of a touch point doesn't | 3937 // Test that consuming the first touch move event of a touch point doesn't |
| 3837 // prevent pinching once an additional touch has been pressed. | 3938 // prevent pinching once an additional touch has been pressed. |
| 3838 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) { | 3939 TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) { |
| 3940 // Consuming moves within the touch slop and the the disposition handling of | |
| 3941 // pinch events behave differently between the Unified GR and the Aura GR. | |
| 3942 if (UsingUnifiedGR()) | |
| 3943 return; | |
| 3944 | |
| 3839 scoped_ptr<QueueTouchEventDelegate> delegate( | 3945 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3840 new QueueTouchEventDelegate(host()->dispatcher())); | 3946 new QueueTouchEventDelegate(host()->dispatcher())); |
| 3841 TimedEvents tes; | 3947 TimedEvents tes; |
| 3842 const int kTouchId1 = 7; | 3948 const int kTouchId1 = 7; |
| 3843 const int kTouchId2 = 4; | 3949 const int kTouchId2 = 4; |
| 3844 gfx::Rect bounds(0, 0, 1000, 1000); | 3950 gfx::Rect bounds(0, 0, 1000, 1000); |
| 3845 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3951 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3846 delegate.get(), -1234, bounds, root_window())); | 3952 delegate.get(), -1234, bounds, root_window())); |
| 3847 | 3953 |
| 3848 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 3954 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3885 kTouchId2, tes.Now()); | 3991 kTouchId2, tes.Now()); |
| 3886 DispatchEventUsingWindowDispatcher(&move4); | 3992 DispatchEventUsingWindowDispatcher(&move4); |
| 3887 delegate->ReceivedAck(); | 3993 delegate->ReceivedAck(); |
| 3888 | 3994 |
| 3889 EXPECT_TRUE(delegate->pinch_update()); | 3995 EXPECT_TRUE(delegate->pinch_update()); |
| 3890 EXPECT_EQ(10, delegate->scroll_x()); | 3996 EXPECT_EQ(10, delegate->scroll_x()); |
| 3891 EXPECT_EQ(10, delegate->scroll_y()); | 3997 EXPECT_EQ(10, delegate->scroll_y()); |
| 3892 } | 3998 } |
| 3893 | 3999 |
| 3894 // Test that consuming the first move touch doesn't prevent a tap. | 4000 // Test that consuming the first move touch doesn't prevent a tap. |
| 3895 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { | 4001 TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) { |
| 3896 scoped_ptr<QueueTouchEventDelegate> delegate( | 4002 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3897 new QueueTouchEventDelegate(host()->dispatcher())); | 4003 new QueueTouchEventDelegate(host()->dispatcher())); |
| 3898 TimedEvents tes; | 4004 TimedEvents tes; |
| 3899 const int kTouchId = 7; | 4005 const int kTouchId = 7; |
| 3900 gfx::Rect bounds(0, 0, 1000, 1000); | 4006 gfx::Rect bounds(0, 0, 1000, 1000); |
| 3901 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 4007 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3902 delegate.get(), -1234, bounds, root_window())); | 4008 delegate.get(), -1234, bounds, root_window())); |
| 3903 | 4009 |
| 3904 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), | 4010 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), |
| 3905 kTouchId, tes.Now()); | 4011 kTouchId, tes.Now()); |
| 3906 DispatchEventUsingWindowDispatcher(&press); | 4012 DispatchEventUsingWindowDispatcher(&press); |
| 3907 delegate->ReceivedAck(); | 4013 delegate->ReceivedAck(); |
| 3908 | 4014 |
| 3909 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), | 4015 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(2, 2), |
| 3910 kTouchId, tes.Now()); | 4016 kTouchId, tes.Now()); |
| 3911 DispatchEventUsingWindowDispatcher(&move); | 4017 DispatchEventUsingWindowDispatcher(&move); |
| 3912 delegate->ReceivedAckPreventDefaulted(); | 4018 delegate->ReceivedAckPreventDefaulted(); |
| 3913 | 4019 |
| 3914 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), | 4020 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), |
| 3915 kTouchId, tes.LeapForward(50)); | 4021 kTouchId, tes.LeapForward(50)); |
| 3916 DispatchEventUsingWindowDispatcher(&release); | 4022 DispatchEventUsingWindowDispatcher(&release); |
| 3917 delegate->ReceivedAck(); | 4023 delegate->ReceivedAck(); |
| 3918 | 4024 |
| 3919 EXPECT_TRUE(delegate->tap()); | 4025 EXPECT_TRUE(delegate->tap()); |
| 3920 } | 4026 } |
| 3921 | 4027 |
| 3922 // Test that consuming the first move touch doesn't prevent a long press. | 4028 // Test that consuming the first move touch doesn't prevent a long press. |
| 3923 TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { | 4029 TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) { |
| 3924 scoped_ptr<QueueTouchEventDelegate> delegate( | 4030 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 3925 new QueueTouchEventDelegate(host()->dispatcher())); | 4031 new QueueTouchEventDelegate(host()->dispatcher())); |
| 3926 TimedEvents tes; | 4032 TimedEvents tes; |
| 3927 const int kWindowWidth = 123; | 4033 const int kWindowWidth = 123; |
| 3928 const int kWindowHeight = 45; | 4034 const int kWindowHeight = 45; |
| 3929 const int kTouchId = 2; | 4035 const int kTouchId = 2; |
| 3930 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 4036 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 3931 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 4037 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3932 delegate.get(), -1234, bounds, root_window())); | 4038 delegate.get(), -1234, bounds, root_window())); |
| 3933 | 4039 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 3947 kTouchId, tes.Now()); | 4053 kTouchId, tes.Now()); |
| 3948 DispatchEventUsingWindowDispatcher(&move); | 4054 DispatchEventUsingWindowDispatcher(&move); |
| 3949 delegate->ReceivedAckPreventDefaulted(); | 4055 delegate->ReceivedAckPreventDefaulted(); |
| 3950 | 4056 |
| 3951 // Wait until the timer runs out | 4057 // Wait until the timer runs out |
| 3952 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); | 4058 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); |
| 3953 EXPECT_TRUE(delegate->long_press()); | 4059 EXPECT_TRUE(delegate->long_press()); |
| 3954 } | 4060 } |
| 3955 | 4061 |
| 3956 // Tests that the deltas are correct when leaving the slop region very slowly. | 4062 // Tests that the deltas are correct when leaving the slop region very slowly. |
| 3957 TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) { | 4063 TEST_P(GestureRecognizerTest, TestExceedingSlopSlowly) { |
| 4064 // Disabled for unified GR due to subtle differences in touch slop handling. | |
| 4065 if (UsingUnifiedGR()) | |
| 4066 return; | |
| 4067 | |
| 3958 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); | 4068 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); |
| 3959 scoped_ptr<GestureEventConsumeDelegate> delegate( | 4069 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3960 new GestureEventConsumeDelegate()); | 4070 new GestureEventConsumeDelegate()); |
| 3961 const int kWindowWidth = 234; | 4071 const int kWindowWidth = 234; |
| 3962 const int kWindowHeight = 345; | 4072 const int kWindowHeight = 345; |
| 3963 const int kTouchId = 5; | 4073 const int kTouchId = 5; |
| 3964 TimedEvents tes; | 4074 TimedEvents tes; |
| 3965 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 4075 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 3966 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 4076 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3967 delegate.get(), -1234, bounds, root_window())); | 4077 delegate.get(), -1234, bounds, root_window())); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4005 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(14, 10), kTouchId, | 4115 ui::TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(14, 10), kTouchId, |
| 4006 tes.LeapForward(40)); | 4116 tes.LeapForward(40)); |
| 4007 DispatchEventUsingWindowDispatcher(&move4); | 4117 DispatchEventUsingWindowDispatcher(&move4); |
| 4008 EXPECT_FALSE(delegate->scroll_begin()); | 4118 EXPECT_FALSE(delegate->scroll_begin()); |
| 4009 EXPECT_TRUE(delegate->scroll_update()); | 4119 EXPECT_TRUE(delegate->scroll_update()); |
| 4010 EXPECT_EQ(1, delegate->scroll_x()); | 4120 EXPECT_EQ(1, delegate->scroll_x()); |
| 4011 EXPECT_EQ(0, delegate->scroll_x_hint()); | 4121 EXPECT_EQ(0, delegate->scroll_x_hint()); |
| 4012 delegate->Reset(); | 4122 delegate->Reset(); |
| 4013 } | 4123 } |
| 4014 | 4124 |
| 4015 TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) { | 4125 TEST_P(GestureRecognizerTest, ScrollAlternatelyConsumedTest) { |
| 4016 scoped_ptr<QueueTouchEventDelegate> delegate( | 4126 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 4017 new QueueTouchEventDelegate(host()->dispatcher())); | 4127 new QueueTouchEventDelegate(host()->dispatcher())); |
| 4018 TimedEvents tes; | 4128 TimedEvents tes; |
| 4019 const int kWindowWidth = 3000; | 4129 const int kWindowWidth = 3000; |
| 4020 const int kWindowHeight = 3000; | 4130 const int kWindowHeight = 3000; |
| 4021 const int kTouchId = 2; | 4131 const int kTouchId = 2; |
| 4022 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 4132 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 4023 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 4133 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 4024 delegate.get(), -1234, bounds, root_window())); | 4134 delegate.get(), -1234, bounds, root_window())); |
| 4025 | 4135 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4064 ui::TouchEvent move3( | 4174 ui::TouchEvent move3( |
| 4065 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId, tes.Now()); | 4175 ui::ET_TOUCH_MOVED, gfx::Point(x, y), kTouchId, tes.Now()); |
| 4066 DispatchEventUsingWindowDispatcher(&move3); | 4176 DispatchEventUsingWindowDispatcher(&move3); |
| 4067 delegate->ReceivedAckPreventDefaulted(); | 4177 delegate->ReceivedAckPreventDefaulted(); |
| 4068 EXPECT_FALSE(delegate->scroll_begin()); | 4178 EXPECT_FALSE(delegate->scroll_begin()); |
| 4069 EXPECT_FALSE(delegate->scroll_update()); | 4179 EXPECT_FALSE(delegate->scroll_update()); |
| 4070 delegate->Reset(); | 4180 delegate->Reset(); |
| 4071 } | 4181 } |
| 4072 } | 4182 } |
| 4073 | 4183 |
| 4074 TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) { | 4184 TEST_P(GestureRecognizerTest, PinchAlternatelyConsumedTest) { |
| 4185 // Disabled for unified GR due to differences in when scroll update is | |
| 4186 // sent. The Aura GR will never send a ScrollUpdate with a ScrollBegin, but | |
| 4187 // the unified GR will. | |
| 4188 if (UsingUnifiedGR()) | |
| 4189 return; | |
| 4190 | |
| 4075 scoped_ptr<QueueTouchEventDelegate> delegate( | 4191 scoped_ptr<QueueTouchEventDelegate> delegate( |
| 4076 new QueueTouchEventDelegate(host()->dispatcher())); | 4192 new QueueTouchEventDelegate(host()->dispatcher())); |
| 4077 TimedEvents tes; | 4193 TimedEvents tes; |
| 4078 const int kWindowWidth = 3000; | 4194 const int kWindowWidth = 3000; |
| 4079 const int kWindowHeight = 3000; | 4195 const int kWindowHeight = 3000; |
| 4080 const int kTouchId1 = 5; | 4196 const int kTouchId1 = 5; |
| 4081 const int kTouchId2 = 7; | 4197 const int kTouchId2 = 7; |
| 4082 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 4198 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 4083 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 4199 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 4084 delegate.get(), -1234, bounds, root_window())); | 4200 delegate.get(), -1234, bounds, root_window())); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4148 EXPECT_FALSE(delegate->scroll_begin()); | 4264 EXPECT_FALSE(delegate->scroll_begin()); |
| 4149 EXPECT_FALSE(delegate->scroll_update()); | 4265 EXPECT_FALSE(delegate->scroll_update()); |
| 4150 EXPECT_FALSE(delegate->scroll_end()); | 4266 EXPECT_FALSE(delegate->scroll_end()); |
| 4151 EXPECT_FALSE(delegate->pinch_begin()); | 4267 EXPECT_FALSE(delegate->pinch_begin()); |
| 4152 EXPECT_FALSE(delegate->pinch_update()); | 4268 EXPECT_FALSE(delegate->pinch_update()); |
| 4153 EXPECT_FALSE(delegate->pinch_end()); | 4269 EXPECT_FALSE(delegate->pinch_end()); |
| 4154 delegate->Reset(); | 4270 delegate->Reset(); |
| 4155 } | 4271 } |
| 4156 } | 4272 } |
| 4157 | 4273 |
| 4274 // Test that touch event flags are passed through to the gesture event. | |
| 4275 TEST_P(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) { | |
| 4276 scoped_ptr<GestureEventConsumeDelegate> delegate( | |
| 4277 new GestureEventConsumeDelegate()); | |
| 4278 TimedEvents tes; | |
| 4279 const int kWindowWidth = 123; | |
| 4280 const int kWindowHeight = 45; | |
| 4281 const int kTouchId = 6; | |
| 4282 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | |
| 4283 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | |
| 4284 delegate.get(), -1234, bounds, root_window())); | |
| 4285 | |
| 4286 delegate->Reset(); | |
| 4287 | |
| 4288 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), | |
| 4289 kTouchId, tes.Now()); | |
| 4290 DispatchEventUsingWindowDispatcher(&press1); | |
| 4291 EXPECT_TRUE(delegate->tap_down()); | |
| 4292 | |
| 4293 int default_flags = delegate->flags(); | |
| 4294 | |
| 4295 ui::TouchEvent move1( | |
| 4296 ui::ET_TOUCH_MOVED, gfx::Point(397, 149), kTouchId, tes.LeapForward(50)); | |
| 4297 move1.set_flags(992); | |
| 4298 | |
| 4299 DispatchEventUsingWindowDispatcher(&move1); | |
| 4300 EXPECT_NE(default_flags, delegate->flags()); | |
| 4301 } | |
| 4302 | |
| 4303 INSTANTIATE_TEST_CASE_P(GestureRecognizer, | |
| 4304 GestureRecognizerTest, | |
| 4305 ::testing::Bool()); | |
| 4306 | |
| 4158 } // namespace test | 4307 } // namespace test |
| 4159 } // namespace aura | 4308 } // namespace aura |
| OLD | NEW |