| 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" | |
| 11 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| 11 #include "ash/common/test/test_session_controller_client.h" |
| 12 #include "ash/common/wm/system_modal_container_layout_manager.h" | 12 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 13 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 14 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 15 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
| 16 #include "ash/public/cpp/shell_window_ids.h" | 16 #include "ash/public/cpp/shell_window_ids.h" |
| 17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 18 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| 19 #include "ash/wm/window_properties.h" | 19 #include "ash/wm/window_properties.h" |
| 20 #include "ash/wm/window_state_aura.h" | 20 #include "ash/wm/window_state_aura.h" |
| 21 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 390 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
| 391 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 391 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
| 392 controller->GetSystemModalLayoutManager(NULL)); | 392 controller->GetSystemModalLayoutManager(NULL)); |
| 393 | 393 |
| 394 views::Widget* session_modal_widget = | 394 views::Widget* session_modal_widget = |
| 395 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 395 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 396 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 396 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
| 397 controller->GetSystemModalLayoutManager( | 397 controller->GetSystemModalLayoutManager( |
| 398 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 398 WmWindow::Get(session_modal_widget->GetNativeWindow()))); |
| 399 | 399 |
| 400 wm_shell->GetSessionStateDelegate()->LockScreen(); | 400 wm_shell->session_controller()->LockScreenAndFlushForTest(); |
| 401 EXPECT_EQ(LoginStatus::LOCKED, | 401 EXPECT_EQ(LoginStatus::LOCKED, |
| 402 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 402 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
| 403 EXPECT_EQ( | 403 EXPECT_EQ( |
| 404 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 404 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
| 405 controller->GetSystemModalLayoutManager(nullptr)); | 405 controller->GetSystemModalLayoutManager(nullptr)); |
| 406 | 406 |
| 407 aura::Window* lock_container = | 407 aura::Window* lock_container = |
| 408 controller->GetContainer(kShellWindowId_LockScreenContainer); | 408 controller->GetContainer(kShellWindowId_LockScreenContainer); |
| 409 views::Widget* lock_modal_widget = | 409 views::Widget* lock_modal_widget = |
| 410 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); | 410 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); |
| 411 EXPECT_EQ( | 411 EXPECT_EQ( |
| 412 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 412 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
| 413 controller->GetSystemModalLayoutManager( | 413 controller->GetSystemModalLayoutManager( |
| 414 WmWindow::Get(lock_modal_widget->GetNativeWindow()))); | 414 WmWindow::Get(lock_modal_widget->GetNativeWindow()))); |
| 415 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 415 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
| 416 controller->GetSystemModalLayoutManager( | 416 controller->GetSystemModalLayoutManager( |
| 417 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 417 WmWindow::Get(session_modal_widget->GetNativeWindow()))); |
| 418 | 418 |
| 419 wm_shell->GetSessionStateDelegate()->UnlockScreen(); | 419 GetSessionControllerClient()->UnlockScreen(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { | 422 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { |
| 423 UpdateDisplay("600x600"); | 423 UpdateDisplay("600x600"); |
| 424 | 424 |
| 425 // Configure login screen environment. | 425 // Configure login screen environment. |
| 426 SessionStateDelegate* session_state_delegate = | 426 SessionController* session_controller = WmShell::Get()->session_controller(); |
| 427 WmShell::Get()->GetSessionStateDelegate(); | |
| 428 SetUserLoggedIn(false); | 427 SetUserLoggedIn(false); |
| 429 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, | 428 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, |
| 430 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); | 429 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); |
| 431 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers()); | 430 EXPECT_EQ(0, session_controller->NumberOfLoggedInUsers()); |
| 432 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted()); | 431 EXPECT_FALSE(session_controller->IsActiveUserSessionStarted()); |
| 433 | 432 |
| 434 RootWindowController* controller = | 433 RootWindowController* controller = |
| 435 WmShell::Get()->GetPrimaryRootWindowController(); | 434 WmShell::Get()->GetPrimaryRootWindowController(); |
| 436 EXPECT_EQ( | 435 EXPECT_EQ( |
| 437 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 436 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
| 438 controller->GetSystemModalLayoutManager(NULL)); | 437 controller->GetSystemModalLayoutManager(NULL)); |
| 439 | 438 |
| 440 aura::Window* lock_container = | 439 aura::Window* lock_container = |
| 441 controller->GetContainer(kShellWindowId_LockScreenContainer); | 440 controller->GetContainer(kShellWindowId_LockScreenContainer); |
| 442 views::Widget* login_modal_widget = | 441 views::Widget* login_modal_widget = |
| 443 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); | 442 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); |
| 444 EXPECT_EQ( | 443 EXPECT_EQ( |
| 445 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 444 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
| 446 controller->GetSystemModalLayoutManager( | 445 controller->GetSystemModalLayoutManager( |
| 447 WmWindow::Get(login_modal_widget->GetNativeWindow()))); | 446 WmWindow::Get(login_modal_widget->GetNativeWindow()))); |
| 448 login_modal_widget->Close(); | 447 login_modal_widget->Close(); |
| 449 | 448 |
| 450 // Configure user session environment. | 449 // Configure user session environment. |
| 451 SetUserLoggedIn(true); | 450 SetUserLoggedIn(true); |
| 452 SetSessionStarted(true); | 451 SetSessionStarted(true); |
| 453 EXPECT_EQ(LoginStatus::USER, | 452 EXPECT_EQ(LoginStatus::USER, |
| 454 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); | 453 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); |
| 455 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers()); | 454 EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers()); |
| 456 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted()); | 455 EXPECT_TRUE(session_controller->IsActiveUserSessionStarted()); |
| 457 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 456 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
| 458 controller->GetSystemModalLayoutManager(NULL)); | 457 controller->GetSystemModalLayoutManager(NULL)); |
| 459 | 458 |
| 460 views::Widget* session_modal_widget = | 459 views::Widget* session_modal_widget = |
| 461 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 460 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 462 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 461 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
| 463 controller->GetSystemModalLayoutManager( | 462 controller->GetSystemModalLayoutManager( |
| 464 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 463 WmWindow::Get(session_modal_widget->GetNativeWindow()))); |
| 465 } | 464 } |
| 466 | 465 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 ASSERT_TRUE(keyboard_container); | 926 ASSERT_TRUE(keyboard_container); |
| 928 keyboard_container->Show(); | 927 keyboard_container->Show(); |
| 929 | 928 |
| 930 aura::Window* keyboard_window = | 929 aura::Window* keyboard_window = |
| 931 keyboard::KeyboardController::GetInstance()->ui()->GetKeyboardWindow(); | 930 keyboard::KeyboardController::GetInstance()->ui()->GetKeyboardWindow(); |
| 932 keyboard_container->AddChild(keyboard_window); | 931 keyboard_container->AddChild(keyboard_window); |
| 933 keyboard_window->set_owned_by_parent(false); | 932 keyboard_window->set_owned_by_parent(false); |
| 934 keyboard_window->SetBounds(gfx::Rect()); | 933 keyboard_window->SetBounds(gfx::Rect()); |
| 935 keyboard_window->Show(); | 934 keyboard_window->Show(); |
| 936 | 935 |
| 936 // Make sure no pending mouse events in the queue. |
| 937 RunAllPendingInMessageLoop(); |
| 938 |
| 937 ui::test::TestEventHandler handler; | 939 ui::test::TestEventHandler handler; |
| 938 root_window->AddPreTargetHandler(&handler); | 940 root_window->AddPreTargetHandler(&handler); |
| 939 | 941 |
| 940 ui::test::EventGenerator event_generator(root_window, keyboard_window); | 942 ui::test::EventGenerator event_generator(root_window, keyboard_window); |
| 941 event_generator.ClickLeftButton(); | 943 event_generator.ClickLeftButton(); |
| 942 int expected_mouse_presses = 1; | 944 int expected_mouse_presses = 1; |
| 943 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); | 945 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); |
| 944 | 946 |
| 945 for (int block_reason = FIRST_BLOCK_REASON; | 947 for (int block_reason = FIRST_BLOCK_REASON; |
| 946 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { | 948 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1240 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1239 gfx::Rect(0, 400, 800, 200)); | 1241 gfx::Rect(0, 400, 800, 200)); |
| 1240 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1242 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1241 | 1243 |
| 1242 UpdateDisplay("600x800"); | 1244 UpdateDisplay("600x800"); |
| 1243 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1245 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1244 } | 1246 } |
| 1245 | 1247 |
| 1246 } // namespace test | 1248 } // namespace test |
| 1247 } // namespace ash | 1249 } // namespace ash |
| OLD | NEW |