| 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 406b79c0b4637861d7f32bf890764cb1d4080ef4..0248672f84301a91477a77ac6c5de5c0fbaa84fb 100644
|
| --- a/ui/aura/gestures/gesture_recognizer_unittest.cc
|
| +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
|
| @@ -212,11 +212,14 @@ class QueueTouchEventDelegate : public GestureEventConsumeDelegate {
|
| public:
|
| explicit QueueTouchEventDelegate(RootWindow* root_window)
|
| : window_(NULL),
|
| - root_window_(root_window) {
|
| + root_window_(root_window),
|
| + queue_events_(true) {
|
| }
|
| virtual ~QueueTouchEventDelegate() {}
|
|
|
| virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
|
| + if (!queue_events_)
|
| + return ui::TOUCH_STATUS_UNKNOWN;
|
| return event->type() == ui::ET_TOUCH_RELEASED ?
|
| ui::TOUCH_STATUS_QUEUED_END : ui::TOUCH_STATUS_QUEUED;
|
| }
|
| @@ -230,10 +233,12 @@ class QueueTouchEventDelegate : public GestureEventConsumeDelegate {
|
| }
|
|
|
| void set_window(Window* w) { window_ = w; }
|
| + void set_queue_events(bool queue) { queue_events_ = queue; }
|
|
|
| private:
|
| Window* window_;
|
| RootWindow* root_window_;
|
| + bool queue_events_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(QueueTouchEventDelegate);
|
| };
|
| @@ -1930,6 +1935,53 @@ TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
|
| EXPECT_FALSE(delegate->scroll_begin());
|
| }
|
|
|
| +// Tests that if a consumer has touch-events queued, then no touch-event gets
|
| +// processed synchronously until all the queued evets are processed.
|
| +TEST_F(GestureRecognizerTest, SyncTouchEventWithQueuedTouchEvents) {
|
| + scoped_ptr<QueueTouchEventDelegate> queued_delegate(
|
| + new QueueTouchEventDelegate(root_window()));
|
| + const int kWindowWidth = 123;
|
| + const int kWindowHeight = 45;
|
| + const int kTouchId1 = 6;
|
| + gfx::Rect bounds(10, 20, kWindowWidth, kWindowHeight);
|
| + scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate(
|
| + queued_delegate.get(), -1234, bounds, NULL));
|
| +
|
| + queued_delegate->set_window(queue.get());
|
| +
|
| + // Send a touch-event to the window so that the event gets queued. No gesture
|
| + // event should be created.
|
| + ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(20, 30), kTouchId1,
|
| + GetTime());
|
| + ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(80, 25), kTouchId1,
|
| + press1.time_stamp() + base::TimeDelta::FromMilliseconds(100));
|
| + ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(80, 25), kTouchId1,
|
| + move1.time_stamp() + base::TimeDelta::FromMilliseconds(100));
|
| + root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
|
| + root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1);
|
| + EXPECT_FALSE(queued_delegate->begin());
|
| + EXPECT_FALSE(queued_delegate->tap_down());
|
| + EXPECT_FALSE(queued_delegate->scroll_begin());
|
| +
|
| + // Stop queueing events.
|
| + queued_delegate->set_queue_events(false);
|
| + root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
|
| +
|
| + // Process the two queued events.
|
| + queued_delegate->ReceivedAck();
|
| + RunAllPendingInMessageLoop();
|
| + EXPECT_TRUE(queued_delegate->begin());
|
| + EXPECT_TRUE(queued_delegate->tap_down());
|
| + queued_delegate->Reset();
|
| +
|
| + queued_delegate->ReceivedAck();
|
| + RunAllPendingInMessageLoop();
|
| + EXPECT_TRUE(queued_delegate->scroll_begin());
|
| + EXPECT_TRUE(queued_delegate->scroll_update());
|
| + EXPECT_TRUE(queued_delegate->scroll_end());
|
| + EXPECT_TRUE(queued_delegate->end());
|
| +}
|
| +
|
| TEST_F(GestureRecognizerTest, TwoFingerTap) {
|
| scoped_ptr<GestureEventConsumeDelegate> delegate(
|
| new GestureEventConsumeDelegate());
|
|
|