Chromium Code Reviews| Index: ui/aura/root_window_unittest.cc |
| diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc |
| index 2ce2f73d64e1b1800a8e272e85406fdf6a0ef879..9c484f9b2da118ba9f1599e1cf79fab633aa2e27 100644 |
| --- a/ui/aura/root_window_unittest.cc |
| +++ b/ui/aura/root_window_unittest.cc |
| @@ -430,7 +430,9 @@ class EventFilterRecorder : public ui::EventHandler { |
| typedef std::vector<ui::EventType> Events; |
| typedef std::vector<gfx::Point> EventLocations; |
| - EventFilterRecorder() {} |
| + EventFilterRecorder() |
| + : wait_until_event_(ui::ET_UNKNOWN) { |
| + } |
| const Events& events() const { return events_; } |
| @@ -438,6 +440,13 @@ class EventFilterRecorder : public ui::EventHandler { |
| gfx::Point mouse_location(int i) const { return mouse_locations_[i]; } |
| const EventLocations& touch_locations() const { return touch_locations_; } |
| + void WaitUntilReceivedGesture(ui::EventType type) { |
|
sadrul
2014/01/15 19:08:59
Call this WaitUntilReceivedEvent
tdresser
2014/01/15 19:30:41
Done.
|
| + wait_until_event_ = type; |
| + run_loop_.reset(new base::RunLoop( |
| + Env::GetInstance()->GetDispatcher())); |
| + run_loop_->Run(); |
| + } |
| + |
| Events GetAndResetEvents() { |
| Events events = events_; |
| Reset(); |
| @@ -464,7 +473,17 @@ class EventFilterRecorder : public ui::EventHandler { |
| touch_locations_.push_back(event->location()); |
| } |
| + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
| + if (wait_until_event_ == event->type() && run_loop_) { |
| + run_loop_->Quit(); |
| + wait_until_event_ = ui::ET_UNKNOWN; |
|
sadrul
2014/01/15 19:08:59
Do this in OnEvent
tdresser
2014/01/15 19:30:41
Done.
|
| + } |
| + } |
| + |
| private: |
| + scoped_ptr<base::RunLoop> run_loop_; |
| + ui::EventType wait_until_event_; |
| + |
| Events events_; |
| EventLocations mouse_locations_; |
| EventLocations touch_locations_; |
| @@ -669,13 +688,7 @@ TEST_F(RootWindowTest, MouseMovesHeld) { |
| EXPECT_TRUE(filter->events().empty()); |
| } |
| -#if defined(OS_CHROMEOS) |
| -// This test may be flaky on Chromium OS valgrind bots: http://crbug.com/333644 |
| -#define MAYBE_TouchMovesHeld DISABLED_TouchMovesHeld |
| -#else |
| -#define MAYBE_TouchMovesHeld TouchMovesHeld |
| -#endif |
| -TEST_F(RootWindowTest, MAYBE_TouchMovesHeld) { |
| +TEST_F(RootWindowTest, TouchMovesHeld) { |
| EventFilterRecorder* filter = new EventFilterRecorder; |
| root_window()->SetEventFilter(filter); // passes ownership |
| @@ -691,7 +704,7 @@ TEST_F(RootWindowTest, MAYBE_TouchMovesHeld) { |
| 0, base::TimeDelta()); |
| dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent( |
| &touch_pressed_event); |
| - RunAllPendingInMessageLoop(); |
| + filter->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
| filter->Reset(); |
| dispatcher()->HoldPointerMoves(); |