diff options
author | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 22:32:34 +0000 |
---|---|---|
committer | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 22:32:34 +0000 |
commit | 6f6714e064b0fbbbc0a3f07ebcc1359c30d55f91 (patch) | |
tree | 0fe99a8df58caf5eb07912959e65f8bf64cabda4 /chrome/browser/chromeos | |
parent | e61b4baa6f2baba95804eff4a615ec1fbca873a2 (diff) | |
download | chromium_src-6f6714e064b0fbbbc0a3f07ebcc1359c30d55f91.zip chromium_src-6f6714e064b0fbbbc0a3f07ebcc1359c30d55f91.tar.gz chromium_src-6f6714e064b0fbbbc0a3f07ebcc1359c30d55f91.tar.bz2 |
Do not enforce auto-reboot policies in non-kiosk-app sessions
This CL replaces the two auto-reboot policies added in M27 with new ones
that work in exactly the same way as before but are not enforced when a
non-kiosk-app session is in progress.
BUG=243166
TEST=Manual in VM and unit tests
Review URL: https://chromiumcodereview.appspot.com/15955006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
3 files changed, 352 insertions, 104 deletions
diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager.cc b/chrome/browser/chromeos/system/automatic_reboot_manager.cc index 635b01d..b13db1c 100644 --- a/chrome/browser/chromeos/system/automatic_reboot_manager.cc +++ b/chrome/browser/chromeos/system/automatic_reboot_manager.cc @@ -377,6 +377,12 @@ void AutomaticRebootManager::MaybeReboot(bool ignore_session) { } void AutomaticRebootManager::Reboot() { + // If a non-kiosk-app session is in progress, do not reboot. + if (UserManager::Get()->IsUserLoggedIn() && + !UserManager::Get()->IsLoggedInAsKioskApp()) { + return; + } + login_screen_idle_timer_.reset(); grace_start_timer_.reset(); grace_end_timer_.reset(); diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager.h b/chrome/browser/chromeos/system/automatic_reboot_manager.h index 1c82cbb..9d29262 100644 --- a/chrome/browser/chromeos/system/automatic_reboot_manager.h +++ b/chrome/browser/chromeos/system/automatic_reboot_manager.h @@ -53,6 +53,11 @@ namespace system { // a session, the user suspends the device). If reboots remain inhibited for the // entire grace period, a reboot is unconditionally performed at its end. // +// Note: Currently, automatic reboots are only enabled while the login screen is +// being shown or a kiosk app session is in progress. This will change in the +// future and the policy will always apply, regardless of whether a session of +// any particular type is in progress or not. http://crbug.com/244972 +// // Reboots may be scheduled and canceled at any time. This causes the time at // which a reboot should be requested and the grace period that follows it to // be recalculated. diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc index c1247d2..fbd2178 100644 --- a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc +++ b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc @@ -147,6 +147,8 @@ class AutomaticRebootManagerBasicTest : public testing::Test { void VerifyGracePeriod(const base::TimeDelta& start_uptime) const; bool is_user_logged_in_; + bool is_logged_in_as_kiosk_app_; + // The uptime is read in the blocking thread pool and then processed on the // UI thread. This causes the UI thread to start processing the uptime when it // has increased by a small offset already. The offset is calculated and @@ -185,10 +187,19 @@ class AutomaticRebootManagerBasicTest : public testing::Test { ScopedUserManagerEnabler user_manager_enabler_; }; -// This class runs each test case twice, once with and once without a logged-in -// user. -class AutomaticRebootManagerTest : public AutomaticRebootManagerBasicTest, - public testing::WithParamInterface<bool> { +enum AutomaticRebootManagerTestScenario { + AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, + AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, + AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION, +}; + +// This class runs each test case three times: +// * once while the login screen is being shown +// * once while a kiosk app session is in progress +// * once while a non-kiosk-app session is in progress +class AutomaticRebootManagerTest + : public AutomaticRebootManagerBasicTest, + public testing::WithParamInterface<AutomaticRebootManagerTestScenario> { protected: AutomaticRebootManagerTest(); virtual ~AutomaticRebootManagerTest(); @@ -318,6 +329,7 @@ base::TimeTicks MockTimeTickClock::NowTicks() { AutomaticRebootManagerBasicTest::AutomaticRebootManagerBasicTest() : is_user_logged_in_(false), + is_logged_in_as_kiosk_app_(false), task_runner_(new MockTimeSingleThreadTaskRunner), power_manager_client_(NULL), update_engine_client_(NULL), @@ -354,6 +366,8 @@ void AutomaticRebootManagerBasicTest::SetUp() { EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) .WillRepeatedly(ReturnPointee(&is_user_logged_in_)); + EXPECT_CALL(*mock_user_manager_, IsLoggedInAsKioskApp()) + .WillRepeatedly(ReturnPointee(&is_logged_in_as_kiosk_app_)); } void AutomaticRebootManagerBasicTest::TearDown() { @@ -537,15 +551,28 @@ void AutomaticRebootManagerBasicTest::SetUpdateStatusNeedReboot() { } AutomaticRebootManagerTest::AutomaticRebootManagerTest() { - is_user_logged_in_ = GetParam(); + switch (GetParam()) { + case AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN: + is_user_logged_in_ = false; + is_logged_in_as_kiosk_app_ = false; + break; + case AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION: + is_user_logged_in_ = true; + is_logged_in_as_kiosk_app_ = true; + break; + case AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION: + is_user_logged_in_ = true; + is_logged_in_as_kiosk_app_ = false; + break; + } } AutomaticRebootManagerTest::~AutomaticRebootManagerTest() { } // Chrome is showing the login screen. The current uptime is 12 hours. -// Verifies that the idle timer is running. Further verifies that when a user -// logs in, the idle timer is stopped. +// Verifies that the idle timer is running. Further verifies that when a kiosk +// app session begins, the idle timer is stopped. TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) { task_runner_->SetUptime(base::TimeDelta::FromHours(12)); @@ -553,7 +580,32 @@ TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) { // idle timer is started. CreateAutomaticRebootManager(false); - // Notify that a user has logged in. + // Notify that a kiosk app session has been started. + is_user_logged_in_ = true; + is_logged_in_as_kiosk_app_ = true; + automatic_reboot_manager_->Observe( + chrome::NOTIFICATION_LOGIN_USER_CHANGED, + content::Source<AutomaticRebootManagerBasicTest>(this), + content::NotificationService::NoDetails()); + + // Verify that the login screen idle timer is stopped. + VerifyLoginScreenIdleTimerIsStopped(); + + // Verify that the device does not reboot eventually. + FastForwardUntilNoTasksRemain(false); +} + +// Chrome is showing the login screen. The current uptime is 12 hours. +// Verifies that the idle timer is running. Further verifies that when a +// non-kiosk-app session begins, the idle timer is stopped. +TEST_F(AutomaticRebootManagerBasicTest, NonKioskLoginStopsIdleTimer) { + task_runner_->SetUptime(base::TimeDelta::FromHours(12)); + + // Verify that the device does not reboot immediately and the login screen + // idle timer is started. + CreateAutomaticRebootManager(false); + + // Notify that a non-kiosk-app session has been started. is_user_logged_in_ = true; automatic_reboot_manager_->Observe( chrome::NOTIFICATION_LOGIN_USER_CHANGED, @@ -600,11 +652,12 @@ TEST_F(AutomaticRebootManagerBasicTest, UserActivityResetsIdleTimer) { FastForwardBy(base::TimeDelta::FromSeconds(60), true); } -// Chrome is running a user session. The current uptime is 10 days. +// Chrome is running a kiosk app session. The current uptime is 10 days. // Verifies that when the device is suspended and then resumes, it does not // immediately reboot. TEST_F(AutomaticRebootManagerBasicTest, ResumeNoPolicy) { is_user_logged_in_ = true; + is_logged_in_as_kiosk_app_ = true; task_runner_->SetUptime(base::TimeDelta::FromDays(10)); // Verify that the device does not reboot immediately. @@ -621,12 +674,34 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeNoPolicy) { FastForwardUntilNoTasksRemain(false); } -// Chrome is running a user session. The uptime limit is 24 hours. The current -// uptime is 12 hours. +// Chrome is running a non-kiosk-app session. The current uptime is 10 days. +// Verifies that when the device is suspended and then resumes, it does not +// immediately reboot. +TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAppNoPolicy) { + is_user_logged_in_ = true; + task_runner_->SetUptime(base::TimeDelta::FromDays(10)); + + // Verify that the device does not reboot immediately. + CreateAutomaticRebootManager(false); + + // Verify that no grace period has started. + VerifyNoGracePeriod(); + + // Notify that the device has resumed from 1 hour of sleep. Verify that the + // device does not reboot immediately. + NotifyResumed(false); + + // Verify that the device does not reboot eventually. + FastForwardUntilNoTasksRemain(false); +} + +// Chrome is running a kiosk app session. The uptime limit is 24 hours. The +// current uptime is 12 hours. // Verifies that when the device is suspended and then resumes, it does not // immediately reboot. TEST_F(AutomaticRebootManagerBasicTest, ResumeBeforeGracePeriod) { is_user_logged_in_ = true; + is_logged_in_as_kiosk_app_ = true; task_runner_->SetUptime(base::TimeDelta::FromHours(12)); // Verify that the device does not reboot immediately. @@ -646,12 +721,38 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeBeforeGracePeriod) { FastForwardUntilNoTasksRemain(true); } -// Chrome is running a user session. The uptime limit is 6 hours. The current -// uptime is 12 hours. +// Chrome is running a non-kiosk-app session. The uptime limit is 24 hours. The +// current uptime is 12 hours. +// Verifies that when the device is suspended and then resumes, it does not +// immediately reboot. +TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeBeforeGracePeriod) { + is_user_logged_in_ = true; + task_runner_->SetUptime(base::TimeDelta::FromHours(12)); + + // Verify that the device does not reboot immediately. + CreateAutomaticRebootManager(false); + + // Set the uptime limit. Verify that the device does not reboot immediately. + SetUptimeLimit(base::TimeDelta::FromHours(24), false); + + // Verify that a grace period has been scheduled to start in the future. + VerifyGracePeriod(uptime_limit_); + + // Notify that the device has resumed from 1 hour of sleep. Verify that the + // device does not reboot immediately. + NotifyResumed(false); + + // Verify that the device does not reboot eventually. + FastForwardUntilNoTasksRemain(false); +} + +// Chrome is running a kiosk app session. The uptime limit is 6 hours. The +// current uptime is 12 hours. // Verifies that when the device is suspended and then resumes, it immediately // reboots. TEST_F(AutomaticRebootManagerBasicTest, ResumeInGracePeriod) { is_user_logged_in_ = true; + is_logged_in_as_kiosk_app_ = true; task_runner_->SetUptime(base::TimeDelta::FromHours(12)); // Verify that the device does not reboot immediately. @@ -668,12 +769,38 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeInGracePeriod) { NotifyResumed(true); } -// Chrome is running a user session. The uptime limit is 6 hours. The current -// uptime is 29 hours 30 minutes. +// Chrome is running a non-kiosk-app session. The uptime limit is 6 hours. The +// current uptime is 12 hours. +// Verifies that when the device is suspended and then resumes, it does not +// immediately reboot. +TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeInGracePeriod) { + is_user_logged_in_ = true; + task_runner_->SetUptime(base::TimeDelta::FromHours(12)); + + // Verify that the device does not reboot immediately. + CreateAutomaticRebootManager(false); + + // Set the uptime limit. Verify that the device does not reboot immediately. + SetUptimeLimit(base::TimeDelta::FromHours(6), false); + + // Verify that a grace period has started. + VerifyGracePeriod(uptime_limit_); + + // Notify that the device has resumed from 1 hour of sleep. Verify that the + // device does not reboot immediately. + NotifyResumed(false); + + // Verify that the device does not reboot eventually. + FastForwardUntilNoTasksRemain(false); +} + +// Chrome is running a kiosk app session. The uptime limit is 6 hours. The +// current uptime is 29 hours 30 minutes. // Verifies that when the device is suspended and then resumes, it immediately // reboots. TEST_F(AutomaticRebootManagerBasicTest, ResumeAfterGracePeriod) { is_user_logged_in_ = true; + is_logged_in_as_kiosk_app_ = true; task_runner_->SetUptime(base::TimeDelta::FromHours(29) + base::TimeDelta::FromMinutes(30)); @@ -691,6 +818,32 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeAfterGracePeriod) { NotifyResumed(true); } +// Chrome is running a non-kiosk-app session. The uptime limit is 6 hours. The +// current uptime is 29 hours 30 minutes. +// Verifies that when the device is suspended and then resumes, it does not +// immediately reboot. +TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) { + is_user_logged_in_ = true; + task_runner_->SetUptime(base::TimeDelta::FromHours(29) + + base::TimeDelta::FromMinutes(30)); + + // Verify that the device does not reboot immediately. + CreateAutomaticRebootManager(false); + + // Set the uptime limit. Verify that the device does not reboot immediately. + SetUptimeLimit(base::TimeDelta::FromHours(6), false); + + // Verify that a grace period has started. + VerifyGracePeriod(uptime_limit_); + + // Notify that the device has resumed from 1 hour of sleep. Verify that the + // device does not reboot immediately. + NotifyResumed(false); + + // Verify that the device does not reboot eventually. + FastForwardUntilNoTasksRemain(false); +} + // Chrome is running. The current uptime is 10 days. // Verifies that when the browser terminates, the device does not immediately // reboot. @@ -730,16 +883,16 @@ TEST_P(AutomaticRebootManagerTest, TerminateBeforeGracePeriod) { // reboot immediately. NotifyTerminating(false); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The uptime limit is set to 6 hours. The current uptime is // 12 hours. -// Verifies that when the browser terminates while Chrome is showing the login -// screen, the device does not immediately reboot. -// Verifies that when the browser terminates while Chrome is running a user -// session, the device immediately reboots. +// Verifies that when the browser terminates, the device immediately reboots if +// a kiosk app session is in progress. TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) { task_runner_->SetUptime(base::TimeDelta::FromHours(12)); @@ -752,13 +905,14 @@ TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) { // Verify that a grace period has started. VerifyGracePeriod(uptime_limit_); - // Notify that the browser is terminating. Verify that the device does not - // reboot immediately if Chrome is showing the login screen and that it does - // reboot immediately if Chrome is running a user session. - NotifyTerminating(is_user_logged_in_); + // Notify that the browser is terminating. Verify that the device immediately + // reboots if a kiosk app session is in progress. + NotifyTerminating(is_logged_in_as_kiosk_app_); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that if a non-kiosk-app session is in progress, the device does not + // reboot eventually. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The current uptime is 12 hours. @@ -779,8 +933,10 @@ TEST_P(AutomaticRebootManagerTest, BeforeUptimeLimitGracePeriod) { // Verify that a grace period has been scheduled to start in the future. VerifyGracePeriod(uptime_limit_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The current uptime is 12 hours. @@ -801,13 +957,16 @@ TEST_P(AutomaticRebootManagerTest, InUptimeLimitGracePeriod) { // Verify that a grace period has started. VerifyGracePeriod(uptime_limit_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The current uptime is 10 days. // Verifies that when the uptime limit is set to 6 hours, the device reboots -// immediately because the grace period ended after 6 + 24 hours of uptime. +// immediately if no non-kiosk-app-session is in progress because the grace +// period ended after 6 + 24 hours of uptime. TEST_P(AutomaticRebootManagerTest, AfterUptimeLimitGracePeriod) { task_runner_->SetUptime(base::TimeDelta::FromDays(10)); @@ -817,8 +976,15 @@ TEST_P(AutomaticRebootManagerTest, AfterUptimeLimitGracePeriod) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Set the uptime limit. Verify that the device reboots immediately. - SetUptimeLimit(base::TimeDelta::FromHours(6), true); + // Set the uptime limit. Verify that unless a non-kiosk-app session is in + // progress, the the device immediately reboots. + SetUptimeLimit(base::TimeDelta::FromHours(6), !is_user_logged_in_ || + is_logged_in_as_kiosk_app_); + + // Verify that if a non-kiosk-app session is in progress, the device does not + // reboot eventually. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The uptime limit is set to 12 hours. The current uptime is @@ -847,7 +1013,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffBeforeGracePeriod) { // Verify that the grace period has been removed. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -877,7 +1043,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) { // Verify that the grace period has been removed. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -909,8 +1075,10 @@ TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitBeforeGracePeriod) { // future. VerifyGracePeriod(uptime_limit_); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The uptime limit is set to 12 hours. The current uptime is @@ -940,8 +1108,10 @@ TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) { // Verify that the grace period has been rescheduled to start in the future. VerifyGracePeriod(uptime_limit_); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The uptime limit is set to 18 hours. The current uptime is @@ -971,8 +1141,10 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitBeforeToInGracePeriod) { // Verify that the grace period has been rescheduled and has started already. VerifyGracePeriod(uptime_limit_); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The uptime limit is set to 24 hours. The current uptime is @@ -1002,15 +1174,17 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) { // Verify that the grace period has been rescheduled to have started earlier. VerifyGracePeriod(uptime_limit_); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The uptime limit is set to 24 hours. The current uptime is // 36 hours. // Verifies that when the uptime limit is shortened to 6 hours, the device -// reboots immediately because the grace period ended after 6 + 24 hours of -// uptime. +// reboots immediately if no non-kiosk-app session is in progress because the +// grace period ended after 6 + 24 hours of uptime. TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) { task_runner_->SetUptime(base::TimeDelta::FromHours(36)); @@ -1027,8 +1201,15 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) { // reboot immediately. FastForwardBy(base::TimeDelta::FromSeconds(20), false); - // Shorten the uptime limit. Verify that the device reboots immediately. - SetUptimeLimit(base::TimeDelta::FromHours(6), true); + // Shorten the uptime limit. Verify that unless a non-kiosk-app session is in + // progress, the the device immediately reboots. + SetUptimeLimit(base::TimeDelta::FromHours(6), !is_user_logged_in_ || + is_logged_in_as_kiosk_app_); + + // Verify that if a non-kiosk-app session is in progress, the device does not + // reboot eventually. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The current uptime is 12 hours. @@ -1058,7 +1239,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1090,8 +1271,10 @@ TEST_P(AutomaticRebootManagerTest, Update) { // Verify that a grace period has started. VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The current uptime is 12 hours. @@ -1136,8 +1319,10 @@ TEST_P(AutomaticRebootManagerTest, UpdateAfterUpdate) { &new_update_reboot_needed_uptime)); EXPECT_EQ(update_reboot_needed_uptime_, new_update_reboot_needed_uptime); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The current uptime is 10 minutes. @@ -1169,8 +1354,10 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) { // Verify that a grace period has been scheduled to begin in the future. VerifyGracePeriod(base::TimeDelta::FromHours(1)); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. An update was applied and a reboot became necessary to @@ -1203,16 +1390,18 @@ TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateInGracePeriod) { // Verify that a grace period has started. VerifyGracePeriod(base::TimeDelta::FromHours(6) + uptime_processing_delay_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. An update was applied and a reboot became necessary to // complete the update process after 6 hours of uptime. The current uptime is // 10 days. // Verifies that when the policy to automatically reboot after an update is -// enabled, the device reboots immediately because the grace period ended after -// 6 + 24 hours of uptime. +// enabled, the device reboots immediately if no non-kiosk-app session is in +// progress because the grace period ended after 6 + 24 hours of uptime. TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateAfterGracePeriod) { task_runner_->SetUptime(base::TimeDelta::FromHours(6)); @@ -1232,8 +1421,14 @@ TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateAfterGracePeriod) { automatic_reboot_manager_->OnUserActivity(); // Enable automatic rebooting after an update has been applied. Verify that - // the device reboots immediately. - SetRebootAfterUpdate(true, true); + // unless a non-kiosk-app session is in progress, the the device immediately + // reboots. + SetRebootAfterUpdate(true, !is_user_logged_in_ || is_logged_in_as_kiosk_app_); + + // Verify that if a non-kiosk-app session is in progress, the device does not + // reboot eventually. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. An update was applied and a reboot became necessary to @@ -1267,7 +1462,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) { // Verify that the grace period has been removed. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1305,7 +1500,7 @@ TEST_P(AutomaticRebootManagerTest, NoUptime) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1345,8 +1540,10 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) { // Verify that the grace period has not been rescheduled. VerifyGracePeriod(uptime_limit_); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The policy to automatically reboot after an update is @@ -1386,8 +1583,10 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) { // the update became available. VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); - // Verify that the device eventually reboots. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is running. The uptime limit is set to 24 hours. An update was applied @@ -1442,7 +1641,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffThenUptimeLimitOff) { // Verify that the grace period has been removed. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1500,14 +1699,14 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) { // Verify that the grace period has been removed. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } // Chrome is running. The uptime limit is 6 hours. The current uptime is // 29 hours 59 minutes 59 seconds. -// Verifies that the device reboots immediately when the grace period ends after -// 6 + 24 hours of uptime. +// Verifies that if no non-kiosk-app session is in progress, the device reboots +// immediately when the grace period ends after 6 + 24 hours of uptime. TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) { task_runner_->SetUptime(base::TimeDelta::FromHours(29) + base::TimeDelta::FromMinutes(59) + @@ -1522,9 +1721,15 @@ TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) { // Verify that a grace period has started. VerifyGracePeriod(uptime_limit_); - // Fast forward the uptime by 1 second. Verify that the device reboots - // immediately. - FastForwardBy(base::TimeDelta::FromSeconds(1), true); + // Fast forward the uptime by 1 second. Verify that unless a non-kiosk-app + // session is in progress, the the device immediately reboots. + FastForwardBy(base::TimeDelta::FromSeconds(1), !is_user_logged_in_ || + is_logged_in_as_kiosk_app_); + + // Verify that if a non-kiosk-app session is in progress, the device does not + // reboot eventually. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. The current uptime is 10 days. @@ -1539,7 +1744,7 @@ TEST_P(AutomaticRebootManagerTest, StartNoPolicy) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1557,20 +1762,29 @@ TEST_P(AutomaticRebootManagerTest, StartBeforeUptimeLimitGracePeriod) { // Verify that a grace period has been scheduled to start in the future. VerifyGracePeriod(uptime_limit_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. The uptime limit is set to 6 hours. The current uptime is // 10 days. -// Verifies that the device reboots immediately because the grace period ended -// after 6 + 24 hours of uptime. +// Verifies that if no non-kiosk-app session is in progress, the device reboots +// immediately because the grace period ended after 6 + 24 hours of uptime. TEST_P(AutomaticRebootManagerTest, StartAfterUptimeLimitGracePeriod) { SetUptimeLimit(base::TimeDelta::FromHours(6), false); task_runner_->SetUptime(base::TimeDelta::FromDays(10)); - // Verify that the device reboots immediately. - CreateAutomaticRebootManager(true); + // Verify that unless a non-kiosk-app session is in progress, the the device + // immediately reboots. + CreateAutomaticRebootManager(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); + + // Verify that if a non-kiosk-app session is in progress, the device does not + // reboot eventually. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. The uptime limit is set to 6 hours. The current uptime is @@ -1587,24 +1801,33 @@ TEST_P(AutomaticRebootManagerTest, StartInUptimeLimitGracePeriod) { // Verify that a grace period has started. VerifyGracePeriod(uptime_limit_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. An update was applied and a reboot became necessary to // complete the update process after 6 hours of uptime. The current uptime is // 10 days. // Verifies that when the policy to automatically reboot after an update is -// enabled, the device reboots immediately because the grace period ended after -// 6 + 24 hours of uptime. +// enabled, the device reboots immediately if no non-kiosk-app session is in +// progress because the grace period ended after 6 + 24 hours of uptime. TEST_P(AutomaticRebootManagerTest, StartAfterUpdateGracePeriod) { SetUpdateStatusNeedReboot(); SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); task_runner_->SetUptime(base::TimeDelta::FromDays(10)); SetRebootAfterUpdate(true, false); - // Verify that the device reboots immediately. - CreateAutomaticRebootManager(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // reboots immediately. + CreateAutomaticRebootManager(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); + + // Verify that if a non-kiosk-app session is in progress, the device does not + // reboot eventually. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. An update was applied and a reboot became necessary to @@ -1625,8 +1848,10 @@ TEST_P(AutomaticRebootManagerTest, StartInUpdateGracePeriod) { // Verify that a grace period has started. VerifyGracePeriod(update_reboot_needed_uptime_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. An update was applied and a reboot became necessary to @@ -1647,8 +1872,10 @@ TEST_P(AutomaticRebootManagerTest, StartBeforeUpdateGracePeriod) { // Verify that a grace period has been scheduled to start in the future. VerifyGracePeriod(base::TimeDelta::FromHours(1)); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. An update was applied and a reboot became necessary to @@ -1667,7 +1894,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicy) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1695,8 +1922,10 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateTimeLost) { // Verify that a grace period has started. VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. An update was applied and a reboot became necessary to @@ -1722,7 +1951,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1746,7 +1975,7 @@ TEST_P(AutomaticRebootManagerTest, StartNoUpdate) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } @@ -1769,8 +1998,10 @@ TEST_P(AutomaticRebootManagerTest, StartUptimeLimitBeforeUpdate) { // Verify that a grace period has started. VerifyGracePeriod(uptime_limit_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. The uptime limit is set to 8 hours. Also, an update was @@ -1792,8 +2023,10 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateBeforeUptimeLimit) { // Verify that a grace period has started. VerifyGracePeriod(update_reboot_needed_uptime_); - // Verify that the device reboots eventually. - FastForwardUntilNoTasksRemain(true); + // Verify that unless a non-kiosk-app session is in progress, the device + // eventually reboots. + FastForwardUntilNoTasksRemain(!is_user_logged_in_ || + is_logged_in_as_kiosk_app_); } // Chrome is starting. The uptime limit is set to 6 hours. Also, an update was @@ -1813,13 +2046,17 @@ TEST_P(AutomaticRebootManagerTest, StartNoUptime) { // Verify that no grace period has started. VerifyNoGracePeriod(); - // Verify that the device does not eventually reboot. + // Verify that the device does not reboot eventually. FastForwardUntilNoTasksRemain(false); } -INSTANTIATE_TEST_CASE_P(AutomaticRebootManagerTestInstance, - AutomaticRebootManagerTest, - ::testing::Bool()); +INSTANTIATE_TEST_CASE_P( + AutomaticRebootManagerTestInstance, + AutomaticRebootManagerTest, + ::testing::Values( + AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, + AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, + AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); } // namespace system } // namespace chromeos |