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

Side by Side Diff: ash/wm/lock_state_controller_unittest.cc

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase to get WorkspaceLayoutManagerSoloTest change 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
« no previous file with comments | « ash/wm/event_client_impl.cc ('k') | ash/wm/power_button_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/wm/lock_state_controller.h" 5 #include "ash/wm/lock_state_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_controller.h"
11 #include "ash/common/shutdown_controller.h" 11 #include "ash/common/shutdown_controller.h"
12 #include "ash/common/test/test_session_state_delegate.h" 12 #include "ash/common/test/test_session_controller_client.h"
13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
14 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
17 #include "ash/test/lock_state_controller_test_api.h" 17 #include "ash/test/lock_state_controller_test_api.h"
18 #include "ash/test/test_screenshot_delegate.h" 18 #include "ash/test/test_screenshot_delegate.h"
19 #include "ash/test/test_session_state_animator.h" 19 #include "ash/test/test_session_state_animator.h"
20 #include "ash/test/test_shell_delegate.h" 20 #include "ash/test/test_shell_delegate.h"
21 #include "ash/wm/power_button_controller.h" 21 #include "ash/wm/power_button_controller.h"
22 #include "ash/wm/session_state_animator.h" 22 #include "ash/wm/session_state_animator.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 SCOPED_TRACE("Failure in ExpectRestoringWallpaperVisibility"); 270 SCOPED_TRACE("Failure in ExpectRestoringWallpaperVisibility");
271 EXPECT_LT(0u, test_animator_->GetAnimationCount()); 271 EXPECT_LT(0u, test_animator_->GetAnimationCount());
272 EXPECT_TRUE(test_animator_->AreContainersAnimated( 272 EXPECT_TRUE(test_animator_->AreContainersAnimated(
273 SessionStateAnimator::WALLPAPER, 273 SessionStateAnimator::WALLPAPER,
274 SessionStateAnimator::ANIMATION_FADE_IN)); 274 SessionStateAnimator::ANIMATION_FADE_IN));
275 } 275 }
276 276
277 void ExpectUnlockedState() { 277 void ExpectUnlockedState() {
278 SCOPED_TRACE("Failure in ExpectUnlockedState"); 278 SCOPED_TRACE("Failure in ExpectUnlockedState");
279 EXPECT_EQ(0u, test_animator_->GetAnimationCount()); 279 EXPECT_EQ(0u, test_animator_->GetAnimationCount());
280 EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); 280 EXPECT_FALSE(WmShell::Get()->session_controller()->IsScreenLocked());
281 } 281 }
282 282
283 void ExpectLockedState() { 283 void ExpectLockedState() {
284 SCOPED_TRACE("Failure in ExpectLockedState"); 284 SCOPED_TRACE("Failure in ExpectLockedState");
285 EXPECT_EQ(0u, test_animator_->GetAnimationCount()); 285 EXPECT_EQ(0u, test_animator_->GetAnimationCount());
286 EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); 286 EXPECT_TRUE(WmShell::Get()->session_controller()->IsScreenLocked());
287 } 287 }
288 288
289 void HideWallpaper() { test_animator_->HideWallpaper(); } 289 void HideWallpaper() { test_animator_->HideWallpaper(); }
290 290
291 void PressPowerButton() { 291 void PressPowerButton() {
292 power_button_controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 292 power_button_controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
293 } 293 }
294 294
295 void ReleasePowerButton() { 295 void ReleasePowerButton() {
296 power_button_controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); 296 power_button_controller_->OnPowerButtonEvent(false, base::TimeTicks::Now());
(...skipping 10 matching lines...) Expand all
307 void PressVolumeDown() { 307 void PressVolumeDown() {
308 GetEventGenerator().PressKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 308 GetEventGenerator().PressKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
309 } 309 }
310 310
311 void ReleaseVolumeDown() { 311 void ReleaseVolumeDown() {
312 GetEventGenerator().ReleaseKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 312 GetEventGenerator().ReleaseKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
313 } 313 }
314 314
315 void SystemLocks() { 315 void SystemLocks() {
316 lock_state_controller_->OnLockStateChanged(true); 316 lock_state_controller_->OnLockStateChanged(true);
317 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); 317 WmShell::Get()->session_controller()->LockScreenAndFlushForTest();
318 } 318 }
319 319
320 void SuccessfulAuthentication(bool* call_flag) { 320 void SuccessfulAuthentication(bool* call_flag) {
321 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); 321 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag);
322 lock_state_controller_->OnLockScreenHide(closure); 322 lock_state_controller_->OnLockScreenHide(closure);
323 } 323 }
324 324
325 void SystemUnlocks() { 325 void SystemUnlocks() {
326 lock_state_controller_->OnLockStateChanged(false); 326 lock_state_controller_->OnLockStateChanged(false);
327 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); 327 GetSessionControllerClient()->UnlockScreen();
328 } 328 }
329 329
330 void EnableMaximizeMode(bool enable) { 330 void EnableMaximizeMode(bool enable) {
331 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 331 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
332 enable); 332 enable);
333 } 333 }
334 334
335 void Initialize(bool legacy_button, LoginStatus status) { 335 void Initialize(bool legacy_button, LoginStatus status) {
336 power_button_controller_->set_has_legacy_power_button_for_test( 336 power_button_controller_->set_has_legacy_power_button_for_test(
337 legacy_button); 337 legacy_button);
338 lock_state_controller_->OnLoginStateChanged(status); 338 lock_state_controller_->OnLoginStateChanged(status);
339 SetUserLoggedIn(status != LoginStatus::NOT_LOGGED_IN); 339 SetUserLoggedIn(status != LoginStatus::NOT_LOGGED_IN);
340 if (status == LoginStatus::GUEST) 340 if (status == LoginStatus::GUEST)
341 TestSessionStateDelegate::SetCanLockScreen(false); 341 SetCanLockScreen(false);
342 lock_state_controller_->OnLockStateChanged(false); 342 lock_state_controller_->OnLockStateChanged(false);
343 } 343 }
344 344
345 PowerButtonController* power_button_controller_; // not owned 345 PowerButtonController* power_button_controller_; // not owned
346 LockStateController* lock_state_controller_; // not owned 346 LockStateController* lock_state_controller_; // not owned
347 TestShutdownController test_shutdown_controller_; 347 TestShutdownController test_shutdown_controller_;
348 // Ownership is passed on to chromeos::DBusThreadManager. 348 // Ownership is passed on to chromeos::DBusThreadManager.
349 chromeos::FakeSessionManagerClient* session_manager_client_; 349 chromeos::FakeSessionManagerClient* session_manager_client_;
350 TestSessionStateAnimator* test_animator_; // not owned 350 TestSessionStateAnimator* test_animator_; // not owned
351 std::unique_ptr<LockStateControllerTestApi> test_api_; 351 std::unique_ptr<LockStateControllerTestApi> test_api_;
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); 1074 ASSERT_EQ(0, delegate->handle_take_screenshot_count());
1075 PressVolumeDown(); 1075 PressVolumeDown();
1076 PressPowerButton(); 1076 PressPowerButton();
1077 ReleasePowerButton(); 1077 ReleasePowerButton();
1078 ReleaseVolumeDown(); 1078 ReleaseVolumeDown();
1079 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); 1079 EXPECT_EQ(1, delegate->handle_take_screenshot_count());
1080 } 1080 }
1081 1081
1082 } // namespace test 1082 } // namespace test
1083 } // namespace ash 1083 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/event_client_impl.cc ('k') | ash/wm/power_button_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698