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/shell_observer.h" | 10 #include "ash/common/shell_observer.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 const void* key, | 296 const void* key, |
297 intptr_t old) override { | 297 intptr_t old) override { |
298 if (!window_) | 298 if (!window_) |
299 return; | 299 return; |
300 | 300 |
301 if (wm::GetWindowState(window)->IsMaximized()) { | 301 if (wm::GetWindowState(window)->IsMaximized()) { |
302 aura::Window* w = window_; | 302 aura::Window* w = window_; |
303 window_ = nullptr; | 303 window_ = nullptr; |
304 | 304 |
305 gfx::Rect shelf_bounds( | 305 gfx::Rect shelf_bounds( |
306 Shelf::ForPrimaryDisplay()->shelf_layout_manager()->GetIdealBounds()); | 306 GetPrimaryShelf()->shelf_layout_manager()->GetIdealBounds()); |
307 const gfx::Rect& window_bounds(w->bounds()); | 307 const gfx::Rect& window_bounds(w->bounds()); |
308 w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1, | 308 w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1, |
309 window_bounds.width(), window_bounds.height())); | 309 window_bounds.width(), window_bounds.height())); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 private: | 313 private: |
314 aura::Window* window_; | 314 aura::Window* window_; |
315 | 315 |
316 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver); | 316 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 | 726 |
727 /* | 727 /* |
728 // Verify if the window is not resized during screen lock. See: crbug.com/173127 | 728 // Verify if the window is not resized during screen lock. See: crbug.com/173127 |
729 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { | 729 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { |
730 SetCanLockScreen(true); | 730 SetCanLockScreen(true); |
731 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 731 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
732 // window with AlwaysOnTop will be managed by BaseLayoutManager. | 732 // window with AlwaysOnTop will be managed by BaseLayoutManager. |
733 window->SetProperty(aura::client::kAlwaysOnTopKey, true); | 733 window->SetProperty(aura::client::kAlwaysOnTopKey, true); |
734 window->Show(); | 734 window->Show(); |
735 | 735 |
736 ShelfLayoutManager* shelf_layout_manager = | 736 WmShelf* shelf = GetPrimaryShelf(); |
737 Shelf::ForWindow(window.get())->shelf_layout_manager(); | 737 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
738 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
739 | 738 |
740 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); | 739 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); |
741 gfx::Rect window_bounds = window->bounds(); | 740 gfx::Rect window_bounds = window->bounds(); |
742 EXPECT_EQ( | 741 EXPECT_EQ( |
743 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 742 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
744 window_bounds.ToString()); | 743 window_bounds.ToString()); |
745 | 744 |
746 // The window size should not get touched while we are in lock screen. | 745 // The window size should not get touched while we are in lock screen. |
747 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 746 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
748 shelf_layout_manager->UpdateVisibilityState(); | 747 shelf->UpdateVisibilityState(); |
749 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 748 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
750 | 749 |
751 // Coming out of the lock screen the window size should still remain. | 750 // Coming out of the lock screen the window size should still remain. |
752 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); | 751 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); |
753 shelf_layout_manager->UpdateVisibilityState(); | 752 shelf->UpdateVisibilityState(); |
754 EXPECT_EQ( | 753 EXPECT_EQ( |
755 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 754 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
756 window_bounds.ToString()); | 755 window_bounds.ToString()); |
757 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 756 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
758 } | 757 } |
759 | 758 |
760 // TODO(sky): these are commented out until maximize mode ported. | 759 // TODO(sky): these are commented out until maximize mode ported. |
761 // http://crbug.com/612629. | 760 // http://crbug.com/612629. |
762 | 761 |
763 // Following tests are written to test the backdrop functionality. | 762 // Following tests are written to test the backdrop functionality. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 window3.get())); | 929 window3.get())); |
931 ShowTopWindowBackdrop(false); | 930 ShowTopWindowBackdrop(false); |
932 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), | 931 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), |
933 window3.get())); | 932 window3.get())); |
934 } | 933 } |
935 | 934 |
936 // Tests that when hidding the shelf, that the backdrop resizes to fill the | 935 // Tests that when hidding the shelf, that the backdrop resizes to fill the |
937 // entire workspace area. | 936 // entire workspace area. |
938 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { | 937 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { |
939 ShelfLayoutManager* shelf_layout_manager = | 938 ShelfLayoutManager* shelf_layout_manager = |
940 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); | 939 GetPrimaryShelf()->shelf_layout_manager(); |
941 ShowTopWindowBackdrop(true); | 940 ShowTopWindowBackdrop(true); |
942 RunAllPendingInMessageLoop(); | 941 RunAllPendingInMessageLoop(); |
943 | 942 |
944 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 943 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
945 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); | 944 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); |
946 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 945 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
947 shelf_layout_manager->UpdateVisibilityState(); | 946 shelf_layout_manager->UpdateVisibilityState(); |
948 | 947 |
949 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children | 948 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children |
950 // including the backdrop. | 949 // including the backdrop. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 occluded_window_bounds.width(), | 1091 occluded_window_bounds.width(), |
1093 occluded_window_bounds.height()).ToString(), | 1092 occluded_window_bounds.height()).ToString(), |
1094 window->bounds().ToString()); | 1093 window->bounds().ToString()); |
1095 HideKeyboard(); | 1094 HideKeyboard(); |
1096 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); | 1095 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); |
1097 } | 1096 } |
1098 */ | 1097 */ |
1099 | 1098 |
1100 } // namespace mus | 1099 } // namespace mus |
1101 } // namespace ash | 1100 } // namespace ash |
OLD | NEW |