| 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/common/session/session_controller.h" | 9 #include "ash/common/session/session_controller.h" |
| 10 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 1067 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
| 1068 ASSERT_TRUE(keyboard_container); | 1068 ASSERT_TRUE(keyboard_container); |
| 1069 keyboard_container->Show(); | 1069 keyboard_container->Show(); |
| 1070 | 1070 |
| 1071 const int keyboard_height = 100; | 1071 const int keyboard_height = 100; |
| 1072 aura::Window* keyboard_window = ui->GetKeyboardWindow(); | 1072 aura::Window* keyboard_window = ui->GetKeyboardWindow(); |
| 1073 keyboard_container->AddChild(keyboard_window); | 1073 keyboard_container->AddChild(keyboard_window); |
| 1074 keyboard_window->set_owned_by_parent(false); | 1074 keyboard_window->set_owned_by_parent(false); |
| 1075 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 1075 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 1076 root_window->bounds(), keyboard_height)); | 1076 root_window->bounds(), keyboard_height)); |
| 1077 keyboard_window->Show(); |
| 1077 | 1078 |
| 1078 ui->EnsureCaretInWorkArea(); | 1079 ui->EnsureCaretInWorkArea(); |
| 1079 ASSERT_EQ(root_window->bounds().width(), | 1080 ASSERT_EQ(root_window->bounds().width(), |
| 1080 text_input_client.caret_exclude_rect().width()); | 1081 text_input_client.caret_exclude_rect().width()); |
| 1081 ASSERT_EQ(keyboard_height, text_input_client.caret_exclude_rect().height()); | 1082 ASSERT_EQ(keyboard_height, text_input_client.caret_exclude_rect().height()); |
| 1082 | 1083 |
| 1083 input_method->SetFocusedTextInputClient(NULL); | 1084 input_method->SetFocusedTextInputClient(nullptr); |
| 1084 } | 1085 } |
| 1085 | 1086 |
| 1086 TEST_F(VirtualKeyboardRootWindowControllerTest, | 1087 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 1087 EnsureCaretInWorkAreaWithMultipleDisplays) { | 1088 EnsureCaretInWorkAreaWithMultipleDisplays) { |
| 1088 // TODO: fails in mash. http://crbug.com/695640. | 1089 // TODO: fails in mash. http://crbug.com/695640. |
| 1089 if (WmShell::Get()->IsRunningInMash()) | 1090 if (WmShell::Get()->IsRunningInMash()) |
| 1090 return; | 1091 return; |
| 1091 | 1092 |
| 1092 UpdateDisplay("500x500,600x600"); | 1093 UpdateDisplay("500x500,600x600"); |
| 1093 const int64_t primary_display_id = | 1094 const int64_t primary_display_id = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1114 // the secondary screen. | 1115 // the secondary screen. |
| 1115 aura::Window* keyboard_container = Shell::GetContainer( | 1116 aura::Window* keyboard_container = Shell::GetContainer( |
| 1116 primary_root_window, kShellWindowId_VirtualKeyboardContainer); | 1117 primary_root_window, kShellWindowId_VirtualKeyboardContainer); |
| 1117 ASSERT_TRUE(keyboard_container); | 1118 ASSERT_TRUE(keyboard_container); |
| 1118 keyboard_container->Show(); | 1119 keyboard_container->Show(); |
| 1119 aura::Window* keyboard_window = ui->GetKeyboardWindow(); | 1120 aura::Window* keyboard_window = ui->GetKeyboardWindow(); |
| 1120 keyboard_container->AddChild(keyboard_window); | 1121 keyboard_container->AddChild(keyboard_window); |
| 1121 keyboard_window->set_owned_by_parent(false); | 1122 keyboard_window->set_owned_by_parent(false); |
| 1122 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 1123 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 1123 primary_root_window->bounds(), keyboard_height)); | 1124 primary_root_window->bounds(), keyboard_height)); |
| 1125 keyboard_window->Show(); |
| 1124 | 1126 |
| 1127 ui->EnsureCaretInWorkArea(); |
| 1125 EXPECT_TRUE(primary_root_window->GetBoundsInScreen().Contains( | 1128 EXPECT_TRUE(primary_root_window->GetBoundsInScreen().Contains( |
| 1126 text_input_client.caret_exclude_rect())); | 1129 text_input_client.caret_exclude_rect())); |
| 1130 EXPECT_EQ(primary_root_window->GetBoundsInScreen().width(), |
| 1131 text_input_client.caret_exclude_rect().width()); |
| 1127 EXPECT_FALSE(secondary_root_window->GetBoundsInScreen().Contains( | 1132 EXPECT_FALSE(secondary_root_window->GetBoundsInScreen().Contains( |
| 1128 text_input_client.caret_exclude_rect())); | 1133 text_input_client.caret_exclude_rect())); |
| 1129 | 1134 |
| 1130 // Move the keyboard into the secondary display and check that the keyboard | 1135 // Move the keyboard into the secondary display and check that the keyboard |
| 1131 // doesn't cover the window on the primary screen. | 1136 // doesn't cover the window on the primary screen. |
| 1132 keyboard_controller->ShowKeyboardInDisplay(secondary_display_id); | 1137 keyboard_controller->ShowKeyboardInDisplay(secondary_display_id); |
| 1133 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 1138 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 1134 secondary_root_window->bounds(), keyboard_height)); | 1139 secondary_root_window->bounds(), keyboard_height)); |
| 1135 | 1140 |
| 1136 ui->EnsureCaretInWorkArea(); | 1141 ui->EnsureCaretInWorkArea(); |
| 1137 EXPECT_FALSE(primary_root_window->GetBoundsInScreen().Contains( | 1142 EXPECT_FALSE(primary_root_window->GetBoundsInScreen().Contains( |
| 1138 text_input_client.caret_exclude_rect())); | 1143 text_input_client.caret_exclude_rect())); |
| 1139 EXPECT_TRUE(secondary_root_window->GetBoundsInScreen().Contains( | 1144 EXPECT_TRUE(secondary_root_window->GetBoundsInScreen().Contains( |
| 1140 text_input_client.caret_exclude_rect())); | 1145 text_input_client.caret_exclude_rect())); |
| 1146 EXPECT_EQ(secondary_root_window->GetBoundsInScreen().width(), |
| 1147 text_input_client.caret_exclude_rect().width()); |
| 1141 | 1148 |
| 1142 input_method->SetFocusedTextInputClient(nullptr); | 1149 input_method->SetFocusedTextInputClient(nullptr); |
| 1143 } | 1150 } |
| 1144 | 1151 |
| 1145 // Tests that the virtual keyboard does not block context menus. The virtual | 1152 // Tests that the virtual keyboard does not block context menus. The virtual |
| 1146 // keyboard should appear in front of most content, but not context menus. See | 1153 // keyboard should appear in front of most content, but not context menus. See |
| 1147 // crbug/377180. | 1154 // crbug/377180. |
| 1148 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { | 1155 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { |
| 1149 UpdateDisplay("800x600"); | 1156 UpdateDisplay("800x600"); |
| 1150 keyboard::KeyboardController* keyboard_controller = | 1157 keyboard::KeyboardController* keyboard_controller = |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1247 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1241 gfx::Rect(0, 400, 800, 200)); | 1248 gfx::Rect(0, 400, 800, 200)); |
| 1242 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1249 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1243 | 1250 |
| 1244 UpdateDisplay("600x800"); | 1251 UpdateDisplay("600x800"); |
| 1245 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1252 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1246 } | 1253 } |
| 1247 | 1254 |
| 1248 } // namespace test | 1255 } // namespace test |
| 1249 } // namespace ash | 1256 } // namespace ash |
| OLD | NEW |