Chromium Code Reviews| 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/common/wm/system_modal_container_layout_manager.h" | 5 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/wm/container_finder.h" | 10 #include "ash/common/wm/container_finder.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 145 |
| 146 } // namespace | 146 } // namespace |
| 147 | 147 |
| 148 class SystemModalContainerLayoutManagerTest : public AshTestBase { | 148 class SystemModalContainerLayoutManagerTest : public AshTestBase { |
| 149 public: | 149 public: |
| 150 void SetUp() override { | 150 void SetUp() override { |
| 151 // Allow a virtual keyboard (and initialize it per default). | 151 // Allow a virtual keyboard (and initialize it per default). |
| 152 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 152 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 153 keyboard::switches::kEnableVirtualKeyboard); | 153 keyboard::switches::kEnableVirtualKeyboard); |
| 154 AshTestBase::SetUp(); | 154 AshTestBase::SetUp(); |
| 155 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 155 // TODO: mash doesn't support keyboard. http://crbug.com/698892. |
|
msw
2017/03/07 21:36:01
nit: virtual keyboard here and below?
sky
2017/03/07 21:43:30
Done.
| |
| 156 keyboard::KeyboardController::GetInstance()); | 156 if (!WmShell::Get()->IsRunningInMash()) { |
| 157 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | |
| 158 keyboard::KeyboardController::GetInstance()); | |
| 159 } | |
| 157 } | 160 } |
| 158 | 161 |
| 159 void TearDown() override { | 162 void TearDown() override { |
| 160 Shell::GetPrimaryRootWindowController()->DeactivateKeyboard( | 163 // TODO: mash doesn't support keyboard. http://crbug.com/698892. |
| 161 keyboard::KeyboardController::GetInstance()); | 164 if (!WmShell::Get()->IsRunningInMash()) { |
| 165 Shell::GetPrimaryRootWindowController()->DeactivateKeyboard( | |
| 166 keyboard::KeyboardController::GetInstance()); | |
| 167 } | |
| 162 AshTestBase::TearDown(); | 168 AshTestBase::TearDown(); |
| 163 } | 169 } |
| 164 | 170 |
| 165 aura::Window* OpenToplevelTestWindow(bool modal) { | 171 aura::Window* OpenToplevelTestWindow(bool modal) { |
| 166 views::Widget* widget = views::Widget::CreateWindowWithContext( | 172 views::Widget* widget = views::Widget::CreateWindowWithContext( |
| 167 new TestWindow(modal), CurrentContext()); | 173 new TestWindow(modal), CurrentContext()); |
| 168 widget->Show(); | 174 widget->Show(); |
| 169 return widget->GetNativeView(); | 175 return widget->GetNativeView(); |
| 170 } | 176 } |
| 171 | 177 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 modal1->Hide(); | 640 modal1->Hide(); |
| 635 TestWindow::CloseTestWindow(modal1.release()); | 641 TestWindow::CloseTestWindow(modal1.release()); |
| 636 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); | 642 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); |
| 637 EXPECT_TRUE(wm::IsActiveWindow(normal.get())); | 643 EXPECT_TRUE(wm::IsActiveWindow(normal.get())); |
| 638 } | 644 } |
| 639 | 645 |
| 640 // Test that with the visible keyboard, an existing system modal dialog gets | 646 // Test that with the visible keyboard, an existing system modal dialog gets |
| 641 // positioned into the visible area. | 647 // positioned into the visible area. |
| 642 TEST_F(SystemModalContainerLayoutManagerTest, | 648 TEST_F(SystemModalContainerLayoutManagerTest, |
| 643 SystemModalDialogGetPushedFromKeyboard) { | 649 SystemModalDialogGetPushedFromKeyboard) { |
| 650 // TODO: mash doesn't support keyboard. http://crbug.com/698892. | |
| 651 if (WmShell::Get()->IsRunningInMash()) | |
| 652 return; | |
| 653 | |
| 644 const gfx::Rect& container_bounds = GetModalContainer()->bounds(); | 654 const gfx::Rect& container_bounds = GetModalContainer()->bounds(); |
| 645 // Place the window at the bottom of the screen. | 655 // Place the window at the bottom of the screen. |
| 646 gfx::Size modal_size(100, 100); | 656 gfx::Size modal_size(100, 100); |
| 647 gfx::Point modal_origin = gfx::Point( | 657 gfx::Point modal_origin = gfx::Point( |
| 648 (container_bounds.right() - modal_size.width()) / 2, // X centered | 658 (container_bounds.right() - modal_size.width()) / 2, // X centered |
| 649 container_bounds.bottom() - modal_size.height()); // at bottom | 659 container_bounds.bottom() - modal_size.height()); // at bottom |
| 650 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); | 660 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); |
| 651 | 661 |
| 652 // Create a modal window. | 662 // Create a modal window. |
| 653 std::unique_ptr<aura::Window> parent(OpenToplevelTestWindow(false)); | 663 std::unique_ptr<aura::Window> parent(OpenToplevelTestWindow(false)); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 670 ShowKeyboard(false); | 680 ShowKeyboard(false); |
| 671 EXPECT_NE(modal_bounds.ToString(), modal_window->bounds().ToString()); | 681 EXPECT_NE(modal_bounds.ToString(), modal_window->bounds().ToString()); |
| 672 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); | 682 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); |
| 673 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); | 683 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
| 674 } | 684 } |
| 675 | 685 |
| 676 // Test that windows will not get cropped through the visible virtual keyboard - | 686 // Test that windows will not get cropped through the visible virtual keyboard - |
| 677 // if centered. | 687 // if centered. |
| 678 TEST_F(SystemModalContainerLayoutManagerTest, | 688 TEST_F(SystemModalContainerLayoutManagerTest, |
| 679 SystemModalDialogGetPushedButNotCroppedFromKeyboard) { | 689 SystemModalDialogGetPushedButNotCroppedFromKeyboard) { |
| 690 // TODO: mash doesn't support keyboard. http://crbug.com/698892. | |
| 691 if (WmShell::Get()->IsRunningInMash()) | |
| 692 return; | |
| 693 | |
| 680 const gfx::Rect& container_bounds = GetModalContainer()->bounds(); | 694 const gfx::Rect& container_bounds = GetModalContainer()->bounds(); |
| 681 const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size(); | 695 const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size(); |
| 682 // Place the window at the bottom of the screen. | 696 // Place the window at the bottom of the screen. |
| 683 gfx::Size modal_size(100, screen_size.height() - 70); | 697 gfx::Size modal_size(100, screen_size.height() - 70); |
| 684 gfx::Point modal_origin = gfx::Point( | 698 gfx::Point modal_origin = gfx::Point( |
| 685 (container_bounds.right() - modal_size.width()) / 2, // X centered | 699 (container_bounds.right() - modal_size.width()) / 2, // X centered |
| 686 container_bounds.bottom() - modal_size.height()); // at bottom | 700 container_bounds.bottom() - modal_size.height()); // at bottom |
| 687 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); | 701 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); |
| 688 | 702 |
| 689 // Create a modal window. | 703 // Create a modal window. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 703 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); | 717 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
| 704 EXPECT_EQ(0, modal_window->bounds().y()); | 718 EXPECT_EQ(0, modal_window->bounds().y()); |
| 705 | 719 |
| 706 ShowKeyboard(false); | 720 ShowKeyboard(false); |
| 707 } | 721 } |
| 708 | 722 |
| 709 // Test that windows will not get cropped through the visible virtual keyboard - | 723 // Test that windows will not get cropped through the visible virtual keyboard - |
| 710 // if not centered. | 724 // if not centered. |
| 711 TEST_F(SystemModalContainerLayoutManagerTest, | 725 TEST_F(SystemModalContainerLayoutManagerTest, |
| 712 SystemModalDialogGetPushedButNotCroppedFromKeyboardIfNotCentered) { | 726 SystemModalDialogGetPushedButNotCroppedFromKeyboardIfNotCentered) { |
| 727 // TODO: mash doesn't support keyboard. http://crbug.com/698892. | |
| 728 if (WmShell::Get()->IsRunningInMash()) | |
| 729 return; | |
| 730 | |
| 713 const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size(); | 731 const gfx::Size screen_size = Shell::GetPrimaryRootWindow()->bounds().size(); |
| 714 // Place the window at the bottom of the screen. | 732 // Place the window at the bottom of the screen. |
| 715 gfx::Size modal_size(100, screen_size.height() - 70); | 733 gfx::Size modal_size(100, screen_size.height() - 70); |
| 716 gfx::Point modal_origin = gfx::Point(10, 20); | 734 gfx::Point modal_origin = gfx::Point(10, 20); |
| 717 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); | 735 gfx::Rect modal_bounds = gfx::Rect(modal_origin, modal_size); |
| 718 | 736 |
| 719 // Create a modal window. | 737 // Create a modal window. |
| 720 std::unique_ptr<aura::Window> parent(OpenToplevelTestWindow(false)); | 738 std::unique_ptr<aura::Window> parent(OpenToplevelTestWindow(false)); |
| 721 std::unique_ptr<aura::Window> modal_window( | 739 std::unique_ptr<aura::Window> modal_window( |
| 722 OpenTestWindowWithParent(parent.get(), true)); | 740 OpenTestWindowWithParent(parent.get(), true)); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 | 908 |
| 891 // Make sure that events are properly blocked in multi displays environment. | 909 // Make sure that events are properly blocked in multi displays environment. |
| 892 TEST_F(SystemModalContainerLayoutManagerTest, BlockEventsInMultiDisplays) { | 910 TEST_F(SystemModalContainerLayoutManagerTest, BlockEventsInMultiDisplays) { |
| 893 UpdateDisplay("500x500, 500x500"); | 911 UpdateDisplay("500x500, 500x500"); |
| 894 InputTestDelegate delegate; | 912 InputTestDelegate delegate; |
| 895 delegate.RunTest(this); | 913 delegate.RunTest(this); |
| 896 } | 914 } |
| 897 | 915 |
| 898 } // namespace test | 916 } // namespace test |
| 899 } // namespace ash | 917 } // namespace ash |
| OLD | NEW |