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

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

Issue 2041233005: Moves ash::user::LoginStatus to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 6 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/lock_state_controller.cc ('k') | ash/wm/overlay_event_filter.h » ('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_state_delegate.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 void SystemUnlocks() { 324 void SystemUnlocks() {
325 lock_state_controller_->OnLockStateChanged(false); 325 lock_state_controller_->OnLockStateChanged(false);
326 session_state_delegate_->UnlockScreen(); 326 session_state_delegate_->UnlockScreen();
327 } 327 }
328 328
329 void EnableMaximizeMode(bool enable) { 329 void EnableMaximizeMode(bool enable) {
330 Shell::GetInstance()->maximize_mode_controller()-> 330 Shell::GetInstance()->maximize_mode_controller()->
331 EnableMaximizeModeWindowManager(enable); 331 EnableMaximizeModeWindowManager(enable);
332 } 332 }
333 333
334 void Initialize(bool legacy_button, user::LoginStatus status) { 334 void Initialize(bool legacy_button, LoginStatus status) {
335 power_button_controller_->set_has_legacy_power_button_for_test( 335 power_button_controller_->set_has_legacy_power_button_for_test(
336 legacy_button); 336 legacy_button);
337 lock_state_controller_->OnLoginStateChanged(status); 337 lock_state_controller_->OnLoginStateChanged(status);
338 SetUserLoggedIn(status != user::LOGGED_IN_NONE); 338 SetUserLoggedIn(status != LoginStatus::NOT_LOGGED_IN);
339 if (status == user::LOGGED_IN_GUEST) 339 if (status == LoginStatus::GUEST)
340 SetCanLockScreen(false); 340 SetCanLockScreen(false);
341 lock_state_controller_->OnLockStateChanged(false); 341 lock_state_controller_->OnLockStateChanged(false);
342 } 342 }
343 343
344 PowerButtonController* power_button_controller_; // not owned 344 PowerButtonController* power_button_controller_; // not owned
345 LockStateController* lock_state_controller_; // not owned 345 LockStateController* lock_state_controller_; // not owned
346 TestLockStateControllerDelegate* 346 TestLockStateControllerDelegate*
347 lock_state_controller_delegate_; // not owned 347 lock_state_controller_delegate_; // not owned
348 TestSessionStateAnimator* test_animator_; // not owned 348 TestSessionStateAnimator* test_animator_; // not owned
349 SessionStateDelegate* session_state_delegate_; // not owned 349 SessionStateDelegate* session_state_delegate_; // not owned
350 std::unique_ptr<LockStateController::TestApi> test_api_; 350 std::unique_ptr<LockStateController::TestApi> test_api_;
351 TestShellDelegate* shell_delegate_; // not owned 351 TestShellDelegate* shell_delegate_; // not owned
352 352
353 private: 353 private:
354 DISALLOW_COPY_AND_ASSIGN(LockStateControllerTest); 354 DISALLOW_COPY_AND_ASSIGN(LockStateControllerTest);
355 }; 355 };
356 356
357 // Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't 357 // Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't
358 // correctly report power button releases. We should lock immediately the first 358 // correctly report power button releases. We should lock immediately the first
359 // time the button is pressed and shut down when it's pressed from the locked 359 // time the button is pressed and shut down when it's pressed from the locked
360 // state. 360 // state.
361 TEST_F(LockStateControllerTest, LegacyLockAndShutDown) { 361 TEST_F(LockStateControllerTest, LegacyLockAndShutDown) {
362 Initialize(true, user::LOGGED_IN_USER); 362 Initialize(true, LoginStatus::USER);
363 363
364 ExpectUnlockedState(); 364 ExpectUnlockedState();
365 365
366 // We should request that the screen be locked immediately after seeing the 366 // We should request that the screen be locked immediately after seeing the
367 // power button get pressed. 367 // power button get pressed.
368 PressPowerButton(); 368 PressPowerButton();
369 369
370 EXPECT_FALSE(test_api_->is_lock_cancellable()); 370 EXPECT_FALSE(test_api_->is_lock_cancellable());
371 371
372 ExpectPreLockAnimationStarted(); 372 ExpectPreLockAnimationStarted();
(...skipping 29 matching lines...) Expand all
402 EXPECT_FALSE(cursor_visible()); 402 EXPECT_FALSE(cursor_visible());
403 403
404 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 404 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
405 test_api_->trigger_real_shutdown_timeout(); 405 test_api_->trigger_real_shutdown_timeout();
406 EXPECT_EQ(1, NumShutdownRequests()); 406 EXPECT_EQ(1, NumShutdownRequests());
407 } 407 }
408 408
409 // Test that we start shutting down immediately if the power button is pressed 409 // Test that we start shutting down immediately if the power button is pressed
410 // while we're not logged in on an unofficial system. 410 // while we're not logged in on an unofficial system.
411 TEST_F(LockStateControllerTest, LegacyNotLoggedIn) { 411 TEST_F(LockStateControllerTest, LegacyNotLoggedIn) {
412 Initialize(true, user::LOGGED_IN_NONE); 412 Initialize(true, LoginStatus::NOT_LOGGED_IN);
413 413
414 PressPowerButton(); 414 PressPowerButton();
415 ExpectShutdownAnimationStarted(); 415 ExpectShutdownAnimationStarted();
416 416
417 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 417 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
418 } 418 }
419 419
420 // Test that we start shutting down immediately if the power button is pressed 420 // Test that we start shutting down immediately if the power button is pressed
421 // while we're logged in as a guest on an unofficial system. 421 // while we're logged in as a guest on an unofficial system.
422 TEST_F(LockStateControllerTest, LegacyGuest) { 422 TEST_F(LockStateControllerTest, LegacyGuest) {
423 Initialize(true, user::LOGGED_IN_GUEST); 423 Initialize(true, LoginStatus::GUEST);
424 424
425 PressPowerButton(); 425 PressPowerButton();
426 ExpectShutdownAnimationStarted(); 426 ExpectShutdownAnimationStarted();
427 427
428 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 428 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
429 } 429 }
430 430
431 // When we hold the power button while the user isn't logged in, we should shut 431 // When we hold the power button while the user isn't logged in, we should shut
432 // down the machine directly. 432 // down the machine directly.
433 TEST_F(LockStateControllerTest, ShutdownWhenNotLoggedIn) { 433 TEST_F(LockStateControllerTest, ShutdownWhenNotLoggedIn) {
434 Initialize(false, user::LOGGED_IN_NONE); 434 Initialize(false, LoginStatus::NOT_LOGGED_IN);
435 435
436 // Press the power button and check that we start the shutdown timer. 436 // Press the power button and check that we start the shutdown timer.
437 PressPowerButton(); 437 PressPowerButton();
438 EXPECT_FALSE(test_api_->is_animating_lock()); 438 EXPECT_FALSE(test_api_->is_animating_lock());
439 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); 439 EXPECT_TRUE(test_api_->shutdown_timer_is_running());
440 ExpectShutdownAnimationStarted(); 440 ExpectShutdownAnimationStarted();
441 441
442 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f); 442 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f);
443 443
444 // Release the power button before the shutdown timer fires. 444 // Release the power button before the shutdown timer fires.
(...skipping 18 matching lines...) Expand all
463 EXPECT_EQ(0, NumShutdownRequests()); 463 EXPECT_EQ(0, NumShutdownRequests());
464 464
465 // When the timout fires, we should request a shutdown. 465 // When the timout fires, we should request a shutdown.
466 test_api_->trigger_real_shutdown_timeout(); 466 test_api_->trigger_real_shutdown_timeout();
467 467
468 EXPECT_EQ(1, NumShutdownRequests()); 468 EXPECT_EQ(1, NumShutdownRequests());
469 } 469 }
470 470
471 // Test that we lock the screen and deal with unlocking correctly. 471 // Test that we lock the screen and deal with unlocking correctly.
472 TEST_F(LockStateControllerTest, LockAndUnlock) { 472 TEST_F(LockStateControllerTest, LockAndUnlock) {
473 Initialize(false, user::LOGGED_IN_USER); 473 Initialize(false, LoginStatus::USER);
474 474
475 ExpectUnlockedState(); 475 ExpectUnlockedState();
476 476
477 // Press the power button and check that the lock timer is started and that we 477 // Press the power button and check that the lock timer is started and that we
478 // start lifting the non-screen-locker containers. 478 // start lifting the non-screen-locker containers.
479 PressPowerButton(); 479 PressPowerButton();
480 480
481 ExpectPreLockAnimationStarted(); 481 ExpectPreLockAnimationStarted();
482 EXPECT_TRUE(test_api_->is_lock_cancellable()); 482 EXPECT_TRUE(test_api_->is_lock_cancellable());
483 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests()); 483 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 ExpectUnlockAfterUIDestroyedAnimationStarted(); 523 ExpectUnlockAfterUIDestroyedAnimationStarted();
524 test_animator_->CompleteAllAnimations(true); 524 test_animator_->CompleteAllAnimations(true);
525 ExpectUnlockAfterUIDestroyedAnimationFinished(); 525 ExpectUnlockAfterUIDestroyedAnimationFinished();
526 526
527 ExpectUnlockedState(); 527 ExpectUnlockedState();
528 } 528 }
529 529
530 // Test that we deal with cancelling lock correctly. 530 // Test that we deal with cancelling lock correctly.
531 TEST_F(LockStateControllerTest, LockAndCancel) { 531 TEST_F(LockStateControllerTest, LockAndCancel) {
532 Initialize(false, user::LOGGED_IN_USER); 532 Initialize(false, LoginStatus::USER);
533 533
534 ExpectUnlockedState(); 534 ExpectUnlockedState();
535 535
536 // Press the power button and check that the lock timer is started and that we 536 // Press the power button and check that the lock timer is started and that we
537 // start lifting the non-screen-locker containers. 537 // start lifting the non-screen-locker containers.
538 PressPowerButton(); 538 PressPowerButton();
539 539
540 ExpectPreLockAnimationStarted(); 540 ExpectPreLockAnimationStarted();
541 EXPECT_TRUE(test_api_->is_lock_cancellable()); 541 EXPECT_TRUE(test_api_->is_lock_cancellable());
542 542
543 // forward only half way through 543 // forward only half way through
544 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); 544 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f);
545 545
546 // Release the button before the lock timer fires. 546 // Release the button before the lock timer fires.
547 ReleasePowerButton(); 547 ReleasePowerButton();
548 548
549 ExpectPreLockAnimationCancel(); 549 ExpectPreLockAnimationCancel();
550 550
551 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); 551 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
552 ExpectUnlockedState(); 552 ExpectUnlockedState();
553 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests()); 553 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests());
554 } 554 }
555 555
556 // Test that we deal with cancelling lock correctly. 556 // Test that we deal with cancelling lock correctly.
557 TEST_F(LockStateControllerTest, LockAndCancelAndLockAgain) { 557 TEST_F(LockStateControllerTest, LockAndCancelAndLockAgain) {
558 Initialize(false, user::LOGGED_IN_USER); 558 Initialize(false, LoginStatus::USER);
559 559
560 ExpectUnlockedState(); 560 ExpectUnlockedState();
561 561
562 // Press the power button and check that the lock timer is started and that we 562 // Press the power button and check that the lock timer is started and that we
563 // start lifting the non-screen-locker containers. 563 // start lifting the non-screen-locker containers.
564 PressPowerButton(); 564 PressPowerButton();
565 565
566 ExpectPreLockAnimationStarted(); 566 ExpectPreLockAnimationStarted();
567 EXPECT_TRUE(test_api_->is_lock_cancellable()); 567 EXPECT_TRUE(test_api_->is_lock_cancellable());
568 568
(...skipping 15 matching lines...) Expand all
584 584
585 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests()); 585 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests());
586 586
587 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.6f); 587 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.6f);
588 ExpectPreLockAnimationFinished(); 588 ExpectPreLockAnimationFinished();
589 EXPECT_EQ(1, lock_state_controller_delegate_->num_lock_requests()); 589 EXPECT_EQ(1, lock_state_controller_delegate_->num_lock_requests());
590 } 590 }
591 591
592 // Hold the power button down from the unlocked state to eventual shutdown. 592 // Hold the power button down from the unlocked state to eventual shutdown.
593 TEST_F(LockStateControllerTest, LockToShutdown) { 593 TEST_F(LockStateControllerTest, LockToShutdown) {
594 Initialize(false, user::LOGGED_IN_USER); 594 Initialize(false, LoginStatus::USER);
595 595
596 // Hold the power button and lock the screen. 596 // Hold the power button and lock the screen.
597 PressPowerButton(); 597 PressPowerButton();
598 EXPECT_TRUE(test_api_->is_animating_lock()); 598 EXPECT_TRUE(test_api_->is_animating_lock());
599 599
600 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); 600 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
601 SystemLocks(); 601 SystemLocks();
602 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); 602 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
603 603
604 // When the lock-to-shutdown timeout fires, we should start the shutdown 604 // When the lock-to-shutdown timeout fires, we should start the shutdown
(...skipping 12 matching lines...) Expand all
617 617
618 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 618 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
619 EXPECT_EQ(0, NumShutdownRequests()); 619 EXPECT_EQ(0, NumShutdownRequests());
620 test_api_->trigger_real_shutdown_timeout(); 620 test_api_->trigger_real_shutdown_timeout();
621 EXPECT_EQ(1, NumShutdownRequests()); 621 EXPECT_EQ(1, NumShutdownRequests());
622 } 622 }
623 623
624 // Hold the power button down from the unlocked state to eventual shutdown, 624 // Hold the power button down from the unlocked state to eventual shutdown,
625 // then release the button while system does locking. 625 // then release the button while system does locking.
626 TEST_F(LockStateControllerTest, CancelLockToShutdown) { 626 TEST_F(LockStateControllerTest, CancelLockToShutdown) {
627 Initialize(false, user::LOGGED_IN_USER); 627 Initialize(false, LoginStatus::USER);
628 628
629 PressPowerButton(); 629 PressPowerButton();
630 630
631 // Hold the power button and lock the screen. 631 // Hold the power button and lock the screen.
632 EXPECT_TRUE(test_api_->is_animating_lock()); 632 EXPECT_TRUE(test_api_->is_animating_lock());
633 633
634 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); 634 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
635 SystemLocks(); 635 SystemLocks();
636 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, 0.5f); 636 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, 0.5f);
637 637
638 // Power button is released while system attempts to lock. 638 // Power button is released while system attempts to lock.
639 ReleasePowerButton(); 639 ReleasePowerButton();
640 640
641 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); 641 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
642 642
643 EXPECT_FALSE(lock_state_controller_->ShutdownRequested()); 643 EXPECT_FALSE(lock_state_controller_->ShutdownRequested());
644 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); 644 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running());
645 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); 645 EXPECT_FALSE(test_api_->shutdown_timer_is_running());
646 } 646 }
647 647
648 // TODO(bruthig): Investigate why this hangs on Windows 8 and whether it can be 648 // TODO(bruthig): Investigate why this hangs on Windows 8 and whether it can be
649 // safely enabled on OS_WIN. 649 // safely enabled on OS_WIN.
650 #ifndef OS_WIN 650 #ifndef OS_WIN
651 // Test that we handle the case where lock requests are ignored. 651 // Test that we handle the case where lock requests are ignored.
652 TEST_F(LockStateControllerTest, Lock) { 652 TEST_F(LockStateControllerTest, Lock) {
653 Initialize(false, user::LOGGED_IN_USER); 653 Initialize(false, LoginStatus::USER);
654 654
655 // Hold the power button and lock the screen. 655 // Hold the power button and lock the screen.
656 PressPowerButton(); 656 PressPowerButton();
657 ExpectPreLockAnimationStarted(); 657 ExpectPreLockAnimationStarted();
658 658
659 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); 659 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
660 660
661 EXPECT_EQ(1, lock_state_controller_delegate_->num_lock_requests()); 661 EXPECT_EQ(1, lock_state_controller_delegate_->num_lock_requests());
662 EXPECT_TRUE(test_api_->lock_fail_timer_is_running()); 662 EXPECT_TRUE(test_api_->lock_fail_timer_is_running());
663 // We shouldn't start the lock-to-shutdown timer until the screen has actually 663 // We shouldn't start the lock-to-shutdown timer until the screen has actually
664 // been locked and this was animated. 664 // been locked and this was animated.
665 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); 665 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running());
666 666
667 // Act as if the request timed out. 667 // Act as if the request timed out.
668 EXPECT_DEATH(test_api_->trigger_lock_fail_timeout(), ""); 668 EXPECT_DEATH(test_api_->trigger_lock_fail_timeout(), "");
669 } 669 }
670 #endif 670 #endif
671 671
672 // Test the basic operation of the lock button (not logged in). 672 // Test the basic operation of the lock button (not logged in).
673 TEST_F(LockStateControllerTest, LockButtonBasicNotLoggedIn) { 673 TEST_F(LockStateControllerTest, LockButtonBasicNotLoggedIn) {
674 // The lock button shouldn't do anything if we aren't logged in. 674 // The lock button shouldn't do anything if we aren't logged in.
675 Initialize(false, user::LOGGED_IN_NONE); 675 Initialize(false, LoginStatus::NOT_LOGGED_IN);
676 676
677 PressLockButton(); 677 PressLockButton();
678 EXPECT_FALSE(test_api_->is_animating_lock()); 678 EXPECT_FALSE(test_api_->is_animating_lock());
679 ReleaseLockButton(); 679 ReleaseLockButton();
680 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests()); 680 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests());
681 } 681 }
682 682
683 // Test the basic operation of the lock button (guest). 683 // Test the basic operation of the lock button (guest).
684 TEST_F(LockStateControllerTest, LockButtonBasicGuest) { 684 TEST_F(LockStateControllerTest, LockButtonBasicGuest) {
685 // The lock button shouldn't do anything when we're logged in as a guest. 685 // The lock button shouldn't do anything when we're logged in as a guest.
686 Initialize(false, user::LOGGED_IN_GUEST); 686 Initialize(false, LoginStatus::GUEST);
687 687
688 PressLockButton(); 688 PressLockButton();
689 EXPECT_FALSE(test_api_->is_animating_lock()); 689 EXPECT_FALSE(test_api_->is_animating_lock());
690 ReleaseLockButton(); 690 ReleaseLockButton();
691 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests()); 691 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests());
692 } 692 }
693 693
694 // Test the basic operation of the lock button. 694 // Test the basic operation of the lock button.
695 TEST_F(LockStateControllerTest, LockButtonBasic) { 695 TEST_F(LockStateControllerTest, LockButtonBasic) {
696 // If we're logged in as a regular user, we should start the lock timer and 696 // If we're logged in as a regular user, we should start the lock timer and
697 // the pre-lock animation. 697 // the pre-lock animation.
698 Initialize(false, user::LOGGED_IN_USER); 698 Initialize(false, LoginStatus::USER);
699 699
700 PressLockButton(); 700 PressLockButton();
701 ExpectPreLockAnimationStarted(); 701 ExpectPreLockAnimationStarted();
702 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); 702 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f);
703 703
704 // If the button is released immediately, we shouldn't lock the screen. 704 // If the button is released immediately, we shouldn't lock the screen.
705 ReleaseLockButton(); 705 ReleaseLockButton();
706 ExpectPreLockAnimationCancel(); 706 ExpectPreLockAnimationCancel();
707 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); 707 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
708 708
(...skipping 25 matching lines...) Expand all
734 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); 734 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
735 ExpectPostLockAnimationFinished(); 735 ExpectPostLockAnimationFinished();
736 736
737 PressLockButton(); 737 PressLockButton();
738 ReleaseLockButton(); 738 ReleaseLockButton();
739 ExpectPostLockAnimationFinished(); 739 ExpectPostLockAnimationFinished();
740 } 740 }
741 741
742 // Test that the power button takes priority over the lock button. 742 // Test that the power button takes priority over the lock button.
743 TEST_F(LockStateControllerTest, PowerButtonPreemptsLockButton) { 743 TEST_F(LockStateControllerTest, PowerButtonPreemptsLockButton) {
744 Initialize(false, user::LOGGED_IN_USER); 744 Initialize(false, LoginStatus::USER);
745 745
746 // While the lock button is down, hold the power button. 746 // While the lock button is down, hold the power button.
747 PressLockButton(); 747 PressLockButton();
748 ExpectPreLockAnimationStarted(); 748 ExpectPreLockAnimationStarted();
749 749
750 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f); 750 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f);
751 ExpectPreLockAnimationRunning(); 751 ExpectPreLockAnimationRunning();
752 752
753 PressPowerButton(); 753 PressPowerButton();
754 ExpectPreLockAnimationRunning(); 754 ExpectPreLockAnimationRunning();
(...skipping 29 matching lines...) Expand all
784 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f); 784 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f);
785 785
786 ReleaseLockButton(); 786 ReleaseLockButton();
787 ExpectPreLockAnimationCancel(); 787 ExpectPreLockAnimationCancel();
788 } 788 }
789 789
790 // When the screen is locked without going through the usual power-button 790 // When the screen is locked without going through the usual power-button
791 // slow-close path (e.g. via the wrench menu), test that we still show the 791 // slow-close path (e.g. via the wrench menu), test that we still show the
792 // fast-close animation. 792 // fast-close animation.
793 TEST_F(LockStateControllerTest, LockWithoutButton) { 793 TEST_F(LockStateControllerTest, LockWithoutButton) {
794 Initialize(false, user::LOGGED_IN_USER); 794 Initialize(false, LoginStatus::USER);
795 lock_state_controller_->OnStartingLock(); 795 lock_state_controller_->OnStartingLock();
796 796
797 ExpectPreLockAnimationStarted(); 797 ExpectPreLockAnimationStarted();
798 EXPECT_FALSE(test_api_->is_lock_cancellable()); 798 EXPECT_FALSE(test_api_->is_lock_cancellable());
799 EXPECT_LT(0u, test_animator_->GetAnimationCount()); 799 EXPECT_LT(0u, test_animator_->GetAnimationCount());
800 800
801 test_animator_->CompleteAllAnimations(true); 801 test_animator_->CompleteAllAnimations(true);
802 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests()); 802 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests());
803 } 803 }
804 804
805 // When we hear that the process is exiting but we haven't had a chance to 805 // When we hear that the process is exiting but we haven't had a chance to
806 // display an animation, we should just blank the screen. 806 // display an animation, we should just blank the screen.
807 TEST_F(LockStateControllerTest, ShutdownWithoutButton) { 807 TEST_F(LockStateControllerTest, ShutdownWithoutButton) {
808 Initialize(false, user::LOGGED_IN_USER); 808 Initialize(false, LoginStatus::USER);
809 lock_state_controller_->OnAppTerminating(); 809 lock_state_controller_->OnAppTerminating();
810 810
811 EXPECT_TRUE( 811 EXPECT_TRUE(
812 test_animator_->AreContainersAnimated( 812 test_animator_->AreContainersAnimated(
813 SessionStateAnimator::kAllNonRootContainersMask, 813 SessionStateAnimator::kAllNonRootContainersMask,
814 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); 814 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY));
815 GenerateMouseMoveEvent(); 815 GenerateMouseMoveEvent();
816 EXPECT_FALSE(cursor_visible()); 816 EXPECT_FALSE(cursor_visible());
817 } 817 }
818 818
819 // Test that we display the fast-close animation and shut down when we get an 819 // Test that we display the fast-close animation and shut down when we get an
820 // outside request to shut down (e.g. from the login or lock screen). 820 // outside request to shut down (e.g. from the login or lock screen).
821 TEST_F(LockStateControllerTest, RequestShutdownFromLoginScreen) { 821 TEST_F(LockStateControllerTest, RequestShutdownFromLoginScreen) {
822 Initialize(false, user::LOGGED_IN_NONE); 822 Initialize(false, LoginStatus::NOT_LOGGED_IN);
823 823
824 lock_state_controller_->RequestShutdown(); 824 lock_state_controller_->RequestShutdown();
825 825
826 ExpectShutdownAnimationStarted(); 826 ExpectShutdownAnimationStarted();
827 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 827 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
828 828
829 GenerateMouseMoveEvent(); 829 GenerateMouseMoveEvent();
830 EXPECT_FALSE(cursor_visible()); 830 EXPECT_FALSE(cursor_visible());
831 831
832 EXPECT_EQ(0, NumShutdownRequests()); 832 EXPECT_EQ(0, NumShutdownRequests());
833 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 833 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
834 test_api_->trigger_real_shutdown_timeout(); 834 test_api_->trigger_real_shutdown_timeout();
835 EXPECT_EQ(1, NumShutdownRequests()); 835 EXPECT_EQ(1, NumShutdownRequests());
836 } 836 }
837 837
838 TEST_F(LockStateControllerTest, RequestShutdownFromLockScreen) { 838 TEST_F(LockStateControllerTest, RequestShutdownFromLockScreen) {
839 Initialize(false, user::LOGGED_IN_USER); 839 Initialize(false, LoginStatus::USER);
840 840
841 SystemLocks(); 841 SystemLocks();
842 842
843 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 843 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
844 ExpectPostLockAnimationFinished(); 844 ExpectPostLockAnimationFinished();
845 845
846 lock_state_controller_->RequestShutdown(); 846 lock_state_controller_->RequestShutdown();
847 847
848 ExpectShutdownAnimationStarted(); 848 ExpectShutdownAnimationStarted();
849 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 849 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
850 850
851 GenerateMouseMoveEvent(); 851 GenerateMouseMoveEvent();
852 EXPECT_FALSE(cursor_visible()); 852 EXPECT_FALSE(cursor_visible());
853 853
854 EXPECT_EQ(0, NumShutdownRequests()); 854 EXPECT_EQ(0, NumShutdownRequests());
855 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 855 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
856 test_api_->trigger_real_shutdown_timeout(); 856 test_api_->trigger_real_shutdown_timeout();
857 EXPECT_EQ(1, NumShutdownRequests()); 857 EXPECT_EQ(1, NumShutdownRequests());
858 } 858 }
859 859
860 TEST_F(LockStateControllerTest, RequestAndCancelShutdownFromLockScreen) { 860 TEST_F(LockStateControllerTest, RequestAndCancelShutdownFromLockScreen) {
861 Initialize(false, user::LOGGED_IN_USER); 861 Initialize(false, LoginStatus::USER);
862 862
863 SystemLocks(); 863 SystemLocks();
864 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 864 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
865 ExpectLockedState(); 865 ExpectLockedState();
866 866
867 // Press the power button and check that we start the shutdown timer. 867 // Press the power button and check that we start the shutdown timer.
868 PressPowerButton(); 868 PressPowerButton();
869 EXPECT_FALSE(test_api_->is_animating_lock()); 869 EXPECT_FALSE(test_api_->is_animating_lock());
870 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); 870 EXPECT_TRUE(test_api_->shutdown_timer_is_running());
871 871
872 ExpectShutdownAnimationStarted(); 872 ExpectShutdownAnimationStarted();
873 873
874 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f); 874 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f);
875 875
876 // Release the power button before the shutdown timer fires. 876 // Release the power button before the shutdown timer fires.
877 ReleasePowerButton(); 877 ReleasePowerButton();
878 878
879 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); 879 EXPECT_FALSE(test_api_->shutdown_timer_is_running());
880 880
881 ExpectShutdownAnimationCancel(); 881 ExpectShutdownAnimationCancel();
882 882
883 Advance(SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); 883 Advance(SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN);
884 ExpectLockedState(); 884 ExpectLockedState();
885 } 885 }
886 886
887 // Test that we ignore power button presses when the screen is turned off. 887 // Test that we ignore power button presses when the screen is turned off.
888 TEST_F(LockStateControllerTest, IgnorePowerButtonIfScreenIsOff) { 888 TEST_F(LockStateControllerTest, IgnorePowerButtonIfScreenIsOff) {
889 Initialize(false, user::LOGGED_IN_USER); 889 Initialize(false, LoginStatus::USER);
890 890
891 // When the screen brightness is at 0%, we shouldn't do anything in response 891 // When the screen brightness is at 0%, we shouldn't do anything in response
892 // to power button presses. 892 // to power button presses.
893 power_button_controller_->OnScreenBrightnessChanged(0.0); 893 power_button_controller_->OnScreenBrightnessChanged(0.0);
894 PressPowerButton(); 894 PressPowerButton();
895 EXPECT_FALSE(test_api_->is_animating_lock()); 895 EXPECT_FALSE(test_api_->is_animating_lock());
896 ReleasePowerButton(); 896 ReleasePowerButton();
897 897
898 // After increasing the brightness to 10%, we should start the timer like 898 // After increasing the brightness to 10%, we should start the timer like
899 // usual. 899 // usual.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 external_display.set_current_mode(external_display.modes().back().get()); 940 external_display.set_current_mode(external_display.modes().back().get());
941 power_button_controller_->OnDisplayModeChanged(outputs); 941 power_button_controller_->OnDisplayModeChanged(outputs);
942 PressPowerButton(); 942 PressPowerButton();
943 EXPECT_TRUE(test_api_->is_animating_lock()); 943 EXPECT_TRUE(test_api_->is_animating_lock());
944 ReleasePowerButton(); 944 ReleasePowerButton();
945 } 945 }
946 #endif 946 #endif
947 947
948 // Test that hidden background appears and revers correctly on lock/cancel. 948 // Test that hidden background appears and revers correctly on lock/cancel.
949 TEST_F(LockStateControllerTest, TestHiddenBackgroundLockCancel) { 949 TEST_F(LockStateControllerTest, TestHiddenBackgroundLockCancel) {
950 Initialize(false, user::LOGGED_IN_USER); 950 Initialize(false, LoginStatus::USER);
951 HideBackground(); 951 HideBackground();
952 952
953 ExpectUnlockedState(); 953 ExpectUnlockedState();
954 PressPowerButton(); 954 PressPowerButton();
955 955
956 ExpectPreLockAnimationStarted(); 956 ExpectPreLockAnimationStarted();
957 ExpectBackgroundIsShowing(); 957 ExpectBackgroundIsShowing();
958 958
959 // Forward only half way through. 959 // Forward only half way through.
960 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); 960 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f);
961 961
962 // Release the button before the lock timer fires. 962 // Release the button before the lock timer fires.
963 ReleasePowerButton(); 963 ReleasePowerButton();
964 ExpectPreLockAnimationCancel(); 964 ExpectPreLockAnimationCancel();
965 ExpectBackgroundIsHiding(); 965 ExpectBackgroundIsHiding();
966 966
967 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); 967 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS);
968 968
969 // When the CancelPrelockAnimation sequence finishes it queues up a 969 // When the CancelPrelockAnimation sequence finishes it queues up a
970 // restore background visibility sequence when the background is hidden. 970 // restore background visibility sequence when the background is hidden.
971 ExpectRestoringBackgroundVisibility(); 971 ExpectRestoringBackgroundVisibility();
972 972
973 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 973 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
974 974
975 ExpectUnlockedState(); 975 ExpectUnlockedState();
976 } 976 }
977 977
978 // Test that hidden background appears and revers correctly on lock/unlock. 978 // Test that hidden background appears and revers correctly on lock/unlock.
979 TEST_F(LockStateControllerTest, TestHiddenBackgroundLockUnlock) { 979 TEST_F(LockStateControllerTest, TestHiddenBackgroundLockUnlock) {
980 Initialize(false, user::LOGGED_IN_USER); 980 Initialize(false, LoginStatus::USER);
981 HideBackground(); 981 HideBackground();
982 982
983 ExpectUnlockedState(); 983 ExpectUnlockedState();
984 984
985 // Press the power button and check that the lock timer is started and that we 985 // Press the power button and check that the lock timer is started and that we
986 // start lifting the non-screen-locker containers. 986 // start lifting the non-screen-locker containers.
987 PressPowerButton(); 987 PressPowerButton();
988 988
989 ExpectPreLockAnimationStarted(); 989 ExpectPreLockAnimationStarted();
990 ExpectBackgroundIsShowing(); 990 ExpectBackgroundIsShowing();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 PressVolumeDown(); 1069 PressVolumeDown();
1070 PressPowerButton(); 1070 PressPowerButton();
1071 ReleasePowerButton(); 1071 ReleasePowerButton();
1072 ReleaseVolumeDown(); 1072 ReleaseVolumeDown();
1073 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); 1073 EXPECT_EQ(1, delegate->handle_take_screenshot_count());
1074 } 1074 }
1075 1075
1076 // Tests that a lock action is cancellable when quick lock is turned on and 1076 // Tests that a lock action is cancellable when quick lock is turned on and
1077 // maximize mode is not active. 1077 // maximize mode is not active.
1078 TEST_F(LockStateControllerTest, QuickLockWhileNotInMaximizeMode) { 1078 TEST_F(LockStateControllerTest, QuickLockWhileNotInMaximizeMode) {
1079 Initialize(false, user::LOGGED_IN_USER); 1079 Initialize(false, LoginStatus::USER);
1080 power_button_controller_->set_enable_quick_lock_for_test(true); 1080 power_button_controller_->set_enable_quick_lock_for_test(true);
1081 EnableMaximizeMode(false); 1081 EnableMaximizeMode(false);
1082 1082
1083 PressPowerButton(); 1083 PressPowerButton();
1084 1084
1085 ExpectPreLockAnimationStarted(); 1085 ExpectPreLockAnimationStarted();
1086 EXPECT_TRUE(test_api_->is_animating_lock()); 1086 EXPECT_TRUE(test_api_->is_animating_lock());
1087 EXPECT_TRUE(lock_state_controller_->CanCancelLockAnimation()); 1087 EXPECT_TRUE(lock_state_controller_->CanCancelLockAnimation());
1088 1088
1089 ReleasePowerButton(); 1089 ReleasePowerButton();
1090 1090
1091 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests()); 1091 EXPECT_EQ(0, lock_state_controller_delegate_->num_lock_requests());
1092 } 1092 }
1093 1093
1094 // Tests that a lock action is not cancellable when quick lock is turned on and 1094 // Tests that a lock action is not cancellable when quick lock is turned on and
1095 // maximize mode is active. 1095 // maximize mode is active.
1096 TEST_F(LockStateControllerTest, QuickLockWhileInMaximizeMode) { 1096 TEST_F(LockStateControllerTest, QuickLockWhileInMaximizeMode) {
1097 Initialize(false, user::LOGGED_IN_USER); 1097 Initialize(false, LoginStatus::USER);
1098 power_button_controller_->set_enable_quick_lock_for_test(true); 1098 power_button_controller_->set_enable_quick_lock_for_test(true);
1099 EnableMaximizeMode(true); 1099 EnableMaximizeMode(true);
1100 1100
1101 PressPowerButton(); 1101 PressPowerButton();
1102 1102
1103 ExpectPreLockAnimationStarted(); 1103 ExpectPreLockAnimationStarted();
1104 EXPECT_TRUE(test_api_->is_animating_lock()); 1104 EXPECT_TRUE(test_api_->is_animating_lock());
1105 EXPECT_FALSE(lock_state_controller_->CanCancelLockAnimation()); 1105 EXPECT_FALSE(lock_state_controller_->CanCancelLockAnimation());
1106 1106
1107 ReleasePowerButton(); 1107 ReleasePowerButton();
1108 1108
1109 ExpectPreLockAnimationStarted(); 1109 ExpectPreLockAnimationStarted();
1110 1110
1111 test_animator_->CompleteAllAnimations(true); 1111 test_animator_->CompleteAllAnimations(true);
1112 EXPECT_EQ(1, lock_state_controller_delegate_->num_lock_requests()); 1112 EXPECT_EQ(1, lock_state_controller_delegate_->num_lock_requests());
1113 } 1113 }
1114 1114
1115 } // namespace test 1115 } // namespace test
1116 } // namespace ash 1116 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/lock_state_controller.cc ('k') | ash/wm/overlay_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698