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

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

Issue 2815043002: Removes ShellPort::IsRunningInMash() (Closed)
Patch Set: dont set instance_ in constructor Created 3 years, 8 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 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/public/cpp/config.h"
10 #include "ash/session/session_controller.h" 11 #include "ash/session/session_controller.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/shell_port.h"
13 #include "ash/shutdown_controller.h" 13 #include "ash/shutdown_controller.h"
14 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
15 #include "ash/test/lock_state_controller_test_api.h" 15 #include "ash/test/lock_state_controller_test_api.h"
16 #include "ash/test/test_screenshot_delegate.h" 16 #include "ash/test/test_screenshot_delegate.h"
17 #include "ash/test/test_session_controller_client.h" 17 #include "ash/test/test_session_controller_client.h"
18 #include "ash/test/test_session_state_animator.h" 18 #include "ash/test/test_session_state_animator.h"
19 #include "ash/test/test_shell_delegate.h" 19 #include "ash/test/test_shell_delegate.h"
20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 20 #include "ash/wm/maximize_mode/maximize_mode_controller.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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 test_api_.reset(new LockStateControllerTestApi(lock_state_controller_)); 86 test_api_.reset(new LockStateControllerTestApi(lock_state_controller_));
87 test_api_->set_shutdown_controller(&test_shutdown_controller_); 87 test_api_->set_shutdown_controller(&test_shutdown_controller_);
88 88
89 power_button_controller_ = Shell::Get()->power_button_controller(); 89 power_button_controller_ = Shell::Get()->power_button_controller();
90 90
91 shell_delegate_ = 91 shell_delegate_ =
92 static_cast<TestShellDelegate*>(Shell::Get()->shell_delegate()); 92 static_cast<TestShellDelegate*>(Shell::Get()->shell_delegate());
93 } 93 }
94 94
95 void TearDown() override { 95 void TearDown() override {
96 const bool is_mash = ShellPort::Get()->IsRunningInMash(); 96 const bool is_mash = Shell::GetAshConfig() == Config::MASH;
97 AshTestBase::TearDown(); 97 AshTestBase::TearDown();
98 // Mash shuts down DBus during normal destruction. 98 // Mash shuts down DBus during normal destruction.
99 if (!is_mash) 99 if (!is_mash)
100 chromeos::DBusThreadManager::Shutdown(); 100 chromeos::DBusThreadManager::Shutdown();
101 } 101 }
102 102
103 protected: 103 protected:
104 void GenerateMouseMoveEvent() { 104 void GenerateMouseMoveEvent() {
105 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 105 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
106 generator.MoveMouseTo(10, 10); 106 generator.MoveMouseTo(10, 10);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 // Hold the button again and check that we start shutting down. 395 // Hold the button again and check that we start shutting down.
396 PressPowerButton(); 396 PressPowerButton();
397 397
398 ExpectShutdownAnimationStarted(); 398 ExpectShutdownAnimationStarted();
399 399
400 EXPECT_EQ(0, NumShutdownRequests()); 400 EXPECT_EQ(0, NumShutdownRequests());
401 // Make sure a mouse move event won't show the cursor. 401 // Make sure a mouse move event won't show the cursor.
402 GenerateMouseMoveEvent(); 402 GenerateMouseMoveEvent();
403 // TODO: CursorManager not created in mash. http://crbug.com/631103. 403 // TODO: CursorManager not created in mash. http://crbug.com/631103.
404 if (!ShellPort::Get()->IsRunningInMash()) 404 if (Shell::GetAshConfig() != Config::MASH)
405 EXPECT_FALSE(cursor_visible()); 405 EXPECT_FALSE(cursor_visible());
406 406
407 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 407 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
408 test_api_->trigger_real_shutdown_timeout(); 408 test_api_->trigger_real_shutdown_timeout();
409 EXPECT_EQ(1, NumShutdownRequests()); 409 EXPECT_EQ(1, NumShutdownRequests());
410 } 410 }
411 411
412 // Test that we start shutting down immediately if the power button is pressed 412 // Test that we start shutting down immediately if the power button is pressed
413 // while we're not logged in on an unofficial system. 413 // while we're not logged in on an unofficial system.
414 TEST_F(LockStateControllerTest, LegacyNotLoggedIn) { 414 TEST_F(LockStateControllerTest, LegacyNotLoggedIn) {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // display an animation, we should just blank the screen. 805 // display an animation, we should just blank the screen.
806 TEST_F(LockStateControllerTest, ShutdownWithoutButton) { 806 TEST_F(LockStateControllerTest, ShutdownWithoutButton) {
807 Initialize(false, LoginStatus::USER); 807 Initialize(false, LoginStatus::USER);
808 lock_state_controller_->OnAppTerminating(); 808 lock_state_controller_->OnAppTerminating();
809 809
810 EXPECT_TRUE(test_animator_->AreContainersAnimated( 810 EXPECT_TRUE(test_animator_->AreContainersAnimated(
811 SessionStateAnimator::kAllNonRootContainersMask, 811 SessionStateAnimator::kAllNonRootContainersMask,
812 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); 812 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY));
813 GenerateMouseMoveEvent(); 813 GenerateMouseMoveEvent();
814 // TODO: CursorManager not created in mash. http://crbug.com/631103. 814 // TODO: CursorManager not created in mash. http://crbug.com/631103.
815 if (!ShellPort::Get()->IsRunningInMash()) 815 if (Shell::GetAshConfig() != Config::MASH)
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, LoginStatus::NOT_LOGGED_IN); 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 // TODO: CursorManager not created in mash. http://crbug.com/631103. 830 // TODO: CursorManager not created in mash. http://crbug.com/631103.
831 if (!ShellPort::Get()->IsRunningInMash()) 831 if (Shell::GetAshConfig() != Config::MASH)
832 EXPECT_FALSE(cursor_visible()); 832 EXPECT_FALSE(cursor_visible());
833 833
834 EXPECT_EQ(0, NumShutdownRequests()); 834 EXPECT_EQ(0, NumShutdownRequests());
835 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 835 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
836 test_api_->trigger_real_shutdown_timeout(); 836 test_api_->trigger_real_shutdown_timeout();
837 EXPECT_EQ(1, NumShutdownRequests()); 837 EXPECT_EQ(1, NumShutdownRequests());
838 } 838 }
839 839
840 TEST_F(LockStateControllerTest, RequestShutdownFromLockScreen) { 840 TEST_F(LockStateControllerTest, RequestShutdownFromLockScreen) {
841 Initialize(false, LoginStatus::USER); 841 Initialize(false, LoginStatus::USER);
842 842
843 SystemLocks(); 843 SystemLocks();
844 844
845 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 845 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
846 ExpectPostLockAnimationFinished(); 846 ExpectPostLockAnimationFinished();
847 847
848 lock_state_controller_->RequestShutdown(); 848 lock_state_controller_->RequestShutdown();
849 849
850 ExpectShutdownAnimationStarted(); 850 ExpectShutdownAnimationStarted();
851 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 851 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
852 852
853 GenerateMouseMoveEvent(); 853 GenerateMouseMoveEvent();
854 // TODO: CursorManager not created in mash. http://crbug.com/631103. 854 // TODO: CursorManager not created in mash. http://crbug.com/631103.
855 if (!ShellPort::Get()->IsRunningInMash()) 855 if (Shell::GetAshConfig() != Config::MASH)
856 EXPECT_FALSE(cursor_visible()); 856 EXPECT_FALSE(cursor_visible());
857 857
858 EXPECT_EQ(0, NumShutdownRequests()); 858 EXPECT_EQ(0, NumShutdownRequests());
859 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 859 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
860 test_api_->trigger_real_shutdown_timeout(); 860 test_api_->trigger_real_shutdown_timeout();
861 EXPECT_EQ(1, NumShutdownRequests()); 861 EXPECT_EQ(1, NumShutdownRequests());
862 } 862 }
863 863
864 TEST_F(LockStateControllerTest, RequestAndCancelShutdownFromLockScreen) { 864 TEST_F(LockStateControllerTest, RequestAndCancelShutdownFromLockScreen) {
865 Initialize(false, LoginStatus::USER); 865 Initialize(false, LoginStatus::USER);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1024
1025 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 1025 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
1026 1026
1027 ExpectUnlockAfterUIDestroyedAnimationFinished(); 1027 ExpectUnlockAfterUIDestroyedAnimationFinished();
1028 1028
1029 ExpectUnlockedState(); 1029 ExpectUnlockedState();
1030 } 1030 }
1031 1031
1032 TEST_F(LockStateControllerTest, Screenshot) { 1032 TEST_F(LockStateControllerTest, Screenshot) {
1033 // TODO: fails because of no screenshot in mash. http://crbug.com/698033. 1033 // TODO: fails because of no screenshot in mash. http://crbug.com/698033.
1034 if (ShellPort::Get()->IsRunningInMash()) 1034 if (Shell::GetAshConfig() == Config::MASH)
1035 return; 1035 return;
1036 1036
1037 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); 1037 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate();
1038 delegate->set_can_take_screenshot(true); 1038 delegate->set_can_take_screenshot(true);
1039 1039
1040 EnableMaximizeMode(false); 1040 EnableMaximizeMode(false);
1041 1041
1042 // Screenshot handling should not be active when not in maximize mode. 1042 // Screenshot handling should not be active when not in maximize mode.
1043 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); 1043 ASSERT_EQ(0, delegate->handle_take_screenshot_count());
1044 PressVolumeDown(); 1044 PressVolumeDown();
(...skipping 29 matching lines...) Expand all
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/immersive_fullscreen_controller_unittest.cc ('k') | ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698