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

Unified Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 679633005: Expose native, desktop and mobile gesture detection defaults (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 years 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 | « ui/aura/window_event_dispatcher.cc ('k') | ui/chromeos/touch_exploration_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_event_dispatcher_unittest.cc
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc
index 25f9186836352a8ebc582cb18e76a84e45e36177..b9994ed07b8b99e536b0f6b4dad50674b3fbdf49 100644
--- a/ui/aura/window_event_dispatcher_unittest.cc
+++ b/ui/aura/window_event_dispatcher_unittest.cc
@@ -449,7 +449,8 @@ class EventFilterRecorder : public ui::EventHandler {
typedef std::vector<int> EventFlags;
EventFilterRecorder()
- : wait_until_event_(ui::ET_UNKNOWN) {
+ : wait_until_event_(ui::ET_UNKNOWN),
+ last_touch_may_cause_scrolling_(false) {
}
const Events& events() const { return events_; }
@@ -478,6 +479,7 @@ class EventFilterRecorder : public ui::EventHandler {
touch_locations_.clear();
gesture_locations_.clear();
mouse_event_flags_.clear();
+ last_touch_may_cause_scrolling_ = false;
}
// ui::EventHandler overrides:
@@ -497,6 +499,7 @@ class EventFilterRecorder : public ui::EventHandler {
void OnTouchEvent(ui::TouchEvent* event) override {
touch_locations_.push_back(event->location());
+ last_touch_may_cause_scrolling_ = event->may_cause_scrolling();
}
void OnGestureEvent(ui::GestureEvent* event) override {
@@ -507,6 +510,10 @@ class EventFilterRecorder : public ui::EventHandler {
return std::find(events_.begin(), events_.end(), type) != events_.end();
}
+ bool LastTouchMayCauseScrolling() const {
+ return last_touch_may_cause_scrolling_;
+ }
+
private:
scoped_ptr<base::RunLoop> run_loop_;
ui::EventType wait_until_event_;
@@ -516,6 +523,7 @@ class EventFilterRecorder : public ui::EventHandler {
EventLocations touch_locations_;
EventLocations gesture_locations_;
EventFlags mouse_event_flags_;
+ bool last_touch_may_cause_scrolling_;
DISALLOW_COPY_AND_ASSIGN(EventFilterRecorder);
};
@@ -2378,4 +2386,51 @@ TEST_F(WindowEventDispatcherTest, GestureEventCoordinates) {
recorder.gesture_locations()[0].ToString());
}
+// Tests that a scroll-generating touch-event is marked as such.
+TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
+ EventFilterRecorder recorder;
+ root_window()->AddPreTargetHandler(&recorder);
+
+ const gfx::Point location(20, 20);
+ ui::TouchEvent press(
+ ui::ET_TOUCH_PRESSED, location, 0, ui::EventTimeForNow());
+ DispatchEventUsingWindowDispatcher(&press);
+ EXPECT_FALSE(recorder.LastTouchMayCauseScrolling());
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_PRESSED));
+ recorder.Reset();
+
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED,
+ location + gfx::Vector2d(100, 100),
+ 0,
+ ui::EventTimeForNow());
+ DispatchEventUsingWindowDispatcher(&move);
+ EXPECT_TRUE(recorder.LastTouchMayCauseScrolling());
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED));
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_BEGIN));
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_UPDATE));
+ recorder.Reset();
+
+ ui::TouchEvent move2(ui::ET_TOUCH_MOVED,
+ location + gfx::Vector2d(200, 200),
+ 0,
+ ui::EventTimeForNow());
+ DispatchEventUsingWindowDispatcher(&move2);
+ EXPECT_TRUE(recorder.LastTouchMayCauseScrolling());
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED));
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_UPDATE));
+ recorder.Reset();
+
+ // Delay the release to avoid fling generation.
+ ui::TouchEvent release(
+ ui::ET_TOUCH_RELEASED,
+ location + gfx::Vector2dF(200, 200),
+ 0,
+ ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1));
+ DispatchEventUsingWindowDispatcher(&release);
+ EXPECT_FALSE(recorder.LastTouchMayCauseScrolling());
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED));
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_END));
+
+ root_window()->RemovePreTargetHandler(&recorder);
+}
} // namespace aura
« no previous file with comments | « ui/aura/window_event_dispatcher.cc ('k') | ui/chromeos/touch_exploration_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698