Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

Unified Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 9452024: Gestures are now possible using touch events with any ids (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Commented GetPointByPointId Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fc1689f34869f301da0359fe7bda43904a4c83c5..64e08e4adee7f7c9ffa6c2f67b14ac23d8235f3d 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -69,7 +69,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
float scroll_x() const { return scroll_x_; }
float scroll_y() const { return scroll_y_; }
- unsigned int touch_id() const { return touch_id_; }
+ int touch_id() const { return touch_id_; }
virtual ui::GestureStatus OnGestureEvent(GestureEvent* gesture) OVERRIDE {
switch (gesture->type()) {
@@ -126,7 +126,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate {
float scroll_x_;
float scroll_y_;
- unsigned int touch_id_;
+ int touch_id_;
DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate);
};
@@ -262,6 +262,7 @@ void SendScrollEvents(RootWindow* root_window,
base::TimeDelta time_start,
int dx,
int dy,
+ int touch_id,
int time_step,
int num_steps,
GestureEventConsumeDelegate* delegate) {
@@ -271,7 +272,7 @@ void SendScrollEvents(RootWindow* root_window,
for (int i = 0; i < num_steps; i++) {
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 0);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), touch_id);
Event::TestApi test_move(&move);
test_move.set_time_stamp(time);
root_window->DispatchTouchEvent(&move);
@@ -284,9 +285,10 @@ void SendScrollEvents(RootWindow* root_window,
void SendScrollEvent(RootWindow* root_window,
int x,
int y,
+ int touch_id,
GestureEventConsumeDelegate* delegate) {
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), 0);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), touch_id);
root_window->DispatchTouchEvent(&move);
}
@@ -302,12 +304,13 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
+ const int kTouchId = 2;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -320,7 +323,7 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
// Make sure there is enough delay before the touch is released so that it is
// recognized as a tap.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -339,12 +342,13 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
+ const int kTouchId = 5;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -357,7 +361,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
// should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
// The first movement is diagonal, to ensure that we have a free scroll,
// and not a rail scroll.
- SendScrollEvent(root_window(), 130, 230, delegate.get());
+ SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
EXPECT_FALSE(delegate->double_tap());
@@ -368,7 +372,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
EXPECT_EQ(29, delegate->scroll_y());
// Move some more to generate a few more scroll updates.
- SendScrollEvent(root_window(), 110, 211, delegate.get());
+ SendScrollEvent(root_window(), 110, 211, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
EXPECT_FALSE(delegate->double_tap());
@@ -378,7 +382,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
EXPECT_EQ(-20, delegate->scroll_x());
EXPECT_EQ(-19, delegate->scroll_y());
- SendScrollEvent(root_window(), 140, 215, delegate.get());
+ SendScrollEvent(root_window(), 140, 215, kTouchId, delegate.get());
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
EXPECT_FALSE(delegate->double_tap());
@@ -390,7 +394,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
// Release the touch. This should end the scroll.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -409,6 +413,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
+ const int kTouchId = 2;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -423,7 +428,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
RootWindow::GetInstance()->SetGestureRecognizerForTesting(gesture_recognizer);
- TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
RootWindow::GetInstance()->DispatchTouchEvent(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -433,10 +438,10 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
// Wait until the timer runs out
gesture_sequence->ForceTimeout();
EXPECT_TRUE(delegate->long_press());
- EXPECT_EQ(0u, delegate->touch_id());
+ EXPECT_EQ(0, delegate->touch_id());
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
RootWindow::GetInstance()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->long_press());
}
@@ -447,6 +452,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
new GestureEventConsumeDelegate());
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, NULL));
@@ -461,7 +467,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
RootWindow::GetInstance()->SetGestureRecognizerForTesting(gesture_recognizer);
- TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
RootWindow::GetInstance()->DispatchTouchEvent(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -469,13 +475,13 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
EXPECT_FALSE(delegate->long_press());
// Scroll around, to cancel the long press
- SendScrollEvent(root_window(), 130, 230, delegate.get());
+ SendScrollEvent(root_window(), 130, 230, kTouchId, delegate.get());
// Wait until the timer runs out
gesture_sequence->ForceTimeout();
EXPECT_FALSE(delegate->long_press());
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
RootWindow::GetInstance()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->long_press());
}
@@ -486,6 +492,8 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 300;
const int kWindowHeight = 400;
+ const int kTouchId1 = 8;
+ const int kTouchId2 = 2;
gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -499,7 +507,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
RootWindow::GetInstance()->SetGestureRecognizerForTesting(gesture_recognizer);
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
RootWindow::GetInstance()->DispatchTouchEvent(&press);
EXPECT_TRUE(delegate->tap_down());
@@ -508,7 +516,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
// Pinch, to cancel the long press
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
RootWindow::GetInstance()->DispatchTouchEvent(&press2);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->pinch_begin());
@@ -520,7 +528,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
EXPECT_FALSE(delegate->long_press());
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
RootWindow::GetInstance()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->long_press());
}
@@ -530,20 +538,21 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByPinch) {
TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
+ const int kTouchId = 7;
gfx::Rect bounds(0, 0, 1000, 1000);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), kTouchId);
root_window()->DispatchTouchEvent(&press);
// Move the touch-point horizontally enough that it is considered a
// horizontal scroll.
- SendScrollEvent(root_window(), 20, 1, delegate.get());
+ SendScrollEvent(root_window(), 20, 1, kTouchId, delegate.get());
EXPECT_EQ(0, delegate->scroll_y());
EXPECT_EQ(20, delegate->scroll_x());
- SendScrollEvent(root_window(), 25, 6, delegate.get());
+ SendScrollEvent(root_window(), 25, 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.
@@ -552,10 +561,10 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
// Send enough information that a velocity can be calculated for the gesture,
// and we can break the rail
SendScrollEvents(root_window(), 1, 1, press.time_stamp(),
- 1, 100, 1, kBufferedPoints, delegate.get());
+ 1, 100, kTouchId, 1, kBufferedPoints, delegate.get());
- SendScrollEvent(root_window(), 0, 0, delegate.get());
- SendScrollEvent(root_window(), 5, 5, delegate.get());
+ SendScrollEvent(root_window(), 0, 0, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 5, 5, kTouchId, delegate.get());
// The rail should be broken
EXPECT_TRUE(delegate->scroll_update());
@@ -568,20 +577,21 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
+ const int kTouchId = 7;
gfx::Rect bounds(0, 0, 1000, 1000);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), kTouchId);
root_window()->DispatchTouchEvent(&press);
// Move the touch-point vertically enough that it is considered a
// vertical scroll.
- SendScrollEvent(root_window(), 1, 20, delegate.get());
+ SendScrollEvent(root_window(), 1, 20, kTouchId, delegate.get());
EXPECT_EQ(0, delegate->scroll_x());
EXPECT_EQ(20, delegate->scroll_y());
- SendScrollEvent(root_window(), 6, 25, delegate.get());
+ SendScrollEvent(root_window(), 6, 25, 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.
@@ -590,10 +600,10 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
// Send enough information that a velocity can be calculated for the gesture,
// and we can break the rail
SendScrollEvents(root_window(), 1, 1, press.time_stamp(),
- 100, 1, 1, kBufferedPoints, delegate.get());
+ 100, 1, kTouchId, 1, kBufferedPoints, delegate.get());
- SendScrollEvent(root_window(), 0, 0, delegate.get());
- SendScrollEvent(root_window(), 5, 5, delegate.get());
+ SendScrollEvent(root_window(), 0, 0, kTouchId, delegate.get());
+ SendScrollEvent(root_window(), 5, 5, kTouchId, delegate.get());
// The rail should be broken
EXPECT_TRUE(delegate->scroll_update());
@@ -607,12 +617,13 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 123;
const int kWindowHeight = 45;
+ const int kTouchId = 3;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -624,7 +635,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Make sure there is enough delay before the touch is released so that it is
// recognized as a tap.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -639,7 +650,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Now, do a scroll gesture. Delay it sufficiently so that it doesn't trigger
// a double-tap.
delegate->Reset();
- TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId);
Event::TestApi test_release1(&press1);
test_release1.set_time_stamp(release.time_stamp() +
base::TimeDelta::FromMilliseconds(1000));
@@ -656,7 +667,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// The first movement is diagonal, to ensure that we have a free scroll,
// and not a rail scroll.
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230), 0);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 230), kTouchId);
root_window()->DispatchTouchEvent(&move);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -669,7 +680,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Move some more to generate a few more scroll updates.
delegate->Reset();
- TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211), 0);
+ TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(110, 211), kTouchId);
root_window()->DispatchTouchEvent(&move1);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -681,7 +692,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
EXPECT_EQ(-19, delegate->scroll_y());
delegate->Reset();
- TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215), 0);
+ TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(140, 215), kTouchId);
root_window()->DispatchTouchEvent(&move2);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -694,7 +705,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Release the touch. This should end the scroll.
delegate->Reset();
- TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId);
root_window()->DispatchTouchEvent(&release1);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -713,7 +724,7 @@ TEST_F(GestureRecognizerTest, GestureTapSyntheticMouse) {
gfx::Rect(0, 0, 123, 45), NULL));
delegate->Reset();
- GestureEvent tap(ui::ET_GESTURE_TAP, 20, 20, 0, base::Time::Now(), 0, 0);
+ GestureEvent tap(ui::ET_GESTURE_TAP, 20, 20, 0, base::Time::Now(), 0, 6);
root_window()->DispatchGestureEvent(&tap);
EXPECT_TRUE(delegate->mouse_enter());
EXPECT_TRUE(delegate->mouse_press());
@@ -726,6 +737,8 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
new QueueTouchEventDelegate(root_window()));
const int kWindowWidth = 123;
const int kWindowHeight = 45;
+ const int kTouchId1 = 6;
+ const int kTouchId2 = 4;
gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate(
queued_delegate.get(), -1234, bounds, NULL));
@@ -734,7 +747,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
// Touch down on the window. This should not generate any gesture event.
queued_delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
root_window()->DispatchTouchEvent(&press);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -746,7 +759,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
// Introduce some delay before the touch is released so that it is recognized
// as a tap. However, this still should not create any gesture events.
queued_delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -765,7 +778,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), NULL));
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), 0);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), kTouchId2);
root_window()->DispatchTouchEvent(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -774,7 +787,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
EXPECT_FALSE(delegate->scroll_update());
EXPECT_FALSE(delegate->scroll_end());
- TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0);
+ TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), kTouchId2);
root_window()->DispatchTouchEvent(&release2);
// Process the first queued event.
@@ -800,7 +813,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
// Start all over. Press on the first window, then press again on the second
// window. The second press should still go to the first window.
queued_delegate->Reset();
- TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
root_window()->DispatchTouchEvent(&press3);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -811,7 +824,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
queued_delegate->Reset();
delegate->Reset();
- TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), 1);
+ TouchEvent press4(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), kTouchId2);
root_window()->DispatchTouchEvent(&press4);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -854,6 +867,8 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
new GestureEventConsumeDelegate());
const int kWindowWidth = 300;
const int kWindowHeight = 400;
+ const int kTouchId1 = 5;
+ const int kTouchId2 = 3;
gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -861,7 +876,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
aura::RootWindow* root = root_window();
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
root->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -873,7 +888,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Move the touch-point enough so that it is considered as a scroll. This
// should generate both SCROLL_BEGIN and SCROLL_UPDATE gestures.
delegate->Reset();
- TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 201), 0);
+ TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(130, 201), kTouchId1);
root->DispatchTouchEvent(&move);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -884,7 +899,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Press the second finger. It should cause both a tap-down and pinch-begin.
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
root->DispatchTouchEvent(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -896,7 +911,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Move the first finger.
delegate->Reset();
- TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), 0);
+ TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(95, 201), kTouchId1);
root->DispatchTouchEvent(&move3);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -909,7 +924,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Now move the second finger.
delegate->Reset();
- TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 1);
+ TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), kTouchId2);
root->DispatchTouchEvent(&move4);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -922,7 +937,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Release the first finger. This should end pinch.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -937,7 +952,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
// Move the second finger. This should still generate a scroll.
delegate->Reset();
- TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 1);
+ TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), kTouchId2);
root->DispatchTouchEvent(&move5);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -949,11 +964,53 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
EXPECT_FALSE(delegate->pinch_update());
}
+TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
+scoped_ptr<GestureEventConsumeDelegate> delegate(
+ new GestureEventConsumeDelegate());
+ const int kWindowWidth = 300;
+ const int kWindowHeight = 400;
+ const int kTouchId1 = 5;
+ const int kTouchId2 = 3;
+ gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ delegate.get(), -1234, bounds, NULL));
+
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
+ root_window()->DispatchTouchEvent(&press);
+ delegate->Reset();
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
+ root_window()->DispatchTouchEvent(&press2);
+ EXPECT_TRUE(delegate->pinch_begin());
+
+ SendScrollEvent(root_window(), 130, 230, kTouchId1, delegate.get());
+ EXPECT_TRUE(delegate->pinch_update());
+
+ // Pinch has started, now release the second finger
+ delegate->Reset();
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
+ root_window()->DispatchTouchEvent(&release);
+ EXPECT_TRUE(delegate->pinch_end());
+
+ SendScrollEvent(root_window(), 130, 230, kTouchId2, delegate.get());
+ EXPECT_TRUE(delegate->scroll_update());
+
+ // Pinch again
+ delegate->Reset();
+ TouchEvent press3(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId1);
+ root_window()->DispatchTouchEvent(&press3);
+ EXPECT_TRUE(delegate->pinch_begin());
+
+ SendScrollEvent(root_window(), 130, 230, kTouchId1, delegate.get());
+ EXPECT_TRUE(delegate->pinch_update());
+}
+
TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
scoped_ptr<GestureEventConsumeDelegate> delegate(
new GestureEventConsumeDelegate());
const int kWindowWidth = 300;
const int kWindowHeight = 400;
+ const int kTouchId1 = 3;
+ const int kTouchId2 = 5;
gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, bounds, NULL));
@@ -961,7 +1018,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
aura::RootWindow* root = root_window();
delegate->Reset();
- TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 0);
+ TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId1);
root->DispatchTouchEvent(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -973,7 +1030,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Press the second finger. It should cause a tap-down, scroll-begin and
// pinch-begin.
delegate->Reset();
- TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
+ TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), kTouchId2);
root->DispatchTouchEvent(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -985,7 +1042,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Move the first finger.
delegate->Reset();
- TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), 0);
+ TouchEvent move3(ui::ET_TOUCH_MOVED, gfx::Point(65, 201), kTouchId1);
root->DispatchTouchEvent(&move3);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -998,7 +1055,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Now move the second finger.
delegate->Reset();
- TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), 1);
+ TouchEvent move4(ui::ET_TOUCH_MOVED, gfx::Point(55, 15), kTouchId2);
root->DispatchTouchEvent(&move4);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1011,7 +1068,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Release the first finger. This should end pinch.
delegate->Reset();
- TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 0);
+ TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), kTouchId1);
Event::TestApi test_release(&release);
test_release.set_time_stamp(press.time_stamp() +
base::TimeDelta::FromMilliseconds(50));
@@ -1026,7 +1083,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
// Move the second finger. This should still generate a scroll.
delegate->Reset();
- TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), 1);
+ TouchEvent move5(ui::ET_TOUCH_MOVED, gfx::Point(25, 10), kTouchId2);
root->DispatchTouchEvent(&move5);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());

Powered by Google App Engine
This is Rietveld 408576698