| OLD | NEW | 
|    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  Loading... | 
|  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(gfx::Rect(), initial_bounds); |  302   ASSERT_EQ(0, initial_bounds.height()); | 
 |  303   ASSERT_EQ(screen_bounds.height(), initial_bounds.y()); | 
|  303   VerifyKeyboardWindowSize(container, keyboard); |  304   VerifyKeyboardWindowSize(container, keyboard); | 
|  304  |  305  | 
|  305   // In FULL_WIDTH mode, attempt to change window width or move window up from |  306   // In FULL_WIDTH mode, attempt to change window width or move window up from | 
|  306   // the bottom are ignored. Changing window height is supported. |  307   // the bottom are ignored. Changing window height is supported. | 
|  307   gfx::Rect expected_bounds(0, |  308   gfx::Rect expected_bounds(0, | 
|  308                             screen_bounds.height() - 50, |  309                             screen_bounds.height() - 50, | 
|  309                             screen_bounds.width(), |  310                             screen_bounds.width(), | 
|  310                             50); |  311                             50); | 
|  311  |  312  | 
|  312   // The x position of new bounds may not be 0 if shelf is on the left side of |  313   // The x position of new bounds may not be 0 if shelf is on the left side of | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|  333   aura::Window* keyboard(ui()->GetKeyboardWindow()); |  334   aura::Window* keyboard(ui()->GetKeyboardWindow()); | 
|  334   root_window()->AddChild(container); |  335   root_window()->AddChild(container); | 
|  335   controller()->SetKeyboardMode(FLOATING); |  336   controller()->SetKeyboardMode(FLOATING); | 
|  336   container->AddChild(keyboard); |  337   container->AddChild(keyboard); | 
|  337   gfx::Rect new_bounds(0, 50, 50, 50); |  338   gfx::Rect new_bounds(0, 50, 50, 50); | 
|  338   keyboard->SetBounds(new_bounds); |  339   keyboard->SetBounds(new_bounds); | 
|  339   ASSERT_EQ(new_bounds, container->bounds()); |  340   ASSERT_EQ(new_bounds, container->bounds()); | 
|  340   VerifyKeyboardWindowSize(container, keyboard); |  341   VerifyKeyboardWindowSize(container, keyboard); | 
|  341 } |  342 } | 
|  342  |  343  | 
 |  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  | 
|  343 // Tests that tapping/clicking inside the keyboard does not give it focus. |  376 // Tests that tapping/clicking inside the keyboard does not give it focus. | 
|  344 TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) { |  377 TEST_F(KeyboardControllerTest, ClickDoesNotFocusKeyboard) { | 
|  345   keyboard::SetAccessibilityKeyboardEnabled(true); |  378   keyboard::SetAccessibilityKeyboardEnabled(true); | 
|  346   const gfx::Rect& root_bounds = root_window()->bounds(); |  379   const gfx::Rect& root_bounds = root_window()->bounds(); | 
|  347   aura::test::EventCountDelegate delegate; |  380   aura::test::EventCountDelegate delegate; | 
|  348   std::unique_ptr<aura::Window> window(new aura::Window(&delegate)); |  381   std::unique_ptr<aura::Window> window(new aura::Window(&delegate)); | 
|  349   window->Init(ui::LAYER_NOT_DRAWN); |  382   window->Init(ui::LAYER_NOT_DRAWN); | 
|  350   window->SetBounds(root_bounds); |  383   window->SetBounds(root_bounds); | 
|  351   root_window()->AddChild(window.get()); |  384   root_window()->AddChild(window.get()); | 
|  352   window->Show(); |  385   window->Show(); | 
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  700   gfx::Rect new_bounds(0, 0, 1280, 800); |  733   gfx::Rect new_bounds(0, 0, 1280, 800); | 
|  701   ASSERT_NE(new_bounds, root_window()->bounds()); |  734   ASSERT_NE(new_bounds, root_window()->bounds()); | 
|  702   EXPECT_EQ(1, number_of_calls()); |  735   EXPECT_EQ(1, number_of_calls()); | 
|  703   root_window()->SetBounds(new_bounds); |  736   root_window()->SetBounds(new_bounds); | 
|  704   EXPECT_EQ(2, number_of_calls()); |  737   EXPECT_EQ(2, number_of_calls()); | 
|  705   MockRotateScreen(); |  738   MockRotateScreen(); | 
|  706   EXPECT_EQ(3, number_of_calls()); |  739   EXPECT_EQ(3, number_of_calls()); | 
|  707 } |  740 } | 
|  708  |  741  | 
|  709 }  // namespace keyboard |  742 }  // namespace keyboard | 
| OLD | NEW |