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