| 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 <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_controller.h" |
| 11 #include "ash/common/shelf/shelf_constants.h" | 12 #include "ash/common/shelf/shelf_constants.h" |
| 12 #include "ash/common/shelf/shelf_layout_manager.h" | 13 #include "ash/common/shelf/shelf_layout_manager.h" |
| 13 #include "ash/common/shelf/wm_shelf.h" | 14 #include "ash/common/shelf/wm_shelf.h" |
| 14 #include "ash/common/shell_observer.h" | 15 #include "ash/common/shell_observer.h" |
| 15 #include "ash/common/test/ash_test.h" | 16 #include "ash/common/test/ash_test.h" |
| 16 #include "ash/common/test/test_session_state_delegate.h" | 17 #include "ash/common/test/test_session_controller_client.h" |
| 17 #include "ash/common/wm/fullscreen_window_finder.h" | 18 #include "ash/common/wm/fullscreen_window_finder.h" |
| 18 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" | 19 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" |
| 19 #include "ash/common/wm/window_state.h" | 20 #include "ash/common/wm/window_state.h" |
| 20 #include "ash/common/wm/wm_event.h" | 21 #include "ash/common/wm/wm_event.h" |
| 21 #include "ash/common/wm/wm_screen_util.h" | 22 #include "ash/common/wm/wm_screen_util.h" |
| 22 #include "ash/common/wm/workspace/workspace_window_resizer.h" | 23 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 23 #include "ash/common/wm_shell.h" | 24 #include "ash/common/wm_shell.h" |
| 24 #include "ash/common/wm_window.h" | 25 #include "ash/common/wm_window.h" |
| 25 #include "ash/public/cpp/shell_window_ids.h" | 26 #include "ash/public/cpp/shell_window_ids.h" |
| 26 #include "ash/root_window_controller.h" | 27 #include "ash/root_window_controller.h" |
| 27 #include "ash/shell.h" | 28 #include "ash/shell.h" |
| 28 #include "ash/wm/window_state_aura.h" | 29 #include "ash/wm/window_state_aura.h" |
| 29 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 31 #include "base/memory/ptr_util.h" |
| 30 #include "base/run_loop.h" | 32 #include "base/run_loop.h" |
| 31 #include "ui/aura/env.h" | 33 #include "ui/aura/env.h" |
| 32 #include "ui/aura/window.h" | 34 #include "ui/aura/window.h" |
| 33 #include "ui/base/ui_base_switches.h" | 35 #include "ui/base/ui_base_switches.h" |
| 34 #include "ui/base/ui_base_types.h" | 36 #include "ui/base/ui_base_types.h" |
| 35 #include "ui/compositor/layer_type.h" | 37 #include "ui/compositor/layer_type.h" |
| 36 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 38 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 37 #include "ui/display/display.h" | 39 #include "ui/display/display.h" |
| 38 #include "ui/display/screen.h" | 40 #include "ui/display/screen.h" |
| 39 #include "ui/gfx/geometry/insets.h" | 41 #include "ui/gfx/geometry/insets.h" |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 EXPECT_EQ(bounds.ToString(), | 891 EXPECT_EQ(bounds.ToString(), |
| 890 window_state->GetRestoreBoundsInParent().ToString()); | 892 window_state->GetRestoreBoundsInParent().ToString()); |
| 891 EXPECT_TRUE(window_state->IsMaximized()); | 893 EXPECT_TRUE(window_state->IsMaximized()); |
| 892 | 894 |
| 893 window_state->Restore(); | 895 window_state->Restore(); |
| 894 EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString()); | 896 EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString()); |
| 895 } | 897 } |
| 896 | 898 |
| 897 // Verify if the window is not resized during screen lock. See: crbug.com/173127 | 899 // Verify if the window is not resized during screen lock. See: crbug.com/173127 |
| 898 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { | 900 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { |
| 899 test::TestSessionStateDelegate::SetCanLockScreen(true); | 901 std::unique_ptr<test::TestSessionControllerClient> session_controller_client = |
| 902 base::MakeUnique<test::TestSessionControllerClient>( |
| 903 WmShell::Get()->session_controller()); |
| 904 session_controller_client->InitializeAndBind(); |
| 905 session_controller_client->CreatePredefinedUserSessions(1); |
| 906 session_controller_client->SetCanLockScreen(true); |
| 900 std::unique_ptr<WindowOwner> window_owner( | 907 std::unique_ptr<WindowOwner> window_owner( |
| 901 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 908 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 902 WmWindow* window = window_owner->window(); | 909 WmWindow* window = window_owner->window(); |
| 903 // window with AlwaysOnTop will be managed by BaseLayoutManager. | 910 // window with AlwaysOnTop will be managed by BaseLayoutManager. |
| 904 window->SetAlwaysOnTop(true); | 911 window->SetAlwaysOnTop(true); |
| 905 window->Show(); | 912 window->Show(); |
| 906 | 913 |
| 907 WmShelf* shelf = GetPrimaryShelf(); | 914 WmShelf* shelf = GetPrimaryShelf(); |
| 908 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 915 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 909 | 916 |
| 910 window->SetBounds(wm::GetMaximizedWindowBoundsInParent(window)); | 917 window->SetBounds(wm::GetMaximizedWindowBoundsInParent(window)); |
| 911 gfx::Rect window_bounds = window->GetBounds(); | 918 gfx::Rect window_bounds = window->GetBounds(); |
| 912 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), | 919 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), |
| 913 window_bounds.ToString()); | 920 window_bounds.ToString()); |
| 914 | 921 |
| 915 // The window size should not get touched while we are in lock screen. | 922 // The window size should not get touched while we are in lock screen. |
| 916 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 923 WmShell::Get()->session_controller()->LockScreenAndFlushForTest(); |
| 917 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); | 924 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 918 shelf_layout_manager->UpdateVisibilityState(); | 925 shelf_layout_manager->UpdateVisibilityState(); |
| 919 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString()); | 926 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString()); |
| 920 | 927 |
| 921 // Coming out of the lock screen the window size should still remain. | 928 // Coming out of the lock screen the window size should still remain. |
| 922 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); | 929 session_controller_client->UnlockScreen(); |
| 923 shelf_layout_manager->UpdateVisibilityState(); | 930 shelf_layout_manager->UpdateVisibilityState(); |
| 924 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), | 931 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), |
| 925 window_bounds.ToString()); | 932 window_bounds.ToString()); |
| 926 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString()); | 933 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString()); |
| 927 } | 934 } |
| 928 | 935 |
| 929 // Following tests are written to test the backdrop functionality. | 936 // Following tests are written to test the backdrop functionality. |
| 930 | 937 |
| 931 namespace { | 938 namespace { |
| 932 | 939 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 window->SetBounds(keyboard_bounds()); | 1272 window->SetBounds(keyboard_bounds()); |
| 1266 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); | 1273 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); |
| 1267 window->Activate(); | 1274 window->Activate(); |
| 1268 | 1275 |
| 1269 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1276 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1270 ShowKeyboard(); | 1277 ShowKeyboard(); |
| 1271 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1278 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1272 } | 1279 } |
| 1273 | 1280 |
| 1274 } // namespace ash | 1281 } // namespace ash |
| OLD | NEW |