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

Unified Diff: ui/aura/root_window_unittest.cc

Issue 10545129: aura:Delay call to DispatchHeldMouseMove from RootWindow::ReleaseMouseMoves (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 years, 6 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
diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc
index 1b8c804f6a126193537afadbbd354318620cd57c..ad1afd65f15313105f4d16c20370449f1ad9ac38 100644
--- a/ui/aura/root_window_unittest.cc
+++ b/ui/aura/root_window_unittest.cc
@@ -567,4 +567,80 @@ TEST_F(RootWindowTest, MouseMoveThenTouch) {
}
}
+TEST_F(RootWindowTest, HoldMouseMove) {
+ EventFilterRecorder* filter = new EventFilterRecorder;
+ root_window()->SetEventFilter(filter); // passes ownership
+
+ test::TestWindowDelegate delegate;
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
+ &delegate, 1, gfx::Rect(0, 0, 100, 100), NULL));
+
+ MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0),
+ gfx::Point(0, 0), 0);
+ root_window()->DispatchMouseEvent(&mouse_move_event);
+ // Discard MOUSE_ENTER.
+ filter->events().clear();
+
+ root_window()->HoldMouseMoves();
+
+ // Check that we don't immediately dispatch the MOUSE_DRAGGED event.
+ MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0),
+ gfx::Point(0, 0), 0);
+ root_window()->DispatchMouseEvent(&mouse_dragged_event);
+ EXPECT_TRUE(filter->events().empty());
+
+ // Check that we do dispatch the held MOUSE_DRAGGED event before another type
+ // of event.
+ MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0),
+ gfx::Point(0, 0), 0);
+ root_window()->DispatchMouseEvent(&mouse_pressed_event);
+ EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
+ EventTypesToString(filter->events()));
+ filter->events().clear();
+
+ // Check that we coalesce held MOUSE_DRAGGED events.
+ MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1),
+ gfx::Point(1, 1), 0);
+ root_window()->DispatchMouseEvent(&mouse_dragged_event);
+ root_window()->DispatchMouseEvent(&mouse_dragged_event2);
+ EXPECT_TRUE(filter->events().empty());
+ root_window()->DispatchMouseEvent(&mouse_pressed_event);
+ EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
+ EventTypesToString(filter->events()));
+ filter->events().clear();
+
+ // Check that on ReleaseMouseMoves, held events are not dispatched
+ // immediately, but posted instead.
+ root_window()->DispatchMouseEvent(&mouse_dragged_event);
+ root_window()->ReleaseMouseMoves();
+ EXPECT_TRUE(filter->events().empty());
+ RunAllPendingInMessageLoop();
+ EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events()));
+ filter->events().clear();
+
+ // However if another message comes in before the dispatch,
+ // the Check that on ReleaseMouseMoves, held events are not dispatched
+ // immediately, but posted instead.
+ root_window()->HoldMouseMoves();
+ root_window()->DispatchMouseEvent(&mouse_dragged_event);
+ root_window()->ReleaseMouseMoves();
+ root_window()->DispatchMouseEvent(&mouse_pressed_event);
+ EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
+ EventTypesToString(filter->events()));
+ filter->events().clear();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(filter->events().empty());
+
+ // Check that if the other message is another MOUSE_DRAGGED, we still coalesce
+ // them.
+ root_window()->HoldMouseMoves();
+ root_window()->DispatchMouseEvent(&mouse_dragged_event);
+ root_window()->ReleaseMouseMoves();
+ root_window()->DispatchMouseEvent(&mouse_dragged_event2);
+ EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events()));
+ filter->events().clear();
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(filter->events().empty());
+}
+
} // 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