| 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/common/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/common/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" |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 } | 790 } |
| 791 | 791 |
| 792 // Verify if the window is not resized during screen lock. See: crbug.com/173127 | 792 // Verify if the window is not resized during screen lock. See: crbug.com/173127 |
| 793 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { | 793 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { |
| 794 SetCanLockScreen(true); | 794 SetCanLockScreen(true); |
| 795 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 795 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 796 // window with AlwaysOnTop will be managed by BaseLayoutManager. | 796 // window with AlwaysOnTop will be managed by BaseLayoutManager. |
| 797 window->SetProperty(aura::client::kAlwaysOnTopKey, true); | 797 window->SetProperty(aura::client::kAlwaysOnTopKey, true); |
| 798 window->Show(); | 798 window->Show(); |
| 799 | 799 |
| 800 ShelfLayoutManager* shelf_layout_manager = | 800 Shelf* shelf = Shelf::ForWindow(window.get()); |
| 801 Shelf::ForWindow(window.get())->shelf_layout_manager(); | 801 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 802 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 803 | 802 |
| 804 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); | 803 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); |
| 805 gfx::Rect window_bounds = window->bounds(); | 804 gfx::Rect window_bounds = window->bounds(); |
| 806 EXPECT_EQ( | 805 EXPECT_EQ( |
| 807 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 806 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
| 808 window_bounds.ToString()); | 807 window_bounds.ToString()); |
| 809 | 808 |
| 810 // The window size should not get touched while we are in lock screen. | 809 // The window size should not get touched while we are in lock screen. |
| 811 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 810 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
| 811 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 812 shelf_layout_manager->UpdateVisibilityState(); | 812 shelf_layout_manager->UpdateVisibilityState(); |
| 813 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 813 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
| 814 | 814 |
| 815 // Coming out of the lock screen the window size should still remain. | 815 // Coming out of the lock screen the window size should still remain. |
| 816 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 816 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
| 817 shelf_layout_manager->UpdateVisibilityState(); | 817 shelf_layout_manager->UpdateVisibilityState(); |
| 818 EXPECT_EQ( | 818 EXPECT_EQ( |
| 819 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 819 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
| 820 window_bounds.ToString()); | 820 window_bounds.ToString()); |
| 821 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 821 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), | 991 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), |
| 992 window3.get())); | 992 window3.get())); |
| 993 ShowTopWindowBackdrop(false); | 993 ShowTopWindowBackdrop(false); |
| 994 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), | 994 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), |
| 995 window3.get())); | 995 window3.get())); |
| 996 } | 996 } |
| 997 | 997 |
| 998 // Tests that when hidding the shelf, that the backdrop resizes to fill the | 998 // Tests that when hidding the shelf, that the backdrop resizes to fill the |
| 999 // entire workspace area. | 999 // entire workspace area. |
| 1000 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { | 1000 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { |
| 1001 ShelfLayoutManager* shelf_layout_manager = | 1001 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 1002 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); | 1002 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 1003 ShowTopWindowBackdrop(true); | 1003 ShowTopWindowBackdrop(true); |
| 1004 RunAllPendingInMessageLoop(); | 1004 RunAllPendingInMessageLoop(); |
| 1005 | 1005 |
| 1006 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 1006 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| 1007 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); | 1007 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); |
| 1008 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1008 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1009 shelf_layout_manager->UpdateVisibilityState(); | 1009 shelf_layout_manager->UpdateVisibilityState(); |
| 1010 | 1010 |
| 1011 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children | 1011 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children |
| 1012 // including the backdrop. | 1012 // including the backdrop. |
| 1013 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1013 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1014 shelf_layout_manager->UpdateVisibilityState(); | 1014 shelf_layout_manager->UpdateVisibilityState(); |
| 1015 gfx::Rect reduced_bounds = default_container()->children()[0]->bounds(); | 1015 gfx::Rect reduced_bounds = default_container()->children()[0]->bounds(); |
| 1016 EXPECT_LT(reduced_bounds.height(), initial_bounds.height()); | 1016 EXPECT_LT(reduced_bounds.height(), initial_bounds.height()); |
| 1017 | 1017 |
| 1018 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1018 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1019 shelf_layout_manager->UpdateVisibilityState(); | 1019 shelf_layout_manager->UpdateVisibilityState(); |
| 1020 | 1020 |
| 1021 EXPECT_GT(default_container()->children()[0]->bounds().height(), | 1021 EXPECT_GT(default_container()->children()[0]->bounds().height(), |
| 1022 reduced_bounds.height()); | 1022 reduced_bounds.height()); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { | 1025 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { |
| 1026 public: | 1026 public: |
| 1027 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} | 1027 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} |
| 1028 ~WorkspaceLayoutManagerKeyboardTest() override {} | 1028 ~WorkspaceLayoutManagerKeyboardTest() override {} |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 EXPECT_EQ(gfx::Rect(50, | 1152 EXPECT_EQ(gfx::Rect(50, |
| 1153 keyboard_bounds.y() - keyboard_bounds.height()/2, | 1153 keyboard_bounds.y() - keyboard_bounds.height()/2, |
| 1154 occluded_window_bounds.width(), | 1154 occluded_window_bounds.width(), |
| 1155 occluded_window_bounds.height()).ToString(), | 1155 occluded_window_bounds.height()).ToString(), |
| 1156 window->bounds().ToString()); | 1156 window->bounds().ToString()); |
| 1157 HideKeyboard(); | 1157 HideKeyboard(); |
| 1158 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); | 1158 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 } // namespace ash | 1161 } // namespace ash |
| OLD | NEW |