| 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 12 matching lines...) Expand all Loading... |
| 23 #include "ui/aura/client/window_tree_client.h" | 23 #include "ui/aura/client/window_tree_client.h" |
| 24 #include "ui/aura/env.h" | 24 #include "ui/aura/env.h" |
| 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/base/ime/text_input_focus_manager.h" | |
| 34 #include "ui/base/ui_base_switches_util.h" | 33 #include "ui/base/ui_base_switches_util.h" |
| 35 #include "ui/events/test/event_generator.h" | 34 #include "ui/events/test/event_generator.h" |
| 36 #include "ui/events/test/test_event_handler.h" | 35 #include "ui/events/test/test_event_handler.h" |
| 37 #include "ui/keyboard/keyboard_controller_proxy.h" | 36 #include "ui/keyboard/keyboard_controller_proxy.h" |
| 38 #include "ui/keyboard/keyboard_switches.h" | 37 #include "ui/keyboard/keyboard_switches.h" |
| 39 #include "ui/keyboard/keyboard_util.h" | 38 #include "ui/keyboard/keyboard_util.h" |
| 40 #include "ui/views/controls/menu/menu_controller.h" | 39 #include "ui/views/controls/menu/menu_controller.h" |
| 41 #include "ui/views/widget/widget.h" | 40 #include "ui/views/widget/widget.h" |
| 42 #include "ui/views/widget/widget_delegate.h" | 41 #include "ui/views/widget/widget_delegate.h" |
| 43 | 42 |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 // Ensure that the visible area for scrolling the text caret excludes the | 894 // Ensure that the visible area for scrolling the text caret excludes the |
| 896 // region occluded by the on-screen keyboard. | 895 // region occluded by the on-screen keyboard. |
| 897 TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) { | 896 TEST_F(VirtualKeyboardRootWindowControllerTest, EnsureCaretInWorkArea) { |
| 898 keyboard::KeyboardController* keyboard_controller = | 897 keyboard::KeyboardController* keyboard_controller = |
| 899 keyboard::KeyboardController::GetInstance(); | 898 keyboard::KeyboardController::GetInstance(); |
| 900 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); | 899 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); |
| 901 | 900 |
| 902 MockTextInputClient text_input_client; | 901 MockTextInputClient text_input_client; |
| 903 ui::InputMethod* input_method = proxy->GetInputMethod(); | 902 ui::InputMethod* input_method = proxy->GetInputMethod(); |
| 904 ASSERT_TRUE(input_method); | 903 ASSERT_TRUE(input_method); |
| 905 if (switches::IsTextInputFocusManagerEnabled()) { | 904 input_method->SetFocusedTextInputClient(&text_input_client); |
| 906 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient( | |
| 907 &text_input_client); | |
| 908 } else { | |
| 909 input_method->SetFocusedTextInputClient(&text_input_client); | |
| 910 } | |
| 911 | 905 |
| 912 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 906 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 913 aura::Window* keyboard_container = | 907 aura::Window* keyboard_container = |
| 914 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 908 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 915 ASSERT_TRUE(keyboard_container); | 909 ASSERT_TRUE(keyboard_container); |
| 916 keyboard_container->Show(); | 910 keyboard_container->Show(); |
| 917 | 911 |
| 918 const int keyboard_height = 100; | 912 const int keyboard_height = 100; |
| 919 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); | 913 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); |
| 920 keyboard_container->AddChild(keyboard_window); | 914 keyboard_container->AddChild(keyboard_window); |
| 921 keyboard_window->set_owned_by_parent(false); | 915 keyboard_window->set_owned_by_parent(false); |
| 922 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 916 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 923 root_window->bounds(), keyboard_height)); | 917 root_window->bounds(), keyboard_height)); |
| 924 | 918 |
| 925 proxy->EnsureCaretInWorkArea(); | 919 proxy->EnsureCaretInWorkArea(); |
| 926 ASSERT_EQ(root_window->bounds().width(), | 920 ASSERT_EQ(root_window->bounds().width(), |
| 927 text_input_client.visible_rect().width()); | 921 text_input_client.visible_rect().width()); |
| 928 ASSERT_EQ(root_window->bounds().height() - keyboard_height, | 922 ASSERT_EQ(root_window->bounds().height() - keyboard_height, |
| 929 text_input_client.visible_rect().height()); | 923 text_input_client.visible_rect().height()); |
| 930 | 924 |
| 931 if (switches::IsTextInputFocusManagerEnabled()) { | 925 input_method->SetFocusedTextInputClient(NULL); |
| 932 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( | |
| 933 &text_input_client); | |
| 934 } else { | |
| 935 input_method->SetFocusedTextInputClient(NULL); | |
| 936 } | |
| 937 } | 926 } |
| 938 | 927 |
| 939 // Tests that the virtual keyboard does not block context menus. The virtual | 928 // Tests that the virtual keyboard does not block context menus. The virtual |
| 940 // keyboard should appear in front of most content, but not context menus. See | 929 // keyboard should appear in front of most content, but not context menus. See |
| 941 // crbug/377180. | 930 // crbug/377180. |
| 942 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { | 931 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { |
| 943 UpdateDisplay("800x600"); | 932 UpdateDisplay("800x600"); |
| 944 keyboard::KeyboardController* keyboard_controller = | 933 keyboard::KeyboardController* keyboard_controller = |
| 945 keyboard::KeyboardController::GetInstance(); | 934 keyboard::KeyboardController::GetInstance(); |
| 946 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); | 935 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 keyboard_controller->proxy()->GetKeyboardWindow()->SetBounds( | 1033 keyboard_controller->proxy()->GetKeyboardWindow()->SetBounds( |
| 1045 gfx::Rect(0, 400, 800, 200)); | 1034 gfx::Rect(0, 400, 800, 200)); |
| 1046 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1035 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1047 | 1036 |
| 1048 UpdateDisplay("600x800"); | 1037 UpdateDisplay("600x800"); |
| 1049 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1038 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1050 } | 1039 } |
| 1051 | 1040 |
| 1052 } // namespace test | 1041 } // namespace test |
| 1053 } // namespace ash | 1042 } // namespace ash |
| OLD | NEW |