| 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/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
| 8 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "ui/aura/test/test_window_delegate.h" | 25 #include "ui/aura/test/test_window_delegate.h" |
| 26 #include "ui/aura/test/test_windows.h" | 26 #include "ui/aura/test/test_windows.h" |
| 27 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 28 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
| 29 #include "ui/aura/window_tracker.h" | 29 #include "ui/aura/window_tracker.h" |
| 30 #include "ui/base/ime/dummy_text_input_client.h" | 30 #include "ui/base/ime/dummy_text_input_client.h" |
| 31 #include "ui/base/ime/input_method.h" | 31 #include "ui/base/ime/input_method.h" |
| 32 #include "ui/base/ime/text_input_client.h" | 32 #include "ui/base/ime/text_input_client.h" |
| 33 #include "ui/events/test/event_generator.h" | 33 #include "ui/events/test/event_generator.h" |
| 34 #include "ui/events/test/test_event_handler.h" | 34 #include "ui/events/test/test_event_handler.h" |
| 35 #include "ui/keyboard/keyboard_controller_proxy.h" | |
| 36 #include "ui/keyboard/keyboard_switches.h" | 35 #include "ui/keyboard/keyboard_switches.h" |
| 36 #include "ui/keyboard/keyboard_ui.h" |
| 37 #include "ui/keyboard/keyboard_util.h" | 37 #include "ui/keyboard/keyboard_util.h" |
| 38 #include "ui/views/controls/menu/menu_controller.h" | 38 #include "ui/views/controls/menu/menu_controller.h" |
| 39 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
| 40 #include "ui/views/widget/widget_delegate.h" | 40 #include "ui/views/widget/widget_delegate.h" |
| 41 | 41 |
| 42 using aura::Window; | 42 using aura::Window; |
| 43 using views::Widget; | 43 using views::Widget; |
| 44 | 44 |
| 45 namespace ash { | 45 namespace ash { |
| 46 namespace { | 46 namespace { |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive | 763 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive |
| 764 // events at blocked user session. | 764 // events at blocked user session. |
| 765 TEST_F(VirtualKeyboardRootWindowControllerTest, | 765 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 766 ClickVirtualKeyboardInBlockedWindow) { | 766 ClickVirtualKeyboardInBlockedWindow) { |
| 767 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 767 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 768 aura::Window* keyboard_container = | 768 aura::Window* keyboard_container = |
| 769 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 769 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 770 ASSERT_TRUE(keyboard_container); | 770 ASSERT_TRUE(keyboard_container); |
| 771 keyboard_container->Show(); | 771 keyboard_container->Show(); |
| 772 | 772 |
| 773 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> | 773 aura::Window* keyboard_window = |
| 774 proxy()->GetKeyboardWindow(); | 774 keyboard::KeyboardController::GetInstance()->ui()->GetKeyboardWindow(); |
| 775 keyboard_container->AddChild(keyboard_window); | 775 keyboard_container->AddChild(keyboard_window); |
| 776 keyboard_window->set_owned_by_parent(false); | 776 keyboard_window->set_owned_by_parent(false); |
| 777 keyboard_window->SetBounds(gfx::Rect()); | 777 keyboard_window->SetBounds(gfx::Rect()); |
| 778 keyboard_window->Show(); | 778 keyboard_window->Show(); |
| 779 | 779 |
| 780 ui::test::TestEventHandler handler; | 780 ui::test::TestEventHandler handler; |
| 781 root_window->AddPreTargetHandler(&handler); | 781 root_window->AddPreTargetHandler(&handler); |
| 782 | 782 |
| 783 ui::test::EventGenerator event_generator(root_window, keyboard_window); | 783 ui::test::EventGenerator event_generator(root_window, keyboard_window); |
| 784 event_generator.ClickLeftButton(); | 784 event_generator.ClickLeftButton(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 817 |
| 818 // Test for crbug.com/342524. After user login, the work space should restore to | 818 // Test for crbug.com/342524. After user login, the work space should restore to |
| 819 // full screen. | 819 // full screen. |
| 820 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) { | 820 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) { |
| 821 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 821 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 822 aura::Window* keyboard_container = | 822 aura::Window* keyboard_container = |
| 823 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 823 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 824 keyboard_container->Show(); | 824 keyboard_container->Show(); |
| 825 keyboard::KeyboardController* controller = | 825 keyboard::KeyboardController* controller = |
| 826 keyboard::KeyboardController::GetInstance(); | 826 keyboard::KeyboardController::GetInstance(); |
| 827 aura::Window* keyboard_window = controller->proxy()->GetKeyboardWindow(); | 827 aura::Window* keyboard_window = controller->ui()->GetKeyboardWindow(); |
| 828 keyboard_container->AddChild(keyboard_window); | 828 keyboard_container->AddChild(keyboard_window); |
| 829 keyboard_window->set_owned_by_parent(false); | 829 keyboard_window->set_owned_by_parent(false); |
| 830 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 830 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 831 root_window->bounds(), 100)); | 831 root_window->bounds(), 100)); |
| 832 keyboard_window->Show(); | 832 keyboard_window->Show(); |
| 833 | 833 |
| 834 gfx::Rect before = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); | 834 gfx::Rect before = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); |
| 835 | 835 |
| 836 // Notify keyboard bounds changing. | 836 // Notify keyboard bounds changing. |
| 837 controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds()); | 837 controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 848 | 848 |
| 849 // Ensure that system modal dialogs do not block events targeted at the virtual | 849 // Ensure that system modal dialogs do not block events targeted at the virtual |
| 850 // keyboard. | 850 // keyboard. |
| 851 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) { | 851 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) { |
| 852 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 852 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 853 aura::Window* keyboard_container = | 853 aura::Window* keyboard_container = |
| 854 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 854 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 855 ASSERT_TRUE(keyboard_container); | 855 ASSERT_TRUE(keyboard_container); |
| 856 keyboard_container->Show(); | 856 keyboard_container->Show(); |
| 857 | 857 |
| 858 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> | 858 aura::Window* keyboard_window = |
| 859 proxy()->GetKeyboardWindow(); | 859 keyboard::KeyboardController::GetInstance()->ui()->GetKeyboardWindow(); |
| 860 keyboard_container->AddChild(keyboard_window); | 860 keyboard_container->AddChild(keyboard_window); |
| 861 keyboard_window->set_owned_by_parent(false); | 861 keyboard_window->set_owned_by_parent(false); |
| 862 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 862 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 863 root_window->bounds(), 100)); | 863 root_window->bounds(), 100)); |
| 864 | 864 |
| 865 ui::test::TestEventHandler handler; | 865 ui::test::TestEventHandler handler; |
| 866 root_window->AddPreTargetHandler(&handler); | 866 root_window->AddPreTargetHandler(&handler); |
| 867 ui::test::EventGenerator root_window_event_generator(root_window); | 867 ui::test::EventGenerator root_window_event_generator(root_window); |
| 868 ui::test::EventGenerator keyboard_event_generator(root_window, | 868 ui::test::EventGenerator keyboard_event_generator(root_window, |
| 869 keyboard_window); | 869 keyboard_window); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 886 root_window_event_generator.ClickLeftButton(); | 886 root_window_event_generator.ClickLeftButton(); |
| 887 EXPECT_EQ(2, handler.num_mouse_events() / 2); | 887 EXPECT_EQ(2, handler.num_mouse_events() / 2); |
| 888 root_window->RemovePreTargetHandler(&handler); | 888 root_window->RemovePreTargetHandler(&handler); |
| 889 } | 889 } |
| 890 | 890 |
| 891 // Ensure that the visible area for scrolling the text caret excludes the | 891 // Ensure that the visible area for scrolling the text caret excludes the |
| 892 // region occluded by the on-screen keyboard. | 892 // region occluded by the on-screen keyboard. |
| 893 TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) { | 893 TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) { |
| 894 keyboard::KeyboardController* keyboard_controller = | 894 keyboard::KeyboardController* keyboard_controller = |
| 895 keyboard::KeyboardController::GetInstance(); | 895 keyboard::KeyboardController::GetInstance(); |
| 896 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); | 896 keyboard::KeyboardUI* ui = keyboard_controller->ui(); |
| 897 | 897 |
| 898 MockTextInputClient text_input_client; | 898 MockTextInputClient text_input_client; |
| 899 ui::InputMethod* input_method = proxy->GetInputMethod(); | 899 ui::InputMethod* input_method = ui->GetInputMethod(); |
| 900 ASSERT_TRUE(input_method); | 900 ASSERT_TRUE(input_method); |
| 901 input_method->SetFocusedTextInputClient(&text_input_client); | 901 input_method->SetFocusedTextInputClient(&text_input_client); |
| 902 | 902 |
| 903 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 903 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 904 aura::Window* keyboard_container = | 904 aura::Window* keyboard_container = |
| 905 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 905 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 906 ASSERT_TRUE(keyboard_container); | 906 ASSERT_TRUE(keyboard_container); |
| 907 keyboard_container->Show(); | 907 keyboard_container->Show(); |
| 908 | 908 |
| 909 const int keyboard_height = 100; | 909 const int keyboard_height = 100; |
| 910 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); | 910 aura::Window* keyboard_window = ui->GetKeyboardWindow(); |
| 911 keyboard_container->AddChild(keyboard_window); | 911 keyboard_container->AddChild(keyboard_window); |
| 912 keyboard_window->set_owned_by_parent(false); | 912 keyboard_window->set_owned_by_parent(false); |
| 913 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 913 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 914 root_window->bounds(), keyboard_height)); | 914 root_window->bounds(), keyboard_height)); |
| 915 | 915 |
| 916 proxy->EnsureCaretInWorkArea(); | 916 ui->EnsureCaretInWorkArea(); |
| 917 ASSERT_EQ(root_window->bounds().width(), | 917 ASSERT_EQ(root_window->bounds().width(), |
| 918 text_input_client.visible_rect().width()); | 918 text_input_client.visible_rect().width()); |
| 919 ASSERT_EQ(root_window->bounds().height() - keyboard_height, | 919 ASSERT_EQ(root_window->bounds().height() - keyboard_height, |
| 920 text_input_client.visible_rect().height()); | 920 text_input_client.visible_rect().height()); |
| 921 | 921 |
| 922 input_method->SetFocusedTextInputClient(NULL); | 922 input_method->SetFocusedTextInputClient(NULL); |
| 923 } | 923 } |
| 924 | 924 |
| 925 // Tests that the virtual keyboard does not block context menus. The virtual | 925 // Tests that the virtual keyboard does not block context menus. The virtual |
| 926 // keyboard should appear in front of most content, but not context menus. See | 926 // keyboard should appear in front of most content, but not context menus. See |
| 927 // crbug/377180. | 927 // crbug/377180. |
| 928 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { | 928 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { |
| 929 UpdateDisplay("800x600"); | 929 UpdateDisplay("800x600"); |
| 930 keyboard::KeyboardController* keyboard_controller = | 930 keyboard::KeyboardController* keyboard_controller = |
| 931 keyboard::KeyboardController::GetInstance(); | 931 keyboard::KeyboardController::GetInstance(); |
| 932 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); | 932 keyboard::KeyboardUI* ui = keyboard_controller->ui(); |
| 933 | 933 |
| 934 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 934 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 935 aura::Window* keyboard_container = | 935 aura::Window* keyboard_container = |
| 936 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 936 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 937 ASSERT_TRUE(keyboard_container); | 937 ASSERT_TRUE(keyboard_container); |
| 938 keyboard_container->Show(); | 938 keyboard_container->Show(); |
| 939 | 939 |
| 940 const int keyboard_height = 200; | 940 const int keyboard_height = 200; |
| 941 aura::Window* keyboard_window = proxy->GetKeyboardWindow(); | 941 aura::Window* keyboard_window = ui->GetKeyboardWindow(); |
| 942 keyboard_container->AddChild(keyboard_window); | 942 keyboard_container->AddChild(keyboard_window); |
| 943 keyboard_window->set_owned_by_parent(false); | 943 keyboard_window->set_owned_by_parent(false); |
| 944 gfx::Rect keyboard_bounds = keyboard::FullWidthKeyboardBoundsFromRootBounds( | 944 gfx::Rect keyboard_bounds = keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 945 root_window->bounds(), keyboard_height); | 945 root_window->bounds(), keyboard_height); |
| 946 keyboard_window->SetBounds(keyboard_bounds); | 946 keyboard_window->SetBounds(keyboard_bounds); |
| 947 keyboard_window->Show(); | 947 keyboard_window->Show(); |
| 948 | 948 |
| 949 ui::test::EventGenerator generator(root_window); | 949 ui::test::EventGenerator generator(root_window); |
| 950 | 950 |
| 951 // Cover the screen with two windows: a normal window on the left side and a | 951 // Cover the screen with two windows: a normal window on the left side and a |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 // orientation. See crbug/417612. | 1020 // orientation. See crbug/417612. |
| 1021 TEST_F(VirtualKeyboardRootWindowControllerTest, MAYBE_DisplayRotation) { | 1021 TEST_F(VirtualKeyboardRootWindowControllerTest, MAYBE_DisplayRotation) { |
| 1022 UpdateDisplay("800x600"); | 1022 UpdateDisplay("800x600"); |
| 1023 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 1023 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 1024 aura::Window* keyboard_container = | 1024 aura::Window* keyboard_container = |
| 1025 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 1025 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 1026 ASSERT_TRUE(keyboard_container); | 1026 ASSERT_TRUE(keyboard_container); |
| 1027 keyboard::KeyboardController* keyboard_controller = | 1027 keyboard::KeyboardController* keyboard_controller = |
| 1028 keyboard::KeyboardController::GetInstance(); | 1028 keyboard::KeyboardController::GetInstance(); |
| 1029 keyboard_controller->ShowKeyboard(false); | 1029 keyboard_controller->ShowKeyboard(false); |
| 1030 keyboard_controller->proxy()->GetKeyboardWindow()->SetBounds( | 1030 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1031 gfx::Rect(0, 400, 800, 200)); | 1031 gfx::Rect(0, 400, 800, 200)); |
| 1032 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1032 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1033 | 1033 |
| 1034 UpdateDisplay("600x800"); | 1034 UpdateDisplay("600x800"); |
| 1035 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1035 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 } // namespace test | 1038 } // namespace test |
| 1039 } // namespace ash | 1039 } // namespace ash |
| OLD | NEW |