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/base_layout_manager.h" | 5 #include "ash/wm/base_layout_manager.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
15 #include "ash/wm/workspace/workspace_window_resizer.h" | 15 #include "ash/wm/workspace/workspace_window_resizer.h" |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest); | 50 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest); |
51 }; | 51 }; |
52 | 52 |
53 // Tests normal->maximize->normal. | 53 // Tests normal->maximize->normal. |
54 TEST_F(BaseLayoutManagerTest, Maximize) { | 54 TEST_F(BaseLayoutManagerTest, Maximize) { |
55 gfx::Rect bounds(100, 100, 200, 200); | 55 gfx::Rect bounds(100, 100, 200, 200); |
56 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 56 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
57 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 57 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
58 // Maximized window fills the work area, not the whole display. | 58 // Maximized window fills the work area, not the whole display. |
59 EXPECT_EQ( | 59 EXPECT_EQ( |
60 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 60 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
61 window->bounds().ToString()); | 61 window->bounds().ToString()); |
62 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 62 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
63 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 63 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
64 } | 64 } |
65 | 65 |
66 // Tests normal->minimize->normal. | 66 // Tests normal->minimize->normal. |
67 TEST_F(BaseLayoutManagerTest, Minimize) { | 67 TEST_F(BaseLayoutManagerTest, Minimize) { |
68 gfx::Rect bounds(100, 100, 200, 200); | 68 gfx::Rect bounds(100, 100, 200, 200); |
69 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 69 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
70 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 70 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 EXPECT_TRUE(window->IsVisible()); | 125 EXPECT_TRUE(window->IsVisible()); |
126 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, delegate.GetShowStateAndReset()); | 126 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, delegate.GetShowStateAndReset()); |
127 } | 127 } |
128 | 128 |
129 // Tests maximized window size during root window resize. | 129 // Tests maximized window size during root window resize. |
130 TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { | 130 TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { |
131 gfx::Rect bounds(100, 100, 200, 200); | 131 gfx::Rect bounds(100, 100, 200, 200); |
132 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 132 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
133 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 133 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
134 gfx::Rect initial_work_area_bounds = | 134 gfx::Rect initial_work_area_bounds = |
135 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); | 135 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()); |
136 EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString()); | 136 EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString()); |
137 // Enlarge the root window. We should still match the work area size. | 137 // Enlarge the root window. We should still match the work area size. |
138 UpdateDisplay("900x700"); | 138 UpdateDisplay("900x700"); |
139 EXPECT_EQ( | 139 EXPECT_EQ( |
140 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 140 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
141 window->bounds().ToString()); | 141 window->bounds().ToString()); |
142 EXPECT_NE( | 142 EXPECT_NE( |
143 initial_work_area_bounds.ToString(), | 143 initial_work_area_bounds.ToString(), |
144 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString()); | 144 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString()); |
145 } | 145 } |
146 | 146 |
147 // Tests normal->fullscreen->normal. | 147 // Tests normal->fullscreen->normal. |
148 TEST_F(BaseLayoutManagerTest, Fullscreen) { | 148 TEST_F(BaseLayoutManagerTest, Fullscreen) { |
149 gfx::Rect bounds(100, 100, 200, 200); | 149 gfx::Rect bounds(100, 100, 200, 200); |
150 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 150 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
151 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 151 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
152 // Fullscreen window fills the whole display. | 152 // Fullscreen window fills the whole display. |
153 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( | 153 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
154 window.get()).bounds().ToString(), | 154 window.get()).bounds().ToString(), |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // Create a window with bounds that fill the screen. | 211 // Create a window with bounds that fill the screen. |
212 gfx::Rect bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); | 212 gfx::Rect bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); |
213 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 213 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
214 // Maximize it, which writes the old bounds to restore bounds. | 214 // Maximize it, which writes the old bounds to restore bounds. |
215 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 215 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
216 // Restore it. | 216 // Restore it. |
217 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 217 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
218 // It should have the default maximized window bounds, inset by the grid size. | 218 // It should have the default maximized window bounds, inset by the grid size. |
219 int grid_size = internal::WorkspaceWindowResizer::kScreenEdgeInset; | 219 int grid_size = internal::WorkspaceWindowResizer::kScreenEdgeInset; |
220 gfx::Rect max_bounds = | 220 gfx::Rect max_bounds = |
221 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); | 221 ash::ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()); |
222 max_bounds.Inset(grid_size, grid_size); | 222 max_bounds.Inset(grid_size, grid_size); |
223 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); | 223 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); |
224 } | 224 } |
225 | 225 |
226 // Verifies maximizing sets the restore bounds, and restoring | 226 // Verifies maximizing sets the restore bounds, and restoring |
227 // restores the bounds. | 227 // restores the bounds. |
228 TEST_F(BaseLayoutManagerTest, MaximizeSetsRestoreBounds) { | 228 TEST_F(BaseLayoutManagerTest, MaximizeSetsRestoreBounds) { |
229 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 229 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
230 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 230 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
231 | 231 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 SetCanLockScreen(true); | 285 SetCanLockScreen(true); |
286 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 286 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
287 // window with AlwaysOnTop will be managed by BaseLayoutManager. | 287 // window with AlwaysOnTop will be managed by BaseLayoutManager. |
288 window->SetProperty(aura::client::kAlwaysOnTopKey, true); | 288 window->SetProperty(aura::client::kAlwaysOnTopKey, true); |
289 window->Show(); | 289 window->Show(); |
290 | 290 |
291 internal::ShelfLayoutManager* shelf = | 291 internal::ShelfLayoutManager* shelf = |
292 internal::ShelfLayoutManager::ForShelf(window.get()); | 292 internal::ShelfLayoutManager::ForShelf(window.get()); |
293 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 293 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
294 | 294 |
295 window->SetBounds(ScreenAsh::GetMaximizedWindowBoundsInParent(window.get())); | 295 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); |
296 gfx::Rect window_bounds = window->bounds(); | 296 gfx::Rect window_bounds = window->bounds(); |
297 EXPECT_EQ( | 297 EXPECT_EQ( |
298 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 298 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
299 window_bounds.ToString()); | 299 window_bounds.ToString()); |
300 | 300 |
301 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 301 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
302 shelf->UpdateVisibilityState(); | 302 shelf->UpdateVisibilityState(); |
303 EXPECT_NE( | 303 EXPECT_NE( |
304 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), | 304 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), |
305 window_bounds.ToString()); | 305 window_bounds.ToString()); |
306 | 306 |
307 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 307 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
308 shelf->UpdateVisibilityState(); | 308 shelf->UpdateVisibilityState(); |
309 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); | 309 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); |
310 } | 310 } |
311 | 311 |
312 } // namespace | 312 } // namespace |
313 } // namespace ash | 313 } // namespace ash |
OLD | NEW |