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/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/workspace/workspace_layout_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
12 #include "ash/screen_util.h" | 12 #include "ash/screen_util.h" |
13 #include "ash/session/session_state_delegate.h" | 13 #include "ash/session/session_state_delegate.h" |
14 #include "ash/shelf/shelf.h" | 14 #include "ash/shelf/shelf.h" |
15 #include "ash/shelf/shelf_layout_manager.h" | 15 #include "ash/shelf/shelf_layout_manager.h" |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
17 #include "ash/shell_observer.h" | 17 #include "ash/shell_observer.h" |
18 #include "ash/shell_window_ids.h" | 18 #include "ash/shell_window_ids.h" |
19 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
20 #include "ash/test/display_manager_test_api.h" | 20 #include "ash/test/display_manager_test_api.h" |
| 21 #include "ash/wm/aura/wm_window_aura.h" |
21 #include "ash/wm/common/window_state.h" | 22 #include "ash/wm/common/window_state.h" |
22 #include "ash/wm/common/wm_event.h" | 23 #include "ash/wm/common/wm_event.h" |
23 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" | 24 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" |
24 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
25 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
26 #include "ash/wm/workspace/workspace_window_resizer.h" | 27 #include "ash/wm/workspace/workspace_window_resizer.h" |
27 #include "base/compiler_specific.h" | 28 #include "base/compiler_specific.h" |
28 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
29 #include "ui/aura/test/test_windows.h" | 30 #include "ui/aura/test/test_windows.h" |
30 #include "ui/aura/window.h" | 31 #include "ui/aura/window.h" |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 EXPECT_EQ( | 818 EXPECT_EQ( |
818 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 819 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
819 window_bounds.ToString()); | 820 window_bounds.ToString()); |
820 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 821 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
821 } | 822 } |
822 | 823 |
823 // Following tests are written to test the backdrop functionality. | 824 // Following tests are written to test the backdrop functionality. |
824 | 825 |
825 namespace { | 826 namespace { |
826 | 827 |
| 828 WorkspaceLayoutManager* GetWorkspaceLayoutManager(aura::Window* container) { |
| 829 return static_cast<WorkspaceLayoutManager*>( |
| 830 wm::WmWindowAura::Get(container)->GetLayoutManager()); |
| 831 } |
| 832 |
827 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { | 833 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { |
828 public: | 834 public: |
829 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {} | 835 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {} |
830 ~WorkspaceLayoutManagerBackdropTest() override {} | 836 ~WorkspaceLayoutManagerBackdropTest() override {} |
831 | 837 |
832 void SetUp() override { | 838 void SetUp() override { |
833 test::AshTestBase::SetUp(); | 839 test::AshTestBase::SetUp(); |
834 UpdateDisplay("800x600"); | 840 UpdateDisplay("800x600"); |
835 default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(), | 841 default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(), |
836 kShellWindowId_DefaultContainer); | 842 kShellWindowId_DefaultContainer); |
837 } | 843 } |
838 | 844 |
839 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 845 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
840 aura::Window* window = CreateTestWindowInShellWithBounds(bounds); | 846 aura::Window* window = CreateTestWindowInShellWithBounds(bounds); |
841 return window; | 847 return window; |
842 } | 848 } |
843 | 849 |
844 // Turn the top window back drop on / off. | 850 // Turn the top window back drop on / off. |
845 void ShowTopWindowBackdrop(bool show) { | 851 void ShowTopWindowBackdrop(bool show) { |
846 std::unique_ptr<ash::WorkspaceLayoutManagerBackdropDelegate> backdrop; | 852 std::unique_ptr<ash::WorkspaceLayoutManagerBackdropDelegate> backdrop; |
847 if (show) { | 853 if (show) { |
848 backdrop.reset(new ash::WorkspaceBackdropDelegate(default_container_)); | 854 backdrop.reset(new ash::WorkspaceBackdropDelegate(default_container_)); |
849 } | 855 } |
850 (static_cast<WorkspaceLayoutManager*>(default_container_->layout_manager())) | 856 GetWorkspaceLayoutManager(default_container_) |
851 ->SetMaximizeBackdropDelegate(std::move(backdrop)); | 857 ->SetMaximizeBackdropDelegate(std::move(backdrop)); |
852 // Closing and / or opening can be a delayed operation. | 858 // Closing and / or opening can be a delayed operation. |
853 base::MessageLoop::current()->RunUntilIdle(); | 859 base::MessageLoop::current()->RunUntilIdle(); |
854 } | 860 } |
855 | 861 |
856 // Return the default container. | 862 // Return the default container. |
857 aura::Window* default_container() { return default_container_; } | 863 aura::Window* default_container() { return default_container_; } |
858 | 864 |
859 // Return the order of windows (top most first) as they are in the default | 865 // Return the order of windows (top most first) as they are in the default |
860 // container. If the window is visible it will be a big letter, otherwise a | 866 // container. If the window is visible it will be a big letter, otherwise a |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { | 1025 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { |
1020 public: | 1026 public: |
1021 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} | 1027 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} |
1022 ~WorkspaceLayoutManagerKeyboardTest() override {} | 1028 ~WorkspaceLayoutManagerKeyboardTest() override {} |
1023 | 1029 |
1024 void SetUp() override { | 1030 void SetUp() override { |
1025 test::AshTestBase::SetUp(); | 1031 test::AshTestBase::SetUp(); |
1026 UpdateDisplay("800x600"); | 1032 UpdateDisplay("800x600"); |
1027 aura::Window* default_container = Shell::GetContainer( | 1033 aura::Window* default_container = Shell::GetContainer( |
1028 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); | 1034 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); |
1029 layout_manager_ = static_cast<WorkspaceLayoutManager*>( | 1035 layout_manager_ = GetWorkspaceLayoutManager(default_container); |
1030 default_container->layout_manager()); | |
1031 } | 1036 } |
1032 | 1037 |
1033 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 1038 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
1034 return CreateTestWindowInShellWithBounds(bounds); | 1039 return CreateTestWindowInShellWithBounds(bounds); |
1035 } | 1040 } |
1036 | 1041 |
1037 void ShowKeyboard() { | 1042 void ShowKeyboard() { |
1038 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); | 1043 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); |
1039 restore_work_area_insets_ = | 1044 restore_work_area_insets_ = |
1040 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); | 1045 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 EXPECT_EQ(gfx::Rect(50, | 1152 EXPECT_EQ(gfx::Rect(50, |
1148 keyboard_bounds.y() - keyboard_bounds.height()/2, | 1153 keyboard_bounds.y() - keyboard_bounds.height()/2, |
1149 occluded_window_bounds.width(), | 1154 occluded_window_bounds.width(), |
1150 occluded_window_bounds.height()).ToString(), | 1155 occluded_window_bounds.height()).ToString(), |
1151 window->bounds().ToString()); | 1156 window->bounds().ToString()); |
1152 HideKeyboard(); | 1157 HideKeyboard(); |
1153 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); | 1158 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); |
1154 } | 1159 } |
1155 | 1160 |
1156 } // namespace ash | 1161 } // namespace ash |
OLD | NEW |