Index: ui/aura/window_event_dispatcher_unittest.cc |
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc |
index 4fad0f7c71b639d4f3ec115f21f53868aa6da759..c7618fbe0735e954d3841970995a1f42784d932e 100644 |
--- a/ui/aura/window_event_dispatcher_unittest.cc |
+++ b/ui/aura/window_event_dispatcher_unittest.cc |
@@ -916,6 +916,34 @@ TEST_F(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) { |
root_window()->RemovePreTargetHandler(&recorder); |
} |
+// Tests that a mouse-move event is not synthesized when a mouse-button is down. |
+TEST_F(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) { |
+ EventFilterRecorder recorder; |
+ test::TestWindowDelegate delegate; |
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
+ &delegate, 1234, gfx::Rect(5, 5, 100, 100), root_window())); |
+ window->Show(); |
+ |
+ window->AddPreTargetHandler(&recorder); |
+ // Dispatch a non-synthetic mouse event when mouse events are enabled. |
+ ui::MouseEvent mouse1(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), |
+ gfx::Point(10, 10), ui::EF_LEFT_MOUSE_BUTTON, |
+ ui::EF_LEFT_MOUSE_BUTTON); |
+ DispatchEventUsingWindowDispatcher(&mouse1); |
+ ASSERT_EQ(1u, recorder.events().size()); |
+ EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder.events()[0]); |
+ window->RemovePreTargetHandler(&recorder); |
+ recorder.Reset(); |
+ |
+ // Move |window| away from underneath the cursor. |
+ root_window()->AddPreTargetHandler(&recorder); |
+ window->SetBounds(gfx::Rect(30, 30, 100, 100)); |
+ EXPECT_TRUE(recorder.events().empty()); |
+ RunAllPendingInMessageLoop(); |
+ EXPECT_TRUE(recorder.events().empty()); |
+ root_window()->RemovePreTargetHandler(&recorder); |
+} |
+ |
#if defined(OS_WIN) && defined(ARCH_CPU_X86) |
#define MAYBE(x) DISABLED_##x |
#else |