Chromium Code Reviews| Index: ui/keyboard/keyboard_controller_unittest.cc |
| diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc |
| index cee5581bec8153d7f5121566682a08b70c126ec9..4d30d4fb11b8b2ff6d2490a44bdab9751cc835e3 100644 |
| --- a/ui/keyboard/keyboard_controller_unittest.cc |
| +++ b/ui/keyboard/keyboard_controller_unittest.cc |
| @@ -193,8 +193,18 @@ class KeyboardControllerTest : public testing::Test { |
| void SetFocus(ui::TextInputClient* client) { |
| ui::InputMethod* input_method = proxy()->GetInputMethod(); |
| input_method->SetFocusedTextInputClient(client); |
| - if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) |
| + if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) { |
| input_method->ShowImeIfNeeded(); |
| + if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { |
| + // Set initial bounds for test keyboard window. |
| + gfx::Rect window_bounds = controller()->GetContainerWindow()->bounds(); |
|
oshima
2014/04/23 16:14:08
you're doing this in muliple places. Can you add a
bshe
2014/04/23 16:39:07
Done.
|
| + proxy_->GetKeyboardWindow()->SetBounds(gfx::Rect( |
| + window_bounds.x(), |
| + window_bounds.y() + window_bounds.height() - 100, |
| + window_bounds.width(), |
| + 100)); |
| + } |
| + } |
| } |
| bool WillHideKeyboard() { |
| @@ -214,17 +224,27 @@ class KeyboardControllerTest : public testing::Test { |
| TEST_F(KeyboardControllerTest, KeyboardSize) { |
| aura::Window* container(controller()->GetContainerWindow()); |
| - gfx::Rect bounds(0, 0, 100, 100); |
| - container->SetBounds(bounds); |
| + aura::Window* keyboard(proxy()->GetKeyboardWindow()); |
| + container->SetBounds(gfx::Rect(0, 0, 200, 100)); |
| + |
| + container->AddChild(keyboard); |
| + const gfx::Rect& before_bounds = keyboard->bounds(); |
| + // The initial keyboard should be positioned at the bottom of container and |
| + // has 0 height. |
| + ASSERT_EQ(gfx::Rect(0, 100, 200, 0), before_bounds); |
| - const gfx::Rect& before_bounds = proxy()->GetKeyboardWindow()->bounds(); |
| gfx::Rect new_bounds( |
| - before_bounds.x(), before_bounds.y(), |
| - before_bounds.width() / 2, before_bounds.height() / 2); |
| + before_bounds.x(), before_bounds.y() - 50, |
| + before_bounds.width(), 50); |
| + |
| + keyboard->SetBounds(new_bounds); |
| + ASSERT_EQ(new_bounds, keyboard->bounds()); |
| - // The KeyboardController's LayoutManager shouldn't let this happen |
| - proxy()->GetKeyboardWindow()->SetBounds(new_bounds); |
| - ASSERT_EQ(before_bounds, proxy()->GetKeyboardWindow()->bounds()); |
| + // Mock a screen rotation. |
| + container->SetBounds(gfx::Rect(0, 0, 100, 200)); |
| + // The above call should resize keyboard to new width while keeping the old |
| + // height. |
| + ASSERT_EQ(gfx::Rect(0, 150, 100, 50), keyboard->bounds()); |
| } |
| // Tests that tapping/clicking inside the keyboard does not give it focus. |
| @@ -393,33 +413,6 @@ TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) { |
| EXPECT_FALSE(keyboard_container->IsVisible()); |
| } |
| -TEST_F(KeyboardControllerTest, KeyboardResizingFromContents) { |
| - aura::Window* keyboard_container = controller()->GetContainerWindow(); |
| - aura::Window* keyboard_window = proxy()->GetKeyboardWindow(); |
| - keyboard_container->SetBounds(gfx::Rect(800, 600)); |
| - keyboard_container->AddChild(keyboard_window); |
| - |
| - int original_height = keyboard_window->bounds().height(); |
| - |
| - // Resizes from contents when flag is unset. |
| - keyboard_window->SetBounds(gfx::Rect(100, 80)); |
| - EXPECT_EQ(original_height, keyboard_window->bounds().height()); |
| - |
| - // Resizes from contents when flag is set. |
| - proxy()->set_resizing_from_contents(true); |
| - keyboard_window->SetBounds(gfx::Rect(100, 80)); |
| - EXPECT_EQ(80, keyboard_window->bounds().height()); |
| - |
| - // Resizes from container when flag is set. |
| - keyboard_container->SetBounds(gfx::Rect(400, 300)); |
| - EXPECT_EQ(80, keyboard_window->bounds().height()); |
| - |
| - // Resizes from container when flag is unset. |
| - proxy()->set_resizing_from_contents(false); |
| - keyboard_container->SetBounds(gfx::Rect(800, 600)); |
| - EXPECT_EQ(original_height, keyboard_window->bounds().height()); |
| -} |
| - |
| class KeyboardControllerAnimationTest : public KeyboardControllerTest, |
| public KeyboardControllerObserver { |
| public: |