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