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/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/session/session_controller.h" | 11 #include "ash/session/session_controller.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "ash/shell_port.h" | 13 #include "ash/shell_port.h" |
13 #include "ash/system/tray/system_tray_delegate.h" | 14 #include "ash/system/tray/system_tray_delegate.h" |
14 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/test_session_controller_client.h" | 16 #include "ash/test/test_session_controller_client.h" |
16 #include "ash/wm/system_modal_container_layout_manager.h" | 17 #include "ash/wm/system_modal_container_layout_manager.h" |
17 #include "ash/wm/window_properties.h" | 18 #include "ash/wm/window_properties.h" |
18 #include "ash/wm/window_state.h" | 19 #include "ash/wm/window_state.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 EXPECT_EQ(root_windows[1], | 180 EXPECT_EQ(root_windows[1], |
180 unparented_control->GetNativeView()->GetRootWindow()); | 181 unparented_control->GetNativeView()->GetRootWindow()); |
181 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 182 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
182 unparented_control->GetNativeView()->parent()->id()); | 183 unparented_control->GetNativeView()->parent()->id()); |
183 | 184 |
184 aura::Window* panel = CreateTestWindowInShellWithDelegateAndType( | 185 aura::Window* panel = CreateTestWindowInShellWithDelegateAndType( |
185 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(700, 100, 100, 100)); | 186 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(700, 100, 100, 100)); |
186 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); | 187 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); |
187 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); | 188 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); |
188 | 189 |
189 if (ShellPort::Get()->IsRunningInMash()) { | 190 if (Shell::GetAshConfig() == Config::MASH) { |
190 // TODO(erg): Ignore this one part of the test when running mash. We would | 191 // TODO(erg): Ignore this one part of the test when running mash. We would |
191 // crash because the aura::Window |d2| created in the other block doesn't | 192 // crash because the aura::Window |d2| created in the other block doesn't |
192 // get deleted, and thus continues to contain a reference to its delegate, | 193 // get deleted, and thus continues to contain a reference to its delegate, |
193 // |delete_on_blur_delegate|, which is declared on the stack. | 194 // |delete_on_blur_delegate|, which is declared on the stack. |
194 // | 195 // |
195 // Making this work requires building out enough of the display management | 196 // Making this work requires building out enough of the display management |
196 // system; notably the part where updating the display may cause focus | 197 // system; notably the part where updating the display may cause focus |
197 // changes. http://crbug.com/695632. | 198 // changes. http://crbug.com/695632. |
198 UpdateDisplay("600x600"); | 199 UpdateDisplay("600x600"); |
199 } else { | 200 } else { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 UpdateDisplay("500x500"); | 296 UpdateDisplay("500x500"); |
296 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 297 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
297 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 298 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
298 generator_1st.ClickLeftButton(); | 299 generator_1st.ClickLeftButton(); |
299 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 300 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
300 } | 301 } |
301 | 302 |
302 // Make sure lock related windows moves. | 303 // Make sure lock related windows moves. |
303 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { | 304 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { |
304 // TODO: requires unified desktop mode. http://crbug.com/581462. | 305 // TODO: requires unified desktop mode. http://crbug.com/581462. |
305 if (ShellPort::Get()->IsRunningInMash()) | 306 if (Shell::GetAshConfig() == Config::MASH) |
306 return; | 307 return; |
307 | 308 |
308 display_manager()->SetUnifiedDesktopEnabled(true); | 309 display_manager()->SetUnifiedDesktopEnabled(true); |
309 | 310 |
310 UpdateDisplay("500x500"); | 311 UpdateDisplay("500x500"); |
311 const int kLockScreenWindowId = 1000; | 312 const int kLockScreenWindowId = 1000; |
312 const int kLockWallpaperWindowId = 1001; | 313 const int kLockWallpaperWindowId = 1001; |
313 | 314 |
314 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 315 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
315 | 316 |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 kShellWindowId_VirtualKeyboardContainer)); | 757 kShellWindowId_VirtualKeyboardContainer)); |
757 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | 758 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, |
758 kShellWindowId_VirtualKeyboardContainer)); | 759 kShellWindowId_VirtualKeyboardContainer)); |
759 } | 760 } |
760 | 761 |
761 // Test for http://crbug.com/303429. Virtual keyboard container should show on | 762 // Test for http://crbug.com/303429. Virtual keyboard container should show on |
762 // a display which has touch capability. | 763 // a display which has touch capability. |
763 TEST_F(VirtualKeyboardRootWindowControllerTest, | 764 TEST_F(VirtualKeyboardRootWindowControllerTest, |
764 VirtualKeyboardOnTouchableDisplayOnly) { | 765 VirtualKeyboardOnTouchableDisplayOnly) { |
765 // TODO: investigate failure in mash. http://crbug.com/695640. | 766 // TODO: investigate failure in mash. http://crbug.com/695640. |
766 if (ShellPort::Get()->IsRunningInMash()) | 767 if (Shell::GetAshConfig() == Config::MASH) |
767 return; | 768 return; |
768 | 769 |
769 UpdateDisplay("500x500,500x500"); | 770 UpdateDisplay("500x500,500x500"); |
770 display::Display secondary_display = | 771 display::Display secondary_display = |
771 Shell::Get()->display_manager()->GetSecondaryDisplay(); | 772 Shell::Get()->display_manager()->GetSecondaryDisplay(); |
772 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) | 773 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) |
773 .SetTouchSupport(secondary_display.id(), | 774 .SetTouchSupport(secondary_display.id(), |
774 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | 775 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); |
775 | 776 |
776 // The primary display doesn't have touch capability and the secondary display | 777 // The primary display doesn't have touch capability and the secondary display |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 EXPECT_FALSE(Shell::GetContainer(primary_root_window, | 809 EXPECT_FALSE(Shell::GetContainer(primary_root_window, |
809 kShellWindowId_VirtualKeyboardContainer)); | 810 kShellWindowId_VirtualKeyboardContainer)); |
810 EXPECT_TRUE(Shell::GetContainer(secondary_root_window, | 811 EXPECT_TRUE(Shell::GetContainer(secondary_root_window, |
811 kShellWindowId_VirtualKeyboardContainer)); | 812 kShellWindowId_VirtualKeyboardContainer)); |
812 } | 813 } |
813 | 814 |
814 // Test for http://crbug.com/303429. If both of displays have touch capability, | 815 // Test for http://crbug.com/303429. If both of displays have touch capability, |
815 // virtual keyboard follows the input focus. | 816 // virtual keyboard follows the input focus. |
816 TEST_F(VirtualKeyboardRootWindowControllerTest, FollowInputFocus) { | 817 TEST_F(VirtualKeyboardRootWindowControllerTest, FollowInputFocus) { |
817 // TODO: investigate failure in mash. http://crbug.com/695640. | 818 // TODO: investigate failure in mash. http://crbug.com/695640. |
818 if (ShellPort::Get()->IsRunningInMash()) | 819 if (Shell::GetAshConfig() == Config::MASH) |
819 return; | 820 return; |
820 | 821 |
821 UpdateDisplay("500x500,500x500"); | 822 UpdateDisplay("500x500,500x500"); |
822 const int64_t primary_display_id = | 823 const int64_t primary_display_id = |
823 display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 824 display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
824 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) | 825 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) |
825 .SetTouchSupport(primary_display_id, | 826 .SetTouchSupport(primary_display_id, |
826 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | 827 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); |
827 const int64_t secondary_display_id = | 828 const int64_t secondary_display_id = |
828 Shell::Get()->display_manager()->GetSecondaryDisplay().id(); | 829 Shell::Get()->display_manager()->GetSecondaryDisplay().id(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 kShellWindowId_VirtualKeyboardContainer)); | 879 kShellWindowId_VirtualKeyboardContainer)); |
879 EXPECT_FALSE(Shell::GetContainer(secondary_root_window, | 880 EXPECT_FALSE(Shell::GetContainer(secondary_root_window, |
880 kShellWindowId_VirtualKeyboardContainer)); | 881 kShellWindowId_VirtualKeyboardContainer)); |
881 } | 882 } |
882 | 883 |
883 // Test for http://crbug.com/303429. Even if both of display don't have touch | 884 // Test for http://crbug.com/303429. Even if both of display don't have touch |
884 // capability, the virtual keyboard shows up on the specified display. | 885 // capability, the virtual keyboard shows up on the specified display. |
885 TEST_F(VirtualKeyboardRootWindowControllerTest, | 886 TEST_F(VirtualKeyboardRootWindowControllerTest, |
886 VirtualKeyboardShowOnSpecifiedDisplay) { | 887 VirtualKeyboardShowOnSpecifiedDisplay) { |
887 // TODO: fails in mash. http://crbug.com/695640. | 888 // TODO: fails in mash. http://crbug.com/695640. |
888 if (ShellPort::Get()->IsRunningInMash()) | 889 if (Shell::GetAshConfig() == Config::MASH) |
889 return; | 890 return; |
890 | 891 |
891 UpdateDisplay("500x500,500x500"); | 892 UpdateDisplay("500x500,500x500"); |
892 display::Display secondary_display = GetSecondaryDisplay(); | 893 display::Display secondary_display = GetSecondaryDisplay(); |
893 | 894 |
894 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 895 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
895 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | 896 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); |
896 aura::Window* secondary_root_window = root_windows[0] == primary_root_window | 897 aura::Window* secondary_root_window = root_windows[0] == primary_root_window |
897 ? root_windows[1] | 898 ? root_windows[1] |
898 : root_windows[0]; | 899 : root_windows[0]; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(NULL); |
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 (Shell::GetAshConfig() == Config::MASH) |
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 = |
1090 display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1091 display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1091 const int64_t secondary_display_id = GetSecondaryDisplay().id(); | 1092 const int64_t secondary_display_id = GetSecondaryDisplay().id(); |
1092 ASSERT_NE(primary_display_id, secondary_display_id); | 1093 ASSERT_NE(primary_display_id, secondary_display_id); |
1093 | 1094 |
1094 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1095 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1095 ASSERT_EQ(static_cast<size_t>(2), root_windows.size()); | 1096 ASSERT_EQ(static_cast<size_t>(2), root_windows.size()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1237 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
1237 gfx::Rect(0, 400, 800, 200)); | 1238 gfx::Rect(0, 400, 800, 200)); |
1238 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1239 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
1239 | 1240 |
1240 UpdateDisplay("600x800"); | 1241 UpdateDisplay("600x800"); |
1241 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1242 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
1242 } | 1243 } |
1243 | 1244 |
1244 } // namespace test | 1245 } // namespace test |
1245 } // namespace ash | 1246 } // namespace ash |
OLD | NEW |