| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/public/cpp/config.h" | 9 #include "ash/public/cpp/config.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/session/session_state_delegate.h" | 12 #include "ash/session/session_state_delegate.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_port.h" | 14 #include "ash/shell_port.h" |
| 15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/wm/container_finder.h" | 16 #include "ash/wm/container_finder.h" |
| 17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 18 #include "ash/wm_window.h" | |
| 19 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 20 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
| 21 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 22 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 23 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 24 #include "ui/aura/test/test_window_delegate.h" | 23 #include "ui/aura/test/test_window_delegate.h" |
| 25 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_event_dispatcher.h" | 25 #include "ui/aura/window_event_dispatcher.h" |
| 27 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
| 28 #include "ui/compositor/layer.h" | 27 #include "ui/compositor/layer.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 return Shell::GetPrimaryRootWindowController()->GetContainer( | 46 return Shell::GetPrimaryRootWindowController()->GetContainer( |
| 48 ash::kShellWindowId_SystemModalContainer); | 47 ash::kShellWindowId_SystemModalContainer); |
| 49 } | 48 } |
| 50 | 49 |
| 51 bool AllRootWindowsHaveModalBackgroundsForContainer(int container_id) { | 50 bool AllRootWindowsHaveModalBackgroundsForContainer(int container_id) { |
| 52 aura::Window::Windows containers = | 51 aura::Window::Windows containers = |
| 53 wm::GetContainersFromAllRootWindows(container_id); | 52 wm::GetContainersFromAllRootWindows(container_id); |
| 54 bool has_modal_screen = !containers.empty(); | 53 bool has_modal_screen = !containers.empty(); |
| 55 for (aura::Window* container : containers) { | 54 for (aura::Window* container : containers) { |
| 56 has_modal_screen &= static_cast<SystemModalContainerLayoutManager*>( | 55 has_modal_screen &= static_cast<SystemModalContainerLayoutManager*>( |
| 57 WmWindow::Get(container)->GetLayoutManager()) | 56 container->layout_manager()) |
| 58 ->has_window_dimmer(); | 57 ->has_window_dimmer(); |
| 59 } | 58 } |
| 60 return has_modal_screen; | 59 return has_modal_screen; |
| 61 } | 60 } |
| 62 | 61 |
| 63 bool AllRootWindowsHaveLockedModalBackgrounds() { | 62 bool AllRootWindowsHaveLockedModalBackgrounds() { |
| 64 return AllRootWindowsHaveModalBackgroundsForContainer( | 63 return AllRootWindowsHaveModalBackgroundsForContainer( |
| 65 kShellWindowId_LockSystemModalContainer); | 64 kShellWindowId_LockSystemModalContainer); |
| 66 } | 65 } |
| 67 | 66 |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 | 796 |
| 798 TEST_F(SystemModalContainerLayoutManagerTest, VisibilityChange) { | 797 TEST_F(SystemModalContainerLayoutManagerTest, VisibilityChange) { |
| 799 std::unique_ptr<aura::Window> window(OpenToplevelTestWindow(false)); | 798 std::unique_ptr<aura::Window> window(OpenToplevelTestWindow(false)); |
| 800 std::unique_ptr<aura::Window> modal_window( | 799 std::unique_ptr<aura::Window> modal_window( |
| 801 views::Widget::CreateWindowWithContext(new TestWindow(true), | 800 views::Widget::CreateWindowWithContext(new TestWindow(true), |
| 802 CurrentContext()) | 801 CurrentContext()) |
| 803 ->GetNativeWindow()); | 802 ->GetNativeWindow()); |
| 804 SystemModalContainerLayoutManager* layout_manager = | 803 SystemModalContainerLayoutManager* layout_manager = |
| 805 ShellPort::Get() | 804 ShellPort::Get() |
| 806 ->GetPrimaryRootWindowController() | 805 ->GetPrimaryRootWindowController() |
| 807 ->GetSystemModalLayoutManager(WmWindow::Get(modal_window.get())); | 806 ->GetSystemModalLayoutManager(modal_window.get()); |
| 808 | 807 |
| 809 EXPECT_FALSE(ShellPort::Get()->IsSystemModalWindowOpen()); | 808 EXPECT_FALSE(ShellPort::Get()->IsSystemModalWindowOpen()); |
| 810 EXPECT_FALSE(layout_manager->has_window_dimmer()); | 809 EXPECT_FALSE(layout_manager->has_window_dimmer()); |
| 811 | 810 |
| 812 modal_window->Show(); | 811 modal_window->Show(); |
| 813 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); | 812 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); |
| 814 EXPECT_TRUE(layout_manager->has_window_dimmer()); | 813 EXPECT_TRUE(layout_manager->has_window_dimmer()); |
| 815 | 814 |
| 816 // Make sure that a child visibility change should not cause | 815 // Make sure that a child visibility change should not cause |
| 817 // inconsistent state. | 816 // inconsistent state. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 | 922 |
| 924 // Make sure that events are properly blocked in multi displays environment. | 923 // Make sure that events are properly blocked in multi displays environment. |
| 925 TEST_F(SystemModalContainerLayoutManagerTest, BlockEventsInMultiDisplays) { | 924 TEST_F(SystemModalContainerLayoutManagerTest, BlockEventsInMultiDisplays) { |
| 926 UpdateDisplay("500x500, 500x500"); | 925 UpdateDisplay("500x500, 500x500"); |
| 927 InputTestDelegate delegate; | 926 InputTestDelegate delegate; |
| 928 delegate.RunTest(this); | 927 delegate.RunTest(this); |
| 929 } | 928 } |
| 930 | 929 |
| 931 } // namespace test | 930 } // namespace test |
| 932 } // namespace ash | 931 } // namespace ash |
| OLD | NEW |