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

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

Issue 11188012: gesture recognizer: Remove the touch-event queue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 2 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
« no previous file with comments | « content/content_browser.gypi ('k') | ui/aura/root_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22cab46ce46efbd23543191f46be62f2ee15b123..2405df9e7cc1f0cab353c0639c97ebabeeae41ce 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -20,6 +20,8 @@
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
+#include <queue>
+
namespace aura {
namespace test {
@@ -288,21 +290,33 @@ class QueueTouchEventDelegate : public GestureEventConsumeDelegate {
virtual ~QueueTouchEventDelegate() {}
virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
- return queue_events_ ? ui::ER_ASYNC : ui::ER_UNHANDLED;
+ if (queue_events_) {
+ queue_.push(new ui::TouchEvent(*event, window_, window_));
+ return ui::ER_CONSUMED;
+ }
+ return ui::ER_UNHANDLED;
}
void ReceivedAck() {
- root_window_->AdvanceQueuedTouchEvent(window_, false);
+ ReceivedAckImpl(false);
}
void ReceivedAckPreventDefaulted() {
- root_window_->AdvanceQueuedTouchEvent(window_, true);
+ ReceivedAckImpl(true);
}
void set_window(Window* w) { window_ = w; }
void set_queue_events(bool queue) { queue_events_ = queue; }
private:
+ void ReceivedAckImpl(bool prevent_defaulted) {
+ scoped_ptr<ui::TouchEvent> event(queue_.front());
+ root_window_->ProcessedTouchEvent(event.get(), window_,
+ prevent_defaulted ? ui::ER_HANDLED : ui::ER_UNHANDLED);
+ queue_.pop();
+ }
+
+ std::queue<ui::TouchEvent*> queue_;
Window* window_;
RootWindow* root_window_;
bool queue_events_;
@@ -2073,54 +2087,6 @@ 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->tap_cancel());
- 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());
« no previous file with comments | « content/content_browser.gypi ('k') | ui/aura/root_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698