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

Side by Side Diff: ui/keyboard/keyboard_controller_unittest.cc

Issue 2629233003: Revert of Change the keyboard bounds when moving to another display. (Closed)
Patch Set: Created 3 years, 11 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 | « ui/keyboard/keyboard_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 TEST_F(KeyboardControllerTest, KeyboardSize) { 293 TEST_F(KeyboardControllerTest, KeyboardSize) {
294 aura::Window* container(controller()->GetContainerWindow()); 294 aura::Window* container(controller()->GetContainerWindow());
295 aura::Window* keyboard(ui()->GetKeyboardWindow()); 295 aura::Window* keyboard(ui()->GetKeyboardWindow());
296 gfx::Rect screen_bounds = root_window()->bounds(); 296 gfx::Rect screen_bounds = root_window()->bounds();
297 root_window()->AddChild(container); 297 root_window()->AddChild(container);
298 container->AddChild(keyboard); 298 container->AddChild(keyboard);
299 const gfx::Rect& initial_bounds = container->bounds(); 299 const gfx::Rect& initial_bounds = container->bounds();
300 // The container should be positioned at the bottom of screen and has 0 300 // The container should be positioned at the bottom of screen and has 0
301 // height. 301 // height.
302 ASSERT_EQ(0, initial_bounds.height()); 302 ASSERT_EQ(gfx::Rect(), initial_bounds);
303 ASSERT_EQ(screen_bounds.height(), initial_bounds.y());
304 VerifyKeyboardWindowSize(container, keyboard); 303 VerifyKeyboardWindowSize(container, keyboard);
305 304
306 // In FULL_WIDTH mode, attempt to change window width or move window up from 305 // In FULL_WIDTH mode, attempt to change window width or move window up from
307 // the bottom are ignored. Changing window height is supported. 306 // the bottom are ignored. Changing window height is supported.
308 gfx::Rect expected_bounds(0, 307 gfx::Rect expected_bounds(0,
309 screen_bounds.height() - 50, 308 screen_bounds.height() - 50,
310 screen_bounds.width(), 309 screen_bounds.width(),
311 50); 310 50);
312 311
313 // The x position of new bounds may not be 0 if shelf is on the left side of 312 // The x position of new bounds may not be 0 if shelf is on the left side of
(...skipping 20 matching lines...) Expand all
334 aura::Window* keyboard(ui()->GetKeyboardWindow()); 333 aura::Window* keyboard(ui()->GetKeyboardWindow());
335 root_window()->AddChild(container); 334 root_window()->AddChild(container);
336 controller()->SetKeyboardMode(FLOATING); 335 controller()->SetKeyboardMode(FLOATING);
337 container->AddChild(keyboard); 336 container->AddChild(keyboard);
338 gfx::Rect new_bounds(0, 50, 50, 50); 337 gfx::Rect new_bounds(0, 50, 50, 50);
339 keyboard->SetBounds(new_bounds); 338 keyboard->SetBounds(new_bounds);
340 ASSERT_EQ(new_bounds, container->bounds()); 339 ASSERT_EQ(new_bounds, container->bounds());
341 VerifyKeyboardWindowSize(container, keyboard); 340 VerifyKeyboardWindowSize(container, keyboard);
342 } 341 }
343 342
344 TEST_F(KeyboardControllerTest, KeyboardSizeMultiRootWindow) {
345 aura::Window* container(controller()->GetContainerWindow());
346 aura::Window* keyboard(ui()->GetKeyboardWindow());
347 gfx::Rect screen_bounds = root_window()->bounds();
348 root_window()->AddChild(container);
349 container->AddChild(keyboard);
350 const gfx::Rect& initial_bounds = container->bounds();
351 // The container should be positioned at the bottom of screen and has 0
352 // height.
353 ASSERT_EQ(0, initial_bounds.height());
354 ASSERT_EQ(screen_bounds.height(), initial_bounds.y());
355 VerifyKeyboardWindowSize(container, keyboard);
356
357 // Adding new root window.
358 std::unique_ptr<aura::WindowTreeHost> secondary_tree_host =
359 base::WrapUnique<aura::WindowTreeHost>(
360 aura::WindowTreeHost::Create(gfx::Rect(0, 0, 1000, 500)));
361 secondary_tree_host->InitHost();
362 EXPECT_EQ(1000, secondary_tree_host->window()->bounds().width());
363 EXPECT_EQ(500, secondary_tree_host->window()->bounds().height());
364
365 // Move the keyboard into the secondary root window.
366 controller()->HideKeyboard(
367 KeyboardController::HideReason::HIDE_REASON_AUTOMATIC);
368 root_window()->RemoveChild(container);
369 secondary_tree_host->window()->AddChild(container);
370
371 const gfx::Rect& new_bounds = container->bounds();
372 EXPECT_EQ(500, new_bounds.y());
373 VerifyKeyboardWindowSize(container, keyboard);
374 }
375
376 // Tests that tapping/clicking inside the keyboard does not give it focus. 343 // Tests that tapping/clicking inside the keyboard does not give it focus.
377 TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) { 344 TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) {
378 keyboard::SetAccessibilityKeyboardEnabled(true); 345 keyboard::SetAccessibilityKeyboardEnabled(true);
379 const gfx::Rect& root_bounds = root_window()->bounds(); 346 const gfx::Rect& root_bounds = root_window()->bounds();
380 aura::test::EventCountDelegate delegate; 347 aura::test::EventCountDelegate delegate;
381 std::unique_ptr<aura::Window> window(new aura::Window(&delegate)); 348 std::unique_ptr<aura::Window> window(new aura::Window(&delegate));
382 window->Init(ui::LAYER_NOT_DRAWN); 349 window->Init(ui::LAYER_NOT_DRAWN);
383 window->SetBounds(root_bounds); 350 window->SetBounds(root_bounds);
384 root_window()->AddChild(window.get()); 351 root_window()->AddChild(window.get());
385 window->Show(); 352 window->Show();
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 gfx::Rect new_bounds(0, 0, 1280, 800); 700 gfx::Rect new_bounds(0, 0, 1280, 800);
734 ASSERT_NE(new_bounds, root_window()->bounds()); 701 ASSERT_NE(new_bounds, root_window()->bounds());
735 EXPECT_EQ(1, number_of_calls()); 702 EXPECT_EQ(1, number_of_calls());
736 root_window()->SetBounds(new_bounds); 703 root_window()->SetBounds(new_bounds);
737 EXPECT_EQ(2, number_of_calls()); 704 EXPECT_EQ(2, number_of_calls());
738 MockRotateScreen(); 705 MockRotateScreen();
739 EXPECT_EQ(3, number_of_calls()); 706 EXPECT_EQ(3, number_of_calls());
740 } 707 }
741 708
742 } // namespace keyboard 709 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698