diff options
author | tdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-16 03:13:59 +0000 |
---|---|---|
committer | tdresser@chromium.org <tdresser@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-16 03:13:59 +0000 |
commit | 62e30ea1711b73e8bf7ab06d5f7a7227fc03da95 (patch) | |
tree | 573021c0c43cc6ebf64101a7b60cf93a0b5fdf4c /ui/aura/root_window_unittest.cc | |
parent | bcc2c8fab9138ab1862c4c9f72b959f012ff0a57 (diff) | |
download | chromium_src-62e30ea1711b73e8bf7ab06d5f7a7227fc03da95.zip chromium_src-62e30ea1711b73e8bf7ab06d5f7a7227fc03da95.tar.gz chromium_src-62e30ea1711b73e8bf7ab06d5f7a7227fc03da95.tar.bz2 |
Wait for SHOW_PRESS gesture to avoid flake in root_window_unittest.cc
Previously in RootWindowTest.TouchMovesHeld, sometimes a SHOW_PRESS
gesture would be fired, and sometimes it wouldn't, depending on
whether or not the 5ms timer used in tests for the SHOW_PRESS
gesture was fired. Now we explicitly wait for the gesture to be
fired before continuing.
Marked flaky here: https://codereview.chromium.org/136013002/
TEST=RootWindowTest.TouchMovesHeld
BUG=333644
Review URL: https://codereview.chromium.org/136843003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/root_window_unittest.cc')
-rw-r--r-- | ui/aura/root_window_unittest.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc index 2ce2f73..6c99d8f 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 WaitUntilReceivedEvent(ui::EventType type) { + wait_until_event_ = type; + run_loop_.reset(new base::RunLoop( + Env::GetInstance()->GetDispatcher())); + run_loop_->Run(); + } + Events GetAndResetEvents() { Events events = events_; Reset(); @@ -454,6 +463,10 @@ class EventFilterRecorder : public ui::EventHandler { virtual void OnEvent(ui::Event* event) OVERRIDE { ui::EventHandler::OnEvent(event); events_.push_back(event->type()); + if (wait_until_event_ == event->type() && run_loop_) { + run_loop_->Quit(); + wait_until_event_ = ui::ET_UNKNOWN; + } } virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { @@ -465,6 +478,9 @@ class EventFilterRecorder : public ui::EventHandler { } private: + scoped_ptr<base::RunLoop> run_loop_; + ui::EventType wait_until_event_; + Events events_; EventLocations mouse_locations_; EventLocations touch_locations_; @@ -669,13 +685,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 +701,7 @@ TEST_F(RootWindowTest, MAYBE_TouchMovesHeld) { 0, base::TimeDelta()); dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent( &touch_pressed_event); - RunAllPendingInMessageLoop(); + filter->WaitUntilReceivedEvent(ui::ET_GESTURE_SHOW_PRESS); filter->Reset(); dispatcher()->HoldPointerMoves(); |