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/toplevel_layout_manager.h" | 5 #include "ash/wm/toplevel_layout_manager.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/shelf_layout_manager.h" | 10 #include "ash/wm/shelf_layout_manager.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 ToplevelLayoutManagerTest() : layout_manager_(NULL) {} | 27 ToplevelLayoutManagerTest() : layout_manager_(NULL) {} |
28 virtual ~ToplevelLayoutManagerTest() {} | 28 virtual ~ToplevelLayoutManagerTest() {} |
29 | 29 |
30 internal::ToplevelLayoutManager* layout_manager() { | 30 internal::ToplevelLayoutManager* layout_manager() { |
31 return layout_manager_; | 31 return layout_manager_; |
32 } | 32 } |
33 | 33 |
34 virtual void SetUp() OVERRIDE { | 34 virtual void SetUp() OVERRIDE { |
35 test::AshTestBase::SetUp(); | 35 test::AshTestBase::SetUp(); |
36 Shell::GetRootWindow()->screen()->set_work_area_insets( | 36 Shell::GetRootWindow()->SetScreenWorkAreaInsets( |
37 gfx::Insets(1, 2, 3, 4)); | 37 gfx::Insets(1, 2, 3, 4)); |
38 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); | 38 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); |
39 aura::Window* default_container = Shell::GetInstance()->GetContainer( | 39 aura::Window* default_container = Shell::GetInstance()->GetContainer( |
40 internal::kShellWindowId_DefaultContainer); | 40 internal::kShellWindowId_DefaultContainer); |
41 layout_manager_ = new internal::ToplevelLayoutManager(); | 41 layout_manager_ = new internal::ToplevelLayoutManager(); |
42 default_container->SetLayoutManager(layout_manager_); | 42 default_container->SetLayoutManager(layout_manager_); |
43 } | 43 } |
44 | 44 |
45 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 45 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
46 return aura::test::CreateTestWindowWithBounds(bounds, NULL); | 46 return aura::test::CreateTestWindowWithBounds(bounds, NULL); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 gfx::Rect bounds(100, 100, 200, 200); | 93 gfx::Rect bounds(100, 100, 200, 200); |
94 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 94 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
95 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 95 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
96 // Fullscreen window fills the whole monitor. | 96 // Fullscreen window fills the whole monitor. |
97 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), | 97 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), |
98 window->bounds()); | 98 window->bounds()); |
99 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 99 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
100 EXPECT_EQ(bounds, window->bounds()); | 100 EXPECT_EQ(bounds, window->bounds()); |
101 } | 101 } |
102 | 102 |
| 103 // Tests maximized window resizing on work area insets change. |
| 104 TEST_F(ToplevelLayoutManagerTest, |
| 105 ResizeMaximizedWindowOnWorkAreaInsetsChange) { |
| 106 gfx::Rect bounds(100, 100, 200, 200); |
| 107 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 108 Shell::GetRootWindow()->SetScreenWorkAreaInsets( |
| 109 gfx::Insets(0, 0, 30, 0)); |
| 110 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 111 // Maximized window fills the work area. |
| 112 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), |
| 113 window->bounds()); |
| 114 |
| 115 // Change work area insets. |
| 116 Shell::GetRootWindow()->SetScreenWorkAreaInsets( |
| 117 gfx::Insets(0, 0, 60, 0)); |
| 118 // Maximized window fills the changed work area. |
| 119 EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), |
| 120 window->bounds()); |
| 121 } |
| 122 |
103 // Tests fullscreen window size during root window resize. | 123 // Tests fullscreen window size during root window resize. |
104 TEST_F(ToplevelLayoutManagerTest, FullscreenRootWindowResize) { | 124 TEST_F(ToplevelLayoutManagerTest, FullscreenRootWindowResize) { |
105 gfx::Rect bounds(100, 100, 200, 200); | 125 gfx::Rect bounds(100, 100, 200, 200); |
106 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 126 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
107 // Fullscreen window fills the whole monitor. | 127 // Fullscreen window fills the whole monitor. |
108 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 128 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
109 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), | 129 EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(window.get()), |
110 window->bounds()); | 130 window->bounds()); |
111 // Enlarge the root window. We should still match the monitor size. | 131 // Enlarge the root window. We should still match the monitor size. |
112 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); | 132 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 window.reset(); | 222 window.reset(); |
203 // shelf_layout_manager is observing these animations so clean them up first. | 223 // shelf_layout_manager is observing these animations so clean them up first. |
204 launcher->GetNativeView()->layer()->GetAnimator()->StopAnimating(); | 224 launcher->GetNativeView()->layer()->GetAnimator()->StopAnimating(); |
205 status->GetNativeView()->layer()->GetAnimator()->StopAnimating(); | 225 status->GetNativeView()->layer()->GetAnimator()->StopAnimating(); |
206 shelf_layout_manager.reset(); | 226 shelf_layout_manager.reset(); |
207 } | 227 } |
208 | 228 |
209 } // namespace | 229 } // namespace |
210 | 230 |
211 } // namespace ash | 231 } // namespace ash |
OLD | NEW |