OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); | 585 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); |
586 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); | 586 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
587 | 587 |
588 // After the keyboard is gone, the window will remain where it was. | 588 // After the keyboard is gone, the window will remain where it was. |
589 ShowKeyboard(false); | 589 ShowKeyboard(false); |
590 EXPECT_NE(modal_bounds.ToString(), modal_window->bounds().ToString()); | 590 EXPECT_NE(modal_bounds.ToString(), modal_window->bounds().ToString()); |
591 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); | 591 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); |
592 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); | 592 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
593 } | 593 } |
594 | 594 |
| 595 // Test that windows will not get cropped through the visible virtual keyboard - |
| 596 // if centered. |
| 597 TEST_F(SystemModalContainerLayoutManagerTest, |
| 598 SystemModalDialogGetPushedButNotCroppedFromKeyboard) { |
| 599 const gfx::Rect& container_bounds = GetModalContainer()->bounds(); |
| 600 const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size(); |
| 601 // Place the window at the bottom of the screen. |
| 602 gfx::Size modal_size(100, screen_size.height() - 70); |
| 603 gfx::Point modal_origin = gfx::Point( |
| 604 (container_bounds.right() - modal_size.width()) / 2, // X centered |
| 605 container_bounds.bottom() - modal_size.height()); // at bottom |
| 606 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); |
| 607 |
| 608 // Create a modal window. |
| 609 scoped_ptr<aura::Window> parent(OpenToplevelTestWindow(false)); |
| 610 scoped_ptr<aura::Window> modal_window( |
| 611 OpenTestWindowWithParent(parent.get(), true)); |
| 612 modal_window->SetBounds(modal_bounds); |
| 613 parent->Show(); |
| 614 modal_window->Show(); |
| 615 |
| 616 EXPECT_EQ(modal_bounds.ToString(), modal_window->bounds().ToString()); |
| 617 |
| 618 // The keyboard gets shown and the dialog should get pushed up, but not get |
| 619 // cropped (and aligned to the top). |
| 620 ShowKeyboard(true); |
| 621 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); |
| 622 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
| 623 EXPECT_EQ(0, modal_window->bounds().y()); |
| 624 |
| 625 ShowKeyboard(false); |
| 626 } |
| 627 |
| 628 // Test that windows will not get cropped through the visible virtual keyboard - |
| 629 // if not centered. |
| 630 TEST_F(SystemModalContainerLayoutManagerTest, |
| 631 SystemModalDialogGetPushedButNotCroppedFromKeyboardIfNotCentered) { |
| 632 const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size(); |
| 633 // Place the window at the bottom of the screen. |
| 634 gfx::Size modal_size(100, screen_size.height() - 70); |
| 635 gfx::Point modal_origin = gfx::Point(10, 20); |
| 636 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); |
| 637 |
| 638 // Create a modal window. |
| 639 scoped_ptr<aura::Window> parent(OpenToplevelTestWindow(false)); |
| 640 scoped_ptr<aura::Window> modal_window( |
| 641 OpenTestWindowWithParent(parent.get(), true)); |
| 642 modal_window->SetBounds(modal_bounds); |
| 643 parent->Show(); |
| 644 modal_window->Show(); |
| 645 |
| 646 EXPECT_EQ(modal_bounds.ToString(), modal_window->bounds().ToString()); |
| 647 |
| 648 // The keyboard gets shown and the dialog should get pushed up, but not get |
| 649 // cropped (and aligned to the top). |
| 650 ShowKeyboard(true); |
| 651 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); |
| 652 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
| 653 EXPECT_EQ(0, modal_window->bounds().y()); |
| 654 |
| 655 ShowKeyboard(false); |
| 656 } |
| 657 |
595 } // namespace test | 658 } // namespace test |
596 } // namespace ash | 659 } // namespace ash |
OLD | NEW |