| 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/test/ash_test_base.h" | 5 #include "ash/test/ash_test_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/common/test/test_session_state_delegate.h" | 10 #include "ash/common/session/session_controller.h" |
| 11 #include "ash/common/test/test_session_controller_client.h" |
| 11 #include "ash/common/test/test_system_tray_delegate.h" | 12 #include "ash/common/test/test_system_tray_delegate.h" |
| 12 #include "ash/common/wm/window_positioner.h" | 13 #include "ash/common/wm/window_positioner.h" |
| 13 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 14 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
| 15 #include "ash/display/extended_mouse_warp_controller.h" | 16 #include "ash/display/extended_mouse_warp_controller.h" |
| 16 #include "ash/display/mouse_cursor_event_filter.h" | 17 #include "ash/display/mouse_cursor_event_filter.h" |
| 17 #include "ash/display/unified_mouse_warp_controller.h" | 18 #include "ash/display/unified_mouse_warp_controller.h" |
| 18 #include "ash/display/window_tree_host_manager.h" | 19 #include "ash/display/window_tree_host_manager.h" |
| 19 #include "ash/ime/input_method_event_handler.h" | 20 #include "ash/ime/input_method_event_handler.h" |
| 20 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 293 } |
| 293 | 294 |
| 294 void AshTestBase::RunAllPendingInMessageLoop() { | 295 void AshTestBase::RunAllPendingInMessageLoop() { |
| 295 ash_test_helper_->RunAllPendingInMessageLoop(); | 296 ash_test_helper_->RunAllPendingInMessageLoop(); |
| 296 } | 297 } |
| 297 | 298 |
| 298 TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() { | 299 TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() { |
| 299 return ash_test_helper_->test_screenshot_delegate(); | 300 return ash_test_helper_->test_screenshot_delegate(); |
| 300 } | 301 } |
| 301 | 302 |
| 303 TestSessionControllerClient* AshTestBase::GetSessionControllerClient() { |
| 304 return ash_test_helper_->test_session_controller_client(); |
| 305 } |
| 306 |
| 302 TestSystemTrayDelegate* AshTestBase::GetSystemTrayDelegate() { | 307 TestSystemTrayDelegate* AshTestBase::GetSystemTrayDelegate() { |
| 303 return static_cast<TestSystemTrayDelegate*>( | 308 return static_cast<TestSystemTrayDelegate*>( |
| 304 WmShell::Get()->system_tray_delegate()); | 309 WmShell::Get()->system_tray_delegate()); |
| 305 } | 310 } |
| 306 | 311 |
| 307 void AshTestBase::SetSessionStarted(bool session_started) { | 312 void AshTestBase::SetSessionStarted(bool session_started) { |
| 308 AshTestHelper::GetTestSessionStateDelegate()->SetActiveUserSessionStarted( | 313 ash_test_helper_->test_session_controller_client()->SetPredefinedUserSessions( |
| 309 session_started); | 314 session_started ? 1 : 0); |
| 310 } | |
| 311 | |
| 312 void AshTestBase::SetSessionStarting() { | |
| 313 AshTestHelper::GetTestSessionStateDelegate()->set_session_state( | |
| 314 session_manager::SessionState::ACTIVE); | |
| 315 } | 315 } |
| 316 | 316 |
| 317 void AshTestBase::SetUserLoggedIn(bool user_logged_in) { | 317 void AshTestBase::SetUserLoggedIn(bool user_logged_in) { |
| 318 AshTestHelper::GetTestSessionStateDelegate()->SetHasActiveUser( | 318 SetSessionStarted(user_logged_in); |
| 319 user_logged_in); | 319 } |
| 320 |
| 321 void AshTestBase::SetCanLockScreen(bool can_lock) { |
| 322 ash_test_helper_->test_session_controller_client()->SetCanLockScreen( |
| 323 can_lock); |
| 320 } | 324 } |
| 321 | 325 |
| 322 void AshTestBase::SetShouldLockScreenAutomatically(bool should_lock) { | 326 void AshTestBase::SetShouldLockScreenAutomatically(bool should_lock) { |
| 323 AshTestHelper::GetTestSessionStateDelegate() | 327 ash_test_helper_->test_session_controller_client() |
| 324 ->SetShouldLockScreenAutomatically(should_lock); | 328 ->SetShouldLockScreenAutomatically(should_lock); |
| 325 } | 329 } |
| 326 | 330 |
| 327 void AshTestBase::SetUserAddingScreenRunning(bool user_adding_screen_running) { | 331 void AshTestBase::SetUserAddingScreenRunning(bool user_adding_screen_running) { |
| 328 AshTestHelper::GetTestSessionStateDelegate()->SetUserAddingScreenRunning( | 332 ash_test_helper_->test_session_controller_client()->SetSessionState( |
| 329 user_adding_screen_running); | 333 user_adding_screen_running |
| 334 ? session_manager::SessionState::LOGIN_SECONDARY |
| 335 : session_manager::SessionState::ACTIVE); |
| 330 } | 336 } |
| 331 | 337 |
| 332 void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) { | 338 void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) { |
| 333 switch (block_reason) { | 339 switch (block_reason) { |
| 334 case BLOCKED_BY_LOCK_SCREEN: | 340 case BLOCKED_BY_LOCK_SCREEN: |
| 335 SetSessionStarted(true); | 341 SetSessionStarted(true); |
| 336 SetUserAddingScreenRunning(false); | 342 WmShell::Get()->session_controller()->LockScreenAndFlushForTest(); |
| 337 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | |
| 338 Shell::GetInstance()->OnLockStateChanged(true); | 343 Shell::GetInstance()->OnLockStateChanged(true); |
| 339 break; | 344 break; |
| 340 case BLOCKED_BY_LOGIN_SCREEN: | 345 case BLOCKED_BY_LOGIN_SCREEN: |
| 341 SetUserAddingScreenRunning(false); | |
| 342 SetSessionStarted(false); | 346 SetSessionStarted(false); |
| 343 break; | 347 break; |
| 344 case BLOCKED_BY_USER_ADDING_SCREEN: | 348 case BLOCKED_BY_USER_ADDING_SCREEN: |
| 345 SetUserAddingScreenRunning(true); | 349 SetUserAddingScreenRunning(true); |
| 346 SetSessionStarted(true); | |
| 347 break; | 350 break; |
| 348 default: | 351 default: |
| 349 NOTREACHED(); | 352 NOTREACHED(); |
| 350 break; | 353 break; |
| 351 } | 354 } |
| 352 } | 355 } |
| 353 | 356 |
| 354 void AshTestBase::UnblockUserSession() { | 357 void AshTestBase::UnblockUserSession() { |
| 355 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); | |
| 356 SetSessionStarted(true); | 358 SetSessionStarted(true); |
| 357 SetUserAddingScreenRunning(false); | 359 GetSessionControllerClient()->UnlockScreen(); |
| 358 } | 360 } |
| 359 | 361 |
| 360 void AshTestBase::DisableIME() { | 362 void AshTestBase::DisableIME() { |
| 361 // WindowTreeHostManager isn't applicable to mash and IME is routed | 363 // WindowTreeHostManager isn't applicable to mash and IME is routed |
| 362 // differently in mash. | 364 // differently in mash. |
| 363 if (WmShell::Get()->IsRunningInMash()) | 365 if (WmShell::Get()->IsRunningInMash()) |
| 364 return; | 366 return; |
| 365 | 367 |
| 366 Shell::GetInstance()->RemovePreTargetHandler( | 368 Shell::GetInstance()->RemovePreTargetHandler( |
| 367 Shell::GetInstance() | 369 Shell::GetInstance() |
| (...skipping 30 matching lines...) Expand all Loading... |
| 398 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 400 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
| 399 display_manager()->GetSecondaryDisplay().id()); | 401 display_manager()->GetSecondaryDisplay().id()); |
| 400 } | 402 } |
| 401 | 403 |
| 402 display::Display AshTestBase::GetSecondaryDisplay() { | 404 display::Display AshTestBase::GetSecondaryDisplay() { |
| 403 return ash_test_helper_->GetSecondaryDisplay(); | 405 return ash_test_helper_->GetSecondaryDisplay(); |
| 404 } | 406 } |
| 405 | 407 |
| 406 } // namespace test | 408 } // namespace test |
| 407 } // namespace ash | 409 } // namespace ash |
| OLD | NEW |