| Index: ui/aura/gestures/gesture_recognizer_unittest.cc
|
| diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
|
| index 4667a497bd2d9578543c48bba2fe8a538eef236f..1de2c8a5bb6e75d1d7baceb0c4d68aafe8592350 100644
|
| --- a/ui/aura/gestures/gesture_recognizer_unittest.cc
|
| +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
|
| @@ -97,6 +97,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
|
| scroll_y_hint_(0),
|
| tap_count_(0),
|
| flags_(0),
|
| + scroll_rail_state_(ui::GestureEventDetails::ScrollRailState::Free),
|
| wait_until_event_(ui::ET_UNKNOWN) {}
|
|
|
| ~GestureEventConsumeDelegate() override {}
|
| @@ -138,6 +139,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
|
| tap_count_ = 0;
|
| scale_ = 0;
|
| flags_ = 0;
|
| + scroll_rail_state_ = ui::GestureEventDetails::ScrollRailState::Free;
|
| latency_info_.Clear();
|
| }
|
|
|
| @@ -188,6 +190,9 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
|
| const gfx::Rect& bounding_box() const { return bounding_box_; }
|
| int tap_count() const { return tap_count_; }
|
| int flags() const { return flags_; }
|
| + ui::GestureEventDetails::ScrollRailState scroll_rail_state() const {
|
| + return scroll_rail_state_;
|
| + }
|
| const ui::LatencyInfo& latency_info() const { return latency_info_; }
|
|
|
| void WaitUntilReceivedGesture(ui::EventType type) {
|
| @@ -230,6 +235,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
|
| scroll_update_ = true;
|
| scroll_x_ += gesture->details().scroll_x();
|
| scroll_y_ += gesture->details().scroll_y();
|
| + scroll_rail_state_ = gesture->details().scroll_rail_state();
|
| break;
|
| case ui::ET_GESTURE_SCROLL_END:
|
| EXPECT_TRUE(velocity_x_ == 0 && velocity_y_ == 0);
|
| @@ -254,6 +260,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
|
| case ui::ET_SCROLL_FLING_START:
|
| EXPECT_TRUE(gesture->details().velocity_x() != 0 ||
|
| gesture->details().velocity_y() != 0);
|
| + scroll_rail_state_ = gesture->details().scroll_rail_state();
|
| EXPECT_FALSE(scroll_end_);
|
| fling_ = true;
|
| velocity_x_ = gesture->details().velocity_x();
|
| @@ -325,6 +332,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
|
| gfx::Rect bounding_box_;
|
| int tap_count_;
|
| int flags_;
|
| + ui::GestureEventDetails::ScrollRailState scroll_rail_state_;
|
| ui::LatencyInfo latency_info_;
|
|
|
| ui::EventType wait_until_event_;
|
| @@ -1182,8 +1190,10 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
|
| // Move the touch-point horizontally enough that it is considered a
|
| // horizontal scroll.
|
| tes.SendScrollEvent(event_processor(), 30, 1, kTouchId, delegate.get());
|
| - EXPECT_FLOAT_EQ(0, delegate->scroll_y());
|
| + EXPECT_FLOAT_EQ(1, delegate->scroll_y());
|
| EXPECT_FLOAT_EQ(20, delegate->scroll_x());
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Horizontal,
|
| + delegate->scroll_rail_state());
|
|
|
| // Get a high x velocity, while still staying on the rail
|
| const int kScrollAmount = 8;
|
| @@ -1205,7 +1215,9 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
|
| EXPECT_TRUE(delegate->fling());
|
| EXPECT_FALSE(delegate->scroll_end());
|
| EXPECT_GT(delegate->velocity_x(), 0);
|
| - EXPECT_EQ(0, delegate->velocity_y());
|
| + EXPECT_GT(delegate->velocity_y(), 0);
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Horizontal,
|
| + delegate->scroll_rail_state());
|
| }
|
|
|
| // Check Scroll End Events report correct velocities
|
| @@ -1233,8 +1245,10 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
|
| // vertical scroll.
|
| tes.SendScrollEvent(event_processor(), 1, 30, kTouchId, delegate.get());
|
| EXPECT_EQ(20, delegate->scroll_y());
|
| - EXPECT_EQ(0, delegate->scroll_x());
|
| + EXPECT_EQ(1, delegate->scroll_x());
|
| EXPECT_EQ(0, delegate->scroll_velocity_x());
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Vertical,
|
| + delegate->scroll_rail_state());
|
|
|
| // Get a high y velocity, while still staying on the rail
|
| const int kScrollAmount = 8;
|
| @@ -1256,8 +1270,10 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
|
|
|
| EXPECT_TRUE(delegate->fling());
|
| EXPECT_FALSE(delegate->scroll_end());
|
| - EXPECT_EQ(0, delegate->velocity_x());
|
| + EXPECT_GT(delegate->velocity_x(), 0);
|
| EXPECT_GT(delegate->velocity_y(), 0);
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Vertical,
|
| + delegate->scroll_rail_state());
|
| }
|
|
|
| // Check Scroll End Events report non-zero velocities if the user is not on a
|
| @@ -1513,8 +1529,9 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
|
| tes.SendScrollEvent(event_processor(), 30, 6, kTouchId, delegate.get());
|
| EXPECT_TRUE(delegate->scroll_update());
|
| EXPECT_EQ(5, delegate->scroll_x());
|
| - // y shouldn't change, as we're on a horizontal rail.
|
| - EXPECT_EQ(0, delegate->scroll_y());
|
| + EXPECT_EQ(6, delegate->scroll_y());
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Horizontal,
|
| + delegate->scroll_rail_state());
|
|
|
| // Send enough information that a velocity can be calculated for the gesture,
|
| // and we can break the rail
|
| @@ -1536,6 +1553,8 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
|
| EXPECT_TRUE(delegate->scroll_update());
|
| EXPECT_EQ(5, delegate->scroll_x());
|
| EXPECT_EQ(5, delegate->scroll_y());
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Free,
|
| + delegate->scroll_rail_state());
|
| }
|
|
|
| // Check that vertical scroll gestures cause scrolls on vertical rails.
|
| @@ -1568,9 +1587,9 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
|
| tes.SendScrollEvent(event_processor(), 6, 30, kTouchId, delegate.get());
|
| EXPECT_TRUE(delegate->scroll_update());
|
| EXPECT_EQ(5, delegate->scroll_y());
|
| - // x shouldn't change, as we're on a vertical rail.
|
| - EXPECT_EQ(0, delegate->scroll_x());
|
| - EXPECT_EQ(0, delegate->scroll_velocity_x());
|
| + EXPECT_EQ(6, delegate->scroll_x());
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Vertical,
|
| + delegate->scroll_rail_state());
|
|
|
| // Send enough information that a velocity can be calculated for the gesture,
|
| // and we can break the rail
|
| @@ -1592,6 +1611,8 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
|
| EXPECT_TRUE(delegate->scroll_update());
|
| EXPECT_EQ(5, delegate->scroll_x());
|
| EXPECT_EQ(5, delegate->scroll_y());
|
| + EXPECT_EQ(ui::GestureEventDetails::ScrollRailState::Free,
|
| + delegate->scroll_rail_state());
|
| }
|
|
|
| TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
|
|
|