Commit 3fa80032 authored by Eliot Courtney's avatar Eliot Courtney Committed by Commit Bot

Move DeleteDragDetails to destructor in PipWindowResizer.

Bug: b/127224879
Test: drag-move an Android PIP window - no crash upon finishing drag.
Change-Id: I3d455f3545ea1a7bfba4c9ec6f6b51d3b218078d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1498744
Commit-Queue: Eliot Courtney <edcourtney@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637606}
parent adadec6b
...@@ -96,7 +96,11 @@ PipWindowResizer::PipWindowResizer(wm::WindowState* window_state) ...@@ -96,7 +96,11 @@ PipWindowResizer::PipWindowResizer(wm::WindowState* window_state)
} }
} }
PipWindowResizer::~PipWindowResizer() {} PipWindowResizer::~PipWindowResizer() {
// Drag details should be deleted upon destruction of the resizer.
if (window_state())
window_state()->DeleteDragDetails();
}
// TODO(edcourtney): Implement swipe-to-dismiss on fling. // TODO(edcourtney): Implement swipe-to-dismiss on fling.
void PipWindowResizer::Drag(const gfx::Point& location_in_parent, void PipWindowResizer::Drag(const gfx::Point& location_in_parent,
...@@ -190,7 +194,7 @@ void PipWindowResizer::CompleteDrag() { ...@@ -190,7 +194,7 @@ void PipWindowResizer::CompleteDrag() {
} }
window_state()->OnCompleteDrag(last_location_in_screen_); window_state()->OnCompleteDrag(last_location_in_screen_);
window_state()->DeleteDragDetails();
window_state()->ClearRestoreBounds(); window_state()->ClearRestoreBounds();
window_state()->set_bounds_changed_by_user(moved_or_resized_); window_state()->set_bounds_changed_by_user(moved_or_resized_);
......
...@@ -592,6 +592,23 @@ TEST_P(PipWindowResizerTest, PipFreeResizeAreaUmaMetrics) { ...@@ -592,6 +592,23 @@ TEST_P(PipWindowResizerTest, PipFreeResizeAreaUmaMetrics) {
histograms().ExpectTotalCount(kAshPipFreeResizeFinishAreaHistogramName, 1); histograms().ExpectTotalCount(kAshPipFreeResizeFinishAreaHistogramName, 1);
} }
TEST_P(PipWindowResizerTest, DragDetailsAreDestroyed) {
PreparePipWindow(gfx::Rect(200, 200, 100, 100));
wm::WindowState* window_state = wm::GetWindowState(window());
{
std::unique_ptr<PipWindowResizer> resizer(CreateResizerForTest(HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0);
EXPECT_NE(nullptr, window_state->drag_details());
resizer->CompleteDrag();
EXPECT_NE(nullptr, window_state->drag_details());
}
EXPECT_EQ(nullptr, window_state->drag_details());
}
// TODO: UpdateDisplay() doesn't support different layouts of multiple displays. // TODO: UpdateDisplay() doesn't support different layouts of multiple displays.
// We should add some way to try multiple layouts. // We should add some way to try multiple layouts.
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment