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/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
11 #include "ash/common/session/session_controller.h" | |
12 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
13 #include "ash/common/system/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
14 #include "ash/common/wm/system_modal_container_layout_manager.h" | 13 #include "ash/common/wm/system_modal_container_layout_manager.h" |
15 #include "ash/common/wm/window_state.h" | 14 #include "ash/common/wm/window_state.h" |
16 #include "ash/common/wm_lookup.h" | 15 #include "ash/common/wm_lookup.h" |
17 #include "ash/common/wm_root_window_controller.h" | 16 #include "ash/common/wm_root_window_controller.h" |
18 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
19 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
20 #include "ash/public/cpp/shell_window_ids.h" | 19 #include "ash/public/cpp/shell_window_ids.h" |
21 #include "ash/public/interfaces/session_controller.mojom.h" | |
22 #include "ash/shell.h" | 20 #include "ash/shell.h" |
23 #include "ash/test/ash_md_test_base.h" | 21 #include "ash/test/ash_md_test_base.h" |
24 #include "ash/test/ash_test_base.h" | 22 #include "ash/test/ash_test_base.h" |
25 #include "ash/wm/window_properties.h" | 23 #include "ash/wm/window_properties.h" |
26 #include "ash/wm/window_state_aura.h" | 24 #include "ash/wm/window_state_aura.h" |
27 #include "ash/wm/window_util.h" | 25 #include "ash/wm/window_util.h" |
28 #include "base/command_line.h" | 26 #include "base/command_line.h" |
29 #include "ui/aura/client/focus_change_observer.h" | 27 #include "ui/aura/client/focus_change_observer.h" |
30 #include "ui/aura/client/focus_client.h" | 28 #include "ui/aura/client/focus_client.h" |
31 #include "ui/aura/client/window_parenting_client.h" | 29 #include "ui/aura/client/window_parenting_client.h" |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 // GetWindowContainer(). | 968 // GetWindowContainer(). |
971 TEST_F(VirtualKeyboardRootWindowControllerTest, | 969 TEST_F(VirtualKeyboardRootWindowControllerTest, |
972 DeleteOldContainerOnVirtualKeyboardInit) { | 970 DeleteOldContainerOnVirtualKeyboardInit) { |
973 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 971 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
974 aura::Window* keyboard_container = | 972 aura::Window* keyboard_container = |
975 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 973 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
976 ASSERT_TRUE(keyboard_container); | 974 ASSERT_TRUE(keyboard_container); |
977 // Track the keyboard container window. | 975 // Track the keyboard container window. |
978 aura::WindowTracker tracker; | 976 aura::WindowTracker tracker; |
979 tracker.Add(keyboard_container); | 977 tracker.Add(keyboard_container); |
980 // Reinitialize the keyboard. | 978 // Mock a login user profile change to reinitialize the keyboard. |
981 Shell::GetInstance()->CreateKeyboard(); | 979 Shell::GetInstance()->OnLoginUserProfilePrepared(); |
982 // keyboard_container should no longer be present. | 980 // keyboard_container should no longer be present. |
983 EXPECT_FALSE(tracker.Contains(keyboard_container)); | 981 EXPECT_FALSE(tracker.Contains(keyboard_container)); |
984 } | 982 } |
985 | 983 |
986 // Test for crbug.com/342524. After user login, the work space should restore to | 984 // Test for crbug.com/342524. After user login, the work space should restore to |
987 // full screen. | 985 // full screen. |
988 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) { | 986 TEST_F(VirtualKeyboardRootWindowControllerTest, RestoreWorkspaceAfterLogin) { |
989 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 987 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
990 aura::Window* keyboard_container = | 988 aura::Window* keyboard_container = |
991 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 989 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
(...skipping 13 matching lines...) Expand all Loading... |
1005 // Notify keyboard bounds changing. | 1003 // Notify keyboard bounds changing. |
1006 controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds()); | 1004 controller->NotifyKeyboardBoundsChanging(keyboard_container->bounds()); |
1007 | 1005 |
1008 if (!keyboard::IsKeyboardOverscrollEnabled()) { | 1006 if (!keyboard::IsKeyboardOverscrollEnabled()) { |
1009 gfx::Rect after = | 1007 gfx::Rect after = |
1010 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 1008 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
1011 EXPECT_LT(after, before); | 1009 EXPECT_LT(after, before); |
1012 } | 1010 } |
1013 | 1011 |
1014 // Mock a login user profile change to reinitialize the keyboard. | 1012 // Mock a login user profile change to reinitialize the keyboard. |
1015 mojom::SessionInfoPtr info = mojom::SessionInfo::New(); | 1013 Shell::GetInstance()->OnLoginUserProfilePrepared(); |
1016 info->state = session_manager::SessionState::ACTIVE; | |
1017 WmShell::Get()->session_controller()->SetSessionInfo(std::move(info)); | |
1018 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().work_area(), | 1014 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().work_area(), |
1019 before); | 1015 before); |
1020 } | 1016 } |
1021 | 1017 |
1022 // Ensure that system modal dialogs do not block events targeted at the virtual | 1018 // Ensure that system modal dialogs do not block events targeted at the virtual |
1023 // keyboard. | 1019 // keyboard. |
1024 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) { | 1020 TEST_F(VirtualKeyboardRootWindowControllerTest, ClickWithActiveModalDialog) { |
1025 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 1021 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
1026 aura::Window* keyboard_container = | 1022 aura::Window* keyboard_container = |
1027 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 1023 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1246 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
1251 gfx::Rect(0, 400, 800, 200)); | 1247 gfx::Rect(0, 400, 800, 200)); |
1252 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1248 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
1253 | 1249 |
1254 UpdateDisplay("600x800"); | 1250 UpdateDisplay("600x800"); |
1255 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1251 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
1256 } | 1252 } |
1257 | 1253 |
1258 } // namespace test | 1254 } // namespace test |
1259 } // namespace ash | 1255 } // namespace ash |
OLD | NEW |