Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: ash/wm/lock_layout_manager_unittest.cc

Issue 528043002: Fix stale keyboard bounds on login screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/wm/lock_window_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Repro steps for http://crbug.com/401667:
216 // 1. Set up login screen defaults: VK override disabled
217 // 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached.
218 keyboard::SetKeyboardOverscrollOverride(
219 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED);
220 ShowKeyboard(true);
221 ShowKeyboard(false);
222 ash::DisplayManager* display_manager =
223 Shell::GetInstance()->display_manager();
224 display_manager->SetDisplayRotation(primary_display.id(),
225 gfx::Display::ROTATE_90);
226 primary_display = Shell::GetScreen()->GetPrimaryDisplay();
227 screen_bounds = primary_display.bounds();
228 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString());
229 display_manager->SetDisplayRotation(primary_display.id(),
230 gfx::Display::ROTATE_0);
231
208 // When virtual keyboard overscroll is disabled keyboard bounds do 232 // When virtual keyboard overscroll is disabled keyboard bounds do
209 // affect window bounds. 233 // affect window bounds.
210 keyboard::SetKeyboardOverscrollOverride( 234 keyboard::SetKeyboardOverscrollOverride(
211 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); 235 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED);
212 ShowKeyboard(true); 236 ShowKeyboard(true);
213 keyboard::KeyboardController* keyboard = 237 keyboard::KeyboardController* keyboard =
214 keyboard::KeyboardController::GetInstance(); 238 keyboard::KeyboardController::GetInstance();
239 primary_display = Shell::GetScreen()->GetPrimaryDisplay();
240 screen_bounds = primary_display.bounds();
215 gfx::Rect target_bounds(screen_bounds); 241 gfx::Rect target_bounds(screen_bounds);
216 target_bounds.set_height(target_bounds.height() - 242 target_bounds.set_height(target_bounds.height() -
217 keyboard->proxy()->GetKeyboardWindow()->bounds().height()); 243 keyboard->proxy()->GetKeyboardWindow()->bounds().height());
218 EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString()); 244 EXPECT_EQ(target_bounds.ToString(), window->GetBoundsInScreen().ToString());
219 ShowKeyboard(false); 245 ShowKeyboard(false);
220 246
221 keyboard::SetKeyboardOverscrollOverride( 247 keyboard::SetKeyboardOverscrollOverride(
222 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE); 248 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE);
223 } 249 }
224 250
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get()); 293 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window.get());
268 window->SetBounds(work_area); 294 window->SetBounds(work_area);
269 // Usually work_area takes Shelf into account but that doesn't affect 295 // Usually work_area takes Shelf into account but that doesn't affect
270 // LockScreen container windows. 296 // LockScreen container windows.
271 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString()); 297 EXPECT_NE(work_area.ToString(), window->GetBoundsInScreen().ToString());
272 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); 298 EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString());
273 } 299 }
274 300
275 } // namespace test 301 } // namespace test
276 } // namespace ash 302 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/lock_window_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698