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

Unified Diff: ui/aura/root_window_unittest.cc

Issue 23202016: Addressing sadruls comments from the previous CL https://codereview.chromium.org/22865036/ which was (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 4 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 | « ui/aura/root_window.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window_unittest.cc
===================================================================
--- ui/aura/root_window_unittest.cc (revision 219190)
+++ ui/aura/root_window_unittest.cc (working copy)
@@ -908,4 +908,76 @@
filter->events().clear();
}
+// This class inherits from the EventFilterRecorder class which provides a
+// facility to record events. This class additionally provides a facility to
+// repost the ET_GESTURE_TAP_DOWN gesture to the target window and records
+// events after that.
+class RepostGestureEventRecorder : public EventFilterRecorder {
+ public:
+ explicit RepostGestureEventRecorder(aura::Window* repost_target)
+ : repost_target_(repost_target),
+ reposted_(false) {}
+
+ virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
+ if (event->type() == ui::ET_GESTURE_TAP_DOWN && !reposted_) {
+ // We are about to repost here. We clear out the events recorded until
+ // now. This helps in detecting whether the events are recieved in the
+ // correct order at the end, i.e Reposted event first followed by the
+ // rest.
+ events().clear();
sadrul 2013/08/23 15:00:06 We should verify that repost_target_ is not alread
ananta 2013/08/23 20:27:32 Done.
+ reposted_ = true;
+ repost_target_->GetRootWindow()->RepostEvent(*event);
+ return;
+ }
sadrul 2013/08/23 15:00:06 We should also add: if (reposted_) EXPECT_EQ
ananta 2013/08/23 20:27:32 I had to redo the test as we need different root w
+ EventFilterRecorder::OnGestureEvent(event);
+ }
+
+ private:
+ aura::Window* repost_target_;
+ bool reposted_;
+
+ DISALLOW_COPY_AND_ASSIGN(RepostGestureEventRecorder);
+};
+
+// Tests whether events which are generated after the reposted gesture event
+// are received after that. In this case the scroll sequence events should
+// be received after the reposted gesture event.
+TEST_F(RootWindowTest, GestureRepostEventOrder) {
+ // Expected events at the end for the target window. The first three events
+ // are the reposted ones and the rest are for the scroll gesture.
+ const char kExpectedEventOrder[] =
+ "GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_RELEASED TOUCH_PRESSED"
+ " GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED GESTURE_SCROLL_BEGIN"
+ " GESTURE_SCROLL_UPDATE TOUCH_MOVED GESTURE_SCROLL_UPDATE TOUCH_MOVED"
+ " GESTURE_SCROLL_UPDATE TOUCH_RELEASED GESTURE_SCROLL_END GESTURE_END";
+
+ // We create two windows. The first window (repost_window) is the one to
+ // which the initial tap gesture is sent. It reposts this event to the
+ // second window (window2) below. We then generate the scroll sequence for
+ // window 2 and validate the event list at the end.
+ test::TestWindowDelegate delegate;
+ scoped_ptr<aura::Window> repost_window(CreateTestWindowWithDelegate(
+ &delegate, 1, gfx::Rect(0, 0, 50, 50), root_window()));
+
+ scoped_ptr<aura::Window> window2(CreateTestWindowWithDelegate(
+ &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
+
+ RepostGestureEventRecorder* event_recorder =
+ new RepostGestureEventRecorder(window2.get());
+ root_window()->SetEventFilter(event_recorder); // passes ownership
+
+ test::EventGenerator repost_generator(root_window(), repost_window.get());
+ repost_generator.GestureTapAt(gfx::Point(40, 40));
+
+ test::EventGenerator scroll_generator(root_window(), window2.get());
+ scroll_generator.GestureScrollSequence(
+ gfx::Point(60, 60),
+ gfx::Point(90, 90),
+ base::TimeDelta::FromMilliseconds(100),
+ 3);
+
+ EXPECT_TRUE(EventTypesToString(event_recorder->events()) ==
+ kExpectedEventOrder);
+}
+
} // namespace aura
« no previous file with comments | « ui/aura/root_window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698