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

Unified Diff: ui/aura/root_window_unittest.cc

Issue 136843003: Wait for SHOW_PRESS gesture to avoid flake in root_window_unittest.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase? Created 6 years, 11 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 | « no previous file | 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
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698