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/input_method_factory.h" | |
31 #include "ui/base/ime/text_input_client.h" | |
28 #include "ui/events/test/test_event_handler.h" | 32 #include "ui/events/test/test_event_handler.h" |
29 #include "ui/keyboard/keyboard_controller_proxy.h" | 33 #include "ui/keyboard/keyboard_controller_proxy.h" |
30 #include "ui/keyboard/keyboard_switches.h" | 34 #include "ui/keyboard/keyboard_switches.h" |
31 #include "ui/keyboard/keyboard_util.h" | 35 #include "ui/keyboard/keyboard_util.h" |
32 #include "ui/views/controls/menu/menu_controller.h" | 36 #include "ui/views/controls/menu/menu_controller.h" |
33 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
34 #include "ui/views/widget/widget_delegate.h" | 38 #include "ui/views/widget/widget_delegate.h" |
35 | 39 |
36 using aura::Window; | 40 using aura::Window; |
37 using views::Widget; | 41 using views::Widget; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 gfx::Point(size.width() - 1, size.height() - 1))); | 602 gfx::Point(size.width() - 1, size.height() - 1))); |
599 } | 603 } |
600 | 604 |
601 class VirtualKeyboardRootWindowControllerTest : public RootWindowControllerTest | 605 class VirtualKeyboardRootWindowControllerTest : public RootWindowControllerTest |
602 { | 606 { |
603 public: | 607 public: |
604 VirtualKeyboardRootWindowControllerTest() {}; | 608 VirtualKeyboardRootWindowControllerTest() {}; |
605 virtual ~VirtualKeyboardRootWindowControllerTest() {}; | 609 virtual ~VirtualKeyboardRootWindowControllerTest() {}; |
606 | 610 |
607 virtual void SetUp() OVERRIDE { | 611 virtual void SetUp() OVERRIDE { |
612 ui::SetUpInputMethodFactoryForTesting(); | |
608 CommandLine::ForCurrentProcess()->AppendSwitch( | 613 CommandLine::ForCurrentProcess()->AppendSwitch( |
609 keyboard::switches::kEnableVirtualKeyboard); | 614 keyboard::switches::kEnableVirtualKeyboard); |
610 test::AshTestBase::SetUp(); | 615 test::AshTestBase::SetUp(); |
611 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 616 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
612 keyboard::KeyboardController::GetInstance()); | 617 keyboard::KeyboardController::GetInstance()); |
613 } | 618 } |
614 | 619 |
615 private: | 620 private: |
616 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); | 621 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); |
617 }; | 622 }; |
618 | 623 |
624 class MockTextInputClient : public ui::DummyTextInputClient { | |
625 public: | |
626 MockTextInputClient() : | |
627 ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} | |
628 | |
629 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE { | |
630 visible_rect_ = rect; | |
631 } | |
632 | |
633 gfx::Rect& visible_rect() { | |
oshima
2014/05/12 18:09:59
const const ?
kevers
2014/05/13 00:07:49
Done.
| |
634 return visible_rect_; | |
635 } | |
636 | |
637 private: | |
638 gfx::Rect visible_rect_; | |
oshima
2014/05/12 18:09:59
DISALLOW_COPY_AND_ASSIGN
kevers
2014/05/13 00:07:49
Done.
| |
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 input_method->SetFocusedTextInputClient(&text_input_client); | |
801 | |
802 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | |
803 aura::Window* keyboard_container = | |
804 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | |
805 ASSERT_TRUE(keyboard_container); | |
806 keyboard_container->Show(); | |
807 | |
808 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); | |
809 keyboard_container->AddChild(keyboard_window); | |
810 keyboard_window->set_owned_by_parent(false); | |
811 keyboard_window->SetBounds(keyboard::KeyboardBoundsFromWindowBounds( | |
812 keyboard_container->bounds(), 100)); | |
oshima
2014/05/12 18:09:59
define const for vk height
kevers
2014/05/13 00:07:49
Done.
| |
813 | |
814 proxy->EnsureCaretInWorkArea(); | |
815 ASSERT_EQ(keyboard_container->bounds().width(), | |
816 text_input_client.visible_rect().width()); | |
817 ASSERT_EQ(keyboard_container->bounds().height() - 100, | |
818 text_input_client.visible_rect().height()); | |
819 } | |
820 | |
769 } // namespace test | 821 } // namespace test |
770 } // namespace ash | 822 } // namespace ash |
OLD | NEW |