OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ash/wm/system_modal_container_layout_manager.h" | 13 #include "ash/wm/system_modal_container_layout_manager.h" |
14 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" |
15 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
16 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "ui/aura/client/focus_change_observer.h" | 18 #include "ui/aura/client/focus_change_observer.h" |
19 #include "ui/aura/client/focus_client.h" | 19 #include "ui/aura/client/focus_client.h" |
20 #include "ui/aura/client/window_tree_client.h" | 20 #include "ui/aura/client/window_tree_client.h" |
21 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
22 #include "ui/aura/test/event_generator.h" | 22 #include "ui/aura/test/event_generator.h" |
23 #include "ui/aura/test/test_window_delegate.h" | 23 #include "ui/aura/test/test_window_delegate.h" |
24 #include "ui/aura/test/test_windows.h" | 24 #include "ui/aura/test/test_windows.h" |
25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
26 #include "ui/aura/window_event_dispatcher.h" | 26 #include "ui/aura/window_event_dispatcher.h" |
27 #include "ui/aura/window_tracker.h" | 27 #include "ui/aura/window_tracker.h" |
| 28 #include "ui/base/ime/dummy_text_input_client.h" |
| 29 #include "ui/base/ime/input_method.h" |
| 30 #include "ui/base/ime/text_input_client.h" |
28 #include "ui/events/test/test_event_handler.h" | 31 #include "ui/events/test/test_event_handler.h" |
29 #include "ui/keyboard/keyboard_controller_proxy.h" | 32 #include "ui/keyboard/keyboard_controller_proxy.h" |
30 #include "ui/keyboard/keyboard_switches.h" | 33 #include "ui/keyboard/keyboard_switches.h" |
31 #include "ui/keyboard/keyboard_util.h" | 34 #include "ui/keyboard/keyboard_util.h" |
32 #include "ui/views/controls/menu/menu_controller.h" | 35 #include "ui/views/controls/menu/menu_controller.h" |
33 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
34 #include "ui/views/widget/widget_delegate.h" | 37 #include "ui/views/widget/widget_delegate.h" |
35 | 38 |
36 using aura::Window; | 39 using aura::Window; |
37 using views::Widget; | 40 using views::Widget; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 keyboard::switches::kEnableVirtualKeyboard); | 612 keyboard::switches::kEnableVirtualKeyboard); |
610 test::AshTestBase::SetUp(); | 613 test::AshTestBase::SetUp(); |
611 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 614 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
612 keyboard::KeyboardController::GetInstance()); | 615 keyboard::KeyboardController::GetInstance()); |
613 } | 616 } |
614 | 617 |
615 private: | 618 private: |
616 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); | 619 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); |
617 }; | 620 }; |
618 | 621 |
| 622 class MockTextInputClient : public ui::DummyTextInputClient { |
| 623 public: |
| 624 MockTextInputClient() : |
| 625 ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} |
| 626 |
| 627 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE { |
| 628 visible_rect_ = rect; |
| 629 } |
| 630 |
| 631 const gfx::Rect& visible_rect() const { |
| 632 return visible_rect_; |
| 633 } |
| 634 |
| 635 private: |
| 636 gfx::Rect visible_rect_; |
| 637 |
| 638 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); |
| 639 }; |
| 640 |
619 // Test for http://crbug.com/297858. Virtual keyboard container should only show | 641 // Test for http://crbug.com/297858. Virtual keyboard container should only show |
620 // on primary root window. | 642 // on primary root window. |
621 TEST_F(VirtualKeyboardRootWindowControllerTest, | 643 TEST_F(VirtualKeyboardRootWindowControllerTest, |
622 VirtualKeyboardOnPrimaryRootWindowOnly) { | 644 VirtualKeyboardOnPrimaryRootWindowOnly) { |
623 if (!SupportsMultipleDisplays()) | 645 if (!SupportsMultipleDisplays()) |
624 return; | 646 return; |
625 | 647 |
626 UpdateDisplay("500x500,500x500"); | 648 UpdateDisplay("500x500,500x500"); |
627 | 649 |
628 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 650 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 EXPECT_EQ(1, handler.num_mouse_events() / 2); | 781 EXPECT_EQ(1, handler.num_mouse_events() / 2); |
760 | 782 |
761 modal_widget->Close(); | 783 modal_widget->Close(); |
762 | 784 |
763 // Verify that mouse events are now unblocked to the root window. | 785 // Verify that mouse events are now unblocked to the root window. |
764 root_window_event_generator.ClickLeftButton(); | 786 root_window_event_generator.ClickLeftButton(); |
765 EXPECT_EQ(2, handler.num_mouse_events() / 2); | 787 EXPECT_EQ(2, handler.num_mouse_events() / 2); |
766 root_window->RemovePreTargetHandler(&handler); | 788 root_window->RemovePreTargetHandler(&handler); |
767 } | 789 } |
768 | 790 |
| 791 // Ensure that the visible area for scrolling the text caret excludes the |
| 792 // region occluded by the on-screen keyboard. |
| 793 TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) { |
| 794 keyboard::KeyboardController* keyboard_controller = |
| 795 keyboard::KeyboardController::GetInstance(); |
| 796 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); |
| 797 |
| 798 MockTextInputClient text_input_client; |
| 799 ui::InputMethod* input_method = proxy->GetInputMethod(); |
| 800 ASSERT_TRUE(input_method); |
| 801 input_method->SetFocusedTextInputClient(&text_input_client); |
| 802 |
| 803 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 804 aura::Window* keyboard_container = |
| 805 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 806 ASSERT_TRUE(keyboard_container); |
| 807 keyboard_container->Show(); |
| 808 |
| 809 const int keyboard_height = 100; |
| 810 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); |
| 811 keyboard_container->AddChild(keyboard_window); |
| 812 keyboard_window->set_owned_by_parent(false); |
| 813 keyboard_window->SetBounds(keyboard::KeyboardBoundsFromWindowBounds( |
| 814 keyboard_container->bounds(), keyboard_height)); |
| 815 |
| 816 proxy->EnsureCaretInWorkArea(); |
| 817 ASSERT_EQ(keyboard_container->bounds().width(), |
| 818 text_input_client.visible_rect().width()); |
| 819 ASSERT_EQ(keyboard_container->bounds().height() - keyboard_height, |
| 820 text_input_client.visible_rect().height()); |
| 821 } |
| 822 |
769 } // namespace test | 823 } // namespace test |
770 } // namespace ash | 824 } // namespace ash |
OLD | NEW |