| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return widget; | 128 return widget; |
| 129 } | 129 } |
| 130 | 130 |
| 131 aura::Window* GetModalContainer(aura::Window* root_window) { | 131 aura::Window* GetModalContainer(aura::Window* root_window) { |
| 132 return Shell::GetContainer(root_window, | 132 return Shell::GetContainer(root_window, |
| 133 kShellWindowId_SystemModalContainer); | 133 kShellWindowId_SystemModalContainer); |
| 134 } | 134 } |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 137 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { |
| 138 // TODO: triggers shutdown crash in mash. http://crbug.com/695632. |
| 139 if (WmShell::Get()->IsRunningInMash()) |
| 140 return; |
| 141 |
| 138 // Windows origin should be doubled when moved to the 1st display. | 142 // Windows origin should be doubled when moved to the 1st display. |
| 139 UpdateDisplay("600x600,300x300"); | 143 UpdateDisplay("600x600,300x300"); |
| 140 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 144 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 141 | 145 |
| 142 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 146 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
| 143 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 147 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
| 144 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 148 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
| 145 EXPECT_EQ("50,10 100x100", | 149 EXPECT_EQ("50,10 100x100", |
| 146 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 150 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 147 | 151 |
| 148 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); | 152 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
| 149 maximized->Maximize(); | 153 maximized->Maximize(); |
| 150 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); | 154 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
| 151 EXPECT_EQ(gfx::Rect(600, 0, 300, 252).ToString(), | 155 EXPECT_EQ(gfx::Rect(600, 0, 300, 252).ToString(), |
| 152 maximized->GetWindowBoundsInScreen().ToString()); | 156 maximized->GetWindowBoundsInScreen().ToString()); |
| 153 EXPECT_EQ(gfx::Rect(0, 0, 300, 252).ToString(), | 157 EXPECT_EQ(gfx::Rect(0, 0, 300, 252).ToString(), |
| 154 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 158 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 155 | 159 |
| 156 views::Widget* minimized = CreateTestWidget(gfx::Rect(550, 10, 200, 200)); | 160 views::Widget* minimized = CreateTestWidget(gfx::Rect(550, 10, 200, 200)); |
| 157 minimized->Minimize(); | 161 minimized->Minimize(); |
| 158 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); | 162 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
| 159 EXPECT_EQ("550,10 200x200", minimized->GetWindowBoundsInScreen().ToString()); | 163 EXPECT_EQ("550,10 200x200", minimized->GetWindowBoundsInScreen().ToString()); |
| 160 | 164 |
| 161 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 200, 200)); | 165 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 200, 200)); |
| 162 display::Display secondary_display = | 166 display::Display secondary_display = GetSecondaryDisplay(); |
| 163 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); | |
| 164 gfx::Rect orig_bounds = fullscreen->GetWindowBoundsInScreen(); | 167 gfx::Rect orig_bounds = fullscreen->GetWindowBoundsInScreen(); |
| 165 EXPECT_TRUE(secondary_display.work_area().Intersects(orig_bounds)); | 168 EXPECT_TRUE(secondary_display.work_area().Intersects(orig_bounds)); |
| 166 EXPECT_FALSE(secondary_display.work_area().Contains(orig_bounds)); | 169 EXPECT_FALSE(secondary_display.work_area().Contains(orig_bounds)); |
| 167 | 170 |
| 168 fullscreen->SetFullscreen(true); | 171 fullscreen->SetFullscreen(true); |
| 169 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); | 172 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); |
| 170 | 173 |
| 171 EXPECT_EQ("600,0 300x300", fullscreen->GetWindowBoundsInScreen().ToString()); | 174 EXPECT_EQ("600,0 300x300", fullscreen->GetWindowBoundsInScreen().ToString()); |
| 172 EXPECT_EQ("0,0 300x300", | 175 EXPECT_EQ("0,0 300x300", |
| 173 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 176 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 287 |
| 285 UpdateDisplay("500x500"); | 288 UpdateDisplay("500x500"); |
| 286 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 289 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
| 287 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 290 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 288 generator_1st.ClickLeftButton(); | 291 generator_1st.ClickLeftButton(); |
| 289 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 292 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 290 } | 293 } |
| 291 | 294 |
| 292 // Make sure lock related windows moves. | 295 // Make sure lock related windows moves. |
| 293 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { | 296 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { |
| 297 // TODO: requires unified desktop mode. http://crbug.com/581462. |
| 298 if (WmShell::Get()->IsRunningInMash()) |
| 299 return; |
| 300 |
| 294 display_manager()->SetUnifiedDesktopEnabled(true); | 301 display_manager()->SetUnifiedDesktopEnabled(true); |
| 295 | 302 |
| 296 UpdateDisplay("500x500"); | 303 UpdateDisplay("500x500"); |
| 297 const int kLockScreenWindowId = 1000; | 304 const int kLockScreenWindowId = 1000; |
| 298 const int kLockWallpaperWindowId = 1001; | 305 const int kLockWallpaperWindowId = 1001; |
| 299 | 306 |
| 300 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 307 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
| 301 | 308 |
| 302 aura::Window* lock_container = | 309 aura::Window* lock_container = |
| 303 controller->GetContainer(kShellWindowId_LockScreenContainer); | 310 controller->GetContainer(kShellWindowId_LockScreenContainer); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 ASSERT_TRUE(Shell::GetContainer(primary_root_window, | 749 ASSERT_TRUE(Shell::GetContainer(primary_root_window, |
| 743 kShellWindowId_VirtualKeyboardContainer)); | 750 kShellWindowId_VirtualKeyboardContainer)); |
| 744 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | 751 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, |
| 745 kShellWindowId_VirtualKeyboardContainer)); | 752 kShellWindowId_VirtualKeyboardContainer)); |
| 746 } | 753 } |
| 747 | 754 |
| 748 // Test for http://crbug.com/303429. Virtual keyboard container should show on | 755 // Test for http://crbug.com/303429. Virtual keyboard container should show on |
| 749 // a display which has touch capability. | 756 // a display which has touch capability. |
| 750 TEST_F(VirtualKeyboardRootWindowControllerTest, | 757 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 751 VirtualKeyboardOnTouchableDisplayOnly) { | 758 VirtualKeyboardOnTouchableDisplayOnly) { |
| 759 // TODO: investigate failure in mash. http://crbug.com/695640. |
| 760 if (WmShell::Get()->IsRunningInMash()) |
| 761 return; |
| 762 |
| 752 UpdateDisplay("500x500,500x500"); | 763 UpdateDisplay("500x500,500x500"); |
| 753 display::Display secondary_display = | 764 display::Display secondary_display = |
| 754 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); | 765 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); |
| 755 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 766 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) |
| 756 .SetTouchSupport(secondary_display.id(), | 767 .SetTouchSupport(secondary_display.id(), |
| 757 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | 768 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); |
| 758 | 769 |
| 759 // The primary display doesn't have touch capability and the secondary display | 770 // The primary display doesn't have touch capability and the secondary display |
| 760 // does. | 771 // does. |
| 761 ASSERT_NE(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE, | 772 ASSERT_NE(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 792 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false); | 803 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false); |
| 793 EXPECT_FALSE(Shell::GetContainer(primary_root_window, | 804 EXPECT_FALSE(Shell::GetContainer(primary_root_window, |
| 794 kShellWindowId_VirtualKeyboardContainer)); | 805 kShellWindowId_VirtualKeyboardContainer)); |
| 795 EXPECT_TRUE(Shell::GetContainer(secondary_root_window, | 806 EXPECT_TRUE(Shell::GetContainer(secondary_root_window, |
| 796 kShellWindowId_VirtualKeyboardContainer)); | 807 kShellWindowId_VirtualKeyboardContainer)); |
| 797 } | 808 } |
| 798 | 809 |
| 799 // Test for http://crbug.com/303429. If both of displays have touch capability, | 810 // Test for http://crbug.com/303429. If both of displays have touch capability, |
| 800 // virtual keyboard follows the input focus. | 811 // virtual keyboard follows the input focus. |
| 801 TEST_F(VirtualKeyboardRootWindowControllerTest, FollowInputFocus) { | 812 TEST_F(VirtualKeyboardRootWindowControllerTest, FollowInputFocus) { |
| 813 // TODO: investigate failure in mash. http://crbug.com/695640. |
| 814 if (WmShell::Get()->IsRunningInMash()) |
| 815 return; |
| 816 |
| 802 UpdateDisplay("500x500,500x500"); | 817 UpdateDisplay("500x500,500x500"); |
| 803 const int64_t primary_display_id = | 818 const int64_t primary_display_id = |
| 804 display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 819 display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 805 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 820 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) |
| 806 .SetTouchSupport(primary_display_id, | 821 .SetTouchSupport(primary_display_id, |
| 807 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | 822 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); |
| 808 const int64_t secondary_display_id = | 823 const int64_t secondary_display_id = |
| 809 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id(); | 824 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id(); |
| 810 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 825 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) |
| 811 .SetTouchSupport(secondary_display_id, | 826 .SetTouchSupport(secondary_display_id, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 EXPECT_TRUE(Shell::GetContainer(primary_root_window, | 875 EXPECT_TRUE(Shell::GetContainer(primary_root_window, |
| 861 kShellWindowId_VirtualKeyboardContainer)); | 876 kShellWindowId_VirtualKeyboardContainer)); |
| 862 EXPECT_FALSE(Shell::GetContainer(secondary_root_window, | 877 EXPECT_FALSE(Shell::GetContainer(secondary_root_window, |
| 863 kShellWindowId_VirtualKeyboardContainer)); | 878 kShellWindowId_VirtualKeyboardContainer)); |
| 864 } | 879 } |
| 865 | 880 |
| 866 // Test for http://crbug.com/303429. Even if both of display don't have touch | 881 // Test for http://crbug.com/303429. Even if both of display don't have touch |
| 867 // capability, the virtual keyboard shows up on the specified display. | 882 // capability, the virtual keyboard shows up on the specified display. |
| 868 TEST_F(VirtualKeyboardRootWindowControllerTest, | 883 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 869 VirtualKeyboardShowOnSpecifiedDisplay) { | 884 VirtualKeyboardShowOnSpecifiedDisplay) { |
| 885 // TODO: fails in mash. http://crbug.com/695640. |
| 886 if (WmShell::Get()->IsRunningInMash()) |
| 887 return; |
| 888 |
| 870 UpdateDisplay("500x500,500x500"); | 889 UpdateDisplay("500x500,500x500"); |
| 871 display::Display secondary_display = | 890 display::Display secondary_display = GetSecondaryDisplay(); |
| 872 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); | |
| 873 | 891 |
| 874 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 892 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 875 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | 893 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); |
| 876 aura::Window* secondary_root_window = root_windows[0] == primary_root_window | 894 aura::Window* secondary_root_window = root_windows[0] == primary_root_window |
| 877 ? root_windows[1] | 895 ? root_windows[1] |
| 878 : root_windows[0]; | 896 : root_windows[0]; |
| 879 | 897 |
| 880 ASSERT_TRUE(Shell::GetContainer(primary_root_window, | 898 ASSERT_TRUE(Shell::GetContainer(primary_root_window, |
| 881 kShellWindowId_VirtualKeyboardContainer)); | 899 kShellWindowId_VirtualKeyboardContainer)); |
| 882 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | 900 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 ui->EnsureCaretInWorkArea(); | 1069 ui->EnsureCaretInWorkArea(); |
| 1052 ASSERT_EQ(root_window->bounds().width(), | 1070 ASSERT_EQ(root_window->bounds().width(), |
| 1053 text_input_client.caret_exclude_rect().width()); | 1071 text_input_client.caret_exclude_rect().width()); |
| 1054 ASSERT_EQ(keyboard_height, text_input_client.caret_exclude_rect().height()); | 1072 ASSERT_EQ(keyboard_height, text_input_client.caret_exclude_rect().height()); |
| 1055 | 1073 |
| 1056 input_method->SetFocusedTextInputClient(NULL); | 1074 input_method->SetFocusedTextInputClient(NULL); |
| 1057 } | 1075 } |
| 1058 | 1076 |
| 1059 TEST_F(VirtualKeyboardRootWindowControllerTest, | 1077 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 1060 EnsureCaretInWorkAreaWithMultipleDisplays) { | 1078 EnsureCaretInWorkAreaWithMultipleDisplays) { |
| 1079 // TODO: fails in mash. http://crbug.com/695640. |
| 1080 if (WmShell::Get()->IsRunningInMash()) |
| 1081 return; |
| 1082 |
| 1061 UpdateDisplay("500x500,600x600"); | 1083 UpdateDisplay("500x500,600x600"); |
| 1062 const int64_t primary_display_id = | 1084 const int64_t primary_display_id = |
| 1063 display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1085 display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1064 const int64_t secondary_display_id = | 1086 const int64_t secondary_display_id = GetSecondaryDisplay().id(); |
| 1065 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id(); | |
| 1066 ASSERT_NE(primary_display_id, secondary_display_id); | 1087 ASSERT_NE(primary_display_id, secondary_display_id); |
| 1067 | 1088 |
| 1068 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1089 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1069 ASSERT_EQ(static_cast<size_t>(2), root_windows.size()); | 1090 ASSERT_EQ(static_cast<size_t>(2), root_windows.size()); |
| 1070 aura::Window* primary_root_window = root_windows[0]; | 1091 aura::Window* primary_root_window = root_windows[0]; |
| 1071 aura::Window* secondary_root_window = root_windows[1]; | 1092 aura::Window* secondary_root_window = root_windows[1]; |
| 1072 | 1093 |
| 1073 keyboard::KeyboardController* keyboard_controller = | 1094 keyboard::KeyboardController* keyboard_controller = |
| 1074 keyboard::KeyboardController::GetInstance(); | 1095 keyboard::KeyboardController::GetInstance(); |
| 1075 keyboard::KeyboardUI* ui = keyboard_controller->ui(); | 1096 keyboard::KeyboardUI* ui = keyboard_controller->ui(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1231 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1211 gfx::Rect(0, 400, 800, 200)); | 1232 gfx::Rect(0, 400, 800, 200)); |
| 1212 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1233 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1213 | 1234 |
| 1214 UpdateDisplay("600x800"); | 1235 UpdateDisplay("600x800"); |
| 1215 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1236 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1216 } | 1237 } |
| 1217 | 1238 |
| 1218 } // namespace test | 1239 } // namespace test |
| 1219 } // namespace ash | 1240 } // namespace ash |
| OLD | NEW |