| 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" |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) { | 737 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) { |
| 738 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 738 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 739 aura::Window* keyboard_container = | 739 aura::Window* keyboard_container = |
| 740 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 740 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 741 keyboard_container->Show(); | 741 keyboard_container->Show(); |
| 742 keyboard::KeyboardController* controller = | 742 keyboard::KeyboardController* controller = |
| 743 keyboard::KeyboardController::GetInstance(); | 743 keyboard::KeyboardController::GetInstance(); |
| 744 aura::Window* keyboard_window = controller->proxy()->GetKeyboardWindow(); | 744 aura::Window* keyboard_window = controller->proxy()->GetKeyboardWindow(); |
| 745 keyboard_container->AddChild(keyboard_window); | 745 keyboard_container->AddChild(keyboard_window); |
| 746 keyboard_window->set_owned_by_parent(false); | 746 keyboard_window->set_owned_by_parent(false); |
| 747 keyboard_window->SetBounds(keyboard::KeyboardBoundsFromWindowBounds( | 747 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 748 keyboard_container->bounds(), 100)); | 748 root_window->bounds(), 100)); |
| 749 keyboard_window->Show(); | 749 keyboard_window->Show(); |
| 750 | 750 |
| 751 gfx::Rect before = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); | 751 gfx::Rect before = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); |
| 752 | 752 |
| 753 // Notify keyboard bounds changing. | 753 // Notify keyboard bounds changing. |
| 754 controller->NotifyKeyboardBoundsChanging( | 754 controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds()); |
| 755 controller->proxy()->GetKeyboardWindow()->bounds()); | |
| 756 | 755 |
| 757 if (!keyboard::IsKeyboardOverscrollEnabled()) { | 756 if (!keyboard::IsKeyboardOverscrollEnabled()) { |
| 758 gfx::Rect after = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); | 757 gfx::Rect after = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); |
| 759 EXPECT_LT(after, before); | 758 EXPECT_LT(after, before); |
| 760 } | 759 } |
| 761 | 760 |
| 762 // Mock a login user profile change to reinitialize the keyboard. | 761 // Mock a login user profile change to reinitialize the keyboard. |
| 763 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); | 762 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); |
| 764 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(), before); | 763 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(), before); |
| 765 } | 764 } |
| 766 | 765 |
| 767 // Ensure that system modal dialogs do not block events targeted at the virtual | 766 // Ensure that system modal dialogs do not block events targeted at the virtual |
| 768 // keyboard. | 767 // keyboard. |
| 769 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) { | 768 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) { |
| 770 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 769 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 771 aura::Window* keyboard_container = | 770 aura::Window* keyboard_container = |
| 772 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 771 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 773 ASSERT_TRUE(keyboard_container); | 772 ASSERT_TRUE(keyboard_container); |
| 774 keyboard_container->Show(); | 773 keyboard_container->Show(); |
| 775 | 774 |
| 776 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> | 775 aura::Window* keyboard_window = keyboard::KeyboardController::GetInstance()-> |
| 777 proxy()->GetKeyboardWindow(); | 776 proxy()->GetKeyboardWindow(); |
| 778 keyboard_container->AddChild(keyboard_window); | 777 keyboard_container->AddChild(keyboard_window); |
| 779 keyboard_window->set_owned_by_parent(false); | 778 keyboard_window->set_owned_by_parent(false); |
| 780 keyboard_window->SetBounds(keyboard::KeyboardBoundsFromWindowBounds( | 779 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 781 keyboard_container->bounds(), 100)); | 780 root_window->bounds(), 100)); |
| 782 | 781 |
| 783 ui::test::TestEventHandler handler; | 782 ui::test::TestEventHandler handler; |
| 784 root_window->AddPreTargetHandler(&handler); | 783 root_window->AddPreTargetHandler(&handler); |
| 785 ui::test::EventGenerator root_window_event_generator(root_window); | 784 ui::test::EventGenerator root_window_event_generator(root_window); |
| 786 ui::test::EventGenerator keyboard_event_generator(root_window, | 785 ui::test::EventGenerator keyboard_event_generator(root_window, |
| 787 keyboard_window); | 786 keyboard_window); |
| 788 | 787 |
| 789 views::Widget* modal_widget = | 788 views::Widget* modal_widget = |
| 790 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 789 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 791 | 790 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 825 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 827 aura::Window* keyboard_container = | 826 aura::Window* keyboard_container = |
| 828 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 827 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 829 ASSERT_TRUE(keyboard_container); | 828 ASSERT_TRUE(keyboard_container); |
| 830 keyboard_container->Show(); | 829 keyboard_container->Show(); |
| 831 | 830 |
| 832 const int keyboard_height = 100; | 831 const int keyboard_height = 100; |
| 833 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); | 832 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); |
| 834 keyboard_container->AddChild(keyboard_window); | 833 keyboard_container->AddChild(keyboard_window); |
| 835 keyboard_window->set_owned_by_parent(false); | 834 keyboard_window->set_owned_by_parent(false); |
| 836 keyboard_window->SetBounds(keyboard::KeyboardBoundsFromWindowBounds( | 835 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 837 keyboard_container->bounds(), keyboard_height)); | 836 root_window->bounds(), keyboard_height)); |
| 838 | 837 |
| 839 proxy->EnsureCaretInWorkArea(); | 838 proxy->EnsureCaretInWorkArea(); |
| 840 ASSERT_EQ(keyboard_container->bounds().width(), | 839 ASSERT_EQ(root_window->bounds().width(), |
| 841 text_input_client.visible_rect().width()); | 840 text_input_client.visible_rect().width()); |
| 842 ASSERT_EQ(keyboard_container->bounds().height() - keyboard_height, | 841 ASSERT_EQ(root_window->bounds().height() - keyboard_height, |
| 843 text_input_client.visible_rect().height()); | 842 text_input_client.visible_rect().height()); |
| 844 | 843 |
| 845 if (switches::IsTextInputFocusManagerEnabled()) { | 844 if (switches::IsTextInputFocusManagerEnabled()) { |
| 846 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( | 845 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( |
| 847 &text_input_client); | 846 &text_input_client); |
| 848 } else { | 847 } else { |
| 849 input_method->SetFocusedTextInputClient(NULL); | 848 input_method->SetFocusedTextInputClient(NULL); |
| 850 } | 849 } |
| 851 } | 850 } |
| 852 | 851 |
| 853 // Tests that the virtual keyboard does not block context menus. The virtual | 852 // Tests that the virtual keyboard does not block context menus. The virtual |
| 854 // keyboard should appear in front of most content, but not context menus. See | 853 // keyboard should appear in front of most content, but not context menus. See |
| 855 // crbug/377180. | 854 // crbug/377180. |
| 856 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { | 855 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { |
| 857 UpdateDisplay("800x600"); | 856 UpdateDisplay("800x600"); |
| 858 keyboard::KeyboardController* keyboard_controller = | 857 keyboard::KeyboardController* keyboard_controller = |
| 859 keyboard::KeyboardController::GetInstance(); | 858 keyboard::KeyboardController::GetInstance(); |
| 860 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); | 859 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); |
| 861 | 860 |
| 862 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 861 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 863 aura::Window* keyboard_container = | 862 aura::Window* keyboard_container = |
| 864 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 863 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 865 ASSERT_TRUE(keyboard_container); | 864 ASSERT_TRUE(keyboard_container); |
| 866 keyboard_container->Show(); | 865 keyboard_container->Show(); |
| 867 | 866 |
| 868 const int keyboard_height = 200; | 867 const int keyboard_height = 200; |
| 869 aura::Window* keyboard_window = proxy->GetKeyboardWindow(); | 868 aura::Window* keyboard_window = proxy->GetKeyboardWindow(); |
| 870 keyboard_container->AddChild(keyboard_window); | 869 keyboard_container->AddChild(keyboard_window); |
| 871 keyboard_window->set_owned_by_parent(false); | 870 keyboard_window->set_owned_by_parent(false); |
| 872 gfx::Rect keyboard_bounds = keyboard::KeyboardBoundsFromWindowBounds( | 871 gfx::Rect keyboard_bounds = keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 873 keyboard_container->bounds(), keyboard_height); | 872 root_window->bounds(), keyboard_height); |
| 874 keyboard_window->SetBounds(keyboard_bounds); | 873 keyboard_window->SetBounds(keyboard_bounds); |
| 875 keyboard_window->Show(); | 874 keyboard_window->Show(); |
| 876 | 875 |
| 877 ui::test::EventGenerator generator(root_window); | 876 ui::test::EventGenerator generator(root_window); |
| 878 | 877 |
| 879 // Cover the screen with two windows: a normal window on the left side and a | 878 // Cover the screen with two windows: a normal window on the left side and a |
| 880 // context menu on the right side. When the virtual keyboard is displayed it | 879 // context menu on the right side. When the virtual keyboard is displayed it |
| 881 // partially occludes the normal window, but not the context menu. Compute | 880 // partially occludes the normal window, but not the context menu. Compute |
| 882 // positions for generating synthetic click events to perform hit tests, | 881 // positions for generating synthetic click events to perform hit tests, |
| 883 // ensuring the correct window layering. 'top' is above the VK, whereas | 882 // ensuring the correct window layering. 'top' is above the VK, whereas |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 #endif | 944 #endif |
| 946 | 945 |
| 947 // Tests that the virtual keyboard correctly resizes with a change to display | 946 // Tests that the virtual keyboard correctly resizes with a change to display |
| 948 // orientation. See crbug/417612. | 947 // orientation. See crbug/417612. |
| 949 TEST_F(VirtualKeyboardRootWindowControllerTest, MAYBE_DisplayRotation) { | 948 TEST_F(VirtualKeyboardRootWindowControllerTest, MAYBE_DisplayRotation) { |
| 950 UpdateDisplay("800x600"); | 949 UpdateDisplay("800x600"); |
| 951 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 950 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 952 aura::Window* keyboard_container = | 951 aura::Window* keyboard_container = |
| 953 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 952 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 954 ASSERT_TRUE(keyboard_container); | 953 ASSERT_TRUE(keyboard_container); |
| 955 keyboard_container->Show(); | 954 keyboard::KeyboardController* keyboard_controller = |
| 956 EXPECT_EQ("0,0 800x600", keyboard_container->bounds().ToString()); | 955 keyboard::KeyboardController::GetInstance(); |
| 956 keyboard_controller->ShowKeyboard(false); |
| 957 keyboard_controller->proxy()->GetKeyboardWindow()->SetBounds( |
| 958 gfx::Rect(0, 400, 800, 200)); |
| 959 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 957 | 960 |
| 958 UpdateDisplay("600x800"); | 961 UpdateDisplay("600x800"); |
| 959 EXPECT_EQ("0,0 600x800", keyboard_container->bounds().ToString()); | 962 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 960 } | 963 } |
| 961 | 964 |
| 962 } // namespace test | 965 } // namespace test |
| 963 } // namespace ash | 966 } // namespace ash |
| OLD | NEW |