Commit 13325025 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

split view: Modify CanSnapInSplitview to account for divider thickness

Test: SplitViewControllerTest.SnapWindowWithMinimumSizeTest
Bug: 1019965
Change-Id: Ia31c621d18fbdcf6016f095f78aceff1fa0dd600
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891756Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711282}
parent 607ade07
...@@ -1489,24 +1489,26 @@ TEST_P(SplitViewControllerTest, ExitTabletModeEndSplitView) { ...@@ -1489,24 +1489,26 @@ TEST_P(SplitViewControllerTest, ExitTabletModeEndSplitView) {
EXPECT_FALSE(split_view_controller()->InSplitViewMode()); EXPECT_FALSE(split_view_controller()->InSplitViewMode());
} }
// Tests that if a window's minimum size is larger than half of the display work // Test that |CanSnapInSplitview| checks that the minimum size of the window
// area's size, it can't be snapped. // fits into the left or top, with the default divider position. (If the work
// area length is odd, then the right or bottom will be one pixel larger.)
TEST_P(SplitViewControllerTest, SnapWindowWithMinimumSizeTest) { TEST_P(SplitViewControllerTest, SnapWindowWithMinimumSizeTest) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
EXPECT_TRUE(CanSnapInSplitview(window1.get())); EXPECT_TRUE(CanSnapInSplitview(window1.get()));
const gfx::Rect display_bounds = UpdateDisplay("800x600");
screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
window1.get());
aura::test::TestWindowDelegate* delegate = aura::test::TestWindowDelegate* delegate =
static_cast<aura::test::TestWindowDelegate*>(window1->delegate()); static_cast<aura::test::TestWindowDelegate*>(window1->delegate());
delegate->set_minimum_size( delegate->set_minimum_size(gfx::Size(396, 0));
gfx::Size(display_bounds.width() * 0.5f, display_bounds.height()));
EXPECT_TRUE(CanSnapInSplitview(window1.get())); EXPECT_TRUE(CanSnapInSplitview(window1.get()));
delegate->set_minimum_size(gfx::Size(397, 0));
EXPECT_FALSE(CanSnapInSplitview(window1.get()));
delegate->set_minimum_size( UpdateDisplay("799x600");
gfx::Size(display_bounds.width() * 0.67f, display_bounds.height())); delegate->set_minimum_size(gfx::Size(395, 0));
EXPECT_TRUE(CanSnapInSplitview(window1.get()));
delegate->set_minimum_size(gfx::Size(396, 0));
EXPECT_FALSE(CanSnapInSplitview(window1.get())); EXPECT_FALSE(CanSnapInSplitview(window1.get()));
} }
......
...@@ -331,8 +331,9 @@ bool CanSnapInSplitview(aura::Window* window) { ...@@ -331,8 +331,9 @@ bool CanSnapInSplitview(aura::Window* window) {
if (!WindowState::Get(window)->CanSnap()) if (!WindowState::Get(window)->CanSnap())
return false; return false;
// Return true if |window|'s minimum size, if any, fits into half the work // Return true if |window|'s minimum size, if any, fits into the left or top
// area lengthwise. // with the default divider position. (If the work area length is odd, then
// the right or bottom will be one pixel larger.)
if (!window->delegate()) if (!window->delegate())
return true; return true;
const gfx::Size min_size = window->delegate()->GetMinimumSize(); const gfx::Size min_size = window->delegate()->GetMinimumSize();
...@@ -340,8 +341,10 @@ bool CanSnapInSplitview(aura::Window* window) { ...@@ -340,8 +341,10 @@ bool CanSnapInSplitview(aura::Window* window) {
screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer( screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
window); window);
return IsCurrentScreenOrientationLandscape() return IsCurrentScreenOrientationLandscape()
? min_size.width() <= work_area.width() / 2 ? min_size.width() <=
: min_size.height() <= work_area.height() / 2; work_area.width() / 2 - kSplitviewDividerShortSideLength / 2
: min_size.height() <= work_area.height() / 2 -
kSplitviewDividerShortSideLength / 2;
} }
void ShowAppCannotSnapToast() { void ShowAppCannotSnapToast() {
......
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