Commit f97c90d3 authored by skuhne@chromium.org's avatar skuhne@chromium.org

Addressing dialog cropping by the virtual keyboard for M36

BUG=370925
TEST=ash_unittests and visual (using wifi advanced dialog which is the biggest known dialog)

Review URL: https://codereview.chromium.org/277223004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269947 0039d316-1c4b-4281-b951-d872f2087c98
parent 4232b250
......@@ -272,14 +272,23 @@ gfx::Rect SystemModalContainerLayoutManager::GetUsableDialogArea() {
gfx::Rect SystemModalContainerLayoutManager::GetCenteredAndOrFittedBounds(
const aura::Window* window) {
gfx::Rect target_bounds;
gfx::Rect usable_area = GetUsableDialogArea();
if (window->GetProperty(kCenteredKey)) {
// Keep the dialog centered if it was centered before.
gfx::Rect target_bounds = GetUsableDialogArea();
target_bounds = usable_area;
target_bounds.ClampToCenteredSize(window->bounds().size());
return target_bounds;
} else {
// Keep the dialog within the usable area.
target_bounds = window->bounds();
target_bounds.AdjustToFit(usable_area);
}
if (usable_area != container_->bounds()) {
// Don't clamp the dialog for the keyboard. Keep the size as it is but make
// sure that the top remains visible.
// TODO(skuhne): M37 should add over scroll functionality to address this.
target_bounds.set_size(window->bounds().size());
}
gfx::Rect target_bounds = window->bounds();
target_bounds.AdjustToFit(GetUsableDialogArea());
return target_bounds;
}
......
......@@ -592,5 +592,68 @@ TEST_F(SystemModalContainerLayoutManagerTest,
EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
}
// Test that windows will not get cropped through the visible virtual keyboard -
// if centered.
TEST_F(SystemModalContainerLayoutManagerTest,
SystemModalDialogGetPushedButNotCroppedFromKeyboard) {
const gfx::Rect& container_bounds = GetModalContainer()->bounds();
const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size();
// Place the window at the bottom of the screen.
gfx::Size modal_size(100, screen_size.height() - 70);
gfx::Point modal_origin = gfx::Point(
(container_bounds.right() - modal_size.width()) / 2, // X centered
container_bounds.bottom() - modal_size.height()); // at bottom
gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size);
// Create a modal window.
scoped_ptr<aura::Window> parent(OpenToplevelTestWindow(false));
scoped_ptr<aura::Window> modal_window(
OpenTestWindowWithParent(parent.get(), true));
modal_window->SetBounds(modal_bounds);
parent->Show();
modal_window->Show();
EXPECT_EQ(modal_bounds.ToString(), modal_window->bounds().ToString());
// The keyboard gets shown and the dialog should get pushed up, but not get
// cropped (and aligned to the top).
ShowKeyboard(true);
EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString());
EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
EXPECT_EQ(0, modal_window->bounds().y());
ShowKeyboard(false);
}
// Test that windows will not get cropped through the visible virtual keyboard -
// if not centered.
TEST_F(SystemModalContainerLayoutManagerTest,
SystemModalDialogGetPushedButNotCroppedFromKeyboardIfNotCentered) {
const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size();
// Place the window at the bottom of the screen.
gfx::Size modal_size(100, screen_size.height() - 70);
gfx::Point modal_origin = gfx::Point(10, 20);
gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size);
// Create a modal window.
scoped_ptr<aura::Window> parent(OpenToplevelTestWindow(false));
scoped_ptr<aura::Window> modal_window(
OpenTestWindowWithParent(parent.get(), true));
modal_window->SetBounds(modal_bounds);
parent->Show();
modal_window->Show();
EXPECT_EQ(modal_bounds.ToString(), modal_window->bounds().ToString());
// The keyboard gets shown and the dialog should get pushed up, but not get
// cropped (and aligned to the top).
ShowKeyboard(true);
EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString());
EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
EXPECT_EQ(0, modal_window->bounds().y());
ShowKeyboard(false);
}
} // namespace test
} // namespace ash
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