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