OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 #include "ash/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 } else { | 99 } else { |
100 keyboard->HideKeyboard(keyboard::KeyboardController::HIDE_REASON_MANUAL); | 100 keyboard->HideKeyboard(keyboard::KeyboardController::HIDE_REASON_MANUAL); |
101 } | 101 } |
102 | 102 |
103 DCHECK_EQ(show, keyboard->keyboard_visible()); | 103 DCHECK_EQ(show, keyboard->keyboard_visible()); |
104 } | 104 } |
105 }; | 105 }; |
106 | 106 |
107 TEST_F(LockLayoutManagerTest, NorwmalWindowBoundsArePreserved) { | 107 TEST_F(LockLayoutManagerTest, NorwmalWindowBoundsArePreserved) { |
108 gfx::Rect screen_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); | 108 gfx::Rect screen_bounds = |
| 109 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
109 | 110 |
110 views::Widget::InitParams widget_params( | 111 views::Widget::InitParams widget_params( |
111 views::Widget::InitParams::TYPE_WINDOW); | 112 views::Widget::InitParams::TYPE_WINDOW); |
112 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); | 113 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); |
113 widget_params.bounds = bounds; | 114 widget_params.bounds = bounds; |
114 scoped_ptr<aura::Window> window( | 115 scoped_ptr<aura::Window> window( |
115 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 116 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
116 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); | 117 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); |
117 | 118 |
118 gfx::Rect work_area = | 119 gfx::Rect work_area = |
119 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); | 120 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); |
120 window->SetBounds(work_area); | 121 window->SetBounds(work_area); |
121 | 122 |
122 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 123 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
123 EXPECT_NE(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 124 EXPECT_NE(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
124 | 125 |
125 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); | 126 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); |
126 window->SetBounds(bounds2); | 127 window->SetBounds(bounds2); |
127 EXPECT_EQ(bounds2.ToString(), window->GetBoundsInScreen().ToString()); | 128 EXPECT_EQ(bounds2.ToString(), window->GetBoundsInScreen().ToString()); |
128 } | 129 } |
129 | 130 |
130 TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { | 131 TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { |
131 if (!SupportsHostWindowResize()) | 132 if (!SupportsHostWindowResize()) |
132 return; | 133 return; |
133 | 134 |
134 gfx::Rect screen_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); | 135 gfx::Rect screen_bounds = |
| 136 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
135 | 137 |
136 views::Widget::InitParams widget_params( | 138 views::Widget::InitParams widget_params( |
137 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 139 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
138 widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; | 140 widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; |
139 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); | 141 const gfx::Rect bounds = gfx::Rect(10, 10, 300, 300); |
140 widget_params.bounds = bounds; | 142 widget_params.bounds = bounds; |
141 // Maximized TYPE_WINDOW_FRAMELESS windows needs a delegate defined otherwise | 143 // Maximized TYPE_WINDOW_FRAMELESS windows needs a delegate defined otherwise |
142 // it won't get initial SetBounds event. | 144 // it won't get initial SetBounds event. |
143 scoped_ptr<aura::Window> maximized_window( | 145 scoped_ptr<aura::Window> maximized_window( |
144 CreateTestLoginWindow(widget_params, true /* use_delegate */)); | 146 CreateTestLoginWindow(widget_params, true /* use_delegate */)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 EXPECT_EQ(screen_bounds.ToString(), | 178 EXPECT_EQ(screen_bounds.ToString(), |
177 maximized_window->GetBoundsInScreen().ToString()); | 179 maximized_window->GetBoundsInScreen().ToString()); |
178 EXPECT_EQ(screen_bounds.ToString(), | 180 EXPECT_EQ(screen_bounds.ToString(), |
179 fullscreen_window->GetBoundsInScreen().ToString()); | 181 fullscreen_window->GetBoundsInScreen().ToString()); |
180 } | 182 } |
181 | 183 |
182 TEST_F(LockLayoutManagerTest, KeyboardBounds) { | 184 TEST_F(LockLayoutManagerTest, KeyboardBounds) { |
183 if (!SupportsHostWindowResize()) | 185 if (!SupportsHostWindowResize()) |
184 return; | 186 return; |
185 | 187 |
186 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); | 188 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
187 gfx::Rect screen_bounds = primary_display.bounds(); | 189 gfx::Rect screen_bounds = primary_display.bounds(); |
188 | 190 |
189 views::Widget::InitParams widget_params( | 191 views::Widget::InitParams widget_params( |
190 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 192 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
191 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 193 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
192 scoped_ptr<aura::Window> window( | 194 scoped_ptr<aura::Window> window( |
193 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 195 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
194 | 196 |
195 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 197 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
196 | 198 |
(...skipping 15 matching lines...) Expand all Loading... |
212 // 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached. | 214 // 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached. |
213 keyboard::SetKeyboardOverscrollOverride( | 215 keyboard::SetKeyboardOverscrollOverride( |
214 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 216 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
215 ShowKeyboard(true); | 217 ShowKeyboard(true); |
216 ShowKeyboard(false); | 218 ShowKeyboard(false); |
217 ash::DisplayManager* display_manager = | 219 ash::DisplayManager* display_manager = |
218 Shell::GetInstance()->display_manager(); | 220 Shell::GetInstance()->display_manager(); |
219 display_manager->SetDisplayRotation(primary_display.id(), | 221 display_manager->SetDisplayRotation(primary_display.id(), |
220 gfx::Display::ROTATE_90, | 222 gfx::Display::ROTATE_90, |
221 gfx::Display::ROTATION_SOURCE_ACTIVE); | 223 gfx::Display::ROTATION_SOURCE_ACTIVE); |
222 primary_display = Shell::GetScreen()->GetPrimaryDisplay(); | 224 primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
223 screen_bounds = primary_display.bounds(); | 225 screen_bounds = primary_display.bounds(); |
224 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 226 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
225 display_manager->SetDisplayRotation(primary_display.id(), | 227 display_manager->SetDisplayRotation(primary_display.id(), |
226 gfx::Display::ROTATE_0, | 228 gfx::Display::ROTATE_0, |
227 gfx::Display::ROTATION_SOURCE_ACTIVE); | 229 gfx::Display::ROTATION_SOURCE_ACTIVE); |
228 | 230 |
229 // When virtual keyboard overscroll is disabled keyboard bounds do | 231 // When virtual keyboard overscroll is disabled keyboard bounds do |
230 // affect window bounds. | 232 // affect window bounds. |
231 keyboard::SetKeyboardOverscrollOverride( | 233 keyboard::SetKeyboardOverscrollOverride( |
232 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 234 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
233 ShowKeyboard(true); | 235 ShowKeyboard(true); |
234 keyboard::KeyboardController* keyboard = | 236 keyboard::KeyboardController* keyboard = |
235 keyboard::KeyboardController::GetInstance(); | 237 keyboard::KeyboardController::GetInstance(); |
236 primary_display = Shell::GetScreen()->GetPrimaryDisplay(); | 238 primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
237 screen_bounds = primary_display.bounds(); | 239 screen_bounds = primary_display.bounds(); |
238 gfx::Rect target_bounds(screen_bounds); | 240 gfx::Rect target_bounds(screen_bounds); |
239 target_bounds.set_height( | 241 target_bounds.set_height( |
240 target_bounds.height() - | 242 target_bounds.height() - |
241 keyboard->ui()->GetKeyboardWindow()->bounds().height()); | 243 keyboard->ui()->GetKeyboardWindow()->bounds().height()); |
242 EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 244 EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
243 ShowKeyboard(false); | 245 ShowKeyboard(false); |
244 | 246 |
245 keyboard::SetKeyboardOverscrollOverride( | 247 keyboard::SetKeyboardOverscrollOverride( |
246 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); | 248 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); |
247 } | 249 } |
248 | 250 |
249 TEST_F(LockLayoutManagerTest, MultipleMonitors) { | 251 TEST_F(LockLayoutManagerTest, MultipleMonitors) { |
250 if (!SupportsMultipleDisplays()) | 252 if (!SupportsMultipleDisplays()) |
251 return; | 253 return; |
252 | 254 |
253 UpdateDisplay("300x400,400x500"); | 255 UpdateDisplay("300x400,400x500"); |
254 gfx::Rect screen_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); | 256 gfx::Rect screen_bounds = |
| 257 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
255 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 258 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
256 | 259 |
257 views::Widget::InitParams widget_params( | 260 views::Widget::InitParams widget_params( |
258 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 261 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
259 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 262 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
260 scoped_ptr<aura::Window> window( | 263 scoped_ptr<aura::Window> window( |
261 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 264 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
262 window->SetProperty(aura::client::kCanMaximizeKey, true); | 265 window->SetProperty(aura::client::kCanMaximizeKey, true); |
263 | 266 |
264 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 267 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
(...skipping 26 matching lines...) Expand all Loading... |
291 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); | 294 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); |
292 window->SetBounds(work_area); | 295 window->SetBounds(work_area); |
293 // Usually work_area takes Shelf into account but that doesn't affect | 296 // Usually work_area takes Shelf into account but that doesn't affect |
294 // LockScreen container windows. | 297 // LockScreen container windows. |
295 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 298 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
296 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 299 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
297 } | 300 } |
298 | 301 |
299 } // namespace test | 302 } // namespace test |
300 } // namespace ash | 303 } // namespace ash |
OLD | NEW |