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> |
| 8 |
7 #include "ash/display/display_layout.h" | 9 #include "ash/display/display_layout.h" |
8 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
9 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
10 #include "ash/screen_util.h" | 12 #include "ash/screen_util.h" |
11 #include "ash/session/session_state_delegate.h" | 13 #include "ash/session/session_state_delegate.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shell.h" | 15 #include "ash/shell.h" |
14 #include "ash/shell_observer.h" | 16 #include "ash/shell_observer.h" |
15 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
16 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
(...skipping 15 matching lines...) Expand all Loading... |
32 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
33 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
34 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
35 #include "ui/wm/core/window_util.h" | 37 #include "ui/wm/core/window_util.h" |
36 | 38 |
37 namespace ash { | 39 namespace ash { |
38 namespace { | 40 namespace { |
39 | 41 |
40 class MaximizeDelegateView : public views::WidgetDelegateView { | 42 class MaximizeDelegateView : public views::WidgetDelegateView { |
41 public: | 43 public: |
42 MaximizeDelegateView(const gfx::Rect& initial_bounds) | 44 explicit MaximizeDelegateView(const gfx::Rect& initial_bounds) |
43 : initial_bounds_(initial_bounds) { | 45 : initial_bounds_(initial_bounds) { |
44 } | 46 } |
45 virtual ~MaximizeDelegateView() {} | 47 virtual ~MaximizeDelegateView() {} |
46 | 48 |
47 virtual bool GetSavedWindowPlacement( | 49 virtual bool GetSavedWindowPlacement( |
48 const views::Widget* widget, | 50 const views::Widget* widget, |
49 gfx::Rect* bounds, | 51 gfx::Rect* bounds, |
50 ui::WindowShowState* show_state) const OVERRIDE { | 52 ui::WindowShowState* show_state) const OVERRIDE { |
51 *bounds = initial_bounds_; | 53 *bounds = initial_bounds_; |
52 *show_state = ui::SHOW_STATE_MAXIMIZED; | 54 *show_state = ui::SHOW_STATE_MAXIMIZED; |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { | 783 class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase { |
782 public: | 784 public: |
783 WorkspaceLayoutManagerBackdropTest() {} | 785 WorkspaceLayoutManagerBackdropTest() {} |
784 virtual ~WorkspaceLayoutManagerBackdropTest() {} | 786 virtual ~WorkspaceLayoutManagerBackdropTest() {} |
785 | 787 |
786 virtual void SetUp() OVERRIDE { | 788 virtual void SetUp() OVERRIDE { |
787 test::AshTestBase::SetUp(); | 789 test::AshTestBase::SetUp(); |
788 UpdateDisplay("800x600"); | 790 UpdateDisplay("800x600"); |
789 default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(), | 791 default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(), |
790 kShellWindowId_DefaultContainer); | 792 kShellWindowId_DefaultContainer); |
791 // We set the size to something smaller then the display to avoid resizing | |
792 // issues with the shelf. | |
793 default_container_->SetBounds(gfx::Rect(0, 0, 800, 500)); | |
794 } | 793 } |
795 | 794 |
796 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 795 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
797 aura::Window* window = CreateTestWindowInShellWithBounds(bounds); | 796 aura::Window* window = CreateTestWindowInShellWithBounds(bounds); |
798 return window; | 797 return window; |
799 } | 798 } |
800 | 799 |
801 // Turn the top window back drop on / off. | 800 // Turn the top window back drop on / off. |
802 void ShowTopWindowBackdrop(bool show) { | 801 void ShowTopWindowBackdrop(bool show) { |
803 scoped_ptr<ash::WorkspaceLayoutManagerDelegate> backdrop; | 802 scoped_ptr<ash::WorkspaceLayoutManagerDelegate> backdrop; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 window3.reset(); | 934 window3.reset(); |
936 EXPECT_EQ("b,x", | 935 EXPECT_EQ("b,x", |
937 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), | 936 GetWindowOrderAsString(backdrop, window1.get(), window2.get(), |
938 window3.get())); | 937 window3.get())); |
939 ShowTopWindowBackdrop(false); | 938 ShowTopWindowBackdrop(false); |
940 EXPECT_EQ("b", | 939 EXPECT_EQ("b", |
941 GetWindowOrderAsString(NULL, window1.get(), window2.get(), | 940 GetWindowOrderAsString(NULL, window1.get(), window2.get(), |
942 window3.get())); | 941 window3.get())); |
943 } | 942 } |
944 | 943 |
| 944 // Tests that when hidding the shelf, that the backdrop resizes to fill the |
| 945 // entire workspace area. |
| 946 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { |
| 947 ShelfLayoutManager* shelf_layout_manager = |
| 948 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 949 ShowTopWindowBackdrop(true); |
| 950 RunAllPendingInMessageLoop(); |
| 951 |
| 952 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| 953 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); |
| 954 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 955 shelf_layout_manager->UpdateVisibilityState(); |
| 956 |
| 957 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children |
| 958 // including the backdrop. |
| 959 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 960 shelf_layout_manager->UpdateVisibilityState(); |
| 961 gfx::Rect reduced_bounds = default_container()->children()[0]->bounds(); |
| 962 EXPECT_LT(reduced_bounds.height(), initial_bounds.height()); |
| 963 |
| 964 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 965 shelf_layout_manager->UpdateVisibilityState(); |
| 966 |
| 967 EXPECT_GT(default_container()->children()[0]->bounds().height(), |
| 968 reduced_bounds.height()); |
| 969 } |
| 970 |
945 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { | 971 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { |
946 public: | 972 public: |
947 WorkspaceLayoutManagerKeyboardTest() {} | 973 WorkspaceLayoutManagerKeyboardTest() {} |
948 virtual ~WorkspaceLayoutManagerKeyboardTest() {} | 974 virtual ~WorkspaceLayoutManagerKeyboardTest() {} |
949 | 975 |
950 virtual void SetUp() OVERRIDE { | 976 virtual void SetUp() OVERRIDE { |
951 test::AshTestBase::SetUp(); | 977 test::AshTestBase::SetUp(); |
952 UpdateDisplay("800x600"); | 978 UpdateDisplay("800x600"); |
953 aura::Window* default_container = Shell::GetContainer( | 979 aura::Window* default_container = Shell::GetContainer( |
954 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); | 980 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); |
(...skipping 21 matching lines...) Expand all Loading... |
976 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); | 1002 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); |
977 } | 1003 } |
978 | 1004 |
979 void SetKeyboardBounds(const gfx::Rect& bounds) { | 1005 void SetKeyboardBounds(const gfx::Rect& bounds) { |
980 keyboard_bounds_ = bounds; | 1006 keyboard_bounds_ = bounds; |
981 } | 1007 } |
982 | 1008 |
983 private: | 1009 private: |
984 gfx::Insets restore_work_area_insets_; | 1010 gfx::Insets restore_work_area_insets_; |
985 gfx::Rect keyboard_bounds_; | 1011 gfx::Rect keyboard_bounds_; |
986 WorkspaceLayoutManager *layout_manager_; | 1012 WorkspaceLayoutManager* layout_manager_; |
987 | 1013 |
988 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); | 1014 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); |
989 }; | 1015 }; |
990 | 1016 |
991 class FakeTextInputClient : public ui::DummyTextInputClient { | 1017 class FakeTextInputClient : public ui::DummyTextInputClient { |
992 public: | 1018 public: |
993 FakeTextInputClient(gfx::NativeWindow window) : window_(window) {} | 1019 explicit FakeTextInputClient(gfx::NativeWindow window) : window_(window) {} |
994 virtual ~FakeTextInputClient() {} | 1020 virtual ~FakeTextInputClient() {} |
995 | 1021 |
996 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE { | 1022 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE { |
997 return window_; | 1023 return window_; |
998 } | 1024 } |
999 | 1025 |
1000 private: | 1026 private: |
1001 gfx::NativeWindow window_; | 1027 gfx::NativeWindow window_; |
1002 | 1028 |
1003 DISALLOW_COPY_AND_ASSIGN(FakeTextInputClient); | 1029 DISALLOW_COPY_AND_ASSIGN(FakeTextInputClient); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 window->SetBounds(gfx::Rect(50, 50, 100, 500)); | 1062 window->SetBounds(gfx::Rect(50, 50, 100, 500)); |
1037 EXPECT_EQ("50,50 100x500", window->bounds().ToString()); | 1063 EXPECT_EQ("50,50 100x500", window->bounds().ToString()); |
1038 ShowKeyboard(); | 1064 ShowKeyboard(); |
1039 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), | 1065 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), |
1040 window->bounds().ToString()); | 1066 window->bounds().ToString()); |
1041 HideKeyboard(); | 1067 HideKeyboard(); |
1042 input_method->SetFocusedTextInputClient(NULL); | 1068 input_method->SetFocusedTextInputClient(NULL); |
1043 } | 1069 } |
1044 | 1070 |
1045 } // namespace ash | 1071 } // namespace ash |
OLD | NEW |