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

Unified Diff: chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc

Issue 727363002: Fire notifications when reboot is requested, not scheduled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@managed_cros
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
index 6a233763b911caef54753e66e7026bfb42abe8ea..b3429a2b7c9d0d06a39a52e81d4e2826ad82d98c 100644
--- a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
+++ b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
#include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
+#include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chromeos/chromeos_paths.h"
@@ -44,6 +45,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/message_center.h"
+using ::testing::_;
+using ::testing::Mock;
using ::testing::ReturnPointee;
namespace chromeos {
@@ -115,6 +118,20 @@ class MockTimeTickClock : public base::TickClock {
DISALLOW_COPY_AND_ASSIGN(MockTimeTickClock);
};
+class MockAutomaticRebootManagerObserver
+ : public AutomaticRebootManagerObserver {
+ public:
+ MockAutomaticRebootManagerObserver();
+ ~MockAutomaticRebootManagerObserver() override;
+
+ // AutomaticRebootManagerObserver:
+ MOCK_METHOD1(OnRebootRequested, void(Reason));
+ MOCK_METHOD0(WillDestroyAutomaticRebootManager, void());
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockAutomaticRebootManagerObserver);
+};
+
} // namespace
class AutomaticRebootManagerBasicTest : public testing::Test {
@@ -138,9 +155,14 @@ class AutomaticRebootManagerBasicTest : public testing::Test {
void FastForwardBy(const base::TimeDelta& delta, bool expect_reboot);
void FastForwardUntilNoTasksRemain(bool expect_reboot);
+ void ExpectRebootRequest(AutomaticRebootManagerObserver::Reason reason);
+ void ExpectNoRebootRequest();
+
void CreateAutomaticRebootManager(bool expect_reboot);
bool ReadUpdateRebootNeededUptimeFromFile(base::TimeDelta* uptime);
+ void VerifyRebootRequested(AutomaticRebootManagerObserver::Reason reason);
+ void VerifyNoRebootRequested() const;
void VerifyLoginScreenIdleTimerIsStopped() const;
void VerifyNoGracePeriod() const;
void VerifyGracePeriod(const base::TimeDelta& start_uptime) const;
@@ -159,6 +181,7 @@ class AutomaticRebootManagerBasicTest : public testing::Test {
scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_;
+ MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_;
scoped_ptr<AutomaticRebootManager> automatic_reboot_manager_;
protected:
@@ -325,6 +348,12 @@ base::TimeTicks MockTimeTickClock::NowTicks() {
return task_runner_->Now();
}
+MockAutomaticRebootManagerObserver::MockAutomaticRebootManagerObserver() {
+}
+
+MockAutomaticRebootManagerObserver::~MockAutomaticRebootManagerObserver() {
+}
+
AutomaticRebootManagerBasicTest::AutomaticRebootManagerBasicTest()
: is_user_logged_in_(false),
is_logged_in_as_kiosk_app_(false),
@@ -372,10 +401,17 @@ void AutomaticRebootManagerBasicTest::SetUp() {
}
void AutomaticRebootManagerBasicTest::TearDown() {
- // Let the AutomaticRebootManager, if any, unregister itself as an observer of
- // several subsystems.
- automatic_reboot_manager_.reset();
- task_runner_->RunUntilIdle();
+ if (automatic_reboot_manager_) {
+ Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_);
+ EXPECT_CALL(automatic_reboot_manager_observer_,
+ WillDestroyAutomaticRebootManager()).Times(1);
+ EXPECT_CALL(automatic_reboot_manager_observer_,
+ OnRebootRequested(_)).Times(0);
+ // Let the AutomaticRebootManager, if any, unregister itself as an observer
+ // of several subsystems.
+ automatic_reboot_manager_.reset();
+ task_runner_->RunUntilIdle();
+ }
DBusThreadManager::Shutdown();
TestingBrowserProcess::GetGlobal()->SetLocalState(NULL);
@@ -387,7 +423,6 @@ void AutomaticRebootManagerBasicTest::SetUpdateRebootNeededUptime(
SaveUptimeToFile(update_reboot_needed_uptime_file_, uptime);
}
-
void AutomaticRebootManagerBasicTest::SetRebootAfterUpdate(
bool reboot_after_update,
bool expect_reboot) {
@@ -455,10 +490,30 @@ void AutomaticRebootManagerBasicTest::FastForwardUntilNoTasksRemain(
power_manager_client_->num_request_restart_calls());
}
+void AutomaticRebootManagerBasicTest::ExpectRebootRequest(
+ AutomaticRebootManagerObserver::Reason reason) {
+ Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_);
+ EXPECT_CALL(automatic_reboot_manager_observer_,
+ WillDestroyAutomaticRebootManager()).Times(0);
+ EXPECT_CALL(automatic_reboot_manager_observer_,
+ OnRebootRequested(_)).Times(0);
+ EXPECT_CALL(automatic_reboot_manager_observer_,
+ OnRebootRequested(reason)).Times(1);
+}
+
+void AutomaticRebootManagerBasicTest::ExpectNoRebootRequest() {
+ Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_);
+ EXPECT_CALL(automatic_reboot_manager_observer_,
+ WillDestroyAutomaticRebootManager()).Times(0);
+ EXPECT_CALL(automatic_reboot_manager_observer_,
+ OnRebootRequested(_)).Times(0);
+}
+
void AutomaticRebootManagerBasicTest::CreateAutomaticRebootManager(
bool expect_reboot) {
automatic_reboot_manager_.reset(new AutomaticRebootManager(
scoped_ptr<base::TickClock>(new MockTimeTickClock(task_runner_))));
+ automatic_reboot_manager_->AddObserver(&automatic_reboot_manager_observer_);
task_runner_->RunUntilIdle();
EXPECT_EQ(expect_reboot ? 1 : 0,
power_manager_client_->num_request_restart_calls());
@@ -490,6 +545,16 @@ bool AutomaticRebootManagerBasicTest::ReadUpdateRebootNeededUptimeFromFile(
return true;
}
+void AutomaticRebootManagerBasicTest::VerifyRebootRequested(
+ AutomaticRebootManagerObserver::Reason reason) {
+ EXPECT_TRUE(automatic_reboot_manager_->reboot_requested());
+ EXPECT_EQ(reason, automatic_reboot_manager_->reboot_reason());
+}
+
+void AutomaticRebootManagerBasicTest::VerifyNoRebootRequested() const {
+ EXPECT_FALSE(automatic_reboot_manager_->reboot_requested());
+}
+
void AutomaticRebootManagerBasicTest::
VerifyLoginScreenIdleTimerIsStopped() const {
VerifyTimerIsStopped(
@@ -575,9 +640,11 @@ AutomaticRebootManagerTest::~AutomaticRebootManagerTest() {
TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately and the login screen
- // idle timer is started.
+ // Verify that no reboot is requested, the device does not reboot immediately
+ // and the login screen idle timer is started.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Notify that a kiosk app session has been started.
is_user_logged_in_ = true;
@@ -590,7 +657,7 @@ TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) {
// Verify that the login screen idle timer is stopped.
VerifyLoginScreenIdleTimerIsStopped();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -600,9 +667,11 @@ TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) {
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.
+ // Verify that no reboot is requested, the device does not reboot immediately
+ // and the login screen idle timer is started.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Notify that a non-kiosk-app session has been started.
is_user_logged_in_ = true;
@@ -614,7 +683,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskLoginStopsIdleTimer) {
// Verify that the login screen idle timer is stopped.
VerifyLoginScreenIdleTimerIsStopped();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -625,11 +694,15 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskLoginStopsIdleTimer) {
TEST_F(AutomaticRebootManagerBasicTest, UserActivityResetsIdleTimer) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately and the login screen
- // idle timer is started.
+ // Verify that no reboot is requested, the device does not reboot immediately
+ // and the login screen idle timer is started.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -659,17 +732,20 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeNoPolicy) {
is_logged_in_as_kiosk_app_ = true;
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// 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.
+ // Notify that the device has resumed from 1 hour of sleep. Verify that no
+ // reboot is requested and the device does not reboot immediately.
NotifyResumed(false);
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -680,17 +756,20 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAppNoPolicy) {
is_user_logged_in_ = true;
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// 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.
+ // Notify that the device has resumed from 1 hour of sleep. Verify that no
+ // reboot is requested and the device does not reboot immediately.
NotifyResumed(false);
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -703,20 +782,25 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeBeforeGracePeriod) {
is_logged_in_as_kiosk_app_ = true;
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and 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.
+ // Notify that the device has resumed from 1 hour of sleep. Verify that no
+ // reboot is requested and the device does not reboot immediately.
NotifyResumed(false);
- // Verify that the device eventually reboots.
+ // Verify a reboot is requested and the device reboots eventually.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
FastForwardUntilNoTasksRemain(true);
}
@@ -728,20 +812,25 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeBeforeGracePeriod) {
is_user_logged_in_ = true;
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and 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.
+ // Notify that the device has resumed from 1 hour of sleep. Verify that no
+ // reboot is requested and the device does not reboot immediately.
NotifyResumed(false);
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is requested eventually but the device never reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
FastForwardUntilNoTasksRemain(false);
}
@@ -754,10 +843,15 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeInGracePeriod) {
is_logged_in_as_kiosk_app_ = true;
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -776,10 +870,15 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeInGracePeriod) {
is_user_logged_in_ = true;
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -789,7 +888,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeInGracePeriod) {
// device does not reboot immediately.
NotifyResumed(false);
- // Verify that the device does not reboot eventually.
+ // Verify that the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -803,10 +902,15 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeAfterGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(29) +
base::TimeDelta::FromMinutes(30));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -826,10 +930,15 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(29) +
base::TimeDelta::FromMinutes(30));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -839,7 +948,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) {
// device does not reboot immediately.
NotifyResumed(false);
- // Verify that the device does not reboot eventually.
+ // Verify that the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -849,17 +958,20 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) {
TEST_P(AutomaticRebootManagerTest, TerminateNoPolicy) {
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Notify that the browser is terminating. Verify that the device does not
- // reboot immediately.
+ // Notify that the browser is terminating. Verify that no reboot is requested
+ // and the device does not reboot immediately.
NotifyTerminating(false);
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -869,21 +981,26 @@ TEST_P(AutomaticRebootManagerTest, TerminateNoPolicy) {
TEST_P(AutomaticRebootManagerTest, TerminateBeforeGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and 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 browser is terminating. Verify that the device does not
- // reboot immediately.
+ // Notify that the browser is terminating. Verify that no reboot is requested
+ // and the device does not reboot immediately.
NotifyTerminating(false);
- // Verify that unless a non-kiosk-app session is in progress, the device
- // eventually reboots.
+ // Verify that a reboot is requested eventually and unless a non-kiosk-app
+ // session is in progress, the device eventually reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -895,10 +1012,15 @@ TEST_P(AutomaticRebootManagerTest, TerminateBeforeGracePeriod) {
TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -908,8 +1030,8 @@ TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) {
// reboots if a kiosk app session is in progress.
NotifyTerminating(is_logged_in_as_kiosk_app_);
- // Verify that if a non-kiosk-app session is in progress, the device does not
- // reboot eventually.
+ // Verify that if a non-kiosk-app session is in progress, the device never
+ // reboots.
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -920,20 +1042,25 @@ TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) {
TEST_P(AutomaticRebootManagerTest, BeforeUptimeLimitGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and 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_);
- // Verify that unless a non-kiosk-app session is in progress, the device
- // eventually reboots.
+ // Verify that a reboot is requested eventually and unless a non-kiosk-app
+ // session is in progress, the device eventually reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -944,13 +1071,18 @@ TEST_P(AutomaticRebootManagerTest, BeforeUptimeLimitGracePeriod) {
TEST_P(AutomaticRebootManagerTest, InUptimeLimitGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -969,19 +1101,23 @@ TEST_P(AutomaticRebootManagerTest, InUptimeLimitGracePeriod) {
TEST_P(AutomaticRebootManagerTest, AfterUptimeLimitGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Set the uptime limit. Verify that unless a non-kiosk-app session is in
- // progress, the the device immediately reboots.
+ // Set the uptime limit. Verify that a reboot is requested and unless a
+ // non-kiosk-app session is in progress, the the device immediately reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
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.
+ // Verify that if a non-kiosk-app session is in progress, the device never
+ // reboots.
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -992,27 +1128,31 @@ TEST_P(AutomaticRebootManagerTest, AfterUptimeLimitGracePeriod) {
TEST_P(AutomaticRebootManagerTest, UptimeLimitOffBeforeGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(6));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and the device
+ // does not reboot immediately.
SetUptimeLimit(base::TimeDelta::FromHours(12), false);
// Verify that a grace period has been scheduled to start in the future.
VerifyGracePeriod(uptime_limit_);
- // Fast forward the uptime by 1 hour. Verify that the device does not reboot
- // immediately.
+ // Fast forward the uptime by 1 hour. Verify that no reboot is requested and
+ // the device does not reboot immediately.
FastForwardBy(base::TimeDelta::FromHours(1), false);
- // Remove the uptime limit. Verify that the device does not reboot
- // immediately.
+ // Remove the uptime limit. Verify that no reboot is requested and the device
+ // does not reboot immediately.
SetUptimeLimit(base::TimeDelta(), false);
// Verify that the grace period has been removed.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1022,10 +1162,15 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffBeforeGracePeriod) {
TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(24));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(12), false);
// Verify that a grace period has started.
@@ -1042,7 +1187,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) {
// Verify that the grace period has been removed.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1053,29 +1198,34 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) {
TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitBeforeGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(6));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and the device
+ // does not reboot immediately.
SetUptimeLimit(base::TimeDelta::FromHours(12), false);
// Verify that a grace period has been scheduled to start in the future.
VerifyGracePeriod(uptime_limit_);
- // Fast forward the uptime by 20 seconds. Verify that the device does not
- // reboot immediately.
+ // Fast forward the uptime by 20 seconds. Verify that no reboot is requested
+ // and the device does not reboot immediately.
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
- // Extend the uptime limit. Verify that the device does not reboot
- // immediately.
+ // Extend the uptime limit. Verify that no reboot is requested and the device
+ // does not reboot immediately.
SetUptimeLimit(base::TimeDelta::FromHours(24), false);
// Verify that the grace period has been rescheduled to start further in the
// future.
VerifyGracePeriod(uptime_limit_);
- // Verify that unless a non-kiosk-app session is in progress, the device
- // eventually reboots.
+ // Verify that a reboot is requested eventually and unless a non-kiosk-app
+ // session is in progress, the device eventually reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1087,10 +1237,15 @@ TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitBeforeGracePeriod) {
TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(18));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(12), false);
// Verify that a grace period has started.
@@ -1107,8 +1262,9 @@ TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) {
// Verify that the grace period has been rescheduled to start in the future.
VerifyGracePeriod(uptime_limit_);
- // Verify that unless a non-kiosk-app session is in progress, the device
- // eventually reboots.
+ // Verify that a reboot is requested again eventually and unless a
+ // non-kiosk-app session is in progress, the device eventually reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1120,21 +1276,26 @@ TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) {
TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitBeforeToInGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and the device
+ // does not reboot immediately.
SetUptimeLimit(base::TimeDelta::FromHours(18), false);
// Verify that a grace period has been scheduled to start in the future.
VerifyGracePeriod(uptime_limit_);
- // Fast forward the uptime by 20 seconds. Verify that the device does not
- // reboot immediately.
+ // Fast forward the uptime by 20 seconds. Verify that no reboot is requested
+ // and the device does not reboot immediately.
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
- // Shorten the uptime limit. Verify that the device does not reboot
- // immediately.
+ // Shorten the uptime limit. Verify that a reboot is requested but the device
+ // does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that the grace period has been rescheduled and has started already.
@@ -1153,10 +1314,15 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitBeforeToInGracePeriod) {
TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(36));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(24), false);
// Verify that a grace period has started.
@@ -1166,8 +1332,9 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) {
// reboot immediately.
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
- // Shorten the uptime limit. Verify that the device does not reboot
- // immediately.
+ // Shorten the uptime limit. Verify that a reboot is requested again but the
+ // device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(18), false);
// Verify that the grace period has been rescheduled to have started earlier.
@@ -1187,10 +1354,15 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) {
TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(36));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(24), false);
// Verify that a grace period has started.
@@ -1200,13 +1372,15 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) {
// reboot immediately.
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
- // Shorten the uptime limit. Verify that unless a non-kiosk-app session is in
- // progress, the the device immediately reboots.
+ // Shorten the uptime limit. Verify that a reboot is requested again and
+ // unless a non-kiosk-app session is in progress, the the device immediately
+ // reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
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.
+ // Verify that if a non-kiosk-app session is in progress, the device never
+ // reboots.
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1219,14 +1393,17 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) {
TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that no reboot is requested and the device does not reboot immediately.
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1238,7 +1415,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) {
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1251,14 +1428,18 @@ TEST_P(AutomaticRebootManagerTest, Update) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that a reboot is requested but the device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1278,20 +1459,24 @@ TEST_P(AutomaticRebootManagerTest, Update) {
// Chrome is running. The current uptime is 12 hours.
// Verifies that when Chrome is notified twice that an update has been applied,
-// the second notification is ignored and the uptime at which it occured does
+// the second notification is ignored and the uptime at which it occurred does
// not get persisted as the time at which an update became necessary.
TEST_P(AutomaticRebootManagerTest, UpdateAfterUpdate) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that a reboot is requested but the device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1326,7 +1511,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateAfterUpdate) {
// Chrome is running. The current uptime is 10 minutes.
// Verifies that when the policy to automatically reboot after an update is
-// enabled, no reboot occurs a grace period is scheduled to begin after the
+// enabled, no reboot occurs and a grace period is scheduled to begin after the
// minimum of 1 hour of uptime. Further verifies that when an update is applied,
// the current uptime is persisted as the time at which a reboot became
// necessary.
@@ -1334,14 +1519,17 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) {
task_runner_->SetUptime(base::TimeDelta::FromMinutes(10));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that no reboot is requested and the device does not reboot immediately.
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1353,8 +1541,9 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) {
// Verify that a grace period has been scheduled to begin in the future.
VerifyGracePeriod(base::TimeDelta::FromHours(1));
- // Verify that unless a non-kiosk-app session is in progress, the device
- // eventually reboots.
+ // Verify that a reboot is requested eventually and unless a non-kiosk-app
+ // session is in progress, the device eventually reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1368,22 +1557,26 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) {
TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateInGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(6));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that no reboot is requested and the device does not reboot immediately.
NotifyUpdateRebootNeeded();
- // Fast forward the uptime to 12 hours. Verify that the device does not reboot
- // immediately.
+ // Fast forward the uptime to 12 hours. Verify that no reboot is requested and
+ // the device does not reboot immediately.
FastForwardBy(base::TimeDelta::FromHours(6), false);
// Simulate user activity.
automatic_reboot_manager_->OnUserActivity(NULL);
- // Enable automatic reboot after an update has been applied. Verify that the
- // device does not reboot immediately.
+ // Enable automatic reboot after an update has been applied. Verify that a
+ // reboot is requested but the device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
SetRebootAfterUpdate(true, false);
// Verify that a grace period has started.
@@ -1404,15 +1597,18 @@ TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateInGracePeriod) {
TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateAfterGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(6));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that no reboot is requested and the device does not reboot immediately.
NotifyUpdateRebootNeeded();
- // Fast forward the uptime to 12 hours. Verify that the device does not reboot
- // immediately.
+ // Fast forward the uptime to 12 hours. Verify that no reboot is requested and
+ // the device does not reboot immediately.
FastForwardBy(base::TimeDelta::FromDays(10) - base::TimeDelta::FromHours(6),
false);
@@ -1420,12 +1616,13 @@ TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateAfterGracePeriod) {
automatic_reboot_manager_->OnUserActivity(NULL);
// Enable automatic rebooting after an update has been applied. Verify that
- // unless a non-kiosk-app session is in progress, the the device immediately
- // reboots.
+ // a reboot is requested and unless a non-kiosk-app session is in progress,
+ // the the device immediately reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
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.
+ // Verify that if a non-kiosk-app session is in progress, the device never
+ // reboots.
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1440,11 +1637,15 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) {
task_runner_->SetUptime(base::TimeDelta::FromHours(6));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that a reboot is requested but the device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
NotifyUpdateRebootNeeded();
// Verify that a grace period has started.
@@ -1455,13 +1656,13 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) {
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
// Disable automatic rebooting after an update has been applied. Verify that
- // the device does not reboot immediately.
+ // no reboot is requested and the device does not reboot immediately.
SetRebootAfterUpdate(false, false);
// Verify that the grace period has been removed.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1471,24 +1672,28 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) {
// occurs and no grace period is scheduled. Further verifies that no time is
// persisted as the time at which a reboot became necessary.
TEST_P(AutomaticRebootManagerTest, NoUptime) {
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and the device
+ // does not reboot immediately.
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that no grace period has started.
VerifyNoGracePeriod();
// Enable automatic rebooting after an update has been applied. Verify that
- // the device does not reboot immediately.
+ // no reboot is requested and the device does not reboot immediately.
SetRebootAfterUpdate(true, false);
// Verify that no grace period has started.
VerifyNoGracePeriod();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that no reboot is requested and the device does not reboot immediately.
NotifyUpdateRebootNeeded();
// Verify that no time is persisted as the time at which a reboot became
@@ -1499,7 +1704,7 @@ TEST_P(AutomaticRebootManagerTest, NoUptime) {
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1513,10 +1718,15 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has been scheduled to start in the future.
@@ -1527,7 +1737,9 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) {
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that a reboot is requested again but the device does not reboot
+ // immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1555,21 +1767,26 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and 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_);
- // Fast forward the uptime by 20 seconds. Verify that the device does not
- // reboot immediately.
+ // Fast forward the uptime by 20 seconds. Verify that no reboot is requested
+ // and the device does not reboot immediately.
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that a reboot is requested but the device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1593,23 +1810,28 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) {
// The policy to automatically reboot after an update is enabled. The current
// uptime is 12 hours 20 seconds.
// Verifies that when the policy to reboot after an update is disabled, the
-// grace period is rescheduled to start after 24 hours of uptime. Further
+// grace period is rescheduled to start after 12 hours of uptime. Further
// verifies that when the uptime limit is removed, the grace period is removed.
TEST_P(AutomaticRebootManagerTest, PolicyOffThenUptimeLimitOff) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that no reboot is requested and the device
+ // does not reboot immediately.
SetUptimeLimit(base::TimeDelta::FromHours(24), false);
- // Verify that the grace period has started.
+ // Verify that a grace period has been scheduled to start in the future.
VerifyGracePeriod(uptime_limit_);
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that a reboot is requested but the device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1640,7 +1862,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffThenUptimeLimitOff) {
// Verify that the grace period has been removed.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1656,11 +1878,15 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Notify that an update has been applied and a reboot is necessary. Verify
- // that the device does not reboot immediately.
+ // that a reboot is requested but the device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
NotifyUpdateRebootNeeded();
// Verify that the current uptime has been persisted as the time at which a
@@ -1672,7 +1898,9 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) {
// Verify that the grace period has started.
VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_);
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested again but the
+ // device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that the grace period has been rescheduled to have started after
@@ -1683,8 +1911,9 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) {
// reboot immediately.
FastForwardBy(base::TimeDelta::FromSeconds(20), false);
- // Remove the uptime limit. Verify that the device does not reboot
- // immediately.
+ // Remove the uptime limit. Verify that a reboot is requested again but the
+ // device does not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
SetUptimeLimit(base::TimeDelta(), false);
// Verify that a grace period has been rescheduled to have started after 12
@@ -1698,7 +1927,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) {
// Verify that the grace period has been removed.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1711,10 +1940,15 @@ TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) {
base::TimeDelta::FromMinutes(59) +
base::TimeDelta::FromSeconds(59));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
- // Set the uptime limit. Verify that the device does not reboot immediately.
+ // Set the uptime limit. Verify that a reboot is requested but the device does
+ // not reboot immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
// Verify that a grace period has started.
@@ -1725,8 +1959,8 @@ TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) {
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.
+ // Verify that if a non-kiosk-app session is in progress, the device never
+ // reboots.
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1737,13 +1971,16 @@ TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) {
TEST_P(AutomaticRebootManagerTest, StartNoPolicy) {
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1755,14 +1992,18 @@ TEST_P(AutomaticRebootManagerTest, StartBeforeUptimeLimitGracePeriod) {
SetUptimeLimit(base::TimeDelta::FromHours(24), false);
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that a grace period has been scheduled to start in the future.
VerifyGracePeriod(uptime_limit_);
- // Verify that unless a non-kiosk-app session is in progress, the device
- // eventually reboots.
+ // Verify that a reboot is requested eventually and unless a non-kiosk-app
+ // session is in progress, the device eventually reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1775,13 +2016,15 @@ TEST_P(AutomaticRebootManagerTest, StartAfterUptimeLimitGracePeriod) {
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that unless a non-kiosk-app session is in progress, the the device
- // immediately reboots.
+ // Verify that a reboot is requested and unless a non-kiosk-app session is in
+ // progress, the the device immediately reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
CreateAutomaticRebootManager(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
+ VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
- // Verify that if a non-kiosk-app session is in progress, the device does not
- // reboot eventually.
+ // Verify that if a non-kiosk-app session is in progress, the device never
+ // reboots.
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1794,8 +2037,11 @@ TEST_P(AutomaticRebootManagerTest, StartInUptimeLimitGracePeriod) {
SetUptimeLimit(base::TimeDelta::FromHours(6), false);
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
- // Verify that the device does not reboot immediately.
+ // Verify that a reboot is requested but the device does not reboot
+ // immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
CreateAutomaticRebootManager(false);
+ VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
// Verify that a grace period has started.
VerifyGracePeriod(uptime_limit_);
@@ -1818,13 +2064,16 @@ TEST_P(AutomaticRebootManagerTest, StartAfterUpdateGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
SetRebootAfterUpdate(true, false);
- // Verify that unless a non-kiosk-app session is in progress, the device
- // reboots immediately.
+ // Verify that a reboot is requested and unless a non-kiosk-app session is in
+ // progress, the the device immediately reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
CreateAutomaticRebootManager(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
+ VerifyRebootRequested(
+ AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
- // Verify that if a non-kiosk-app session is in progress, the device does not
- // reboot eventually.
+ // Verify that if a non-kiosk-app session is in progress, the device never
+ // reboots.
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1841,8 +2090,12 @@ TEST_P(AutomaticRebootManagerTest, StartInUpdateGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that a reboot is requested but the device does not reboot
+ // immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
CreateAutomaticRebootManager(false);
+ VerifyRebootRequested(
+ AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
// Verify that a grace period has started.
VerifyGracePeriod(update_reboot_needed_uptime_);
@@ -1865,14 +2118,18 @@ TEST_P(AutomaticRebootManagerTest, StartBeforeUpdateGracePeriod) {
task_runner_->SetUptime(base::TimeDelta::FromMinutes(20));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that a grace period has been scheduled to start in the future.
VerifyGracePeriod(base::TimeDelta::FromHours(1));
- // Verify that unless a non-kiosk-app session is in progress, the device
- // eventually reboots.
+ // Verify that a reboot is requested eventually and unless a non-kiosk-app
+ // session is in progress, the device eventually reboots.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
FastForwardUntilNoTasksRemain(!is_user_logged_in_ ||
is_logged_in_as_kiosk_app_);
}
@@ -1887,13 +2144,16 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicy) {
SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6));
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1909,8 +2169,12 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateTimeLost) {
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that a reboot is requested but the device does not reboot
+ // immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
CreateAutomaticRebootManager(false);
+ VerifyRebootRequested(
+ AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
// Verify that the current uptime has been persisted as the time at which a
// reboot became necessary.
@@ -1938,8 +2202,11 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) {
SetUpdateStatusNeedReboot();
task_runner_->SetUptime(base::TimeDelta::FromDays(10));
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that the current uptime has been persisted as the time at which a
// reboot became necessary.
@@ -1950,7 +2217,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) {
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1963,8 +2230,11 @@ TEST_P(AutomaticRebootManagerTest, StartNoUpdate) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no time is persisted as the time at which a reboot became
// necessary.
@@ -1974,7 +2244,7 @@ TEST_P(AutomaticRebootManagerTest, StartNoUpdate) {
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}
@@ -1991,8 +2261,11 @@ TEST_P(AutomaticRebootManagerTest, StartUptimeLimitBeforeUpdate) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that a reboot is requested but the device does not reboot
+ // immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
CreateAutomaticRebootManager(false);
+ VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC);
// Verify that a grace period has started.
VerifyGracePeriod(uptime_limit_);
@@ -2016,8 +2289,12 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateBeforeUptimeLimit) {
task_runner_->SetUptime(base::TimeDelta::FromHours(12));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that a reboot is requested but the device does not reboot
+ // immediately.
+ ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
CreateAutomaticRebootManager(false);
+ VerifyRebootRequested(
+ AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE);
// Verify that a grace period has started.
VerifyGracePeriod(update_reboot_needed_uptime_);
@@ -2039,13 +2316,16 @@ TEST_P(AutomaticRebootManagerTest, StartNoUptime) {
SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6));
SetRebootAfterUpdate(true, false);
- // Verify that the device does not reboot immediately.
+ // Verify that no reboot is requested and the device does not reboot
+ // immediately.
+ ExpectNoRebootRequest();
CreateAutomaticRebootManager(false);
+ VerifyNoRebootRequested();
// Verify that no grace period has started.
VerifyNoGracePeriod();
- // Verify that the device does not reboot eventually.
+ // Verify that a reboot is never requested and the device never reboots.
FastForwardUntilNoTasksRemain(false);
}

Powered by Google App Engine
This is Rietveld 408576698