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/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
6 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
9 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/window_state.h" | 11 #include "ash/wm/window_state.h" |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); | 181 const gfx::Rect bounds2 = gfx::Rect(100, 100, 200, 200); |
181 maximized_window->SetBounds(bounds2); | 182 maximized_window->SetBounds(bounds2); |
182 fullscreen_window->SetBounds(bounds2); | 183 fullscreen_window->SetBounds(bounds2); |
183 EXPECT_EQ(screen_bounds.ToString(), | 184 EXPECT_EQ(screen_bounds.ToString(), |
184 maximized_window->GetBoundsInScreen().ToString()); | 185 maximized_window->GetBoundsInScreen().ToString()); |
185 EXPECT_EQ(screen_bounds.ToString(), | 186 EXPECT_EQ(screen_bounds.ToString(), |
186 fullscreen_window->GetBoundsInScreen().ToString()); | 187 fullscreen_window->GetBoundsInScreen().ToString()); |
187 } | 188 } |
188 | 189 |
189 TEST_F(LockLayoutManagerTest, KeyboardBounds) { | 190 TEST_F(LockLayoutManagerTest, KeyboardBounds) { |
190 gfx::Rect screen_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); | 191 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); |
192 gfx::Rect screen_bounds = primary_display.bounds(); | |
191 | 193 |
192 views::Widget::InitParams widget_params( | 194 views::Widget::InitParams widget_params( |
193 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 195 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
194 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; | 196 widget_params.show_state = ui::SHOW_STATE_FULLSCREEN; |
195 scoped_ptr<aura::Window> window( | 197 scoped_ptr<aura::Window> window( |
196 CreateTestLoginWindow(widget_params, false /* use_delegate */)); | 198 CreateTestLoginWindow(widget_params, false /* use_delegate */)); |
197 | 199 |
198 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 200 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
199 | 201 |
200 // When virtual keyboard overscroll is enabled keyboard bounds should not | 202 // When virtual keyboard overscroll is enabled keyboard bounds should not |
201 // affect window bounds. | 203 // affect window bounds. |
202 keyboard::SetKeyboardOverscrollOverride( | 204 keyboard::SetKeyboardOverscrollOverride( |
203 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED); | 205 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED); |
204 ShowKeyboard(true); | 206 ShowKeyboard(true); |
205 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 207 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
208 gfx::Rect keyboard_bounds = | |
209 keyboard::KeyboardController::GetInstance()->current_keyboard_bounds(); | |
210 EXPECT_NE(keyboard_bounds, gfx::Rect()); | |
206 ShowKeyboard(false); | 211 ShowKeyboard(false); |
207 | 212 |
213 // When keyboard is hidden make sure that rotating the screen gives 100% of | |
214 // screen size to window. | |
215 keyboard::SetKeyboardOverscrollOverride( | |
216 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | |
217 ShowKeyboard(true); | |
218 ShowKeyboard(false); | |
oshima
2014/08/21 15:32:50
why turning on and off?
Nikita (slow)
2014/08/21 16:00:41
This is the way to reproduce this bug before the f
oshima
2014/08/21 16:32:39
Can you mention that this is to repro a bug (with
Nikita (slow)
2014/08/21 16:38:27
Done.
| |
219 ash::DisplayManager* display_manager = | |
220 Shell::GetInstance()->display_manager(); | |
221 display_manager->SetDisplayRotation(primary_display.id(), | |
222 gfx::Display::ROTATE_90); | |
223 screen_bounds = primary_display.bounds(); | |
oshima
2014/08/21 16:32:39
screen_bounds = Shell::GetScreen()->GetPrimaryDisp
Nikita (slow)
2014/08/21 16:38:27
Done.
| |
224 | |
225 // We can't rely on screen_bounds.ToString() here since rotation doesn't | |
226 // affect how bounds are stored. | |
oshima
2014/08/21 15:32:50
rotation should update the display bounds. Have yo
Nikita (slow)
2014/08/21 16:00:41
I'm getting updated screen bounds:
screen_bounds =
| |
227 EXPECT_EQ(screen_bounds.origin(), window->GetBoundsInScreen().origin()); | |
228 EXPECT_EQ(screen_bounds.width(), window->GetBoundsInScreen().height()); | |
229 EXPECT_EQ(screen_bounds.height(), window->GetBoundsInScreen().width()); | |
230 display_manager->SetDisplayRotation(primary_display.id(), | |
231 gfx::Display::ROTATE_0); | |
232 | |
208 // When virtual keyboard overscroll is disabled keyboard bounds do | 233 // When virtual keyboard overscroll is disabled keyboard bounds do |
209 // affect window bounds. | 234 // affect window bounds. |
210 keyboard::SetKeyboardOverscrollOverride( | 235 keyboard::SetKeyboardOverscrollOverride( |
211 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 236 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
212 ShowKeyboard(true); | 237 ShowKeyboard(true); |
213 keyboard::KeyboardController* keyboard = | 238 keyboard::KeyboardController* keyboard = |
214 keyboard::KeyboardController::GetInstance(); | 239 keyboard::KeyboardController::GetInstance(); |
215 gfx::Rect target_bounds(screen_bounds); | 240 gfx::Rect target_bounds(screen_bounds); |
216 target_bounds.set_height(target_bounds.height() - | 241 target_bounds.set_height(target_bounds.height() - |
217 keyboard->proxy()->GetKeyboardWindow()->bounds().height()); | 242 keyboard->proxy()->GetKeyboardWindow()->bounds().height()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); | 292 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); |
268 window->SetBounds(work_area); | 293 window->SetBounds(work_area); |
269 // Usually work_area takes Shelf into account but that doesn't affect | 294 // Usually work_area takes Shelf into account but that doesn't affect |
270 // LockScreen container windows. | 295 // LockScreen container windows. |
271 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 296 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
272 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 297 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
273 } | 298 } |
274 | 299 |
275 } // namespace test | 300 } // namespace test |
276 } // namespace ash | 301 } // namespace ash |
OLD | NEW |