Commit 8f8b5837 authored by tdresser@chromium.org's avatar tdresser@chromium.org

GestureRecognizerTest tests both Aura and Unified Gesture Detectors.

This is in preparation of landing the unified GR
(see https://codereview.chromium.org/251543003/).

There are some cases where behavior differs in minor ways.

This is sometimes dealt with by increasing the test's margin of error
(for instance, slop handling is slightly different, so we now
exceed the slop more thoroughly).

This is sometimes dealt with by ignoring the test if the test is
run with the unified GR.

BUG=332418

Review URL: https://codereview.chromium.org/258633005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266440 0039d316-1c4b-4281-b951-d872f2087c98
parent 0f34a9c6
......@@ -102,8 +102,8 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
scroll_x_hint_(0),
scroll_y_hint_(0),
tap_count_(0),
wait_until_event_(ui::ET_UNKNOWN) {
}
wait_until_event_(ui::ET_UNKNOWN),
flags_(0) {}
virtual ~GestureEventConsumeDelegate() {}
......@@ -149,6 +149,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
scroll_y_hint_ = 0;
tap_count_ = 0;
scale_ = 0;
flags_ = 0;
}
const std::vector<ui::EventType>& events() const { return events_; };
......@@ -203,6 +204,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
float scale() const { return scale_; }
const gfx::Rect& bounding_box() const { return bounding_box_; }
int tap_count() const { return tap_count_; }
int flags() const { return flags_; }
void WaitUntilReceivedGesture(ui::EventType type) {
wait_until_event_ = type;
......@@ -213,6 +215,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE {
events_.push_back(gesture->type());
bounding_box_ = gesture->details().bounding_box();
flags_ = gesture->flags();
switch (gesture->type()) {
case ui::ET_GESTURE_TAP:
tap_location_ = gesture->location();
......@@ -287,6 +290,9 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
swipe_up_ = gesture->details().swipe_up();
swipe_down_ = gesture->details().swipe_down();
break;
case ui::ET_SCROLL_FLING_CANCEL:
// Only used in unified gesture detection.
break;
default:
NOTREACHED();
}
......@@ -343,6 +349,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
float scale_;
gfx::Rect bounding_box_;
int tap_count_;
int flags_;
ui::EventType wait_until_event_;
......@@ -556,7 +563,9 @@ class TimedEvents {
int simulated_now_;
public:
TimedEvents() : simulated_now_(0) {
// Use a non-zero start time to pass DCHECKs which ensure events have had a
// time assigned.
TimedEvents() : simulated_now_(1) {
}
base::TimeDelta Now() {
......@@ -694,13 +703,23 @@ class RemoveOnTouchCancelHandler : public TestEventHandler {
} // namespace
class GestureRecognizerTest : public AuraTestBase {
class GestureRecognizerTest : public AuraTestBase,
public ::testing::WithParamInterface<bool> {
public:
GestureRecognizerTest() {}
bool UsingUnifiedGR() {
return GetParam();
}
virtual void SetUp() OVERRIDE {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableScrollPrediction);
// TODO(tdresser): Once unified GR has landed, only run these tests once.
if (UsingUnifiedGR()) {
// TODO(tdresser): use unified GR once it's available.
// CommandLine::ForCurrentProcess()->AppendSwitch(
// switches::kUseUnifiedGestureDetector);
}
AuraTestBase::SetUp();
}
......@@ -708,7 +727,7 @@ class GestureRecognizerTest : public AuraTestBase {
};
// Check that appropriate touch events generate tap gesture events.
TEST_F(GestureRecognizerTest, GestureEventTap) {
TEST_P(GestureRecognizerTest, GestureEventTap) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -759,7 +778,7 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
// Check that appropriate touch events generate tap gesture events
// when information about the touch radii are provided.
TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
TEST_P(GestureRecognizerTest, GestureEventTapRegion) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -999,7 +1018,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
}
// Check that appropriate touch events generate scroll gesture events.
TEST_F(GestureRecognizerTest, GestureEventScroll) {
TEST_P(GestureRecognizerTest, GestureEventScroll) {
// We'll start by moving the touch point by (10.5, 10.5). We want 5 dips of
// that distance to be consumed by the slop, so we set the slop radius to
// sqrt(5 * 5 + 5 * 5).
......@@ -1043,14 +1062,15 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
// be empty, since it's a single point and the radius for testing is zero.
EXPECT_TRUE(delegate->bounding_box().IsEmpty());
// Move some more to generate a few more scroll updates.
tes.SendScrollEvent(event_processor(), 91, 192, kTouchId, delegate.get());
// Move some more to generate a few more scroll updates. Make sure that we get
// out of the snap channel for the unified GR.
tes.SendScrollEvent(event_processor(), 20, 120, kTouchId, delegate.get());
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
EXPECT_FLOAT_EQ(-20.5, delegate->scroll_x());
EXPECT_FLOAT_EQ(-19.5, delegate->scroll_y());
EXPECT_FLOAT_EQ(-91.5, delegate->scroll_x());
EXPECT_FLOAT_EQ(-91.5, delegate->scroll_y());
EXPECT_TRUE(delegate->bounding_box().IsEmpty());
tes.SendScrollEvent(event_processor(), 121, 196, kTouchId, delegate.get());
tes.SendScrollEvent(event_processor(), 50, 124, kTouchId, delegate.get());
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
EXPECT_EQ(30, delegate->scroll_x());
EXPECT_EQ(4, delegate->scroll_y());
......@@ -1069,7 +1089,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
}
// Check that predicted scroll update positions are correct.
TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
TEST_P(GestureRecognizerTest, GestureEventScrollPrediction) {
const double prediction_interval = 0.03;
ui::GestureConfiguration::set_scroll_prediction_seconds(prediction_interval);
// We'll start by moving the touch point by (5, 5). We want all of that
......@@ -1101,7 +1121,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
delegate->Reset();
// Get rid of touch slop.
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(101, 201),
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(111, 211),
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&move);
EXPECT_3_EVENTS(delegate->events(),
......@@ -1144,7 +1164,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
}
// Check that the bounding box during a scroll event is correct.
TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
TEST_P(GestureRecognizerTest, GestureEventScrollBoundingBox) {
TimedEvents tes;
for (int radius = 1; radius <= 10; ++radius) {
ui::GestureConfiguration::set_default_radius(radius);
......@@ -1201,7 +1221,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
// Check Scroll End Events report correct velocities
// if the user was on a horizontal rail
TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
TEST_P(GestureRecognizerTest, GestureEventHorizontalRailFling) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -1215,7 +1235,7 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
DispatchEventUsingWindowDispatcher(&press);
// Get rid of touch slop.
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(5, 0),
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 0),
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&move);
delegate->Reset();
......@@ -1223,11 +1243,11 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
// Move the touch-point horizontally enough that it is considered a
// horizontal scroll.
tes.SendScrollEvent(event_processor(), 25, 1, kTouchId, delegate.get());
EXPECT_EQ(0, delegate->scroll_y());
EXPECT_EQ(1, delegate->scroll_y_ordinal());
EXPECT_EQ(20, delegate->scroll_x());
EXPECT_EQ(20, delegate->scroll_x_ordinal());
tes.SendScrollEvent(event_processor(), 30, 1, kTouchId, delegate.get());
EXPECT_FLOAT_EQ(0, delegate->scroll_y());
EXPECT_FLOAT_EQ(1, delegate->scroll_y_ordinal());
EXPECT_FLOAT_EQ(20, delegate->scroll_x());
EXPECT_FLOAT_EQ(20, delegate->scroll_x_ordinal());
// Get a high x velocity, while still staying on the rail
tes.SendScrollEvents(event_processor(), 1, 1,
......@@ -1248,7 +1268,7 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
// Check Scroll End Events report correct velocities
// if the user was on a vertical rail
TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
TEST_P(GestureRecognizerTest, GestureEventVerticalRailFling) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -1262,14 +1282,14 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
DispatchEventUsingWindowDispatcher(&press);
// Get rid of touch slop.
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 5),
ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(0, 10),
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&move);
delegate->Reset();
// Move the touch-point vertically enough that it is considered a
// vertical scroll.
tes.SendScrollEvent(event_processor(), 1, 25, kTouchId, delegate.get());
tes.SendScrollEvent(event_processor(), 1, 30, kTouchId, delegate.get());
EXPECT_EQ(20, delegate->scroll_y());
EXPECT_EQ(20, delegate->scroll_y_ordinal());
EXPECT_EQ(0, delegate->scroll_x());
......@@ -1294,9 +1314,9 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
EXPECT_GT(delegate->velocity_y(), 0);
}
// Check Scroll End Events reports zero velocities
// if the user is not on a rail
TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
// Check Scroll End Events report non-zero velocities if the user is not on a
// rail
TEST_P(GestureRecognizerTest, GestureEventNonRailFling) {
ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0);
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
......@@ -1310,10 +1330,11 @@ TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&press);
// Move the touch-point such that a non-rail scroll begins
tes.SendScrollEvent(event_processor(), 20, 20, kTouchId, delegate.get());
EXPECT_EQ(20, delegate->scroll_y());
EXPECT_EQ(20, delegate->scroll_x());
// Move the touch-point such that a non-rail scroll begins, and we're outside
// the snap channel for the unified GR.
tes.SendScrollEvent(event_processor(), 50, 50, kTouchId, delegate.get());
EXPECT_EQ(50, delegate->scroll_y());
EXPECT_EQ(50, delegate->scroll_x());
tes.SendScrollEvents(event_processor(), 1, 1,
10, 100, kTouchId, 1,
......@@ -1332,10 +1353,9 @@ TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
}
// Check that appropriate touch events generate long press events
TEST_F(GestureRecognizerTest, GestureEventLongPress) {
TEST_P(GestureRecognizerTest, GestureEventLongPress) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
const int kWindowWidth = 123;
const int kWindowHeight = 45;
const int kTouchId = 2;
......@@ -1350,8 +1370,10 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
kTouchId, tes.Now());
ui::TouchEvent press1(ui::ET_TOUCH_PRESSED,
gfx::Point(101, 201),
kTouchId,
ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->begin());
......@@ -1366,17 +1388,20 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
EXPECT_FALSE(delegate->tap_cancel());
delegate->Reset();
ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
kTouchId, tes.Now());
ui::TouchEvent release1(ui::ET_TOUCH_RELEASED,
gfx::Point(101, 201),
kTouchId,
ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
// Note the tap down isn't cancelled until the release
// Note the tap cancel isn't dispatched until the release
EXPECT_TRUE(delegate->tap_cancel());
EXPECT_FALSE(delegate->tap());
}
// Check that scrolling cancels a long press
TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
TEST_P(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -1423,10 +1448,9 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
}
// Check that appropriate touch events generate long tap events
TEST_F(GestureRecognizerTest, GestureEventLongTap) {
TEST_P(GestureRecognizerTest, GestureEventLongTap) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
const int kWindowWidth = 123;
const int kWindowHeight = 45;
const int kTouchId = 2;
......@@ -1441,8 +1465,10 @@ TEST_F(GestureRecognizerTest, GestureEventLongTap) {
ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
kTouchId, tes.Now());
ui::TouchEvent press1(ui::ET_TOUCH_PRESSED,
gfx::Point(101, 201),
kTouchId,
ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->begin());
......@@ -1457,18 +1483,26 @@ TEST_F(GestureRecognizerTest, GestureEventLongTap) {
EXPECT_FALSE(delegate->tap_cancel());
delegate->Reset();
ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
kTouchId, tes.Now());
ui::TouchEvent release1(ui::ET_TOUCH_RELEASED,
gfx::Point(101, 201),
kTouchId,
ui::EventTimeForNow());
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
EXPECT_TRUE(delegate->long_tap());
// Note the tap down isn't cancelled until the release
// Note the tap cancel isn't dispatched until the release
EXPECT_TRUE(delegate->tap_cancel());
EXPECT_FALSE(delegate->tap());
}
// Check that second tap cancels a long press
TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
TEST_P(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
// TODO(tdresser): enable this test with unified GR once two finger tap is
// supported. See crbug.com/354396.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -1525,7 +1559,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
// Check that horizontal scroll gestures cause scrolls on horizontal rails.
// Also tests that horizontal rails can be broken.
TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
TEST_P(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -1547,7 +1581,7 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
// Move the touch-point horizontally enough that it is considered a
// horizontal scroll.
tes.SendScrollEvent(event_processor(), 25, 1, kTouchId, delegate.get());
tes.SendScrollEvent(event_processor(), 25, 0, kTouchId, delegate.get());
EXPECT_EQ(0, delegate->scroll_y());
EXPECT_EQ(20, delegate->scroll_x());
......@@ -1575,7 +1609,7 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
// Check that vertical scroll gestures cause scrolls on vertical rails.
// Also tests that vertical rails can be broken.
TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
TEST_P(GestureRecognizerTest, GestureEventVerticalRailScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -1596,7 +1630,7 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
// Move the touch-point vertically enough that it is considered a
// vertical scroll.
tes.SendScrollEvent(event_processor(), 1, 25, kTouchId, delegate.get());
tes.SendScrollEvent(event_processor(), 0, 25, kTouchId, delegate.get());
EXPECT_EQ(0, delegate->scroll_x());
EXPECT_EQ(20, delegate->scroll_y());
......@@ -1623,7 +1657,7 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
EXPECT_EQ(5, delegate->scroll_y());
}
TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
TEST_P(GestureRecognizerTest, GestureTapFollowedByScroll) {
// We'll start by moving the touch point by (5, 5). We want all of that
// distance to be consumed by the slop, so we set the slop radius to
// sqrt(5 * 5 + 5 * 5).
......@@ -1679,14 +1713,14 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
EXPECT_FALSE(delegate->scroll_end());
// Get rid of touch slop.
ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::Point(106, 206),
ui::TouchEvent move_remove_slop(ui::ET_TOUCH_MOVED, gfx::Point(116, 216),
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&move_remove_slop);
EXPECT_TRUE(delegate->tap_cancel());
EXPECT_TRUE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
EXPECT_EQ(5, delegate->scroll_x_hint());
EXPECT_EQ(5, delegate->scroll_y_hint());
EXPECT_TRUE(delegate->scroll_update());
EXPECT_EQ(15, delegate->scroll_x_hint());
EXPECT_EQ(15, delegate->scroll_y_hint());
delegate->Reset();
......@@ -1704,8 +1738,8 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_TRUE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
EXPECT_EQ(29, delegate->scroll_x());
EXPECT_EQ(29, delegate->scroll_y());
EXPECT_EQ(19, delegate->scroll_x());
EXPECT_EQ(19, delegate->scroll_y());
// Move some more to generate a few more scroll updates.
delegate->Reset();
......@@ -1750,7 +1784,11 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
EXPECT_TRUE(delegate->fling());
}
TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
TEST_P(GestureRecognizerTest, AsynchronousGestureRecognition) {
// TODO(tdresser): enable this test with unified GR once two finger tap is
// supported. See crbug.com/354396.
if (UsingUnifiedGR())
return;
scoped_ptr<QueueTouchEventDelegate> queued_delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
const int kWindowWidth = 123;
......@@ -1942,7 +1980,12 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
}
// Check that appropriate touch events generate pinch gesture events.
TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
TEST_P(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Disabled for unified GR due to differences in when pinch begin is sent. The
// Aura GR sends it earlier than is necessary.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -2027,7 +2070,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
EXPECT_TRUE(delegate->bounding_box().IsEmpty());
}
TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
TEST_P(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -2075,16 +2118,20 @@ scoped_ptr<GestureEventConsumeDelegate> delegate(
DispatchEventUsingWindowDispatcher(&press3);
// Now the touch points are close. So we will go into two finger tap.
// Move the touch-point enough to break two-finger-tap and enter pinch.
ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 202),
ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 50),
kTouchId1, tes.Now());
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_TRUE(delegate->pinch_begin());
tes.SendScrollEvent(event_processor(), 130, 230, kTouchId1, delegate.get());
tes.SendScrollEvent(event_processor(), 300, 300, kTouchId1, delegate.get());
EXPECT_TRUE(delegate->pinch_update());
}
TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
TEST_P(GestureRecognizerTest, GestureEventPinchFromTap) {
// TODO(tdresser): enable this test with unified GR once two finger tap.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -2158,7 +2205,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
EXPECT_TRUE(delegate->bounding_box().IsEmpty());
}
TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) {
TEST_P(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -2172,7 +2219,7 @@ TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) {
// Check that a touch is locked to the window of the closest current touch
// within max_separation_for_gesture_touches_in_pixels
TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
TEST_P(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl();
TimedEvents tes;
ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
......@@ -2258,7 +2305,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
// Check that a touch's target will not be effected by a touch on a different
// screen.
TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) {
TEST_P(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
gfx::Rect bounds(0, 0, 10, 10);
......@@ -2288,7 +2335,11 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) {
// Check that touch events outside the root window are still handled
// by the root window's gesture sequence.
TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
TEST_P(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
// TODO(tdresser): write a version of this test for the unified GR.
if (UsingUnifiedGR())
return;
TestGestureRecognizer* gesture_recognizer =
new TestGestureRecognizer();
TimedEvents tes;
......@@ -2317,7 +2368,7 @@ TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
EXPECT_EQ(2, root_window_gesture_sequence->point_count());
}
TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
TEST_P(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -2344,7 +2395,12 @@ TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
EXPECT_TRUE(delegate->tap_cancel());
}
TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
TEST_P(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
// Disabled for unified GR due to differences in when pinch begin is sent. The
// Aura GR sends it earlier than is necessary.
if (UsingUnifiedGR())
return;
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -2438,7 +2494,7 @@ TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
EXPECT_TRUE(delegate->end());
}
TEST_F(GestureRecognizerTest, GestureEndLocation) {
TEST_P(GestureRecognizerTest, GestureEndLocation) {
GestureEventConsumeDelegate delegate;
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
&delegate, -1234, gfx::Rect(10, 10, 300, 300), root_window()));
......@@ -2456,7 +2512,7 @@ TEST_F(GestureRecognizerTest, GestureEndLocation) {
delegate.gesture_end_location().ToString());
}
TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) {
TEST_P(GestureRecognizerTest, CaptureSendsGestureEnd) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TestGestureRecognizer* gesture_recognizer =
......@@ -2485,7 +2541,7 @@ TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) {
// Check that previous touch actions that are completely finished (either
// released or cancelled), do not receive extra synthetic cancels upon change of
// capture.
TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) {
TEST_P(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
scoped_ptr<TestEventHandler> handler(new TestEventHandler);
......@@ -2538,7 +2594,8 @@ TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) {
root_window()->RemovePreTargetHandler(handler.get());
}
TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
// Tests that a press with the same touch id as an existing touch is ignored.
TEST_P(GestureRecognizerTest, PressDoesNotCrash) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TestGestureRecognizer* gesture_recognizer =
......@@ -2567,7 +2624,12 @@ TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
EXPECT_FALSE(delegate->scroll_begin());
}
TEST_F(GestureRecognizerTest, TwoFingerTap) {
TEST_P(GestureRecognizerTest, TwoFingerTap) {
// TODO(tdresser): enable this test with unified GR once two finger tap is
// supported. See crbug.com/354396.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -2655,7 +2717,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTap) {
EXPECT_FALSE(delegate->two_finger_tap());
}
TEST_F(GestureRecognizerTest, TwoFingerTapExpired) {
TEST_P(GestureRecognizerTest, TwoFingerTapExpired) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -2696,7 +2758,12 @@ TEST_F(GestureRecognizerTest, TwoFingerTapExpired) {
EXPECT_FALSE(delegate->two_finger_tap());
}
TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
TEST_P(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
// TODO(tdresser): enable this test with unified GR once two finger tap is
// supported. See crbug.com/354396.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -2768,7 +2835,12 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
}
}
TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) {
TEST_P(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) {
// Disabled for unified GR due to differences in when pinch begin is sent. The
// Aura GR sends it earlier than is necessary.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -2805,7 +2877,7 @@ TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) {
EXPECT_TRUE(delegate->pinch_end());
}
TEST_F(GestureRecognizerTest, MultiFingerSwipe) {
TEST_P(GestureRecognizerTest, MultiFingerSwipe) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -2826,30 +2898,33 @@ TEST_F(GestureRecognizerTest, MultiFingerSwipe) {
aura::test::EventGenerator generator(root_window(), window.get());
// The unified gesture recognizer assumes a finger has stopped if it hasn't
// moved for too long. See ui/events/gesture_detection/velocity_tracker.cc's
// kAssumePointerStoppedTimeMs.
for (int count = 2; count <= kTouchPoints; ++count) {
generator.GestureMultiFingerScroll(
count, points, 1000, kSteps, 0, -11 * kSteps);
count, points, 10, kSteps, 0, -11 * kSteps);
EXPECT_TRUE(delegate->swipe_up());
delegate->Reset();
generator.GestureMultiFingerScroll(
count, points, 1000, kSteps, 0, 11 * kSteps);
count, points, 10, kSteps, 0, 11 * kSteps);
EXPECT_TRUE(delegate->swipe_down());
delegate->Reset();
generator.GestureMultiFingerScroll(
count, points, 1000, kSteps, -11 * kSteps, 0);
count, points, 10, kSteps, -11 * kSteps, 0);
EXPECT_TRUE(delegate->swipe_left());
delegate->Reset();
generator.GestureMultiFingerScroll(
count, points, 1000, kSteps, 11 * kSteps, 0);
count, points, 10, kSteps, 11 * kSteps, 0);
EXPECT_TRUE(delegate->swipe_right());
delegate->Reset();
}
}
TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) {
TEST_P(GestureRecognizerTest, TwoFingerTapCancelled) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -2923,7 +2998,13 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) {
}
}
TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
TEST_P(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
// Disabled for unified GR due to differences in when scroll update is
// sent. The Aura GR will never send a ScrollUpdate with a ScrollBegin, but
// the unified GR will.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 523;
......@@ -2980,7 +3061,7 @@ TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
// Verifies if a window is the target of multiple touch-ids and we hide the
// window everything is cleaned up correctly.
TEST_F(GestureRecognizerTest, FlushAllOnHide) {
TEST_P(GestureRecognizerTest, FlushAllOnHide) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
gfx::Rect bounds(0, 0, 200, 200);
......@@ -3003,7 +3084,11 @@ TEST_F(GestureRecognizerTest, FlushAllOnHide) {
ui::GestureRecognizer::Get()->GetTouchLockedTarget(press2));
}
TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) {
TEST_P(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) {
// TODO(tdresser): write a version of this test for the unified GR.
if (UsingUnifiedGR())
return;
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
const int kTouchId = 2;
......@@ -3063,7 +3148,7 @@ class ConsumesTouchMovesDelegate : public GestureEventConsumeDelegate {
// Same as GestureEventScroll, but tests that the behavior is the same
// even if all the touch-move events are consumed.
TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
TEST_P(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
scoped_ptr<ConsumesTouchMovesDelegate> delegate(
new ConsumesTouchMovesDelegate());
const int kWindowWidth = 123;
......@@ -3115,7 +3200,12 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
}
// Tests the behavior of 2F scroll when all the touch-move events are consumed.
TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
TEST_P(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
// TODO(tdresser): enable this test with unified GR once two finger tap is
// supported. See crbug.com/354396.
if (UsingUnifiedGR())
return;
scoped_ptr<ConsumesTouchMovesDelegate> delegate(
new ConsumesTouchMovesDelegate());
const int kWindowWidth = 123;
......@@ -3222,7 +3312,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
// Like as GestureEventTouchMoveConsumed but tests the different behavior
// depending on whether the events were consumed before or after the scroll
// started.
TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
TEST_P(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
scoped_ptr<ConsumesTouchMovesDelegate> delegate(
new ConsumesTouchMovesDelegate());
const int kWindowWidth = 123;
......@@ -3316,7 +3406,12 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
}
// Check that appropriate touch events generate double tap gesture events.
TEST_F(GestureRecognizerTest, GestureEventDoubleTap) {
TEST_P(GestureRecognizerTest, GestureEventDoubleTap) {
// TODO(tdresser): enable this test with unified GR once double / triple tap
// gestures work. See crbug.com/357270.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -3357,7 +3452,12 @@ TEST_F(GestureRecognizerTest, GestureEventDoubleTap) {
}
// Check that appropriate touch events generate triple tap gesture events.
TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
TEST_P(GestureRecognizerTest, GestureEventTripleTap) {
// TODO(tdresser): enable this test with unified GR once double / triple tap
// gestures work. See crbug.com/357270.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -3412,7 +3512,7 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
}
// Check that we don't get a double tap when the two taps are far apart.
TEST_F(GestureRecognizerTest, TwoTapsFarApart) {
TEST_P(GestureRecognizerTest, TwoTapsFarApart) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -3454,7 +3554,7 @@ TEST_F(GestureRecognizerTest, TwoTapsFarApart) {
// Check that we don't get a double tap when the two taps have a long enough
// delay in between.
TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) {
TEST_P(GestureRecognizerTest, TwoTapsWithDelayBetween) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
......@@ -3497,7 +3597,12 @@ TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) {
// Checks that if the bounding-box of a gesture changes because of change in
// radius of a touch-point, and not because of change in position, then there
// are not gesture events from that.
TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
TEST_P(GestureRecognizerTest, BoundingBoxRadiusChange) {
// TODO(tdresser): enable this test with unified GR when (if?) bounding box
// behavior is unified.
if (UsingUnifiedGR())
return;
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 234;
......@@ -3551,7 +3656,7 @@ TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
// Checks that slow scrolls deliver the correct deltas.
// In particular, fix for http;//crbug.com/150573.
TEST_F(GestureRecognizerTest, NoDriftInScroll) {
TEST_P(GestureRecognizerTest, NoDriftInScroll) {
ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
ui::GestureConfiguration::set_min_scroll_delta_squared(9);
scoped_ptr<GestureEventConsumeDelegate> delegate(
......@@ -3609,7 +3714,7 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) {
// Ensure that move events which are preventDefaulted will cause a tap
// cancel gesture event to be fired if the move would normally cause a
// scroll. See bug http://crbug.com/146397.
TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) {
TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) {
scoped_ptr<ConsumesTouchMovesDelegate> delegate(
new ConsumesTouchMovesDelegate());
const int kTouchId = 5;
......@@ -3639,7 +3744,7 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) {
EXPECT_FALSE(delegate->scroll_end());
}
TEST_F(GestureRecognizerTest,
TEST_P(GestureRecognizerTest,
TransferEventDispatchesTouchCancel) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
......@@ -3682,7 +3787,7 @@ TEST_F(GestureRecognizerTest,
}
// Check that appropriate touch events generate show press events
TEST_F(GestureRecognizerTest, GestureEventShowPress) {
TEST_P(GestureRecognizerTest, GestureEventShowPress) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -3721,12 +3826,13 @@ TEST_F(GestureRecognizerTest, GestureEventShowPress) {
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
// Note the tap down isn't cancelled until the release
EXPECT_TRUE(delegate->tap_cancel());
// Note the tap isn't dispatched until the release
EXPECT_FALSE(delegate->tap_cancel());
EXPECT_TRUE(delegate->tap());
}
// Check that scrolling cancels a show press
TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) {
TEST_P(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -3773,7 +3879,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) {
}
// Test that show press events are sent immediately on tap
TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) {
TEST_P(GestureRecognizerTest, GestureEventShowPressSentOnTap) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
......@@ -3805,7 +3911,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) {
}
// Test that consuming the first move touch event prevents a scroll.
TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) {
TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) {
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -3819,7 +3925,10 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) {
DispatchEventUsingWindowDispatcher(&press);
delegate->ReceivedAck();
ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(2, 2),
// A touch move within the slop region is never consumed in web contents. The
// unified GR won't prevent scroll if a touch move within the slop region is
// consumed, so make sure this touch move exceeds the slop region.
ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(10, 10),
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&move1);
delegate->ReceivedAckPreventDefaulted();
......@@ -3835,7 +3944,12 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) {
// Test that consuming the first touch move event of a touch point doesn't
// prevent pinching once an additional touch has been pressed.
TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) {
TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) {
// Consuming moves within the touch slop and the the disposition handling of
// pinch events behave differently between the Unified GR and the Aura GR.
if (UsingUnifiedGR())
return;
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -3892,7 +4006,7 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMovePinchTest) {
}
// Test that consuming the first move touch doesn't prevent a tap.
TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) {
TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) {
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -3920,7 +4034,7 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) {
}
// Test that consuming the first move touch doesn't prevent a long press.
TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) {
TEST_P(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) {
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -3954,7 +4068,11 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) {
}
// Tests that the deltas are correct when leaving the slop region very slowly.
TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
TEST_P(GestureRecognizerTest, TestExceedingSlopSlowly) {
// Disabled for unified GR due to subtle differences in touch slop handling.
if (UsingUnifiedGR())
return;
ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
......@@ -4012,7 +4130,7 @@ TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
delegate->Reset();
}
TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
TEST_P(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -4071,7 +4189,13 @@ TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
}
}
TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
TEST_P(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
// Disabled for unified GR due to differences in when scroll update is
// sent. The Aura GR will never send a ScrollUpdate with a ScrollBegin, but
// the unified GR will.
if (UsingUnifiedGR())
return;
scoped_ptr<QueueTouchEventDelegate> delegate(
new QueueTouchEventDelegate(host()->dispatcher()));
TimedEvents tes;
......@@ -4155,5 +4279,38 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
}
}
// Test that touch event flags are passed through to the gesture event.
TEST_P(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
TimedEvents tes;
const int kWindowWidth = 123;
const int kWindowHeight = 45;
const int kTouchId = 6;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, root_window()));
delegate->Reset();
ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
kTouchId, tes.Now());
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
int default_flags = delegate->flags();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(397, 149), kTouchId, tes.LeapForward(50));
move1.set_flags(992);
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_NE(default_flags, delegate->flags());
}
INSTANTIATE_TEST_CASE_P(GestureRecognizer,
GestureRecognizerTest,
::testing::Bool());
} // namespace test
} // namespace aura
......@@ -54,7 +54,7 @@ void AuraTestBase::SetUp() {
ui::GestureConfiguration::set_min_rail_break_velocity(200);
ui::GestureConfiguration::set_min_scroll_delta_squared(5 * 5);
ui::GestureConfiguration::
set_min_touch_down_duration_in_seconds_for_click(0.01);
set_min_touch_down_duration_in_seconds_for_click(0.0005);
ui::GestureConfiguration::set_points_buffered_for_velocity(10);
ui::GestureConfiguration::set_rail_break_proportion(15);
ui::GestureConfiguration::set_rail_start_proportion(2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment