diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-19 18:16:40 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-19 18:16:40 +0000 |
commit | c13d5bd0d03211c3770a481f33bb3b3af94c46fa (patch) | |
tree | 485c5d7b02c1f3a91831a8494d9533a2d2997903 | |
parent | 03ad87d3a93f4c934d3233b6dd1435be49053c22 (diff) | |
download | chromium_src-c13d5bd0d03211c3770a481f33bb3b3af94c46fa.zip chromium_src-c13d5bd0d03211c3770a481f33bb3b3af94c46fa.tar.gz chromium_src-c13d5bd0d03211c3770a481f33bb3b3af94c46fa.tar.bz2 |
Fix bug 166776: [Panel] Closing panel at drag causes a crash on Windows
BUG=166776
TEST=Updating panel tests to cover this
Review URL: https://codereview.chromium.org/11638008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173951 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/panels/panel_drag_browsertest.cc | 26 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_drag_controller.cc | 6 |
2 files changed, 26 insertions, 6 deletions
diff --git a/chrome/browser/ui/panels/panel_drag_browsertest.cc b/chrome/browser/ui/panels/panel_drag_browsertest.cc index 662b384..cb98d11 100644 --- a/chrome/browser/ui/panels/panel_drag_browsertest.cc +++ b/chrome/browser/ui/panels/panel_drag_browsertest.cc @@ -644,11 +644,20 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, CloseDockedPanelOnDrag) { EXPECT_EQ(panel1, panels[1]); EXPECT_EQ(position1, panel4->GetBounds().origin()); - // Closing the dragging panel should end the drag. + // Closing the dragging panel should make the drag controller abort. // We have: P4 - CloseWindowAndWait(panel1); + content::WindowedNotificationObserver signal( + chrome::NOTIFICATION_PANEL_CLOSED, content::Source<Panel>(panel1)); + panel1->Close(); EXPECT_FALSE(drag_controller->IsDragging()); + // Continue the drag to ensure the drag controller does not crash. + panel1_new_position.Offset(20, 30); + panel1_testing->DragTitlebar(panel1_new_position); + panel1_testing->FinishDragTitlebar(); + + // Wait till the panel is fully closed. + signal.Wait(); ASSERT_EQ(1, docked_collection->num_panels()); panels = PanelManager::GetInstance()->panels(); EXPECT_EQ(panel4, panels[0]); @@ -832,10 +841,19 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, CloseDetachedPanelOnDrag) { EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin()); EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); - // Closing the dragging panel should end the drag. - CloseWindowAndWait(panel1); + // Closing the dragging panel should make the drag controller abort. + content::WindowedNotificationObserver signal( + chrome::NOTIFICATION_PANEL_CLOSED, content::Source<Panel>(panel1)); + panel1->Close(); EXPECT_FALSE(drag_controller->IsDragging()); + // Continue the drag to ensure the drag controller does not crash. + panel1_new_position.Offset(20, 30); + panel1_testing->DragTitlebar(panel1_new_position); + panel1_testing->FinishDragTitlebar(); + + // Wait till the panel is fully closed. + signal.Wait(); ASSERT_EQ(1, detached_collection->num_panels()); EXPECT_TRUE(detached_collection->HasPanel(panel4)); EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); diff --git a/chrome/browser/ui/panels/panel_drag_controller.cc b/chrome/browser/ui/panels/panel_drag_controller.cc index 2a7d417..5f1d56c 100644 --- a/chrome/browser/ui/panels/panel_drag_controller.cc +++ b/chrome/browser/ui/panels/panel_drag_controller.cc @@ -51,7 +51,8 @@ void PanelDragController::StartDragging(Panel* panel, } void PanelDragController::Drag(const gfx::Point& mouse_location) { - DCHECK(dragging_panel_); + if (!dragging_panel_) + return; PanelCollection* current_collection = dragging_panel_->collection(); @@ -96,7 +97,8 @@ void PanelDragController::Drag(const gfx::Point& mouse_location) { } void PanelDragController::EndDragging(bool cancelled) { - DCHECK(dragging_panel_); + if (!dragging_panel_) + return; PanelCollection* current_collection = dragging_panel_->collection(); if (cancelled) { |