Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" |
| 31 #include "ui/aura/test/test_window_delegate.h" | 31 #include "ui/aura/test/test_window_delegate.h" |
| 32 #include "ui/aura/test/test_windows.h" | 32 #include "ui/aura/test/test_windows.h" |
| 33 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
| 34 #include "ui/aura/window_event_dispatcher.h" | 34 #include "ui/aura/window_event_dispatcher.h" |
| 35 #include "ui/aura/window_tracker.h" | 35 #include "ui/aura/window_tracker.h" |
| 36 #include "ui/base/ime/dummy_text_input_client.h" | 36 #include "ui/base/ime/dummy_text_input_client.h" |
| 37 #include "ui/base/ime/input_method.h" | 37 #include "ui/base/ime/input_method.h" |
| 38 #include "ui/base/ime/text_input_client.h" | 38 #include "ui/base/ime/text_input_client.h" |
| 39 #include "ui/display/manager/display_manager.h" | 39 #include "ui/display/manager/display_manager.h" |
| 40 #include "ui/display/test/display_manager_test_api.h" | |
| 41 #include "ui/events/devices/device_data_manager.h" | |
| 42 #include "ui/events/devices/touchscreen_device.h" | |
| 40 #include "ui/events/test/event_generator.h" | 43 #include "ui/events/test/event_generator.h" |
| 41 #include "ui/events/test/test_event_handler.h" | 44 #include "ui/events/test/test_event_handler.h" |
| 42 #include "ui/keyboard/keyboard_controller.h" | 45 #include "ui/keyboard/keyboard_controller.h" |
| 43 #include "ui/keyboard/keyboard_switches.h" | 46 #include "ui/keyboard/keyboard_switches.h" |
| 44 #include "ui/keyboard/keyboard_ui.h" | 47 #include "ui/keyboard/keyboard_ui.h" |
| 45 #include "ui/keyboard/keyboard_util.h" | 48 #include "ui/keyboard/keyboard_util.h" |
| 46 #include "ui/views/controls/menu/menu_controller.h" | 49 #include "ui/views/controls/menu/menu_controller.h" |
| 47 #include "ui/views/widget/widget.h" | 50 #include "ui/views/widget/widget.h" |
| 48 #include "ui/views/widget/widget_delegate.h" | 51 #include "ui/views/widget/widget_delegate.h" |
| 49 | 52 |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 class VirtualKeyboardRootWindowControllerTest | 699 class VirtualKeyboardRootWindowControllerTest |
| 697 : public RootWindowControllerTest { | 700 : public RootWindowControllerTest { |
| 698 public: | 701 public: |
| 699 VirtualKeyboardRootWindowControllerTest() {} | 702 VirtualKeyboardRootWindowControllerTest() {} |
| 700 ~VirtualKeyboardRootWindowControllerTest() override {} | 703 ~VirtualKeyboardRootWindowControllerTest() override {} |
| 701 | 704 |
| 702 void SetUp() override { | 705 void SetUp() override { |
| 703 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 706 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 704 keyboard::switches::kEnableVirtualKeyboard); | 707 keyboard::switches::kEnableVirtualKeyboard); |
| 705 test::AshTestBase::SetUp(); | 708 test::AshTestBase::SetUp(); |
| 706 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 709 keyboard::SetTouchKeyboardEnabled(true); |
| 707 keyboard::KeyboardController::GetInstance()); | 710 Shell::GetInstance()->CreateKeyboard(); |
| 711 } | |
| 712 | |
| 713 void TearDown() override { | |
| 714 keyboard::SetTouchKeyboardEnabled(false); | |
| 715 test::AshTestBase::TearDown(); | |
| 708 } | 716 } |
| 709 | 717 |
| 710 private: | 718 private: |
| 711 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); | 719 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); |
| 712 }; | 720 }; |
| 713 | 721 |
| 714 class MockTextInputClient : public ui::DummyTextInputClient { | 722 class MockTextInputClient : public ui::DummyTextInputClient { |
| 715 public: | 723 public: |
| 716 MockTextInputClient() : ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} | 724 MockTextInputClient() : ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} |
| 717 | 725 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 736 if (event->type() == ui::ET_MOUSE_PRESSED) | 744 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 737 ui::test::TestEventHandler::OnMouseEvent(event); | 745 ui::test::TestEventHandler::OnMouseEvent(event); |
| 738 event->StopPropagation(); | 746 event->StopPropagation(); |
| 739 } | 747 } |
| 740 | 748 |
| 741 private: | 749 private: |
| 742 DISALLOW_COPY_AND_ASSIGN(TargetHitTestEventHandler); | 750 DISALLOW_COPY_AND_ASSIGN(TargetHitTestEventHandler); |
| 743 }; | 751 }; |
| 744 | 752 |
| 745 // Test for http://crbug.com/297858. Virtual keyboard container should only show | 753 // Test for http://crbug.com/297858. Virtual keyboard container should only show |
| 746 // on primary root window. | 754 // on primary root window if no window has a focus. |
|
oshima
2016/11/08 17:26:04
I assume you meant touch capability?
yhanada
2016/11/14 22:48:47
Done.
| |
| 747 TEST_F(VirtualKeyboardRootWindowControllerTest, | 755 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 748 VirtualKeyboardOnPrimaryRootWindowOnly) { | 756 VirtualKeyboardOnPrimaryRootWindowDefault) { |
| 749 if (!SupportsMultipleDisplays()) | 757 if (!SupportsMultipleDisplays()) |
| 750 return; | 758 return; |
| 751 | 759 |
| 752 UpdateDisplay("500x500,500x500"); | 760 UpdateDisplay("500x500,500x500"); |
| 753 | 761 |
| 754 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 762 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 755 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | 763 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); |
| 764 aura::Window* secondary_root_window = root_windows[0] == primary_root_window | |
| 765 ? root_windows[1] | |
| 766 : root_windows[0]; | |
| 767 | |
| 768 ASSERT_TRUE(Shell::GetContainer(primary_root_window, | |
| 769 kShellWindowId_VirtualKeyboardContainer)); | |
| 770 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | |
| 771 kShellWindowId_VirtualKeyboardContainer)); | |
| 772 } | |
| 773 | |
| 774 // Test for http://crbug.com/303429. Virtual keyboard container should show on | |
| 775 // a display which has touch capability. | |
| 776 TEST_F(VirtualKeyboardRootWindowControllerTest, | |
| 777 VirtualKeyboardOnTouchableDisplayOnly) { | |
| 778 if (!SupportsMultipleDisplays()) | |
| 779 return; | |
| 780 | |
| 781 UpdateDisplay("500x500,500x500"); | |
| 782 display::Display secondary_display = | |
| 783 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); | |
| 784 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | |
| 785 .SetTouchSupport(secondary_display.id(), | |
| 786 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | |
| 787 | |
| 788 // The primary display doesn't have touch capability and the secondary display | |
| 789 // does. | |
| 790 ASSERT_NE(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE, | |
| 791 display::Screen::GetScreen()->GetPrimaryDisplay().touch_support()); | |
| 792 ASSERT_EQ(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE, | |
| 793 Shell::GetInstance() | |
| 794 ->display_manager() | |
| 795 ->GetSecondaryDisplay() | |
| 796 .touch_support()); | |
| 797 | |
| 798 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 799 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | |
| 800 aura::Window* secondary_root_window = root_windows[0] == primary_root_window | |
| 801 ? root_windows[1] | |
| 802 : root_windows[0]; | |
| 803 | |
| 804 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false); | |
| 805 ASSERT_FALSE(Shell::GetContainer(primary_root_window, | |
| 806 kShellWindowId_VirtualKeyboardContainer)); | |
| 807 ASSERT_TRUE(Shell::GetContainer(secondary_root_window, | |
| 808 kShellWindowId_VirtualKeyboardContainer)); | |
| 809 } | |
|
oshima
2016/11/08 17:26:05
can you also test that it opens on the secondary d
yhanada
2016/11/14 22:48:47
Done.
| |
| 810 | |
| 811 // Test for http://crbug.com/303429. If both of displays have touch capability, | |
| 812 // virtual keyboard follows the input focus. | |
| 813 TEST_F(VirtualKeyboardRootWindowControllerTest, FollowInputFocus) { | |
| 814 if (!SupportsMultipleDisplays()) | |
| 815 return; | |
| 816 | |
| 817 UpdateDisplay("500x500,500x500"); | |
| 818 const int64_t primary_display_id = | |
| 819 display::Screen::GetScreen()->GetPrimaryDisplay().id(); | |
| 820 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | |
| 821 .SetTouchSupport(primary_display_id, | |
| 822 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | |
| 823 const int64_t secondary_display_id = | |
| 824 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id(); | |
| 825 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | |
| 826 .SetTouchSupport(secondary_display_id, | |
| 827 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | |
| 828 | |
| 829 // Both of displays have touch capability. | |
| 830 ASSERT_EQ(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE, | |
| 831 display::Screen::GetScreen()->GetPrimaryDisplay().touch_support()); | |
| 832 ASSERT_EQ(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE, | |
| 833 Shell::GetInstance() | |
| 834 ->display_manager() | |
| 835 ->GetSecondaryDisplay() | |
| 836 .touch_support()); | |
| 837 | |
| 838 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 839 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | |
| 840 aura::Window* secondary_root_window = root_windows[0] == primary_root_window | |
| 841 ? root_windows[1] | |
| 842 : root_windows[0]; | |
| 843 aura::Window* focusable_window_in_primary_display = | |
| 844 CreateTestWindowInShellWithBounds( | |
| 845 primary_root_window->GetBoundsInScreen()); | |
| 846 ASSERT_EQ(primary_root_window, | |
| 847 focusable_window_in_primary_display->GetRootWindow()); | |
| 848 aura::Window* focusable_window_in_secondary_display = | |
| 849 CreateTestWindowInShellWithBounds( | |
| 850 secondary_root_window->GetBoundsInScreen()); | |
| 851 ASSERT_EQ(secondary_root_window, | |
| 852 focusable_window_in_secondary_display->GetRootWindow()); | |
| 853 | |
| 854 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false); | |
| 855 ASSERT_TRUE(Shell::GetContainer(primary_root_window, | |
| 856 kShellWindowId_VirtualKeyboardContainer)); | |
| 857 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | |
| 858 kShellWindowId_VirtualKeyboardContainer)); | |
| 859 | |
| 860 // Move the focus to the secondary display. | |
| 861 focusable_window_in_secondary_display->Focus(); | |
| 862 ASSERT_TRUE(focusable_window_in_secondary_display->HasFocus()); | |
| 863 | |
| 864 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false); | |
| 865 ASSERT_FALSE(Shell::GetContainer(primary_root_window, | |
| 866 kShellWindowId_VirtualKeyboardContainer)); | |
| 867 ASSERT_TRUE(Shell::GetContainer(secondary_root_window, | |
| 868 kShellWindowId_VirtualKeyboardContainer)); | |
| 869 | |
| 870 // Move back focus to the primary display. | |
| 871 focusable_window_in_primary_display->Focus(); | |
| 872 ASSERT_TRUE(focusable_window_in_primary_display->HasFocus()); | |
| 873 | |
| 874 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false); | |
| 875 ASSERT_TRUE(Shell::GetContainer(primary_root_window, | |
| 876 kShellWindowId_VirtualKeyboardContainer)); | |
| 877 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | |
| 878 kShellWindowId_VirtualKeyboardContainer)); | |
| 879 } | |
| 880 | |
| 881 // Test for http://crbug.com/303429. Even if both of display don't have touch | |
| 882 // capability, the virtual keyboard shows up on the specified display. | |
| 883 TEST_F(VirtualKeyboardRootWindowControllerTest, | |
| 884 VirtualKeyboardShowOnSpecifiedDisplay) { | |
| 885 if (!SupportsMultipleDisplays()) | |
| 886 return; | |
| 887 | |
| 888 UpdateDisplay("500x500,500x500"); | |
| 889 display::Display secondary_display = | |
| 890 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); | |
| 891 | |
| 892 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 893 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | |
| 756 aura::Window* secondary_root_window = root_windows[0] == primary_root_window | 894 aura::Window* secondary_root_window = root_windows[0] == primary_root_window |
| 757 ? root_windows[1] | 895 ? root_windows[1] |
| 758 : root_windows[0]; | 896 : root_windows[0]; |
| 759 | 897 |
| 760 ASSERT_TRUE(Shell::GetContainer(primary_root_window, | 898 ASSERT_TRUE(Shell::GetContainer(primary_root_window, |
| 761 kShellWindowId_VirtualKeyboardContainer)); | 899 kShellWindowId_VirtualKeyboardContainer)); |
| 762 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | 900 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, |
| 763 kShellWindowId_VirtualKeyboardContainer)); | 901 kShellWindowId_VirtualKeyboardContainer)); |
| 902 | |
| 903 const int64_t secondary_display_id = secondary_display.id(); | |
| 904 keyboard::KeyboardController::GetInstance()->ShowKeyboardInSpecificDisplay( | |
| 905 secondary_display_id); | |
| 906 | |
| 907 ASSERT_FALSE(Shell::GetContainer(primary_root_window, | |
| 908 kShellWindowId_VirtualKeyboardContainer)); | |
| 909 ASSERT_TRUE(Shell::GetContainer(secondary_root_window, | |
| 910 kShellWindowId_VirtualKeyboardContainer)); | |
| 764 } | 911 } |
| 765 | 912 |
| 766 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive | 913 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive |
| 767 // events at blocked user session. | 914 // events at blocked user session. |
| 768 TEST_F(VirtualKeyboardRootWindowControllerTest, | 915 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 769 ClickVirtualKeyboardInBlockedWindow) { | 916 ClickVirtualKeyboardInBlockedWindow) { |
| 770 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 917 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 771 aura::Window* keyboard_container = | 918 aura::Window* keyboard_container = |
| 772 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 919 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 773 ASSERT_TRUE(keyboard_container); | 920 ASSERT_TRUE(keyboard_container); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1031 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1178 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1032 gfx::Rect(0, 400, 800, 200)); | 1179 gfx::Rect(0, 400, 800, 200)); |
| 1033 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1180 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1034 | 1181 |
| 1035 UpdateDisplay("600x800"); | 1182 UpdateDisplay("600x800"); |
| 1036 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1183 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1037 } | 1184 } |
| 1038 | 1185 |
| 1039 } // namespace test | 1186 } // namespace test |
| 1040 } // namespace ash | 1187 } // namespace ash |
| OLD | NEW |