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_ash.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString()); | 94 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString()); |
95 } | 95 } |
96 | 96 |
97 // Tests normal->fullscreen->normal. | 97 // Tests normal->fullscreen->normal. |
98 TEST_F(BaseLayoutManagerTest, Fullscreen) { | 98 TEST_F(BaseLayoutManagerTest, Fullscreen) { |
99 gfx::Rect bounds(100, 100, 200, 200); | 99 gfx::Rect bounds(100, 100, 200, 200); |
100 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 100 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
101 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 101 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
102 // Fullscreen window fills the whole display. | 102 // Fullscreen window fills the whole display. |
103 EXPECT_EQ( | 103 EXPECT_EQ( |
104 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), | 104 ash::Shell::GetAshScreen()->GetDisplayNearestWindow( |
| 105 window.get()).bounds().ToString(), |
105 window->bounds().ToString()); | 106 window->bounds().ToString()); |
106 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 107 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
107 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 108 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
108 } | 109 } |
109 | 110 |
110 // Tests fullscreen window size during root window resize. | 111 // Tests fullscreen window size during root window resize. |
111 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { | 112 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { |
112 gfx::Rect bounds(100, 100, 200, 200); | 113 gfx::Rect bounds(100, 100, 200, 200); |
113 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 114 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
114 // Fullscreen window fills the whole display. | 115 // Fullscreen window fills the whole display. |
115 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 116 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
116 EXPECT_EQ( | 117 EXPECT_EQ( |
117 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), | 118 ash::Shell::GetAshScreen()->GetDisplayNearestWindow( |
| 119 window.get()).bounds().ToString(), |
118 window->bounds().ToString()); | 120 window->bounds().ToString()); |
119 // Enlarge the root window. We should still match the display size. | 121 // Enlarge the root window. We should still match the display size. |
120 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); | 122 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); |
121 EXPECT_EQ( | 123 EXPECT_EQ( |
122 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), | 124 ash::Shell::GetAshScreen()->GetDisplayNearestWindow( |
| 125 window.get()).bounds().ToString(), |
123 window->bounds().ToString()); | 126 window->bounds().ToString()); |
124 } | 127 } |
125 | 128 |
126 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. | 129 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. |
127 #if defined(OS_MACOSX) | 130 #if defined(OS_MACOSX) |
128 #define MAYBE_RootWindowResizeShrinksWindows \ | 131 #define MAYBE_RootWindowResizeShrinksWindows \ |
129 FAILS_RootWindowResizeShrinksWindows | 132 FAILS_RootWindowResizeShrinksWindows |
130 #else | 133 #else |
131 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows | 134 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows |
132 #endif | 135 #endif |
133 // Tests that when the screen gets smaller the windows aren't bigger than | 136 // Tests that when the screen gets smaller the windows aren't bigger than |
134 // the screen. | 137 // the screen. |
135 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) { | 138 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) { |
136 scoped_ptr<aura::Window> window( | 139 scoped_ptr<aura::Window> window( |
137 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); | 140 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); |
138 gfx::Rect work_area = | 141 gfx::Rect work_area = ash::Shell::GetAshScreen()-> |
139 gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); | 142 GetDisplayNearestWindow(window.get()).work_area(); |
140 // Invariant: Window is smaller than work area. | 143 // Invariant: Window is smaller than work area. |
141 EXPECT_LE(window->bounds().width(), work_area.width()); | 144 EXPECT_LE(window->bounds().width(), work_area.width()); |
142 EXPECT_LE(window->bounds().height(), work_area.height()); | 145 EXPECT_LE(window->bounds().height(), work_area.height()); |
143 | 146 |
144 // Make the root window narrower than our window. | 147 // Make the root window narrower than our window. |
145 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 400)); | 148 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 400)); |
146 work_area = gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); | 149 work_area = ash::Shell::GetAshScreen()-> |
| 150 GetDisplayNearestWindow(window.get()).work_area(); |
147 EXPECT_LE(window->bounds().width(), work_area.width()); | 151 EXPECT_LE(window->bounds().width(), work_area.width()); |
148 EXPECT_LE(window->bounds().height(), work_area.height()); | 152 EXPECT_LE(window->bounds().height(), work_area.height()); |
149 | 153 |
150 // Make the root window shorter than our window. | 154 // Make the root window shorter than our window. |
151 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 200)); | 155 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 200)); |
152 work_area = gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); | 156 work_area = ash::Shell::GetAshScreen()-> |
| 157 GetDisplayNearestWindow(window.get()).work_area(); |
153 EXPECT_LE(window->bounds().width(), work_area.width()); | 158 EXPECT_LE(window->bounds().width(), work_area.width()); |
154 EXPECT_LE(window->bounds().height(), work_area.height()); | 159 EXPECT_LE(window->bounds().height(), work_area.height()); |
155 | 160 |
156 // Enlarging the root window does not change the window bounds. | 161 // Enlarging the root window does not change the window bounds. |
157 gfx::Rect old_bounds = window->bounds(); | 162 gfx::Rect old_bounds = window->bounds(); |
158 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); | 163 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); |
159 EXPECT_EQ(old_bounds.width(), window->bounds().width()); | 164 EXPECT_EQ(old_bounds.width(), window->bounds().width()); |
160 EXPECT_EQ(old_bounds.height(), window->bounds().height()); | 165 EXPECT_EQ(old_bounds.height(), window->bounds().height()); |
161 } | 166 } |
162 | 167 |
163 // Tests that a maximized window with too-large restore bounds will be restored | 168 // Tests that a maximized window with too-large restore bounds will be restored |
164 // to smaller than the full work area. | 169 // to smaller than the full work area. |
165 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { | 170 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { |
166 // Create a window with bounds that fill the screen. | 171 // Create a window with bounds that fill the screen. |
167 gfx::Rect bounds = gfx::Screen::GetPrimaryDisplay().bounds(); | 172 gfx::Rect bounds = ash::Shell::GetAshScreen()->GetPrimaryDisplay().bounds(); |
168 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 173 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); |
169 // Maximize it, which writes the old bounds to restore bounds. | 174 // Maximize it, which writes the old bounds to restore bounds. |
170 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 175 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
171 // Restore it. | 176 // Restore it. |
172 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 177 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
173 // It should have the default maximized window bounds, inset by the grid size. | 178 // It should have the default maximized window bounds, inset by the grid size. |
174 int grid_size = internal::WorkspaceWindowResizer::kScreenEdgeInset; | 179 int grid_size = internal::WorkspaceWindowResizer::kScreenEdgeInset; |
175 gfx::Rect max_bounds = | 180 gfx::Rect max_bounds = |
176 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); | 181 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); |
177 max_bounds.Inset(grid_size, grid_size); | 182 max_bounds.Inset(grid_size, grid_size); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 GetRestoreBoundsInParent(window.get()).ToString()); | 232 GetRestoreBoundsInParent(window.get()).ToString()); |
228 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); | 233 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); |
229 | 234 |
230 wm::RestoreWindow(window.get()); | 235 wm::RestoreWindow(window.get()); |
231 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); | 236 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); |
232 } | 237 } |
233 | 238 |
234 } // namespace | 239 } // namespace |
235 | 240 |
236 } // namespace ash | 241 } // namespace ash |
OLD | NEW |