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

Unified Diff: ash/wm/workspace/workspace_event_filter_unittest.cc

Issue 10912098: Fix crash if window is destroyed while dragging it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: virtual Created 8 years, 3 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 | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_event_filter_unittest.cc
diff --git a/ash/wm/workspace/workspace_event_filter_unittest.cc b/ash/wm/workspace/workspace_event_filter_unittest.cc
index e240e8a8da36e8cac12dee2477e31abe57e1a000..3bfc3da0339de1816568aa62f92bdb873c4a73b7 100644
--- a/ash/wm/workspace/workspace_event_filter_unittest.cc
+++ b/ash/wm/workspace/workspace_event_filter_unittest.cc
@@ -135,5 +135,39 @@ TEST_F(WorkspaceEventFilterTest, DoubleTapCaptionTogglesMaximize) {
EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
}
+// Verifies deleting the window while dragging doesn't crash.
+TEST_F(WorkspaceEventFilterTest, DeleteWhenDragging) {
+ // Create a large window in the background. This is necessary so that when we
+ // delete |window| WorkspaceEventFilter is still the active EventFilter.
+ aura::test::TestWindowDelegate wd2;
+ scoped_ptr<aura::Window> window2(
+ CreateTestWindow(&wd2, gfx::Rect(0, 0, 500, 500)));
+
+ aura::test::TestWindowDelegate wd;
+ const gfx::Rect bounds(10, 20, 30, 40);
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
+ wd.set_window_component(HTCAPTION);
+ aura::test::EventGenerator generator(window->GetRootWindow());
+ generator.MoveMouseToCenterOf(window.get());
+ generator.PressLeftButton();
+ generator.MoveMouseTo(generator.current_location().Add(gfx::Point(50, 50)));
+ DCHECK_NE(bounds.origin().ToString(), window->bounds().origin().ToString());
+ window.reset();
+ generator.MoveMouseTo(generator.current_location().Add(gfx::Point(50, 50)));
+}
+
+// Verifies deleting the window while in a run loop doesn't crash.
+TEST_F(WorkspaceEventFilterTest, DeleteWhileInRunLoop) {
+ aura::test::TestWindowDelegate wd;
+ const gfx::Rect bounds(10, 20, 30, 40);
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
+ wd.set_window_component(HTCAPTION);
+
+ ASSERT_TRUE(aura::client::GetWindowMoveClient(window->parent()));
+ MessageLoop::current()->DeleteSoon(FROM_HERE, window.get());
+ aura::client::GetWindowMoveClient(window->parent())->RunMoveLoop(
+ window.release(), gfx::Point());
+}
+
} // namespace internal
} // namespace ash
« no previous file with comments | « ash/wm/window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698