Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: ash/test/ash_test_base.cc

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 GetSessionControllerClient()->CreatePredefinedUserSessions(
309 session_started); 314 session_started ? 1 : 0);
James Cook 2017/03/19 19:02:51 It seems weird you call this with 0 users. See com
xiyuan 2017/03/20 17:12:56 Changed as suggested.
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 GetSessionControllerClient()->SetCanLockScreen(can_lock);
320 } 323 }
321 324
322 void AshTestBase::SetShouldLockScreenAutomatically(bool should_lock) { 325 void AshTestBase::SetShouldLockScreenAutomatically(bool should_lock) {
323 AshTestHelper::GetTestSessionStateDelegate() 326 GetSessionControllerClient()->SetShouldLockScreenAutomatically(should_lock);
324 ->SetShouldLockScreenAutomatically(should_lock);
325 } 327 }
326 328
327 void AshTestBase::SetUserAddingScreenRunning(bool user_adding_screen_running) { 329 void AshTestBase::SetUserAddingScreenRunning(bool user_adding_screen_running) {
328 AshTestHelper::GetTestSessionStateDelegate()->SetUserAddingScreenRunning( 330 GetSessionControllerClient()->SetSessionState(
329 user_adding_screen_running); 331 user_adding_screen_running
332 ? session_manager::SessionState::LOGIN_SECONDARY
333 : session_manager::SessionState::ACTIVE);
330 } 334 }
331 335
332 void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) { 336 void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) {
333 switch (block_reason) { 337 switch (block_reason) {
334 case BLOCKED_BY_LOCK_SCREEN: 338 case BLOCKED_BY_LOCK_SCREEN:
335 SetSessionStarted(true); 339 SetSessionStarted(true);
336 SetUserAddingScreenRunning(false); 340 WmShell::Get()->session_controller()->LockScreenAndFlushForTest();
337 WmShell::Get()->GetSessionStateDelegate()->LockScreen();
338 Shell::GetInstance()->OnLockStateChanged(true); 341 Shell::GetInstance()->OnLockStateChanged(true);
339 break; 342 break;
340 case BLOCKED_BY_LOGIN_SCREEN: 343 case BLOCKED_BY_LOGIN_SCREEN:
341 SetUserAddingScreenRunning(false);
342 SetSessionStarted(false); 344 SetSessionStarted(false);
343 break; 345 break;
344 case BLOCKED_BY_USER_ADDING_SCREEN: 346 case BLOCKED_BY_USER_ADDING_SCREEN:
345 SetUserAddingScreenRunning(true); 347 SetUserAddingScreenRunning(true);
346 SetSessionStarted(true);
347 break; 348 break;
348 default: 349 default:
349 NOTREACHED(); 350 NOTREACHED();
350 break; 351 break;
351 } 352 }
352 } 353 }
353 354
354 void AshTestBase::UnblockUserSession() { 355 void AshTestBase::UnblockUserSession() {
355 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen();
356 SetSessionStarted(true); 356 SetSessionStarted(true);
357 SetUserAddingScreenRunning(false); 357 GetSessionControllerClient()->UnlockScreen();
358 } 358 }
359 359
360 void AshTestBase::DisableIME() { 360 void AshTestBase::DisableIME() {
361 // WindowTreeHostManager isn't applicable to mash and IME is routed 361 // WindowTreeHostManager isn't applicable to mash and IME is routed
362 // differently in mash. 362 // differently in mash.
363 if (WmShell::Get()->IsRunningInMash()) 363 if (WmShell::Get()->IsRunningInMash())
364 return; 364 return;
365 365
366 Shell::GetInstance()->RemovePreTargetHandler( 366 Shell::GetInstance()->RemovePreTargetHandler(
367 Shell::GetInstance() 367 Shell::GetInstance()
(...skipping 30 matching lines...) Expand all
398 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( 398 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId(
399 display_manager()->GetSecondaryDisplay().id()); 399 display_manager()->GetSecondaryDisplay().id());
400 } 400 }
401 401
402 display::Display AshTestBase::GetSecondaryDisplay() { 402 display::Display AshTestBase::GetSecondaryDisplay() {
403 return ash_test_helper_->GetSecondaryDisplay(); 403 return ash_test_helper_->GetSecondaryDisplay();
404 } 404 }
405 405
406 } // namespace test 406 } // namespace test
407 } // namespace ash 407 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698