Chromium Code Reviews| Index: ash/root_window_controller_unittest.cc |
| diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc |
| index cf4e54c212b12a4806df1757d251aae27fcc64e7..9af6954cec438d995f9947e66811f7a4e7deab79 100644 |
| --- a/ash/root_window_controller_unittest.cc |
| +++ b/ash/root_window_controller_unittest.cc |
| @@ -723,14 +723,14 @@ class MockTextInputClient : public ui::DummyTextInputClient { |
| public: |
| MockTextInputClient() : ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} |
| - void EnsureCaretInRect(const gfx::Rect& rect) override { |
| - visible_rect_ = rect; |
| + void EnsureCaretOutOfRect(const gfx::Rect& rect) override { |
| + hidden_rect_ = rect; |
| } |
| - const gfx::Rect& visible_rect() const { return visible_rect_; } |
| + const gfx::Rect& hidden_rect() const { return hidden_rect_; } |
| private: |
| - gfx::Rect visible_rect_; |
| + gfx::Rect hidden_rect_; |
| DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); |
| }; |
| @@ -1083,13 +1083,76 @@ TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) { |
| ui->EnsureCaretInWorkArea(); |
| ASSERT_EQ(root_window->bounds().width(), |
| - text_input_client.visible_rect().width()); |
| - ASSERT_EQ(root_window->bounds().height() - keyboard_height, |
| - text_input_client.visible_rect().height()); |
| + text_input_client.hidden_rect().width()); |
| + ASSERT_EQ(keyboard_height, text_input_client.hidden_rect().height()); |
| input_method->SetFocusedTextInputClient(NULL); |
| } |
| +TEST_F(VirtualKeyboardRootWindowControllerTest, |
| + EnsureCaretInWorkAreaWithMultipleDisplays) { |
| + if (!SupportsMultipleDisplays()) |
| + return; |
| + |
| + UpdateDisplay("500x500,600x600"); |
| + const int64_t primary_display_id = |
| + display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| + const int64_t secondary_display_id = |
| + Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id(); |
| + ASSERT_NE(primary_display_id, secondary_display_id); |
| + |
| + aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| + aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); |
| + aura::Window* secondary_root_window = root_windows[0] == primary_root_window |
| + ? root_windows[1] |
| + : root_windows[0]; |
| + ASSERT_NE(primary_root_window, secondary_root_window); |
| + |
| + keyboard::KeyboardController* keyboard_controller = |
| + keyboard::KeyboardController::GetInstance(); |
| + keyboard::KeyboardUI* ui = keyboard_controller->ui(); |
| + |
| + MockTextInputClient text_input_client; |
| + ui::InputMethod* input_method = ui->GetInputMethod(); |
| + ASSERT_TRUE(input_method); |
| + input_method->SetFocusedTextInputClient(&text_input_client); |
| + |
| + const int keyboard_height = 100; |
| + // Check that the keyboard on the primary screen doesn't cover the window on |
| + // the secondary screen. |
| + aura::Window* keyboard_container = Shell::GetContainer( |
| + primary_root_window, kShellWindowId_VirtualKeyboardContainer); |
| + ASSERT_TRUE(keyboard_container); |
| + keyboard_container->Show(); |
| + aura::Window* keyboard_window = ui->GetKeyboardWindow(); |
| + keyboard_container->AddChild(keyboard_window); |
| + keyboard_window->set_owned_by_parent(false); |
| + keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| + primary_root_window->bounds(), keyboard_height)); |
| + |
| + ui->EnsureCaretInWorkArea(); |
|
oshima
2016/12/06 14:02:25
we may want to remove this as well for consistency
yhanada
2016/12/07 03:25:52
Done.
|
| + EXPECT_EQ(primary_root_window->bounds().width(), |
| + text_input_client.hidden_rect().width()); |
|
oshima
2016/12/06 14:02:25
and contains
yhanada
2016/12/07 03:25:52
Done.
|
| + EXPECT_TRUE(gfx::IntersectRects(text_input_client.hidden_rect(), |
| + secondary_root_window->GetBoundsInScreen()) |
| + .IsEmpty()); |
|
oshima
2016/12/06 14:02:25
!contains?
yhanada
2016/12/07 03:25:52
Done.
|
| + |
| + // Move the keyboard into the secondary display and check that the keyboard |
| + // doesn't cover the window on the primary screen. |
| + keyboard_controller->ShowKeyboardInDisplay(secondary_display_id); |
| + keyboard_container->Show(); |
| + keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| + secondary_root_window->bounds(), keyboard_height)); |
| + |
| + ui->EnsureCaretInWorkArea(); |
| + EXPECT_EQ(secondary_root_window->bounds().width(), |
| + text_input_client.hidden_rect().width()); |
| + EXPECT_TRUE(gfx::IntersectRects(text_input_client.hidden_rect(), |
| + primary_root_window->GetBoundsInScreen()) |
| + .IsEmpty()); |
|
oshima
2016/12/06 14:02:25
ditto
yhanada
2016/12/07 03:25:52
Done.
|
| + input_method->SetFocusedTextInputClient(nullptr); |
| +} |
| + |
| // Tests that the virtual keyboard does not block context menus. The virtual |
| // keyboard should appear in front of most content, but not context menus. See |
| // crbug/377180. |