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

Unified Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 306483003: Prepare for Unified Gesture Recognizer landing in Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable UGR again. Created 6 years, 7 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/window_event_dispatcher_unittest.cc
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc
index 9c3a77ec15ac8d33d605fc36c8a93d740c2faa69..b970792cff7c7791226c9ae686009a725052545a 100644
--- a/ui/aura/window_event_dispatcher_unittest.cc
+++ b/ui/aura/window_event_dispatcher_unittest.cc
@@ -499,6 +499,14 @@ class EventFilterRecorder : public ui::EventHandler {
touch_locations_.push_back(event->location());
}
+ bool HasReceivedEvent(ui::EventType type) {
+ for (size_t i = 0; i < events_.size(); ++i) {
+ if (events_[i] == type)
+ return true;
+ }
+ return false;
+ }
+
private:
scoped_ptr<base::RunLoop> run_loop_;
ui::EventType wait_until_event_;
@@ -754,12 +762,12 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// If another touch event occurs then the held touch should be dispatched
// immediately before it.
ui::TouchEvent touch_released_event(ui::ET_TOUCH_RELEASED, touch_location,
- 0, base::TimeDelta());
+ 0, base::TimeDelta::FromMilliseconds(50));
recorder.Reset();
host()->dispatcher()->HoldPointerMoves();
DispatchEventUsingWindowDispatcher(&touch_moved_event);
DispatchEventUsingWindowDispatcher(&touch_released_event);
- EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP_CANCEL GESTURE_END",
+ EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP GESTURE_END",
EventTypesToString(recorder.events()));
recorder.Reset();
host()->dispatcher()->ReleasePointerMoves();
@@ -1582,8 +1590,10 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) {
window->Hide();
- EXPECT_EQ("TOUCH_CANCELLED GESTURE_TAP_CANCEL GESTURE_END",
- EventTypesToString(recorder.events()));
+ EXPECT_EQ(ui::ET_TOUCH_CANCELLED, recorder.events()[0]);
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_TAP_CANCEL));
+ EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_END));
+ EXPECT_EQ(3U, recorder.events().size());
root_window()->RemovePreTargetHandler(&recorder);
}
@@ -1606,16 +1616,33 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) {
ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, position1, 1, base::TimeDelta());
DispatchEventUsingWindowDispatcher(&press2);
- EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
- "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
- "TOUCH_PRESSED GESTURE_BEGIN GESTURE_PINCH_BEGIN",
- EventTypesToString(recorder.GetAndResetEvents()));
+ // TODO(tdresser): once the unified Gesture Recognizer has stuck, remove the
+ // special casing here. See crbug.com/332418 for details.
+ std::string expected =
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
+ "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_PINCH_BEGIN";
+
+ std::string expected_ugr =
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
+ "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
+ "TOUCH_PRESSED GESTURE_BEGIN";
+
+ std::string events_string = EventTypesToString(recorder.GetAndResetEvents());
+ EXPECT_TRUE((expected == events_string) || (expected_ugr == events_string));
window->Hide();
- EXPECT_EQ("TOUCH_CANCELLED GESTURE_PINCH_END GESTURE_END TOUCH_CANCELLED "
- "GESTURE_SCROLL_END GESTURE_END",
- EventTypesToString(recorder.events()));
+ expected =
+ "TOUCH_CANCELLED GESTURE_PINCH_END GESTURE_END TOUCH_CANCELLED "
+ "GESTURE_SCROLL_END GESTURE_END";
+ expected_ugr =
+ "TOUCH_CANCELLED GESTURE_SCROLL_END GESTURE_END GESTURE_END "
+ "TOUCH_CANCELLED";
+
+ events_string = EventTypesToString(recorder.GetAndResetEvents());
+ EXPECT_TRUE((expected == events_string) || (expected_ugr == events_string));
+
root_window()->RemovePreTargetHandler(&recorder);
}

Powered by Google App Engine
This is Rietveld 408576698