Index: ash/wm/toplevel_window_event_handler_unittest.cc |
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc |
index 3aa25ba7d8b8a1ed02bcf5845b8574eedef11951..74497f7be2b21a89e3a308b432397550c586bf46 100644 |
--- a/ash/wm/toplevel_window_event_handler_unittest.cc |
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc |
@@ -16,6 +16,7 @@ |
#include "ash/wm/workspace_controller.h" |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
+#include "base/message_loop/message_loop.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/test/aura_test_base.h" |
@@ -705,6 +706,37 @@ TEST_F(ToplevelWindowEventHandlerTest, RunMoveLoopFailsDuringInProgressDrag) { |
EXPECT_EQ("10,11 100x100", window1->bounds().ToString()); |
} |
+namespace { |
+ |
+void SendMouseReleaseAndReleaseCapture(aura::test::EventGenerator* generator, |
+ aura::Window* window) { |
+ generator->ReleaseLeftButton(); |
+ window->ReleaseCapture(); |
+} |
+ |
+} // namespace |
+ |
+// Test that a drag is successful even if ET_MOUSE_CAPTURE_CHANGED is sent |
+// immediately after the mouse release. views::Widget has this behavior. |
+TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) { |
+ scoped_ptr<aura::Window> window(CreateWindow(HTNOWHERE)); |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
+ window.get()); |
+ generator.PressLeftButton(); |
+ window->SetCapture(); |
+ |
+ aura::client::WindowMoveClient* move_client = |
+ aura::client::GetWindowMoveClient(window->GetRootWindow()); |
+ base::MessageLoopForUI::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&SendMouseReleaseAndReleaseCapture, |
+ base::Unretained(&generator), |
+ base::Unretained(window.get()))); |
+ EXPECT_EQ(aura::client::MOVE_SUCCESSFUL, |
+ move_client->RunMoveLoop(window.get(), gfx::Vector2d(), |
+ aura::client::WINDOW_MOVE_SOURCE_MOUSE)); |
+} |
+ |
// Showing the resize shadows when the mouse is over the window edges is tested |
// in resize_shadow_and_cursor_test.cc |