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/workspace/workspace_layout_manager.h" | 5 #include "ash/common/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/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
11 #include "ash/common/shelf/shelf_constants.h" | 11 #include "ash/common/shelf/shelf_constants.h" |
12 #include "ash/common/shelf/shelf_layout_manager.h" | 12 #include "ash/common/shelf/shelf_layout_manager.h" |
13 #include "ash/common/shelf/wm_shelf.h" | 13 #include "ash/common/shelf/wm_shelf.h" |
14 #include "ash/common/shell_observer.h" | 14 #include "ash/common/shell_observer.h" |
15 #include "ash/common/test/ash_test.h" | 15 #include "ash/common/test/ash_test.h" |
16 #include "ash/common/test/test_session_state_delegate.h" | 16 #include "ash/common/test/test_session_state_delegate.h" |
17 #include "ash/common/wm/fullscreen_window_finder.h" | 17 #include "ash/common/wm/fullscreen_window_finder.h" |
18 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" | 18 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" |
19 #include "ash/common/wm/window_state.h" | 19 #include "ash/common/wm/window_state.h" |
20 #include "ash/common/wm/wm_event.h" | 20 #include "ash/common/wm/wm_event.h" |
21 #include "ash/common/wm/wm_screen_util.h" | 21 #include "ash/common/wm/wm_screen_util.h" |
22 #include "ash/common/wm/workspace/workspace_window_resizer.h" | 22 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
23 #include "ash/common/wm_lookup.h" | 23 #include "ash/common/wm_lookup.h" |
24 #include "ash/common/wm_root_window_controller.h" | |
25 #include "ash/common/wm_shell.h" | 24 #include "ash/common/wm_shell.h" |
26 #include "ash/public/cpp/shell_window_ids.h" | 25 #include "ash/public/cpp/shell_window_ids.h" |
| 26 #include "ash/root_window_controller.h" |
27 #include "base/command_line.h" | 27 #include "base/command_line.h" |
28 #include "base/run_loop.h" | 28 #include "base/run_loop.h" |
29 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
30 #include "ui/base/ui_base_switches.h" | 30 #include "ui/base/ui_base_switches.h" |
31 #include "ui/base/ui_base_types.h" | 31 #include "ui/base/ui_base_types.h" |
32 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 32 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
33 #include "ui/display/display.h" | 33 #include "ui/display/display.h" |
34 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
35 #include "ui/gfx/geometry/insets.h" | 35 #include "ui/gfx/geometry/insets.h" |
36 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 382 } |
383 | 383 |
384 // Verifies a window created with maximized state has the maximized | 384 // Verifies a window created with maximized state has the maximized |
385 // bounds. | 385 // bounds. |
386 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { | 386 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { |
387 WindowOwner window_owner(WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_NORMAL, | 387 WindowOwner window_owner(WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_NORMAL, |
388 ui::LAYER_TEXTURED)); | 388 ui::LAYER_TEXTURED)); |
389 WmWindow* window = window_owner.window(); | 389 WmWindow* window = window_owner.window(); |
390 window->GetWindowState()->Maximize(); | 390 window->GetWindowState()->Maximize(); |
391 WmWindow* default_container = | 391 WmWindow* default_container = |
392 WmShell::Get()->GetPrimaryRootWindowController()->GetContainer( | 392 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( |
393 kShellWindowId_DefaultContainer); | 393 kShellWindowId_DefaultContainer); |
394 default_container->AddChild(window); | 394 default_container->AddChild(window); |
395 window->Show(); | 395 window->Show(); |
396 gfx::Rect work_area( | 396 gfx::Rect work_area( |
397 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 397 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
398 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 398 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
399 } | 399 } |
400 | 400 |
401 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { | 401 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { |
402 // TODO: fix. This test verifies that when a window is added the bounds are | 402 // TODO: fix. This test verifies that when a window is added the bounds are |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 | 937 |
938 class WorkspaceLayoutManagerBackdropTest : public AshTest { | 938 class WorkspaceLayoutManagerBackdropTest : public AshTest { |
939 public: | 939 public: |
940 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {} | 940 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {} |
941 ~WorkspaceLayoutManagerBackdropTest() override {} | 941 ~WorkspaceLayoutManagerBackdropTest() override {} |
942 | 942 |
943 void SetUp() override { | 943 void SetUp() override { |
944 AshTest::SetUp(); | 944 AshTest::SetUp(); |
945 UpdateDisplay("800x600"); | 945 UpdateDisplay("800x600"); |
946 default_container_ = | 946 default_container_ = |
947 WmShell::Get()->GetPrimaryRootWindowController()->GetContainer( | 947 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( |
948 kShellWindowId_DefaultContainer); | 948 kShellWindowId_DefaultContainer); |
949 } | 949 } |
950 | 950 |
951 // Turn the top window back drop on / off. | 951 // Turn the top window back drop on / off. |
952 void ShowTopWindowBackdrop(bool show) { | 952 void ShowTopWindowBackdrop(bool show) { |
953 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop; | 953 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop; |
954 if (show) | 954 if (show) |
955 backdrop.reset(new WorkspaceBackdropDelegate(default_container_)); | 955 backdrop.reset(new WorkspaceBackdropDelegate(default_container_)); |
956 GetWorkspaceLayoutManager(default_container_) | 956 GetWorkspaceLayoutManager(default_container_) |
957 ->SetMaximizeBackdropDelegate(std::move(backdrop)); | 957 ->SetMaximizeBackdropDelegate(std::move(backdrop)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1118 |
1119 class WorkspaceLayoutManagerKeyboardTest : public AshTest { | 1119 class WorkspaceLayoutManagerKeyboardTest : public AshTest { |
1120 public: | 1120 public: |
1121 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} | 1121 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} |
1122 ~WorkspaceLayoutManagerKeyboardTest() override {} | 1122 ~WorkspaceLayoutManagerKeyboardTest() override {} |
1123 | 1123 |
1124 void SetUp() override { | 1124 void SetUp() override { |
1125 AshTest::SetUp(); | 1125 AshTest::SetUp(); |
1126 UpdateDisplay("800x600"); | 1126 UpdateDisplay("800x600"); |
1127 WmWindow* default_container = | 1127 WmWindow* default_container = |
1128 WmShell::Get()->GetPrimaryRootWindowController()->GetContainer( | 1128 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( |
1129 kShellWindowId_DefaultContainer); | 1129 kShellWindowId_DefaultContainer); |
1130 layout_manager_ = GetWorkspaceLayoutManager(default_container); | 1130 layout_manager_ = GetWorkspaceLayoutManager(default_container); |
1131 } | 1131 } |
1132 | 1132 |
1133 void ShowKeyboard() { | 1133 void ShowKeyboard() { |
1134 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); | 1134 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); |
1135 restore_work_area_insets_ = | 1135 restore_work_area_insets_ = |
1136 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); | 1136 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); |
1137 WmShell::Get()->SetDisplayWorkAreaInsets( | 1137 WmShell::Get()->SetDisplayWorkAreaInsets( |
1138 WmShell::Get()->GetPrimaryRootWindow(), | 1138 WmShell::Get()->GetPrimaryRootWindow(), |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 window->SetBounds(keyboard_bounds()); | 1266 window->SetBounds(keyboard_bounds()); |
1267 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); | 1267 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); |
1268 window->Activate(); | 1268 window->Activate(); |
1269 | 1269 |
1270 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1270 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
1271 ShowKeyboard(); | 1271 ShowKeyboard(); |
1272 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1272 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
1273 } | 1273 } |
1274 | 1274 |
1275 } // namespace ash | 1275 } // namespace ash |
OLD | NEW |