Chromium Code Reviews| 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 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); | |
|
flackr
2014/06/17 15:05:31
Not really clear what the shelf state is at this p
jonross
2014/06/17 17:21:02
Shelf should be visible, I've added an assert to v
| |
| 953 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | |
| 954 shelf_layout_manager->UpdateVisibilityState(); | |
| 955 | |
| 956 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children | |
| 957 // including the backdrop. | |
| 958 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
| 959 shelf_layout_manager->UpdateVisibilityState(); | |
| 960 gfx::Rect reduced_bounds = default_container()->children()[0]->bounds(); | |
| 961 EXPECT_LT(reduced_bounds.height(), initial_bounds.height()); | |
|
flackr
2014/06/17 15:05:31
So after hiding and showing the shelf the bounds a
jonross
2014/06/17 17:21:02
The backdrop delegate is created with the size of
flackr
2014/06/17 23:48:33
Does this manifest on device in any way? It sounds
| |
| 962 | |
| 963 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | |
| 964 shelf_layout_manager->UpdateVisibilityState(); | |
| 965 | |
| 966 EXPECT_GT(default_container()->children()[0]->bounds().height(), | |
| 967 reduced_bounds.height()); | |
| 968 } | |
| 969 | |
| 945 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { | 970 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { |
| 946 public: | 971 public: |
| 947 WorkspaceLayoutManagerKeyboardTest() {} | 972 WorkspaceLayoutManagerKeyboardTest() {} |
| 948 virtual ~WorkspaceLayoutManagerKeyboardTest() {} | 973 virtual ~WorkspaceLayoutManagerKeyboardTest() {} |
| 949 | 974 |
| 950 virtual void SetUp() OVERRIDE { | 975 virtual void SetUp() OVERRIDE { |
| 951 test::AshTestBase::SetUp(); | 976 test::AshTestBase::SetUp(); |
| 952 UpdateDisplay("800x600"); | 977 UpdateDisplay("800x600"); |
| 953 aura::Window* default_container = Shell::GetContainer( | 978 aura::Window* default_container = Shell::GetContainer( |
| 954 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); | 979 Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 976 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); | 1001 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); |
| 977 } | 1002 } |
| 978 | 1003 |
| 979 void SetKeyboardBounds(const gfx::Rect& bounds) { | 1004 void SetKeyboardBounds(const gfx::Rect& bounds) { |
| 980 keyboard_bounds_ = bounds; | 1005 keyboard_bounds_ = bounds; |
| 981 } | 1006 } |
| 982 | 1007 |
| 983 private: | 1008 private: |
| 984 gfx::Insets restore_work_area_insets_; | 1009 gfx::Insets restore_work_area_insets_; |
| 985 gfx::Rect keyboard_bounds_; | 1010 gfx::Rect keyboard_bounds_; |
| 986 WorkspaceLayoutManager *layout_manager_; | 1011 WorkspaceLayoutManager* layout_manager_; |
| 987 | 1012 |
| 988 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); | 1013 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); |
| 989 }; | 1014 }; |
| 990 | 1015 |
| 991 class FakeTextInputClient : public ui::DummyTextInputClient { | 1016 class FakeTextInputClient : public ui::DummyTextInputClient { |
| 992 public: | 1017 public: |
| 993 FakeTextInputClient(gfx::NativeWindow window) : window_(window) {} | 1018 explicit FakeTextInputClient(gfx::NativeWindow window) : window_(window) {} |
| 994 virtual ~FakeTextInputClient() {} | 1019 virtual ~FakeTextInputClient() {} |
| 995 | 1020 |
| 996 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE { | 1021 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE { |
| 997 return window_; | 1022 return window_; |
| 998 } | 1023 } |
| 999 | 1024 |
| 1000 private: | 1025 private: |
| 1001 gfx::NativeWindow window_; | 1026 gfx::NativeWindow window_; |
| 1002 | 1027 |
| 1003 DISALLOW_COPY_AND_ASSIGN(FakeTextInputClient); | 1028 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)); | 1061 window->SetBounds(gfx::Rect(50, 50, 100, 500)); |
| 1037 EXPECT_EQ("50,50 100x500", window->bounds().ToString()); | 1062 EXPECT_EQ("50,50 100x500", window->bounds().ToString()); |
| 1038 ShowKeyboard(); | 1063 ShowKeyboard(); |
| 1039 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), | 1064 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), |
| 1040 window->bounds().ToString()); | 1065 window->bounds().ToString()); |
| 1041 HideKeyboard(); | 1066 HideKeyboard(); |
| 1042 input_method->SetFocusedTextInputClient(NULL); | 1067 input_method->SetFocusedTextInputClient(NULL); |
| 1043 } | 1068 } |
| 1044 | 1069 |
| 1045 } // namespace ash | 1070 } // namespace ash |
| OLD | NEW |