| 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 4f00912050303c7250eacb231c04ef53c71f5c73..ba045ad40271422bae3fc3261ed8cc3499c345a9 100644
|
| --- a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
|
| +++ b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc
|
| @@ -5,7 +5,6 @@
|
| #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
|
|
|
| #include <string>
|
| -#include <utility>
|
|
|
| #include "ash/shell.h"
|
| #include "ash/test/test_shell_delegate.h"
|
| @@ -19,9 +18,9 @@
|
| #include "base/prefs/pref_registry_simple.h"
|
| #include "base/prefs/testing_pref_service.h"
|
| #include "base/run_loop.h"
|
| -#include "base/single_thread_task_runner.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/test/simple_test_tick_clock.h"
|
| +#include "base/test/test_mock_time_task_runner.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "base/time/tick_clock.h"
|
| @@ -55,68 +54,55 @@ namespace system {
|
|
|
| namespace {
|
|
|
| -// A SingleThreadTaskRunner that mocks the current time and allows it to be
|
| -// fast-forwarded. The current time in ticks is returned by Now(). The
|
| -// corresponding device uptime is written to |uptime_file_|, providing a mock
|
| -// for /proc/uptime.
|
| -class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner {
|
| +// Provides a mock device uptime that follows the given |tick_clock_| with a
|
| +// configurable offset. The mock uptime can also be written to |uptime_file_|,
|
| +// thusly allowing to mock /proc/uptime.
|
| +class MockUptimeProvider {
|
| public:
|
| - MockTimeSingleThreadTaskRunner();
|
| -
|
| - // base::SingleThreadTaskRunner:
|
| - virtual bool RunsTasksOnCurrentThread() const override;
|
| - virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
|
| - const base::Closure& task,
|
| - base::TimeDelta delay) override;
|
| - virtual bool PostNonNestableDelayedTask(
|
| - const tracked_objects::Location& from_here,
|
| - const base::Closure& task,
|
| - base::TimeDelta delay) override;
|
| -
|
| - void SetUptimeFile(const base::FilePath& uptime_file);
|
| + explicit MockUptimeProvider(scoped_ptr<base::TickClock> tick_clock);
|
| +
|
| + void WriteUptimeToFile();
|
| +
|
| + // Adjusts the offset so that the current mock uptime will be |uptime|.
|
| void SetUptime(const base::TimeDelta& uptime);
|
|
|
| - const base::TimeDelta& Uptime() const;
|
| - const base::TimeTicks& Now() const;
|
| + void set_uptime_file_path(const base::FilePath& uptime_file_path) {
|
| + uptime_file_path_ = uptime_file_path;
|
| + }
|
|
|
| - void FastForwardBy(const base::TimeDelta& delta);
|
| - void FastForwardUntilNoTasksRemain();
|
| - void RunUntilIdle();
|
| + base::TimeDelta uptime() const {
|
| + return tick_clock_->NowTicks() - base::TimeTicks() + uptime_offset_;
|
| + }
|
|
|
| private:
|
| - // Strict weak temporal ordering of tasks.
|
| - class TemporalOrder {
|
| - public:
|
| - bool operator()(
|
| - const std::pair<base::TimeTicks, base::Closure>& first_task,
|
| - const std::pair<base::TimeTicks, base::Closure>& second_task) const;
|
| - };
|
| -
|
| - virtual ~MockTimeSingleThreadTaskRunner();
|
| -
|
| - base::FilePath uptime_file_;
|
| - base::TimeDelta uptime_;
|
| - base::TimeTicks now_;
|
| - std::priority_queue<std::pair<base::TimeTicks, base::Closure>,
|
| - std::vector<std::pair<base::TimeTicks, base::Closure> >,
|
| - TemporalOrder> tasks_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(MockTimeSingleThreadTaskRunner);
|
| + scoped_ptr<base::TickClock> tick_clock_;
|
| +
|
| + base::FilePath uptime_file_path_;
|
| + base::TimeDelta uptime_offset_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MockUptimeProvider);
|
| };
|
|
|
| -class MockTimeTickClock : public base::TickClock {
|
| +class TestAutomaticRebootManagerTaskRunner
|
| + : public base::TestMockTimeTaskRunner {
|
| public:
|
| - explicit MockTimeTickClock(
|
| - scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner);
|
| - virtual ~MockTimeTickClock();
|
| + TestAutomaticRebootManagerTaskRunner();
|
|
|
| - // base::TickClock:
|
| - virtual base::TimeTicks NowTicks() override;
|
| + MockUptimeProvider* uptime_provider() const {
|
| + return uptime_provider_.get();
|
| + }
|
|
|
| private:
|
| - scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_;
|
| + ~TestAutomaticRebootManagerTaskRunner() override;
|
| +
|
| + // base::TestMockTimeTaskRunner:
|
| + void OnBeforeSelectingTask() override;
|
| + void OnAfterTimePassed() override;
|
| + void OnAfterTaskRun() override;
|
| +
|
| + scoped_ptr<MockUptimeProvider> uptime_provider_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(MockTimeTickClock);
|
| + DISALLOW_COPY_AND_ASSIGN(TestAutomaticRebootManagerTaskRunner);
|
| };
|
|
|
| class MockAutomaticRebootManagerObserver
|
| @@ -177,6 +163,10 @@ class AutomaticRebootManagerBasicTest : public testing::Test {
|
| // Sets the status of |update_engine_client_| to NEED_REBOOT for tests.
|
| void SetUpdateStatusNeedReboot();
|
|
|
| + MockUptimeProvider* uptime_provider() const {
|
| + return task_runner_->uptime_provider();
|
| + }
|
| +
|
| bool is_user_logged_in_;
|
| bool is_logged_in_as_kiosk_app_;
|
|
|
| @@ -189,7 +179,7 @@ class AutomaticRebootManagerBasicTest : public testing::Test {
|
| base::TimeDelta update_reboot_needed_uptime_;
|
| base::TimeDelta uptime_limit_;
|
|
|
| - scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_;
|
| + scoped_refptr<TestAutomaticRebootManagerTaskRunner> task_runner_;
|
|
|
| MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_;
|
| scoped_ptr<AutomaticRebootManager> automatic_reboot_manager_;
|
| @@ -244,114 +234,40 @@ void SaveUptimeToFile(const base::FilePath& path,
|
| uptime_seconds.size()));
|
| }
|
|
|
| -MockTimeSingleThreadTaskRunner::MockTimeSingleThreadTaskRunner() {
|
| +MockUptimeProvider::MockUptimeProvider(scoped_ptr<base::TickClock> tick_clock)
|
| + : tick_clock_(tick_clock.Pass()) {
|
| }
|
|
|
| -bool MockTimeSingleThreadTaskRunner::RunsTasksOnCurrentThread() const {
|
| - return true;
|
| +void MockUptimeProvider::WriteUptimeToFile() {
|
| + SaveUptimeToFile(uptime_file_path_, uptime());
|
| }
|
|
|
| -bool MockTimeSingleThreadTaskRunner::PostDelayedTask(
|
| - const tracked_objects::Location& from_here,
|
| - const base::Closure& task,
|
| - base::TimeDelta delay) {
|
| - tasks_.push(std::pair<base::TimeTicks, base::Closure>(now_ + delay, task));
|
| - return true;
|
| +void MockUptimeProvider::SetUptime(const base::TimeDelta& uptime) {
|
| + uptime_offset_ = uptime - (tick_clock_->NowTicks() - base::TimeTicks());
|
| + WriteUptimeToFile();
|
| }
|
|
|
| -bool MockTimeSingleThreadTaskRunner::PostNonNestableDelayedTask(
|
| - const tracked_objects::Location& from_here,
|
| - const base::Closure& task,
|
| - base::TimeDelta delay) {
|
| - NOTREACHED();
|
| - return false;
|
| +TestAutomaticRebootManagerTaskRunner::TestAutomaticRebootManagerTaskRunner()
|
| + : uptime_provider_(new MockUptimeProvider(GetMockTickClock())) {
|
| }
|
|
|
| -void MockTimeSingleThreadTaskRunner::SetUptimeFile(
|
| - const base::FilePath& uptime_file) {
|
| - uptime_file_ = uptime_file;
|
| - SaveUptimeToFile(uptime_file_, uptime_);
|
| +TestAutomaticRebootManagerTaskRunner::~TestAutomaticRebootManagerTaskRunner() {
|
| }
|
|
|
| -void MockTimeSingleThreadTaskRunner::SetUptime(const base::TimeDelta& uptime) {
|
| - uptime_ = uptime;
|
| - SaveUptimeToFile(uptime_file_, uptime_);
|
| -}
|
| -
|
| -const base::TimeDelta& MockTimeSingleThreadTaskRunner::Uptime() const {
|
| - return uptime_;
|
| -}
|
| -
|
| -const base::TimeTicks& MockTimeSingleThreadTaskRunner::Now() const {
|
| - return now_;
|
| -}
|
| -
|
| -void MockTimeSingleThreadTaskRunner::FastForwardBy(
|
| - const base::TimeDelta& delta) {
|
| - const base::TimeTicks latest = now_ + delta;
|
| +void TestAutomaticRebootManagerTaskRunner::OnBeforeSelectingTask() {
|
| base::SequencedWorkerPool* blocking_pool =
|
| content::BrowserThread::GetBlockingPool();
|
| blocking_pool->FlushForTesting();
|
| - while (!tasks_.empty() && tasks_.top().first <= latest) {
|
| - uptime_ += tasks_.top().first - now_;
|
| - SaveUptimeToFile(uptime_file_, uptime_);
|
| - now_ = tasks_.top().first;
|
| - base::Closure task = tasks_.top().second;
|
| - tasks_.pop();
|
| - task.Run();
|
| - blocking_pool->FlushForTesting();
|
| - }
|
| - uptime_ += latest - now_;
|
| - SaveUptimeToFile(uptime_file_, uptime_);
|
| - now_ = latest;
|
| }
|
|
|
| -void MockTimeSingleThreadTaskRunner::FastForwardUntilNoTasksRemain() {
|
| - base::SequencedWorkerPool* blocking_pool =
|
| - content::BrowserThread::GetBlockingPool();
|
| - blocking_pool->FlushForTesting();
|
| - while (!tasks_.empty()) {
|
| - uptime_ += tasks_.top().first - now_;
|
| - SaveUptimeToFile(uptime_file_, uptime_);
|
| - now_ = tasks_.top().first;
|
| - base::Closure task = tasks_.top().second;
|
| - tasks_.pop();
|
| - task.Run();
|
| - blocking_pool->FlushForTesting();
|
| - }
|
| +void TestAutomaticRebootManagerTaskRunner::OnAfterTimePassed() {
|
| + uptime_provider_->WriteUptimeToFile();
|
| }
|
|
|
| -void MockTimeSingleThreadTaskRunner::RunUntilIdle() {
|
| +void TestAutomaticRebootManagerTaskRunner::OnAfterTaskRun() {
|
| base::SequencedWorkerPool* blocking_pool =
|
| content::BrowserThread::GetBlockingPool();
|
| blocking_pool->FlushForTesting();
|
| - while (!tasks_.empty() && tasks_.top().first <= now_) {
|
| - base::Closure task = tasks_.top().second;
|
| - tasks_.pop();
|
| - task.Run();
|
| - blocking_pool->FlushForTesting();
|
| - }
|
| -}
|
| -
|
| -bool MockTimeSingleThreadTaskRunner::TemporalOrder::operator()(
|
| - const std::pair<base::TimeTicks, base::Closure>& first_task,
|
| - const std::pair<base::TimeTicks, base::Closure>& second_task) const {
|
| - return first_task.first > second_task.first;
|
| -}
|
| -
|
| -MockTimeSingleThreadTaskRunner::~MockTimeSingleThreadTaskRunner() {
|
| -}
|
| -
|
| -MockTimeTickClock::MockTimeTickClock(
|
| - scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner)
|
| - : task_runner_(task_runner) {
|
| -}
|
| -
|
| -MockTimeTickClock::~MockTimeTickClock() {
|
| -}
|
| -
|
| -base::TimeTicks MockTimeTickClock::NowTicks() {
|
| - return task_runner_->Now();
|
| }
|
|
|
| MockAutomaticRebootManagerObserver::MockAutomaticRebootManagerObserver()
|
| @@ -383,7 +299,7 @@ void MockAutomaticRebootManagerObserver::StopObserving() {
|
| AutomaticRebootManagerBasicTest::AutomaticRebootManagerBasicTest()
|
| : is_user_logged_in_(false),
|
| is_logged_in_as_kiosk_app_(false),
|
| - task_runner_(new MockTimeSingleThreadTaskRunner),
|
| + task_runner_(new TestAutomaticRebootManagerTaskRunner),
|
| reboot_after_update_(false),
|
| ui_thread_task_runner_handle_(task_runner_),
|
| mock_user_manager_(new MockUserManager),
|
| @@ -399,7 +315,7 @@ void AutomaticRebootManagerBasicTest::SetUp() {
|
| ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| const base::FilePath& temp_dir = temp_dir_.path();
|
| const base::FilePath uptime_file = temp_dir.Append("uptime");
|
| - task_runner_->SetUptimeFile(uptime_file);
|
| + uptime_provider()->set_uptime_file_path(uptime_file);
|
| ASSERT_FALSE(base::WriteFile(uptime_file, NULL, 0));
|
| update_reboot_needed_uptime_file_ =
|
| temp_dir.Append("update_reboot_needed_uptime");
|
| @@ -538,7 +454,7 @@ void AutomaticRebootManagerBasicTest::ExpectNoRebootRequest() {
|
| void AutomaticRebootManagerBasicTest::CreateAutomaticRebootManager(
|
| bool expect_reboot) {
|
| automatic_reboot_manager_.reset(new AutomaticRebootManager(
|
| - scoped_ptr<base::TickClock>(new MockTimeTickClock(task_runner_))));
|
| + scoped_ptr<base::TickClock>(task_runner_->GetMockTickClock())));
|
| automatic_reboot_manager_observer_.Init(automatic_reboot_manager_.get());
|
| task_runner_->RunUntilIdle();
|
| EXPECT_EQ(expect_reboot ? 1 : 0,
|
| @@ -546,7 +462,7 @@ void AutomaticRebootManagerBasicTest::CreateAutomaticRebootManager(
|
|
|
| uptime_processing_delay_ =
|
| base::TimeTicks() - automatic_reboot_manager_->boot_time_ -
|
| - task_runner_->Uptime();
|
| + uptime_provider()->uptime();
|
| EXPECT_GE(uptime_processing_delay_, base::TimeDelta());
|
| EXPECT_LE(uptime_processing_delay_, base::TimeDelta::FromSeconds(1));
|
|
|
| @@ -596,7 +512,7 @@ void AutomaticRebootManagerBasicTest::VerifyNoGracePeriod() const {
|
| void AutomaticRebootManagerBasicTest::VerifyGracePeriod(
|
| const base::TimeDelta& start_uptime) const {
|
| const base::TimeDelta start =
|
| - start_uptime - task_runner_->Uptime() - uptime_processing_delay_;
|
| + start_uptime - uptime_provider()->uptime() - uptime_processing_delay_;
|
| const base::TimeDelta end = start + base::TimeDelta::FromHours(24);
|
| if (start <= base::TimeDelta()) {
|
| EXPECT_TRUE(automatic_reboot_manager_->reboot_requested_);
|
| @@ -664,7 +580,7 @@ AutomaticRebootManagerTest::~AutomaticRebootManagerTest() {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested, the device does not reboot immediately
|
| // and the login screen idle timer is started.
|
| @@ -691,7 +607,7 @@ TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested, the device does not reboot immediately
|
| // and the login screen idle timer is started.
|
| @@ -718,7 +634,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskLoginStopsIdleTimer) {
|
| // Verifies that user activity prevents the device from rebooting. Further
|
| // verifies that when user activity ceases, the devices reboots.
|
| TEST_F(AutomaticRebootManagerBasicTest, UserActivityResetsIdleTimer) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested, the device does not reboot immediately
|
| // and the login screen idle timer is started.
|
| @@ -756,7 +672,7 @@ TEST_F(AutomaticRebootManagerBasicTest, UserActivityResetsIdleTimer) {
|
| TEST_F(AutomaticRebootManagerBasicTest, ResumeNoPolicy) {
|
| is_user_logged_in_ = true;
|
| is_logged_in_as_kiosk_app_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -780,7 +696,7 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeNoPolicy) {
|
| // immediately reboot.
|
| TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAppNoPolicy) {
|
| is_user_logged_in_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -806,7 +722,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAppNoPolicy) {
|
| TEST_F(AutomaticRebootManagerBasicTest, ResumeBeforeGracePeriod) {
|
| is_user_logged_in_ = true;
|
| is_logged_in_as_kiosk_app_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -836,7 +752,7 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeBeforeGracePeriod) {
|
| // immediately reboot.
|
| TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeBeforeGracePeriod) {
|
| is_user_logged_in_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -867,7 +783,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeBeforeGracePeriod) {
|
| TEST_F(AutomaticRebootManagerBasicTest, ResumeInGracePeriod) {
|
| is_user_logged_in_ = true;
|
| is_logged_in_as_kiosk_app_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -894,7 +810,7 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeInGracePeriod) {
|
| // immediately reboot.
|
| TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeInGracePeriod) {
|
| is_user_logged_in_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -925,7 +841,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeInGracePeriod) {
|
| TEST_F(AutomaticRebootManagerBasicTest, ResumeAfterGracePeriod) {
|
| is_user_logged_in_ = true;
|
| is_logged_in_as_kiosk_app_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(29) +
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(29) +
|
| base::TimeDelta::FromMinutes(30));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -953,7 +869,7 @@ TEST_F(AutomaticRebootManagerBasicTest, ResumeAfterGracePeriod) {
|
| // immediately reboot.
|
| TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) {
|
| is_user_logged_in_ = true;
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(29) +
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(29) +
|
| base::TimeDelta::FromMinutes(30));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -982,7 +898,7 @@ TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) {
|
| // Verifies that when the browser terminates, the device does not immediately
|
| // reboot.
|
| TEST_P(AutomaticRebootManagerTest, TerminateNoPolicy) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1005,7 +921,7 @@ TEST_P(AutomaticRebootManagerTest, TerminateNoPolicy) {
|
| // 12 hours.
|
| // Verifies that when the browser terminates, it does not immediately reboot.
|
| TEST_P(AutomaticRebootManagerTest, TerminateBeforeGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1036,7 +952,7 @@ TEST_P(AutomaticRebootManagerTest, TerminateBeforeGracePeriod) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1066,7 +982,7 @@ TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) {
|
| // Verifies that when the uptime limit is set to 24 hours, no reboot occurs and
|
| // a grace period is scheduled to begin after 24 hours of uptime.
|
| TEST_P(AutomaticRebootManagerTest, BeforeUptimeLimitGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1095,7 +1011,7 @@ TEST_P(AutomaticRebootManagerTest, BeforeUptimeLimitGracePeriod) {
|
| // Verifies that when the uptime limit is set to 6 hours, a reboot is requested
|
| // and a grace period is started that will end after 6 + 24 hours of uptime.
|
| TEST_P(AutomaticRebootManagerTest, InUptimeLimitGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1125,7 +1041,7 @@ TEST_P(AutomaticRebootManagerTest, InUptimeLimitGracePeriod) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1152,7 +1068,7 @@ TEST_P(AutomaticRebootManagerTest, AfterUptimeLimitGracePeriod) {
|
| // 6 hours.
|
| // Verifies that when the uptime limit is removed, the grace period is removed.
|
| TEST_P(AutomaticRebootManagerTest, UptimeLimitOffBeforeGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(6));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(6));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1186,7 +1102,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffBeforeGracePeriod) {
|
| // 24 hours.
|
| // Verifies that when the uptime limit is removed, the grace period is removed.
|
| TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(24));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(24));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1222,7 +1138,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) {
|
| // Verifies that when the uptime limit is extended to 24 hours, the grace period
|
| // is rescheduled to start further in the future.
|
| TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitBeforeGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(6));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(6));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1261,7 +1177,7 @@ TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitBeforeGracePeriod) {
|
| // Verifies that when the uptime limit is extended to 24 hours, the grace period
|
| // is rescheduled to start in the future.
|
| TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(18));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(18));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1300,7 +1216,7 @@ TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) {
|
| // Verifies that when the uptime limit is shortened to 6 hours, the grace period
|
| // is rescheduled to have already started.
|
| TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitBeforeToInGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1338,7 +1254,7 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitBeforeToInGracePeriod) {
|
| // Verifies that when the uptime limit is shortened to 18 hours, the grace
|
| // period is rescheduled to have started earlier.
|
| TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(36));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(36));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1378,7 +1294,7 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(36));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1417,7 +1333,7 @@ TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) {
|
| // policy to automatically reboot after an update is not enabled, no reboot
|
| // occurs and no grace period is scheduled.
|
| TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1436,7 +1352,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that no grace period has started.
|
| VerifyNoGracePeriod();
|
| @@ -1451,7 +1367,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) {
|
| // policy to automatically reboot after an update is enabled, a reboot is
|
| // requested and a grace period is started that will end 24 hours from now.
|
| TEST_P(AutomaticRebootManagerTest, Update) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1472,7 +1388,7 @@ TEST_P(AutomaticRebootManagerTest, Update) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that a grace period has started.
|
| VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_);
|
| @@ -1488,7 +1404,7 @@ TEST_P(AutomaticRebootManagerTest, Update) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1509,7 +1425,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateAfterUpdate) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that a grace period has started.
|
| VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_);
|
| @@ -1542,7 +1458,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateAfterUpdate) {
|
| // the current uptime is persisted as the time at which a reboot became
|
| // necessary.
|
| TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromMinutes(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromMinutes(10));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1562,7 +1478,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that a grace period has been scheduled to begin in the future.
|
| VerifyGracePeriod(base::TimeDelta::FromHours(1));
|
| @@ -1581,7 +1497,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) {
|
| // enabled, a reboot is requested and a grace period is started that will end
|
| // after 6 + 24 hours of uptime.
|
| TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateInGracePeriod) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(6));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(6));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1621,7 +1537,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateInGracePeriod) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(6));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -1660,7 +1576,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateAfterGracePeriod) {
|
| // Verifies that when the policy to automatically reboot after an update is
|
| // disabled, the reboot request and grace period are removed.
|
| TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(6));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(6));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1675,7 +1591,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) {
|
| NotifyUpdateRebootNeeded();
|
|
|
| // Verify that a grace period has started.
|
| - VerifyGracePeriod(task_runner_->Uptime() + uptime_processing_delay_);
|
| + VerifyGracePeriod(uptime_provider()->uptime() + uptime_processing_delay_);
|
|
|
| // Fast forward the uptime by 20 seconds. Verify that the device does not
|
| // reboot immediately.
|
| @@ -1741,7 +1657,7 @@ TEST_P(AutomaticRebootManagerTest, NoUptime) {
|
| // that the current uptime is persisted as the time at which a reboot became
|
| // necessary.
|
| TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1772,7 +1688,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that the grace period has not been rescheduled.
|
| VerifyGracePeriod(uptime_limit_);
|
| @@ -1790,7 +1706,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) {
|
| // from now. Further verifies that the current uptime is persisted as the time
|
| // at which a reboot became necessary.
|
| TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1819,7 +1735,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that the grace period has been rescheduled to start at the time that
|
| // the update became available.
|
| @@ -1839,7 +1755,7 @@ TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1864,7 +1780,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffThenUptimeLimitOff) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that a grace period has been rescheduled to end 24 hours from now.
|
| VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_);
|
| @@ -1901,7 +1817,7 @@ TEST_P(AutomaticRebootManagerTest, PolicyOffThenUptimeLimitOff) {
|
| // when the policy to reboot after an update is disabled, the reboot request and
|
| // grace period are removed.
|
| TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -1919,7 +1835,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that the grace period has started.
|
| VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_);
|
| @@ -1962,7 +1878,7 @@ TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) {
|
| // 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) +
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(29) +
|
| base::TimeDelta::FromMinutes(59) +
|
| base::TimeDelta::FromSeconds(59));
|
|
|
| @@ -1995,7 +1911,7 @@ TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) {
|
| // Verifies that when no automatic reboot policy is enabled, no reboot occurs
|
| // and no grace period is scheduled.
|
| TEST_P(AutomaticRebootManagerTest, StartNoPolicy) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -2016,7 +1932,7 @@ TEST_P(AutomaticRebootManagerTest, StartNoPolicy) {
|
| // 24 hours of uptime.
|
| TEST_P(AutomaticRebootManagerTest, StartBeforeUptimeLimitGracePeriod) {
|
| SetUptimeLimit(base::TimeDelta::FromHours(24), false);
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -2040,7 +1956,7 @@ TEST_P(AutomaticRebootManagerTest, StartBeforeUptimeLimitGracePeriod) {
|
| // 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));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that a reboot is requested and unless a non-kiosk-app session is in
|
| // progress, the the device immediately reboots.
|
| @@ -2061,7 +1977,7 @@ TEST_P(AutomaticRebootManagerTest, StartAfterUptimeLimitGracePeriod) {
|
| // end after 6 + 24 hours of uptime.
|
| TEST_P(AutomaticRebootManagerTest, StartInUptimeLimitGracePeriod) {
|
| SetUptimeLimit(base::TimeDelta::FromHours(6), false);
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
|
|
| // Verify that a reboot is requested but the device does not reboot
|
| // immediately.
|
| @@ -2087,7 +2003,7 @@ TEST_P(AutomaticRebootManagerTest, StartInUptimeLimitGracePeriod) {
|
| TEST_P(AutomaticRebootManagerTest, StartAfterUpdateGracePeriod) {
|
| SetUpdateStatusNeedReboot();
|
| SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6));
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that a reboot is requested and unless a non-kiosk-app session is in
|
| @@ -2113,7 +2029,7 @@ TEST_P(AutomaticRebootManagerTest, StartAfterUpdateGracePeriod) {
|
| TEST_P(AutomaticRebootManagerTest, StartInUpdateGracePeriod) {
|
| SetUpdateStatusNeedReboot();
|
| SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6));
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that a reboot is requested but the device does not reboot
|
| @@ -2141,7 +2057,7 @@ TEST_P(AutomaticRebootManagerTest, StartInUpdateGracePeriod) {
|
| TEST_P(AutomaticRebootManagerTest, StartBeforeUpdateGracePeriod) {
|
| SetUpdateStatusNeedReboot();
|
| SetUpdateRebootNeededUptime(base::TimeDelta::FromMinutes(10));
|
| - task_runner_->SetUptime(base::TimeDelta::FromMinutes(20));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromMinutes(20));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -2168,7 +2084,7 @@ TEST_P(AutomaticRebootManagerTest, StartBeforeUpdateGracePeriod) {
|
| TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicy) {
|
| SetUpdateStatusNeedReboot();
|
| SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6));
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -2192,7 +2108,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicy) {
|
| // is started that will end 24 hours from now.
|
| TEST_P(AutomaticRebootManagerTest, StartUpdateTimeLost) {
|
| SetUpdateStatusNeedReboot();
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that a reboot is requested but the device does not reboot
|
| @@ -2206,7 +2122,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateTimeLost) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that a grace period has started.
|
| VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_);
|
| @@ -2226,7 +2142,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateTimeLost) {
|
| // is scheduled.
|
| TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) {
|
| SetUpdateStatusNeedReboot();
|
| - task_runner_->SetUptime(base::TimeDelta::FromDays(10));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromDays(10));
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| // immediately.
|
| @@ -2238,7 +2154,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) {
|
| // reboot became necessary.
|
| EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile(
|
| &update_reboot_needed_uptime_));
|
| - EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_);
|
| + EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_);
|
|
|
| // Verify that no grace period has started.
|
| VerifyNoGracePeriod();
|
| @@ -2253,7 +2169,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) {
|
| // necessary. Further verifies that no reboot occurs and no grace period is
|
| // scheduled.
|
| TEST_P(AutomaticRebootManagerTest, StartNoUpdate) {
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that no reboot is requested and the device does not reboot
|
| @@ -2284,7 +2200,7 @@ TEST_P(AutomaticRebootManagerTest, StartUptimeLimitBeforeUpdate) {
|
| SetUptimeLimit(base::TimeDelta::FromHours(6), false);
|
| SetUpdateStatusNeedReboot();
|
| SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(8));
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that a reboot is requested but the device does not reboot
|
| @@ -2312,7 +2228,7 @@ TEST_P(AutomaticRebootManagerTest, StartUpdateBeforeUptimeLimit) {
|
| SetUptimeLimit(base::TimeDelta::FromHours(8), false);
|
| SetUpdateStatusNeedReboot();
|
| SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6));
|
| - task_runner_->SetUptime(base::TimeDelta::FromHours(12));
|
| + uptime_provider()->SetUptime(base::TimeDelta::FromHours(12));
|
| SetRebootAfterUpdate(true, false);
|
|
|
| // Verify that a reboot is requested but the device does not reboot
|
|
|