Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" | 5 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | |
| 9 | 8 |
| 10 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 11 #include "ash/test/test_shell_delegate.h" | 10 #include "ash/test/test_shell_delegate.h" |
| 12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 17 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 18 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 19 #include "base/prefs/pref_registry_simple.h" | 18 #include "base/prefs/pref_registry_simple.h" |
| 20 #include "base/prefs/testing_pref_service.h" | 19 #include "base/prefs/testing_pref_service.h" |
| 21 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 22 #include "base/single_thread_task_runner.h" | |
| 23 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/test/simple_test_tick_clock.h" | 22 #include "base/test/simple_test_tick_clock.h" |
| 23 #include "base/test/test_mock_time_task_runner.h" | |
| 25 #include "base/thread_task_runner_handle.h" | 24 #include "base/thread_task_runner_handle.h" |
| 26 #include "base/threading/sequenced_worker_pool.h" | 25 #include "base/threading/sequenced_worker_pool.h" |
| 27 #include "base/time/tick_clock.h" | 26 #include "base/time/tick_clock.h" |
| 28 #include "base/values.h" | 27 #include "base/values.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" | 29 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" |
| 31 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 30 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 32 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h" | 31 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h" |
| 33 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 34 #include "chrome/test/base/testing_browser_process.h" | 33 #include "chrome/test/base/testing_browser_process.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 48 using ::testing::_; | 47 using ::testing::_; |
| 49 using ::testing::Invoke; | 48 using ::testing::Invoke; |
| 50 using ::testing::Mock; | 49 using ::testing::Mock; |
| 51 using ::testing::ReturnPointee; | 50 using ::testing::ReturnPointee; |
| 52 | 51 |
| 53 namespace chromeos { | 52 namespace chromeos { |
| 54 namespace system { | 53 namespace system { |
| 55 | 54 |
| 56 namespace { | 55 namespace { |
| 57 | 56 |
| 58 // A SingleThreadTaskRunner that mocks the current time and allows it to be | 57 // Provides a mock device uptime that follows the mock time maintained by the |
| 59 // fast-forwarded. The current time in ticks is returned by Now(). The | 58 // given |mock_time_task_runner| with a configurable offset. The mock uptime can |
| 60 // corresponding device uptime is written to |uptime_file_|, providing a mock | 59 // also be written to |uptime_file_|, thusly allowing to mock /proc/uptime. |
| 61 // for /proc/uptime. | 60 class MockUptimeProvider { |
| 62 class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { | |
| 63 public: | 61 public: |
| 64 MockTimeSingleThreadTaskRunner(); | 62 explicit MockUptimeProvider( |
| 63 base::TestMockTimeTaskRunner* mock_time_task_runner); | |
|
bartfab (slow)
2015/01/13 18:15:46
You should specify that |mock_time_task_runner| ne
engedy
2015/01/13 18:25:56
This will be owned by the test-specific class deri
bartfab (slow)
2015/01/13 18:29:34
You could make the self-reference not be a problem
| |
| 65 | 64 |
| 66 // base::SingleThreadTaskRunner: | 65 void WriteUptimeToFile(); |
| 67 virtual bool RunsTasksOnCurrentThread() const override; | |
| 68 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | |
| 69 const base::Closure& task, | |
| 70 base::TimeDelta delay) override; | |
| 71 virtual bool PostNonNestableDelayedTask( | |
| 72 const tracked_objects::Location& from_here, | |
| 73 const base::Closure& task, | |
| 74 base::TimeDelta delay) override; | |
| 75 | 66 |
| 76 void SetUptimeFile(const base::FilePath& uptime_file); | 67 // Adjusts the offset so that the current mock uptime will be |uptime|. |
| 77 void SetUptime(const base::TimeDelta& uptime); | 68 void SetUptime(const base::TimeDelta& uptime); |
| 78 | 69 |
| 79 const base::TimeDelta& Uptime() const; | 70 void set_uptime_file_path(const base::FilePath& uptime_file_path) { |
| 80 const base::TimeTicks& Now() const; | 71 uptime_file_path_ = uptime_file_path; |
| 72 } | |
| 81 | 73 |
| 82 void FastForwardBy(const base::TimeDelta& delta); | 74 base::TimeDelta uptime() const { |
| 83 void FastForwardUntilNoTasksRemain(); | 75 return mock_time_task_runner_->GetCurrentMockTime() - base::TimeTicks() + |
| 84 void RunUntilIdle(); | 76 uptime_offset_; |
| 77 } | |
| 85 | 78 |
| 86 private: | 79 private: |
| 87 // Strict weak temporal ordering of tasks. | 80 base::TestMockTimeTaskRunner* mock_time_task_runner_; |
| 88 class TemporalOrder { | |
| 89 public: | |
| 90 bool operator()( | |
| 91 const std::pair<base::TimeTicks, base::Closure>& first_task, | |
| 92 const std::pair<base::TimeTicks, base::Closure>& second_task) const; | |
| 93 }; | |
| 94 | 81 |
| 95 virtual ~MockTimeSingleThreadTaskRunner(); | 82 base::FilePath uptime_file_path_; |
| 83 base::TimeDelta uptime_offset_; | |
| 96 | 84 |
| 97 base::FilePath uptime_file_; | 85 DISALLOW_COPY_AND_ASSIGN(MockUptimeProvider); |
| 98 base::TimeDelta uptime_; | |
| 99 base::TimeTicks now_; | |
| 100 std::priority_queue<std::pair<base::TimeTicks, base::Closure>, | |
| 101 std::vector<std::pair<base::TimeTicks, base::Closure> >, | |
| 102 TemporalOrder> tasks_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(MockTimeSingleThreadTaskRunner); | |
| 105 }; | 86 }; |
| 106 | 87 |
| 107 class MockTimeTickClock : public base::TickClock { | 88 class TestAutomaticRebootManagerTaskRunner |
| 89 : public base::TestMockTimeTaskRunner { | |
| 108 public: | 90 public: |
| 109 explicit MockTimeTickClock( | 91 TestAutomaticRebootManagerTaskRunner(); |
| 110 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner); | |
| 111 virtual ~MockTimeTickClock(); | |
| 112 | 92 |
| 113 // base::TickClock: | 93 MockUptimeProvider* uptime_provider() const { |
| 114 virtual base::TimeTicks NowTicks() override; | 94 return uptime_provider_.get(); |
| 95 } | |
| 115 | 96 |
| 116 private: | 97 private: |
| 117 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_; | 98 ~TestAutomaticRebootManagerTaskRunner() override; |
| 118 | 99 |
| 119 DISALLOW_COPY_AND_ASSIGN(MockTimeTickClock); | 100 // base::TestMockTimeTaskRunner: |
| 101 void OnBeforeSelectingTask() override; | |
| 102 void OnAfterTimePassed() override; | |
| 103 void OnAfterTaskRun() override; | |
| 104 | |
| 105 scoped_ptr<MockUptimeProvider> uptime_provider_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(TestAutomaticRebootManagerTaskRunner); | |
| 120 }; | 108 }; |
| 121 | 109 |
| 122 class MockAutomaticRebootManagerObserver | 110 class MockAutomaticRebootManagerObserver |
| 123 : public AutomaticRebootManagerObserver { | 111 : public AutomaticRebootManagerObserver { |
| 124 public: | 112 public: |
| 125 MockAutomaticRebootManagerObserver(); | 113 MockAutomaticRebootManagerObserver(); |
| 126 ~MockAutomaticRebootManagerObserver() override; | 114 ~MockAutomaticRebootManagerObserver() override; |
| 127 | 115 |
| 128 void Init(AutomaticRebootManager* automatic_reboot_manger); | 116 void Init(AutomaticRebootManager* automatic_reboot_manger); |
| 129 | 117 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 bool ReadUpdateRebootNeededUptimeFromFile(base::TimeDelta* uptime); | 158 bool ReadUpdateRebootNeededUptimeFromFile(base::TimeDelta* uptime); |
| 171 void VerifyRebootRequested(AutomaticRebootManagerObserver::Reason reason); | 159 void VerifyRebootRequested(AutomaticRebootManagerObserver::Reason reason); |
| 172 void VerifyNoRebootRequested() const; | 160 void VerifyNoRebootRequested() const; |
| 173 void VerifyLoginScreenIdleTimerIsStopped() const; | 161 void VerifyLoginScreenIdleTimerIsStopped() const; |
| 174 void VerifyNoGracePeriod() const; | 162 void VerifyNoGracePeriod() const; |
| 175 void VerifyGracePeriod(const base::TimeDelta& start_uptime) const; | 163 void VerifyGracePeriod(const base::TimeDelta& start_uptime) const; |
| 176 | 164 |
| 177 // Sets the status of |update_engine_client_| to NEED_REBOOT for tests. | 165 // Sets the status of |update_engine_client_| to NEED_REBOOT for tests. |
| 178 void SetUpdateStatusNeedReboot(); | 166 void SetUpdateStatusNeedReboot(); |
| 179 | 167 |
| 168 MockUptimeProvider* uptime_provider() const { | |
| 169 return task_runner_->uptime_provider(); | |
| 170 } | |
| 171 | |
| 180 bool is_user_logged_in_; | 172 bool is_user_logged_in_; |
| 181 bool is_logged_in_as_kiosk_app_; | 173 bool is_logged_in_as_kiosk_app_; |
| 182 | 174 |
| 183 // The uptime is read in the blocking thread pool and then processed on the | 175 // The uptime is read in the blocking thread pool and then processed on the |
| 184 // UI thread. This causes the UI thread to start processing the uptime when it | 176 // UI thread. This causes the UI thread to start processing the uptime when it |
| 185 // has increased by a small offset already. The offset is calculated and | 177 // has increased by a small offset already. The offset is calculated and |
| 186 // stored in |uptime_processing_delay_| so that tests can accurately determine | 178 // stored in |uptime_processing_delay_| so that tests can accurately determine |
| 187 // the uptime seen by the UI thread. | 179 // the uptime seen by the UI thread. |
| 188 base::TimeDelta uptime_processing_delay_; | 180 base::TimeDelta uptime_processing_delay_; |
| 189 base::TimeDelta update_reboot_needed_uptime_; | 181 base::TimeDelta update_reboot_needed_uptime_; |
| 190 base::TimeDelta uptime_limit_; | 182 base::TimeDelta uptime_limit_; |
| 191 | 183 |
| 192 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_; | 184 scoped_refptr<TestAutomaticRebootManagerTaskRunner> task_runner_; |
| 193 | 185 |
| 194 MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_; | 186 MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_; |
| 195 scoped_ptr<AutomaticRebootManager> automatic_reboot_manager_; | 187 scoped_ptr<AutomaticRebootManager> automatic_reboot_manager_; |
| 196 | 188 |
| 197 private: | 189 private: |
| 198 void VerifyTimerIsStopped(const Timer* timer) const; | 190 void VerifyTimerIsStopped(const Timer* timer) const; |
| 199 void VerifyTimerIsRunning(const Timer* timer, | 191 void VerifyTimerIsRunning(const Timer* timer, |
| 200 const base::TimeDelta& delay) const; | 192 const base::TimeDelta& delay) const; |
| 201 void VerifyLoginScreenIdleTimerIsRunning() const; | 193 void VerifyLoginScreenIdleTimerIsRunning() const; |
| 202 | 194 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 const base::TimeDelta& uptime) { | 229 const base::TimeDelta& uptime) { |
| 238 if (path.empty() || uptime == base::TimeDelta()) | 230 if (path.empty() || uptime == base::TimeDelta()) |
| 239 return; | 231 return; |
| 240 | 232 |
| 241 const std::string uptime_seconds = base::DoubleToString(uptime.InSecondsF()); | 233 const std::string uptime_seconds = base::DoubleToString(uptime.InSecondsF()); |
| 242 ASSERT_EQ(static_cast<int>(uptime_seconds.size()), | 234 ASSERT_EQ(static_cast<int>(uptime_seconds.size()), |
| 243 base::WriteFile(path, uptime_seconds.c_str(), | 235 base::WriteFile(path, uptime_seconds.c_str(), |
| 244 uptime_seconds.size())); | 236 uptime_seconds.size())); |
| 245 } | 237 } |
| 246 | 238 |
| 247 MockTimeSingleThreadTaskRunner::MockTimeSingleThreadTaskRunner() { | 239 MockUptimeProvider::MockUptimeProvider( |
| 240 base::TestMockTimeTaskRunner* mock_time_task_runner) | |
| 241 : mock_time_task_runner_(mock_time_task_runner) { | |
| 248 } | 242 } |
| 249 | 243 |
| 250 bool MockTimeSingleThreadTaskRunner::RunsTasksOnCurrentThread() const { | 244 void MockUptimeProvider::WriteUptimeToFile() { |
| 251 return true; | 245 SaveUptimeToFile(uptime_file_path_, uptime()); |
| 252 } | 246 } |
| 253 | 247 |
| 254 bool MockTimeSingleThreadTaskRunner::PostDelayedTask( | 248 void MockUptimeProvider::SetUptime(const base::TimeDelta& uptime) { |
| 255 const tracked_objects::Location& from_here, | 249 uptime_offset_ = uptime - (mock_time_task_runner_->GetCurrentMockTime() - |
| 256 const base::Closure& task, | 250 base::TimeTicks()); |
| 257 base::TimeDelta delay) { | 251 WriteUptimeToFile(); |
| 258 tasks_.push(std::pair<base::TimeTicks, base::Closure>(now_ + delay, task)); | |
| 259 return true; | |
| 260 } | 252 } |
| 261 | 253 |
| 262 bool MockTimeSingleThreadTaskRunner::PostNonNestableDelayedTask( | 254 TestAutomaticRebootManagerTaskRunner::TestAutomaticRebootManagerTaskRunner() |
| 263 const tracked_objects::Location& from_here, | 255 : uptime_provider_(new MockUptimeProvider(this)) { |
| 264 const base::Closure& task, | |
| 265 base::TimeDelta delay) { | |
| 266 NOTREACHED(); | |
| 267 return false; | |
| 268 } | 256 } |
| 269 | 257 |
| 270 void MockTimeSingleThreadTaskRunner::SetUptimeFile( | 258 TestAutomaticRebootManagerTaskRunner::~TestAutomaticRebootManagerTaskRunner() { |
| 271 const base::FilePath& uptime_file) { | |
| 272 uptime_file_ = uptime_file; | |
| 273 SaveUptimeToFile(uptime_file_, uptime_); | |
| 274 } | 259 } |
| 275 | 260 |
| 276 void MockTimeSingleThreadTaskRunner::SetUptime(const base::TimeDelta& uptime) { | 261 void TestAutomaticRebootManagerTaskRunner::OnBeforeSelectingTask() { |
| 277 uptime_ = uptime; | |
| 278 SaveUptimeToFile(uptime_file_, uptime_); | |
| 279 } | |
| 280 | |
| 281 const base::TimeDelta& MockTimeSingleThreadTaskRunner::Uptime() const { | |
| 282 return uptime_; | |
| 283 } | |
| 284 | |
| 285 const base::TimeTicks& MockTimeSingleThreadTaskRunner::Now() const { | |
| 286 return now_; | |
| 287 } | |
| 288 | |
| 289 void MockTimeSingleThreadTaskRunner::FastForwardBy( | |
| 290 const base::TimeDelta& delta) { | |
| 291 const base::TimeTicks latest = now_ + delta; | |
| 292 base::SequencedWorkerPool* blocking_pool = | 262 base::SequencedWorkerPool* blocking_pool = |
| 293 content::BrowserThread::GetBlockingPool(); | 263 content::BrowserThread::GetBlockingPool(); |
| 294 blocking_pool->FlushForTesting(); | 264 blocking_pool->FlushForTesting(); |
| 295 while (!tasks_.empty() && tasks_.top().first <= latest) { | |
| 296 uptime_ += tasks_.top().first - now_; | |
| 297 SaveUptimeToFile(uptime_file_, uptime_); | |
| 298 now_ = tasks_.top().first; | |
| 299 base::Closure task = tasks_.top().second; | |
| 300 tasks_.pop(); | |
| 301 task.Run(); | |
| 302 blocking_pool->FlushForTesting(); | |
| 303 } | |
| 304 uptime_ += latest - now_; | |
| 305 SaveUptimeToFile(uptime_file_, uptime_); | |
| 306 now_ = latest; | |
| 307 } | 265 } |
| 308 | 266 |
| 309 void MockTimeSingleThreadTaskRunner::FastForwardUntilNoTasksRemain() { | 267 void TestAutomaticRebootManagerTaskRunner::OnAfterTimePassed() { |
| 268 uptime_provider_->WriteUptimeToFile(); | |
| 269 } | |
| 270 | |
| 271 void TestAutomaticRebootManagerTaskRunner::OnAfterTaskRun() { | |
| 310 base::SequencedWorkerPool* blocking_pool = | 272 base::SequencedWorkerPool* blocking_pool = |
| 311 content::BrowserThread::GetBlockingPool(); | 273 content::BrowserThread::GetBlockingPool(); |
| 312 blocking_pool->FlushForTesting(); | 274 blocking_pool->FlushForTesting(); |
| 313 while (!tasks_.empty()) { | |
| 314 uptime_ += tasks_.top().first - now_; | |
| 315 SaveUptimeToFile(uptime_file_, uptime_); | |
| 316 now_ = tasks_.top().first; | |
| 317 base::Closure task = tasks_.top().second; | |
| 318 tasks_.pop(); | |
| 319 task.Run(); | |
| 320 blocking_pool->FlushForTesting(); | |
| 321 } | |
| 322 } | |
| 323 | |
| 324 void MockTimeSingleThreadTaskRunner::RunUntilIdle() { | |
| 325 base::SequencedWorkerPool* blocking_pool = | |
| 326 content::BrowserThread::GetBlockingPool(); | |
| 327 blocking_pool->FlushForTesting(); | |
| 328 while (!tasks_.empty() && tasks_.top().first <= now_) { | |
| 329 base::Closure task = tasks_.top().second; | |
| 330 tasks_.pop(); | |
| 331 task.Run(); | |
| 332 blocking_pool->FlushForTesting(); | |
| 333 } | |
| 334 } | |
| 335 | |
| 336 bool MockTimeSingleThreadTaskRunner::TemporalOrder::operator()( | |
| 337 const std::pair<base::TimeTicks, base::Closure>& first_task, | |
| 338 const std::pair<base::TimeTicks, base::Closure>& second_task) const { | |
| 339 return first_task.first > second_task.first; | |
| 340 } | |
| 341 | |
| 342 MockTimeSingleThreadTaskRunner::~MockTimeSingleThreadTaskRunner() { | |
| 343 } | |
| 344 | |
| 345 MockTimeTickClock::MockTimeTickClock( | |
| 346 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner) | |
| 347 : task_runner_(task_runner) { | |
| 348 } | |
| 349 | |
| 350 MockTimeTickClock::~MockTimeTickClock() { | |
| 351 } | |
| 352 | |
| 353 base::TimeTicks MockTimeTickClock::NowTicks() { | |
| 354 return task_runner_->Now(); | |
| 355 } | 275 } |
| 356 | 276 |
| 357 MockAutomaticRebootManagerObserver::MockAutomaticRebootManagerObserver() | 277 MockAutomaticRebootManagerObserver::MockAutomaticRebootManagerObserver() |
| 358 : automatic_reboot_manger_(nullptr) { | 278 : automatic_reboot_manger_(nullptr) { |
| 359 ON_CALL(*this, WillDestroyAutomaticRebootManager()) | 279 ON_CALL(*this, WillDestroyAutomaticRebootManager()) |
| 360 .WillByDefault( | 280 .WillByDefault( |
| 361 Invoke(this, | 281 Invoke(this, |
| 362 &MockAutomaticRebootManagerObserver::StopObserving)); | 282 &MockAutomaticRebootManagerObserver::StopObserving)); |
| 363 } | 283 } |
| 364 | 284 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 376 | 296 |
| 377 void MockAutomaticRebootManagerObserver::StopObserving() { | 297 void MockAutomaticRebootManagerObserver::StopObserving() { |
| 378 ASSERT_TRUE(automatic_reboot_manger_); | 298 ASSERT_TRUE(automatic_reboot_manger_); |
| 379 automatic_reboot_manger_->RemoveObserver(this); | 299 automatic_reboot_manger_->RemoveObserver(this); |
| 380 automatic_reboot_manger_ = nullptr; | 300 automatic_reboot_manger_ = nullptr; |
| 381 } | 301 } |
| 382 | 302 |
| 383 AutomaticRebootManagerBasicTest::AutomaticRebootManagerBasicTest() | 303 AutomaticRebootManagerBasicTest::AutomaticRebootManagerBasicTest() |
| 384 : is_user_logged_in_(false), | 304 : is_user_logged_in_(false), |
| 385 is_logged_in_as_kiosk_app_(false), | 305 is_logged_in_as_kiosk_app_(false), |
| 386 task_runner_(new MockTimeSingleThreadTaskRunner), | 306 task_runner_(new TestAutomaticRebootManagerTaskRunner), |
| 387 reboot_after_update_(false), | 307 reboot_after_update_(false), |
| 388 ui_thread_task_runner_handle_(task_runner_), | 308 ui_thread_task_runner_handle_(task_runner_), |
| 389 mock_user_manager_(new MockUserManager), | 309 mock_user_manager_(new MockUserManager), |
| 390 user_manager_enabler_(mock_user_manager_), | 310 user_manager_enabler_(mock_user_manager_), |
| 391 power_manager_client_(NULL), | 311 power_manager_client_(NULL), |
| 392 update_engine_client_(NULL) { | 312 update_engine_client_(NULL) { |
| 393 } | 313 } |
| 394 | 314 |
| 395 AutomaticRebootManagerBasicTest::~AutomaticRebootManagerBasicTest() { | 315 AutomaticRebootManagerBasicTest::~AutomaticRebootManagerBasicTest() { |
| 396 } | 316 } |
| 397 | 317 |
| 398 void AutomaticRebootManagerBasicTest::SetUp() { | 318 void AutomaticRebootManagerBasicTest::SetUp() { |
| 399 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 319 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 400 const base::FilePath& temp_dir = temp_dir_.path(); | 320 const base::FilePath& temp_dir = temp_dir_.path(); |
| 401 const base::FilePath uptime_file = temp_dir.Append("uptime"); | 321 const base::FilePath uptime_file = temp_dir.Append("uptime"); |
| 402 task_runner_->SetUptimeFile(uptime_file); | 322 uptime_provider()->set_uptime_file_path(uptime_file); |
| 403 ASSERT_FALSE(base::WriteFile(uptime_file, NULL, 0)); | 323 ASSERT_FALSE(base::WriteFile(uptime_file, NULL, 0)); |
| 404 update_reboot_needed_uptime_file_ = | 324 update_reboot_needed_uptime_file_ = |
| 405 temp_dir.Append("update_reboot_needed_uptime"); | 325 temp_dir.Append("update_reboot_needed_uptime"); |
| 406 ASSERT_FALSE(base::WriteFile(update_reboot_needed_uptime_file_, NULL, 0)); | 326 ASSERT_FALSE(base::WriteFile(update_reboot_needed_uptime_file_, NULL, 0)); |
| 407 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPTIME, uptime_file)); | 327 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPTIME, uptime_file)); |
| 408 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME, | 328 ASSERT_TRUE(PathService::Override(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME, |
| 409 update_reboot_needed_uptime_file_)); | 329 update_reboot_needed_uptime_file_)); |
| 410 | 330 |
| 411 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | 331 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); |
| 412 AutomaticRebootManager::RegisterPrefs(local_state_.registry()); | 332 AutomaticRebootManager::RegisterPrefs(local_state_.registry()); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_); | 451 Mock::VerifyAndClearExpectations(&automatic_reboot_manager_observer_); |
| 532 EXPECT_CALL(automatic_reboot_manager_observer_, | 452 EXPECT_CALL(automatic_reboot_manager_observer_, |
| 533 WillDestroyAutomaticRebootManager()).Times(0); | 453 WillDestroyAutomaticRebootManager()).Times(0); |
| 534 EXPECT_CALL(automatic_reboot_manager_observer_, | 454 EXPECT_CALL(automatic_reboot_manager_observer_, |
| 535 OnRebootRequested(_)).Times(0); | 455 OnRebootRequested(_)).Times(0); |
| 536 } | 456 } |
| 537 | 457 |
| 538 void AutomaticRebootManagerBasicTest::CreateAutomaticRebootManager( | 458 void AutomaticRebootManagerBasicTest::CreateAutomaticRebootManager( |
| 539 bool expect_reboot) { | 459 bool expect_reboot) { |
| 540 automatic_reboot_manager_.reset(new AutomaticRebootManager( | 460 automatic_reboot_manager_.reset(new AutomaticRebootManager( |
| 541 scoped_ptr<base::TickClock>(new MockTimeTickClock(task_runner_)))); | 461 scoped_ptr<base::TickClock>(task_runner_->GetMockTickClock()))); |
| 542 automatic_reboot_manager_observer_.Init(automatic_reboot_manager_.get()); | 462 automatic_reboot_manager_observer_.Init(automatic_reboot_manager_.get()); |
| 543 task_runner_->RunUntilIdle(); | 463 task_runner_->RunUntilIdle(); |
| 544 EXPECT_EQ(expect_reboot ? 1 : 0, | 464 EXPECT_EQ(expect_reboot ? 1 : 0, |
| 545 power_manager_client_->num_request_restart_calls()); | 465 power_manager_client_->num_request_restart_calls()); |
| 546 | 466 |
| 547 uptime_processing_delay_ = | 467 uptime_processing_delay_ = |
| 548 base::TimeTicks() - automatic_reboot_manager_->boot_time_ - | 468 base::TimeTicks() - automatic_reboot_manager_->boot_time_ - |
| 549 task_runner_->Uptime(); | 469 uptime_provider()->uptime(); |
| 550 EXPECT_GE(uptime_processing_delay_, base::TimeDelta()); | 470 EXPECT_GE(uptime_processing_delay_, base::TimeDelta()); |
| 551 EXPECT_LE(uptime_processing_delay_, base::TimeDelta::FromSeconds(1)); | 471 EXPECT_LE(uptime_processing_delay_, base::TimeDelta::FromSeconds(1)); |
| 552 | 472 |
| 553 if (is_user_logged_in_ || expect_reboot) | 473 if (is_user_logged_in_ || expect_reboot) |
| 554 VerifyLoginScreenIdleTimerIsStopped(); | 474 VerifyLoginScreenIdleTimerIsStopped(); |
| 555 else | 475 else |
| 556 VerifyLoginScreenIdleTimerIsRunning(); | 476 VerifyLoginScreenIdleTimerIsRunning(); |
| 557 } | 477 } |
| 558 | 478 |
| 559 bool AutomaticRebootManagerBasicTest::ReadUpdateRebootNeededUptimeFromFile( | 479 bool AutomaticRebootManagerBasicTest::ReadUpdateRebootNeededUptimeFromFile( |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 589 | 509 |
| 590 void AutomaticRebootManagerBasicTest::VerifyNoGracePeriod() const { | 510 void AutomaticRebootManagerBasicTest::VerifyNoGracePeriod() const { |
| 591 EXPECT_FALSE(automatic_reboot_manager_->reboot_requested_); | 511 EXPECT_FALSE(automatic_reboot_manager_->reboot_requested_); |
| 592 VerifyTimerIsStopped(automatic_reboot_manager_->grace_start_timer_.get()); | 512 VerifyTimerIsStopped(automatic_reboot_manager_->grace_start_timer_.get()); |
| 593 VerifyTimerIsStopped(automatic_reboot_manager_->grace_end_timer_.get()); | 513 VerifyTimerIsStopped(automatic_reboot_manager_->grace_end_timer_.get()); |
| 594 } | 514 } |
| 595 | 515 |
| 596 void AutomaticRebootManagerBasicTest::VerifyGracePeriod( | 516 void AutomaticRebootManagerBasicTest::VerifyGracePeriod( |
| 597 const base::TimeDelta& start_uptime) const { | 517 const base::TimeDelta& start_uptime) const { |
| 598 const base::TimeDelta start = | 518 const base::TimeDelta start = |
| 599 start_uptime - task_runner_->Uptime() - uptime_processing_delay_; | 519 start_uptime - uptime_provider()->uptime() - uptime_processing_delay_; |
| 600 const base::TimeDelta end = start + base::TimeDelta::FromHours(24); | 520 const base::TimeDelta end = start + base::TimeDelta::FromHours(24); |
| 601 if (start <= base::TimeDelta()) { | 521 if (start <= base::TimeDelta()) { |
| 602 EXPECT_TRUE(automatic_reboot_manager_->reboot_requested_); | 522 EXPECT_TRUE(automatic_reboot_manager_->reboot_requested_); |
| 603 VerifyTimerIsStopped(automatic_reboot_manager_->grace_start_timer_.get()); | 523 VerifyTimerIsStopped(automatic_reboot_manager_->grace_start_timer_.get()); |
| 604 VerifyTimerIsRunning(automatic_reboot_manager_->grace_end_timer_.get(), | 524 VerifyTimerIsRunning(automatic_reboot_manager_->grace_end_timer_.get(), |
| 605 end); | 525 end); |
| 606 } else { | 526 } else { |
| 607 EXPECT_FALSE(automatic_reboot_manager_->reboot_requested_); | 527 EXPECT_FALSE(automatic_reboot_manager_->reboot_requested_); |
| 608 VerifyTimerIsRunning(automatic_reboot_manager_->grace_start_timer_.get(), | 528 VerifyTimerIsRunning(automatic_reboot_manager_->grace_start_timer_.get(), |
| 609 start); | 529 start); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 } | 577 } |
| 658 } | 578 } |
| 659 | 579 |
| 660 AutomaticRebootManagerTest::~AutomaticRebootManagerTest() { | 580 AutomaticRebootManagerTest::~AutomaticRebootManagerTest() { |
| 661 } | 581 } |
| 662 | 582 |
| 663 // Chrome is showing the login screen. The current uptime is 12 hours. | 583 // Chrome is showing the login screen. The current uptime is 12 hours. |
| 664 // Verifies that the idle timer is running. Further verifies that when a kiosk | 584 // Verifies that the idle timer is running. Further verifies that when a kiosk |
| 665 // app session begins, the idle timer is stopped. | 585 // app session begins, the idle timer is stopped. |
| 666 TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) { | 586 TEST_F(AutomaticRebootManagerBasicTest, LoginStopsIdleTimer) { |
| 667 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 587 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 668 | 588 |
| 669 // Verify that no reboot is requested, the device does not reboot immediately | 589 // Verify that no reboot is requested, the device does not reboot immediately |
| 670 // and the login screen idle timer is started. | 590 // and the login screen idle timer is started. |
| 671 ExpectNoRebootRequest(); | 591 ExpectNoRebootRequest(); |
| 672 CreateAutomaticRebootManager(false); | 592 CreateAutomaticRebootManager(false); |
| 673 VerifyNoRebootRequested(); | 593 VerifyNoRebootRequested(); |
| 674 | 594 |
| 675 // Notify that a kiosk app session has been started. | 595 // Notify that a kiosk app session has been started. |
| 676 is_user_logged_in_ = true; | 596 is_user_logged_in_ = true; |
| 677 is_logged_in_as_kiosk_app_ = true; | 597 is_logged_in_as_kiosk_app_ = true; |
| 678 automatic_reboot_manager_->Observe( | 598 automatic_reboot_manager_->Observe( |
| 679 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 599 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 680 content::Source<AutomaticRebootManagerBasicTest>(this), | 600 content::Source<AutomaticRebootManagerBasicTest>(this), |
| 681 content::NotificationService::NoDetails()); | 601 content::NotificationService::NoDetails()); |
| 682 | 602 |
| 683 // Verify that the login screen idle timer is stopped. | 603 // Verify that the login screen idle timer is stopped. |
| 684 VerifyLoginScreenIdleTimerIsStopped(); | 604 VerifyLoginScreenIdleTimerIsStopped(); |
| 685 | 605 |
| 686 // Verify that a reboot is never requested and the device never reboots. | 606 // Verify that a reboot is never requested and the device never reboots. |
| 687 FastForwardUntilNoTasksRemain(false); | 607 FastForwardUntilNoTasksRemain(false); |
| 688 } | 608 } |
| 689 | 609 |
| 690 // Chrome is showing the login screen. The current uptime is 12 hours. | 610 // Chrome is showing the login screen. The current uptime is 12 hours. |
| 691 // Verifies that the idle timer is running. Further verifies that when a | 611 // Verifies that the idle timer is running. Further verifies that when a |
| 692 // non-kiosk-app session begins, the idle timer is stopped. | 612 // non-kiosk-app session begins, the idle timer is stopped. |
| 693 TEST_F(AutomaticRebootManagerBasicTest, NonKioskLoginStopsIdleTimer) { | 613 TEST_F(AutomaticRebootManagerBasicTest, NonKioskLoginStopsIdleTimer) { |
| 694 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 614 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 695 | 615 |
| 696 // Verify that no reboot is requested, the device does not reboot immediately | 616 // Verify that no reboot is requested, the device does not reboot immediately |
| 697 // and the login screen idle timer is started. | 617 // and the login screen idle timer is started. |
| 698 ExpectNoRebootRequest(); | 618 ExpectNoRebootRequest(); |
| 699 CreateAutomaticRebootManager(false); | 619 CreateAutomaticRebootManager(false); |
| 700 VerifyNoRebootRequested(); | 620 VerifyNoRebootRequested(); |
| 701 | 621 |
| 702 // Notify that a non-kiosk-app session has been started. | 622 // Notify that a non-kiosk-app session has been started. |
| 703 is_user_logged_in_ = true; | 623 is_user_logged_in_ = true; |
| 704 automatic_reboot_manager_->Observe( | 624 automatic_reboot_manager_->Observe( |
| 705 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 625 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 706 content::Source<AutomaticRebootManagerBasicTest>(this), | 626 content::Source<AutomaticRebootManagerBasicTest>(this), |
| 707 content::NotificationService::NoDetails()); | 627 content::NotificationService::NoDetails()); |
| 708 | 628 |
| 709 // Verify that the login screen idle timer is stopped. | 629 // Verify that the login screen idle timer is stopped. |
| 710 VerifyLoginScreenIdleTimerIsStopped(); | 630 VerifyLoginScreenIdleTimerIsStopped(); |
| 711 | 631 |
| 712 // Verify that a reboot is never requested and the device never reboots. | 632 // Verify that a reboot is never requested and the device never reboots. |
| 713 FastForwardUntilNoTasksRemain(false); | 633 FastForwardUntilNoTasksRemain(false); |
| 714 } | 634 } |
| 715 | 635 |
| 716 // Chrome is showing the login screen. The uptime limit is 6 hours. The current | 636 // Chrome is showing the login screen. The uptime limit is 6 hours. The current |
| 717 // uptime is 12 hours. | 637 // uptime is 12 hours. |
| 718 // Verifies that user activity prevents the device from rebooting. Further | 638 // Verifies that user activity prevents the device from rebooting. Further |
| 719 // verifies that when user activity ceases, the devices reboots. | 639 // verifies that when user activity ceases, the devices reboots. |
| 720 TEST_F(AutomaticRebootManagerBasicTest, UserActivityResetsIdleTimer) { | 640 TEST_F(AutomaticRebootManagerBasicTest, UserActivityResetsIdleTimer) { |
| 721 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 641 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 722 | 642 |
| 723 // Verify that no reboot is requested, the device does not reboot immediately | 643 // Verify that no reboot is requested, the device does not reboot immediately |
| 724 // and the login screen idle timer is started. | 644 // and the login screen idle timer is started. |
| 725 ExpectNoRebootRequest(); | 645 ExpectNoRebootRequest(); |
| 726 CreateAutomaticRebootManager(false); | 646 CreateAutomaticRebootManager(false); |
| 727 VerifyNoRebootRequested(); | 647 VerifyNoRebootRequested(); |
| 728 | 648 |
| 729 // Set the uptime limit. Verify that a reboot is requested but the device does | 649 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 730 // not reboot immediately. | 650 // not reboot immediately. |
| 731 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 651 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 749 // Verify that the device reboots immediately. | 669 // Verify that the device reboots immediately. |
| 750 FastForwardBy(base::TimeDelta::FromSeconds(60), true); | 670 FastForwardBy(base::TimeDelta::FromSeconds(60), true); |
| 751 } | 671 } |
| 752 | 672 |
| 753 // Chrome is running a kiosk app session. The current uptime is 10 days. | 673 // Chrome is running a kiosk app session. The current uptime is 10 days. |
| 754 // Verifies that when the device is suspended and then resumes, it does not | 674 // Verifies that when the device is suspended and then resumes, it does not |
| 755 // immediately reboot. | 675 // immediately reboot. |
| 756 TEST_F(AutomaticRebootManagerBasicTest, ResumeNoPolicy) { | 676 TEST_F(AutomaticRebootManagerBasicTest, ResumeNoPolicy) { |
| 757 is_user_logged_in_ = true; | 677 is_user_logged_in_ = true; |
| 758 is_logged_in_as_kiosk_app_ = true; | 678 is_logged_in_as_kiosk_app_ = true; |
| 759 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 679 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 760 | 680 |
| 761 // Verify that no reboot is requested and the device does not reboot | 681 // Verify that no reboot is requested and the device does not reboot |
| 762 // immediately. | 682 // immediately. |
| 763 ExpectNoRebootRequest(); | 683 ExpectNoRebootRequest(); |
| 764 CreateAutomaticRebootManager(false); | 684 CreateAutomaticRebootManager(false); |
| 765 VerifyNoRebootRequested(); | 685 VerifyNoRebootRequested(); |
| 766 | 686 |
| 767 // Verify that no grace period has started. | 687 // Verify that no grace period has started. |
| 768 VerifyNoGracePeriod(); | 688 VerifyNoGracePeriod(); |
| 769 | 689 |
| 770 // Notify that the device has resumed from 1 hour of sleep. Verify that no | 690 // Notify that the device has resumed from 1 hour of sleep. Verify that no |
| 771 // reboot is requested and the device does not reboot immediately. | 691 // reboot is requested and the device does not reboot immediately. |
| 772 NotifyResumed(false); | 692 NotifyResumed(false); |
| 773 | 693 |
| 774 // Verify that a reboot is never requested and the device never reboots. | 694 // Verify that a reboot is never requested and the device never reboots. |
| 775 FastForwardUntilNoTasksRemain(false); | 695 FastForwardUntilNoTasksRemain(false); |
| 776 } | 696 } |
| 777 | 697 |
| 778 // Chrome is running a non-kiosk-app session. The current uptime is 10 days. | 698 // Chrome is running a non-kiosk-app session. The current uptime is 10 days. |
| 779 // Verifies that when the device is suspended and then resumes, it does not | 699 // Verifies that when the device is suspended and then resumes, it does not |
| 780 // immediately reboot. | 700 // immediately reboot. |
| 781 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAppNoPolicy) { | 701 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAppNoPolicy) { |
| 782 is_user_logged_in_ = true; | 702 is_user_logged_in_ = true; |
| 783 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 703 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 784 | 704 |
| 785 // Verify that no reboot is requested and the device does not reboot | 705 // Verify that no reboot is requested and the device does not reboot |
| 786 // immediately. | 706 // immediately. |
| 787 ExpectNoRebootRequest(); | 707 ExpectNoRebootRequest(); |
| 788 CreateAutomaticRebootManager(false); | 708 CreateAutomaticRebootManager(false); |
| 789 VerifyNoRebootRequested(); | 709 VerifyNoRebootRequested(); |
| 790 | 710 |
| 791 // Verify that no grace period has started. | 711 // Verify that no grace period has started. |
| 792 VerifyNoGracePeriod(); | 712 VerifyNoGracePeriod(); |
| 793 | 713 |
| 794 // Notify that the device has resumed from 1 hour of sleep. Verify that no | 714 // Notify that the device has resumed from 1 hour of sleep. Verify that no |
| 795 // reboot is requested and the device does not reboot immediately. | 715 // reboot is requested and the device does not reboot immediately. |
| 796 NotifyResumed(false); | 716 NotifyResumed(false); |
| 797 | 717 |
| 798 // Verify that a reboot is never requested and the device never reboots. | 718 // Verify that a reboot is never requested and the device never reboots. |
| 799 FastForwardUntilNoTasksRemain(false); | 719 FastForwardUntilNoTasksRemain(false); |
| 800 } | 720 } |
| 801 | 721 |
| 802 // Chrome is running a kiosk app session. The uptime limit is 24 hours. The | 722 // Chrome is running a kiosk app session. The uptime limit is 24 hours. The |
| 803 // current uptime is 12 hours. | 723 // current uptime is 12 hours. |
| 804 // Verifies that when the device is suspended and then resumes, it does not | 724 // Verifies that when the device is suspended and then resumes, it does not |
| 805 // immediately reboot. | 725 // immediately reboot. |
| 806 TEST_F(AutomaticRebootManagerBasicTest, ResumeBeforeGracePeriod) { | 726 TEST_F(AutomaticRebootManagerBasicTest, ResumeBeforeGracePeriod) { |
| 807 is_user_logged_in_ = true; | 727 is_user_logged_in_ = true; |
| 808 is_logged_in_as_kiosk_app_ = true; | 728 is_logged_in_as_kiosk_app_ = true; |
| 809 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 729 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 810 | 730 |
| 811 // Verify that no reboot is requested and the device does not reboot | 731 // Verify that no reboot is requested and the device does not reboot |
| 812 // immediately. | 732 // immediately. |
| 813 ExpectNoRebootRequest(); | 733 ExpectNoRebootRequest(); |
| 814 CreateAutomaticRebootManager(false); | 734 CreateAutomaticRebootManager(false); |
| 815 VerifyNoRebootRequested(); | 735 VerifyNoRebootRequested(); |
| 816 | 736 |
| 817 // Set the uptime limit. Verify that no reboot is requested and the device | 737 // Set the uptime limit. Verify that no reboot is requested and the device |
| 818 // does not reboot immediately. | 738 // does not reboot immediately. |
| 819 SetUptimeLimit(base::TimeDelta::FromHours(24), false); | 739 SetUptimeLimit(base::TimeDelta::FromHours(24), false); |
| 820 | 740 |
| 821 // Verify that a grace period has been scheduled to start in the future. | 741 // Verify that a grace period has been scheduled to start in the future. |
| 822 VerifyGracePeriod(uptime_limit_); | 742 VerifyGracePeriod(uptime_limit_); |
| 823 | 743 |
| 824 // Notify that the device has resumed from 1 hour of sleep. Verify that no | 744 // Notify that the device has resumed from 1 hour of sleep. Verify that no |
| 825 // reboot is requested and the device does not reboot immediately. | 745 // reboot is requested and the device does not reboot immediately. |
| 826 NotifyResumed(false); | 746 NotifyResumed(false); |
| 827 | 747 |
| 828 // Verify a reboot is requested and the device reboots eventually. | 748 // Verify a reboot is requested and the device reboots eventually. |
| 829 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 749 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 830 FastForwardUntilNoTasksRemain(true); | 750 FastForwardUntilNoTasksRemain(true); |
| 831 } | 751 } |
| 832 | 752 |
| 833 // Chrome is running a non-kiosk-app session. The uptime limit is 24 hours. The | 753 // Chrome is running a non-kiosk-app session. The uptime limit is 24 hours. The |
| 834 // current uptime is 12 hours. | 754 // current uptime is 12 hours. |
| 835 // Verifies that when the device is suspended and then resumes, it does not | 755 // Verifies that when the device is suspended and then resumes, it does not |
| 836 // immediately reboot. | 756 // immediately reboot. |
| 837 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeBeforeGracePeriod) { | 757 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeBeforeGracePeriod) { |
| 838 is_user_logged_in_ = true; | 758 is_user_logged_in_ = true; |
| 839 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 759 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 840 | 760 |
| 841 // Verify that no reboot is requested and the device does not reboot | 761 // Verify that no reboot is requested and the device does not reboot |
| 842 // immediately. | 762 // immediately. |
| 843 ExpectNoRebootRequest(); | 763 ExpectNoRebootRequest(); |
| 844 CreateAutomaticRebootManager(false); | 764 CreateAutomaticRebootManager(false); |
| 845 VerifyNoRebootRequested(); | 765 VerifyNoRebootRequested(); |
| 846 | 766 |
| 847 // Set the uptime limit. Verify that no reboot is requested and the device | 767 // Set the uptime limit. Verify that no reboot is requested and the device |
| 848 // does not reboot immediately. | 768 // does not reboot immediately. |
| 849 SetUptimeLimit(base::TimeDelta::FromHours(24), false); | 769 SetUptimeLimit(base::TimeDelta::FromHours(24), false); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 860 FastForwardUntilNoTasksRemain(false); | 780 FastForwardUntilNoTasksRemain(false); |
| 861 } | 781 } |
| 862 | 782 |
| 863 // Chrome is running a kiosk app session. The uptime limit is 6 hours. The | 783 // Chrome is running a kiosk app session. The uptime limit is 6 hours. The |
| 864 // current uptime is 12 hours. | 784 // current uptime is 12 hours. |
| 865 // Verifies that when the device is suspended and then resumes, it immediately | 785 // Verifies that when the device is suspended and then resumes, it immediately |
| 866 // reboots. | 786 // reboots. |
| 867 TEST_F(AutomaticRebootManagerBasicTest, ResumeInGracePeriod) { | 787 TEST_F(AutomaticRebootManagerBasicTest, ResumeInGracePeriod) { |
| 868 is_user_logged_in_ = true; | 788 is_user_logged_in_ = true; |
| 869 is_logged_in_as_kiosk_app_ = true; | 789 is_logged_in_as_kiosk_app_ = true; |
| 870 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 790 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 871 | 791 |
| 872 // Verify that no reboot is requested and the device does not reboot | 792 // Verify that no reboot is requested and the device does not reboot |
| 873 // immediately. | 793 // immediately. |
| 874 ExpectNoRebootRequest(); | 794 ExpectNoRebootRequest(); |
| 875 CreateAutomaticRebootManager(false); | 795 CreateAutomaticRebootManager(false); |
| 876 VerifyNoRebootRequested(); | 796 VerifyNoRebootRequested(); |
| 877 | 797 |
| 878 // Set the uptime limit. Verify that a reboot is requested but the device does | 798 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 879 // not reboot immediately. | 799 // not reboot immediately. |
| 880 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 800 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 881 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 801 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 882 | 802 |
| 883 // Verify that a grace period has started. | 803 // Verify that a grace period has started. |
| 884 VerifyGracePeriod(uptime_limit_); | 804 VerifyGracePeriod(uptime_limit_); |
| 885 | 805 |
| 886 // Notify that the device has resumed from 1 hour of sleep. Verify that the | 806 // Notify that the device has resumed from 1 hour of sleep. Verify that the |
| 887 // device reboots immediately. | 807 // device reboots immediately. |
| 888 NotifyResumed(true); | 808 NotifyResumed(true); |
| 889 } | 809 } |
| 890 | 810 |
| 891 // Chrome is running a non-kiosk-app session. The uptime limit is 6 hours. The | 811 // Chrome is running a non-kiosk-app session. The uptime limit is 6 hours. The |
| 892 // current uptime is 12 hours. | 812 // current uptime is 12 hours. |
| 893 // Verifies that when the device is suspended and then resumes, it does not | 813 // Verifies that when the device is suspended and then resumes, it does not |
| 894 // immediately reboot. | 814 // immediately reboot. |
| 895 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeInGracePeriod) { | 815 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeInGracePeriod) { |
| 896 is_user_logged_in_ = true; | 816 is_user_logged_in_ = true; |
| 897 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 817 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 898 | 818 |
| 899 // Verify that no reboot is requested and the device does not reboot | 819 // Verify that no reboot is requested and the device does not reboot |
| 900 // immediately. | 820 // immediately. |
| 901 ExpectNoRebootRequest(); | 821 ExpectNoRebootRequest(); |
| 902 CreateAutomaticRebootManager(false); | 822 CreateAutomaticRebootManager(false); |
| 903 VerifyNoRebootRequested(); | 823 VerifyNoRebootRequested(); |
| 904 | 824 |
| 905 // Set the uptime limit. Verify that a reboot is requested but the device does | 825 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 906 // not reboot immediately. | 826 // not reboot immediately. |
| 907 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 827 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 918 FastForwardUntilNoTasksRemain(false); | 838 FastForwardUntilNoTasksRemain(false); |
| 919 } | 839 } |
| 920 | 840 |
| 921 // Chrome is running a kiosk app session. The uptime limit is 6 hours. The | 841 // Chrome is running a kiosk app session. The uptime limit is 6 hours. The |
| 922 // current uptime is 29 hours 30 minutes. | 842 // current uptime is 29 hours 30 minutes. |
| 923 // Verifies that when the device is suspended and then resumes, it immediately | 843 // Verifies that when the device is suspended and then resumes, it immediately |
| 924 // reboots. | 844 // reboots. |
| 925 TEST_F(AutomaticRebootManagerBasicTest, ResumeAfterGracePeriod) { | 845 TEST_F(AutomaticRebootManagerBasicTest, ResumeAfterGracePeriod) { |
| 926 is_user_logged_in_ = true; | 846 is_user_logged_in_ = true; |
| 927 is_logged_in_as_kiosk_app_ = true; | 847 is_logged_in_as_kiosk_app_ = true; |
| 928 task_runner_->SetUptime(base::TimeDelta::FromHours(29) + | 848 uptime_provider()->SetUptime(base::TimeDelta::FromHours(29) + |
| 929 base::TimeDelta::FromMinutes(30)); | 849 base::TimeDelta::FromMinutes(30)); |
| 930 | 850 |
| 931 // Verify that no reboot is requested and the device does not reboot | 851 // Verify that no reboot is requested and the device does not reboot |
| 932 // immediately. | 852 // immediately. |
| 933 ExpectNoRebootRequest(); | 853 ExpectNoRebootRequest(); |
| 934 CreateAutomaticRebootManager(false); | 854 CreateAutomaticRebootManager(false); |
| 935 VerifyNoRebootRequested(); | 855 VerifyNoRebootRequested(); |
| 936 | 856 |
| 937 // Set the uptime limit. Verify that a reboot is requested but the device does | 857 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 938 // not reboot immediately. | 858 // not reboot immediately. |
| 939 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 859 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 940 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 860 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 941 | 861 |
| 942 // Verify that a grace period has started. | 862 // Verify that a grace period has started. |
| 943 VerifyGracePeriod(uptime_limit_); | 863 VerifyGracePeriod(uptime_limit_); |
| 944 | 864 |
| 945 // Notify that the device has resumed from 1 hour of sleep. Verify that the | 865 // Notify that the device has resumed from 1 hour of sleep. Verify that the |
| 946 // device reboots immediately. | 866 // device reboots immediately. |
| 947 NotifyResumed(true); | 867 NotifyResumed(true); |
| 948 } | 868 } |
| 949 | 869 |
| 950 // Chrome is running a non-kiosk-app session. The uptime limit is 6 hours. The | 870 // Chrome is running a non-kiosk-app session. The uptime limit is 6 hours. The |
| 951 // current uptime is 29 hours 30 minutes. | 871 // current uptime is 29 hours 30 minutes. |
| 952 // Verifies that when the device is suspended and then resumes, it does not | 872 // Verifies that when the device is suspended and then resumes, it does not |
| 953 // immediately reboot. | 873 // immediately reboot. |
| 954 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) { | 874 TEST_F(AutomaticRebootManagerBasicTest, NonKioskResumeAfterGracePeriod) { |
| 955 is_user_logged_in_ = true; | 875 is_user_logged_in_ = true; |
| 956 task_runner_->SetUptime(base::TimeDelta::FromHours(29) + | 876 uptime_provider()->SetUptime(base::TimeDelta::FromHours(29) + |
| 957 base::TimeDelta::FromMinutes(30)); | 877 base::TimeDelta::FromMinutes(30)); |
| 958 | 878 |
| 959 // Verify that no reboot is requested and the device does not reboot | 879 // Verify that no reboot is requested and the device does not reboot |
| 960 // immediately. | 880 // immediately. |
| 961 ExpectNoRebootRequest(); | 881 ExpectNoRebootRequest(); |
| 962 CreateAutomaticRebootManager(false); | 882 CreateAutomaticRebootManager(false); |
| 963 VerifyNoRebootRequested(); | 883 VerifyNoRebootRequested(); |
| 964 | 884 |
| 965 // Set the uptime limit. Verify that a reboot is requested but the device does | 885 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 966 // not reboot immediately. | 886 // not reboot immediately. |
| 967 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 887 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 968 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 888 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 969 | 889 |
| 970 // Verify that a grace period has started. | 890 // Verify that a grace period has started. |
| 971 VerifyGracePeriod(uptime_limit_); | 891 VerifyGracePeriod(uptime_limit_); |
| 972 | 892 |
| 973 // Notify that the device has resumed from 1 hour of sleep. Verify that the | 893 // Notify that the device has resumed from 1 hour of sleep. Verify that the |
| 974 // device does not reboot immediately. | 894 // device does not reboot immediately. |
| 975 NotifyResumed(false); | 895 NotifyResumed(false); |
| 976 | 896 |
| 977 // Verify that the device never reboots. | 897 // Verify that the device never reboots. |
| 978 FastForwardUntilNoTasksRemain(false); | 898 FastForwardUntilNoTasksRemain(false); |
| 979 } | 899 } |
| 980 | 900 |
| 981 // Chrome is running. The current uptime is 10 days. | 901 // Chrome is running. The current uptime is 10 days. |
| 982 // Verifies that when the browser terminates, the device does not immediately | 902 // Verifies that when the browser terminates, the device does not immediately |
| 983 // reboot. | 903 // reboot. |
| 984 TEST_P(AutomaticRebootManagerTest, TerminateNoPolicy) { | 904 TEST_P(AutomaticRebootManagerTest, TerminateNoPolicy) { |
| 985 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 905 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 986 | 906 |
| 987 // Verify that no reboot is requested and the device does not reboot | 907 // Verify that no reboot is requested and the device does not reboot |
| 988 // immediately. | 908 // immediately. |
| 989 ExpectNoRebootRequest(); | 909 ExpectNoRebootRequest(); |
| 990 CreateAutomaticRebootManager(false); | 910 CreateAutomaticRebootManager(false); |
| 991 VerifyNoRebootRequested(); | 911 VerifyNoRebootRequested(); |
| 992 | 912 |
| 993 // Verify that no grace period has started. | 913 // Verify that no grace period has started. |
| 994 VerifyNoGracePeriod(); | 914 VerifyNoGracePeriod(); |
| 995 | 915 |
| 996 // Notify that the browser is terminating. Verify that no reboot is requested | 916 // Notify that the browser is terminating. Verify that no reboot is requested |
| 997 // and the device does not reboot immediately. | 917 // and the device does not reboot immediately. |
| 998 NotifyTerminating(false); | 918 NotifyTerminating(false); |
| 999 | 919 |
| 1000 // Verify that a reboot is never requested and the device never reboots. | 920 // Verify that a reboot is never requested and the device never reboots. |
| 1001 FastForwardUntilNoTasksRemain(false); | 921 FastForwardUntilNoTasksRemain(false); |
| 1002 } | 922 } |
| 1003 | 923 |
| 1004 // Chrome is running. The uptime limit is set to 24 hours. The current uptime is | 924 // Chrome is running. The uptime limit is set to 24 hours. The current uptime is |
| 1005 // 12 hours. | 925 // 12 hours. |
| 1006 // Verifies that when the browser terminates, it does not immediately reboot. | 926 // Verifies that when the browser terminates, it does not immediately reboot. |
| 1007 TEST_P(AutomaticRebootManagerTest, TerminateBeforeGracePeriod) { | 927 TEST_P(AutomaticRebootManagerTest, TerminateBeforeGracePeriod) { |
| 1008 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 928 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1009 | 929 |
| 1010 // Verify that no reboot is requested and the device does not reboot | 930 // Verify that no reboot is requested and the device does not reboot |
| 1011 // immediately. | 931 // immediately. |
| 1012 ExpectNoRebootRequest(); | 932 ExpectNoRebootRequest(); |
| 1013 CreateAutomaticRebootManager(false); | 933 CreateAutomaticRebootManager(false); |
| 1014 VerifyNoRebootRequested(); | 934 VerifyNoRebootRequested(); |
| 1015 | 935 |
| 1016 // Set the uptime limit. Verify that no reboot is requested and the device | 936 // Set the uptime limit. Verify that no reboot is requested and the device |
| 1017 // does not reboot immediately. | 937 // does not reboot immediately. |
| 1018 SetUptimeLimit(base::TimeDelta::FromHours(24), false); | 938 SetUptimeLimit(base::TimeDelta::FromHours(24), false); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1029 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 949 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1030 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 950 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1031 is_logged_in_as_kiosk_app_); | 951 is_logged_in_as_kiosk_app_); |
| 1032 } | 952 } |
| 1033 | 953 |
| 1034 // Chrome is running. The uptime limit is set to 6 hours. The current uptime is | 954 // Chrome is running. The uptime limit is set to 6 hours. The current uptime is |
| 1035 // 12 hours. | 955 // 12 hours. |
| 1036 // Verifies that when the browser terminates, the device immediately reboots if | 956 // Verifies that when the browser terminates, the device immediately reboots if |
| 1037 // a kiosk app session is in progress. | 957 // a kiosk app session is in progress. |
| 1038 TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) { | 958 TEST_P(AutomaticRebootManagerTest, TerminateInGracePeriod) { |
| 1039 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 959 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1040 | 960 |
| 1041 // Verify that no reboot is requested and the device does not reboot | 961 // Verify that no reboot is requested and the device does not reboot |
| 1042 // immediately. | 962 // immediately. |
| 1043 ExpectNoRebootRequest(); | 963 ExpectNoRebootRequest(); |
| 1044 CreateAutomaticRebootManager(false); | 964 CreateAutomaticRebootManager(false); |
| 1045 VerifyNoRebootRequested(); | 965 VerifyNoRebootRequested(); |
| 1046 | 966 |
| 1047 // Set the uptime limit. Verify that a reboot is requested but the device does | 967 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 1048 // not reboot immediately. | 968 // not reboot immediately. |
| 1049 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 969 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1050 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 970 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 1051 | 971 |
| 1052 // Verify that a grace period has started. | 972 // Verify that a grace period has started. |
| 1053 VerifyGracePeriod(uptime_limit_); | 973 VerifyGracePeriod(uptime_limit_); |
| 1054 | 974 |
| 1055 // Notify that the browser is terminating. Verify that the device immediately | 975 // Notify that the browser is terminating. Verify that the device immediately |
| 1056 // reboots if a kiosk app session is in progress. | 976 // reboots if a kiosk app session is in progress. |
| 1057 NotifyTerminating(is_logged_in_as_kiosk_app_); | 977 NotifyTerminating(is_logged_in_as_kiosk_app_); |
| 1058 | 978 |
| 1059 // Verify that if a non-kiosk-app session is in progress, the device never | 979 // Verify that if a non-kiosk-app session is in progress, the device never |
| 1060 // reboots. | 980 // reboots. |
| 1061 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 981 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1062 is_logged_in_as_kiosk_app_); | 982 is_logged_in_as_kiosk_app_); |
| 1063 } | 983 } |
| 1064 | 984 |
| 1065 // Chrome is running. The current uptime is 12 hours. | 985 // Chrome is running. The current uptime is 12 hours. |
| 1066 // Verifies that when the uptime limit is set to 24 hours, no reboot occurs and | 986 // Verifies that when the uptime limit is set to 24 hours, no reboot occurs and |
| 1067 // a grace period is scheduled to begin after 24 hours of uptime. | 987 // a grace period is scheduled to begin after 24 hours of uptime. |
| 1068 TEST_P(AutomaticRebootManagerTest, BeforeUptimeLimitGracePeriod) { | 988 TEST_P(AutomaticRebootManagerTest, BeforeUptimeLimitGracePeriod) { |
| 1069 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 989 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1070 | 990 |
| 1071 // Verify that no reboot is requested and the device does not reboot | 991 // Verify that no reboot is requested and the device does not reboot |
| 1072 // immediately. | 992 // immediately. |
| 1073 ExpectNoRebootRequest(); | 993 ExpectNoRebootRequest(); |
| 1074 CreateAutomaticRebootManager(false); | 994 CreateAutomaticRebootManager(false); |
| 1075 VerifyNoRebootRequested(); | 995 VerifyNoRebootRequested(); |
| 1076 | 996 |
| 1077 // Verify that no grace period has started. | 997 // Verify that no grace period has started. |
| 1078 VerifyNoGracePeriod(); | 998 VerifyNoGracePeriod(); |
| 1079 | 999 |
| 1080 // Set the uptime limit. Verify that no reboot is requested and the device | 1000 // Set the uptime limit. Verify that no reboot is requested and the device |
| 1081 // does not reboot immediately. | 1001 // does not reboot immediately. |
| 1082 SetUptimeLimit(base::TimeDelta::FromHours(24), false); | 1002 SetUptimeLimit(base::TimeDelta::FromHours(24), false); |
| 1083 | 1003 |
| 1084 // Verify that a grace period has been scheduled to start in the future. | 1004 // Verify that a grace period has been scheduled to start in the future. |
| 1085 VerifyGracePeriod(uptime_limit_); | 1005 VerifyGracePeriod(uptime_limit_); |
| 1086 | 1006 |
| 1087 // Verify that a reboot is requested eventually and unless a non-kiosk-app | 1007 // Verify that a reboot is requested eventually and unless a non-kiosk-app |
| 1088 // session is in progress, the device eventually reboots. | 1008 // session is in progress, the device eventually reboots. |
| 1089 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1009 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1090 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1010 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1091 is_logged_in_as_kiosk_app_); | 1011 is_logged_in_as_kiosk_app_); |
| 1092 } | 1012 } |
| 1093 | 1013 |
| 1094 // Chrome is running. The current uptime is 12 hours. | 1014 // Chrome is running. The current uptime is 12 hours. |
| 1095 // Verifies that when the uptime limit is set to 6 hours, a reboot is requested | 1015 // Verifies that when the uptime limit is set to 6 hours, a reboot is requested |
| 1096 // and a grace period is started that will end after 6 + 24 hours of uptime. | 1016 // and a grace period is started that will end after 6 + 24 hours of uptime. |
| 1097 TEST_P(AutomaticRebootManagerTest, InUptimeLimitGracePeriod) { | 1017 TEST_P(AutomaticRebootManagerTest, InUptimeLimitGracePeriod) { |
| 1098 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1018 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1099 | 1019 |
| 1100 // Verify that no reboot is requested and the device does not reboot | 1020 // Verify that no reboot is requested and the device does not reboot |
| 1101 // immediately. | 1021 // immediately. |
| 1102 ExpectNoRebootRequest(); | 1022 ExpectNoRebootRequest(); |
| 1103 CreateAutomaticRebootManager(false); | 1023 CreateAutomaticRebootManager(false); |
| 1104 VerifyNoRebootRequested(); | 1024 VerifyNoRebootRequested(); |
| 1105 | 1025 |
| 1106 // Verify that no grace period has started. | 1026 // Verify that no grace period has started. |
| 1107 VerifyNoGracePeriod(); | 1027 VerifyNoGracePeriod(); |
| 1108 | 1028 |
| 1109 // Set the uptime limit. Verify that a reboot is requested but the device does | 1029 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 1110 // not reboot immediately. | 1030 // not reboot immediately. |
| 1111 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1031 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1112 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 1032 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 1113 | 1033 |
| 1114 // Verify that a grace period has started. | 1034 // Verify that a grace period has started. |
| 1115 VerifyGracePeriod(uptime_limit_); | 1035 VerifyGracePeriod(uptime_limit_); |
| 1116 | 1036 |
| 1117 // Verify that unless a non-kiosk-app session is in progress, the device | 1037 // Verify that unless a non-kiosk-app session is in progress, the device |
| 1118 // eventually reboots. | 1038 // eventually reboots. |
| 1119 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1039 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1120 is_logged_in_as_kiosk_app_); | 1040 is_logged_in_as_kiosk_app_); |
| 1121 } | 1041 } |
| 1122 | 1042 |
| 1123 // Chrome is running. The current uptime is 10 days. | 1043 // Chrome is running. The current uptime is 10 days. |
| 1124 // Verifies that when the uptime limit is set to 6 hours, the device reboots | 1044 // Verifies that when the uptime limit is set to 6 hours, the device reboots |
| 1125 // immediately if no non-kiosk-app-session is in progress because the grace | 1045 // immediately if no non-kiosk-app-session is in progress because the grace |
| 1126 // period ended after 6 + 24 hours of uptime. | 1046 // period ended after 6 + 24 hours of uptime. |
| 1127 TEST_P(AutomaticRebootManagerTest, AfterUptimeLimitGracePeriod) { | 1047 TEST_P(AutomaticRebootManagerTest, AfterUptimeLimitGracePeriod) { |
| 1128 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 1048 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 1129 | 1049 |
| 1130 // Verify that no reboot is requested and the device does not reboot | 1050 // Verify that no reboot is requested and the device does not reboot |
| 1131 // immediately. | 1051 // immediately. |
| 1132 ExpectNoRebootRequest(); | 1052 ExpectNoRebootRequest(); |
| 1133 CreateAutomaticRebootManager(false); | 1053 CreateAutomaticRebootManager(false); |
| 1134 VerifyNoRebootRequested(); | 1054 VerifyNoRebootRequested(); |
| 1135 | 1055 |
| 1136 // Verify that no grace period has started. | 1056 // Verify that no grace period has started. |
| 1137 VerifyNoGracePeriod(); | 1057 VerifyNoGracePeriod(); |
| 1138 | 1058 |
| 1139 // Set the uptime limit. Verify that a reboot is requested and unless a | 1059 // Set the uptime limit. Verify that a reboot is requested and unless a |
| 1140 // non-kiosk-app session is in progress, the the device immediately reboots. | 1060 // non-kiosk-app session is in progress, the the device immediately reboots. |
| 1141 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1061 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1142 SetUptimeLimit(base::TimeDelta::FromHours(6), !is_user_logged_in_ || | 1062 SetUptimeLimit(base::TimeDelta::FromHours(6), !is_user_logged_in_ || |
| 1143 is_logged_in_as_kiosk_app_); | 1063 is_logged_in_as_kiosk_app_); |
| 1144 | 1064 |
| 1145 // Verify that if a non-kiosk-app session is in progress, the device never | 1065 // Verify that if a non-kiosk-app session is in progress, the device never |
| 1146 // reboots. | 1066 // reboots. |
| 1147 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1067 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1148 is_logged_in_as_kiosk_app_); | 1068 is_logged_in_as_kiosk_app_); |
| 1149 } | 1069 } |
| 1150 | 1070 |
| 1151 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is | 1071 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is |
| 1152 // 6 hours. | 1072 // 6 hours. |
| 1153 // Verifies that when the uptime limit is removed, the grace period is removed. | 1073 // Verifies that when the uptime limit is removed, the grace period is removed. |
| 1154 TEST_P(AutomaticRebootManagerTest, UptimeLimitOffBeforeGracePeriod) { | 1074 TEST_P(AutomaticRebootManagerTest, UptimeLimitOffBeforeGracePeriod) { |
| 1155 task_runner_->SetUptime(base::TimeDelta::FromHours(6)); | 1075 uptime_provider()->SetUptime(base::TimeDelta::FromHours(6)); |
| 1156 | 1076 |
| 1157 // Verify that no reboot is requested and the device does not reboot | 1077 // Verify that no reboot is requested and the device does not reboot |
| 1158 // immediately. | 1078 // immediately. |
| 1159 ExpectNoRebootRequest(); | 1079 ExpectNoRebootRequest(); |
| 1160 CreateAutomaticRebootManager(false); | 1080 CreateAutomaticRebootManager(false); |
| 1161 VerifyNoRebootRequested(); | 1081 VerifyNoRebootRequested(); |
| 1162 | 1082 |
| 1163 // Set the uptime limit. Verify that no reboot is requested and the device | 1083 // Set the uptime limit. Verify that no reboot is requested and the device |
| 1164 // does not reboot immediately. | 1084 // does not reboot immediately. |
| 1165 SetUptimeLimit(base::TimeDelta::FromHours(12), false); | 1085 SetUptimeLimit(base::TimeDelta::FromHours(12), false); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1179 VerifyNoGracePeriod(); | 1099 VerifyNoGracePeriod(); |
| 1180 | 1100 |
| 1181 // Verify that a reboot is never requested and the device never reboots. | 1101 // Verify that a reboot is never requested and the device never reboots. |
| 1182 FastForwardUntilNoTasksRemain(false); | 1102 FastForwardUntilNoTasksRemain(false); |
| 1183 } | 1103 } |
| 1184 | 1104 |
| 1185 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is | 1105 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is |
| 1186 // 24 hours. | 1106 // 24 hours. |
| 1187 // Verifies that when the uptime limit is removed, the grace period is removed. | 1107 // Verifies that when the uptime limit is removed, the grace period is removed. |
| 1188 TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) { | 1108 TEST_P(AutomaticRebootManagerTest, UptimeLimitOffInGracePeriod) { |
| 1189 task_runner_->SetUptime(base::TimeDelta::FromHours(24)); | 1109 uptime_provider()->SetUptime(base::TimeDelta::FromHours(24)); |
| 1190 | 1110 |
| 1191 // Verify that no reboot is requested and the device does not reboot | 1111 // Verify that no reboot is requested and the device does not reboot |
| 1192 // immediately. | 1112 // immediately. |
| 1193 ExpectNoRebootRequest(); | 1113 ExpectNoRebootRequest(); |
| 1194 CreateAutomaticRebootManager(false); | 1114 CreateAutomaticRebootManager(false); |
| 1195 VerifyNoRebootRequested(); | 1115 VerifyNoRebootRequested(); |
| 1196 | 1116 |
| 1197 // Set the uptime limit. Verify that a reboot is requested but the device does | 1117 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 1198 // not reboot immediately. | 1118 // not reboot immediately. |
| 1199 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1119 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1215 | 1135 |
| 1216 // Verify that the device never reboots. | 1136 // Verify that the device never reboots. |
| 1217 FastForwardUntilNoTasksRemain(false); | 1137 FastForwardUntilNoTasksRemain(false); |
| 1218 } | 1138 } |
| 1219 | 1139 |
| 1220 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is | 1140 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is |
| 1221 // 6 hours. | 1141 // 6 hours. |
| 1222 // Verifies that when the uptime limit is extended to 24 hours, the grace period | 1142 // Verifies that when the uptime limit is extended to 24 hours, the grace period |
| 1223 // is rescheduled to start further in the future. | 1143 // is rescheduled to start further in the future. |
| 1224 TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitBeforeGracePeriod) { | 1144 TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitBeforeGracePeriod) { |
| 1225 task_runner_->SetUptime(base::TimeDelta::FromHours(6)); | 1145 uptime_provider()->SetUptime(base::TimeDelta::FromHours(6)); |
| 1226 | 1146 |
| 1227 // Verify that no reboot is requested and the device does not reboot | 1147 // Verify that no reboot is requested and the device does not reboot |
| 1228 // immediately. | 1148 // immediately. |
| 1229 ExpectNoRebootRequest(); | 1149 ExpectNoRebootRequest(); |
| 1230 CreateAutomaticRebootManager(false); | 1150 CreateAutomaticRebootManager(false); |
| 1231 VerifyNoRebootRequested(); | 1151 VerifyNoRebootRequested(); |
| 1232 | 1152 |
| 1233 // Set the uptime limit. Verify that no reboot is requested and the device | 1153 // Set the uptime limit. Verify that no reboot is requested and the device |
| 1234 // does not reboot immediately. | 1154 // does not reboot immediately. |
| 1235 SetUptimeLimit(base::TimeDelta::FromHours(12), false); | 1155 SetUptimeLimit(base::TimeDelta::FromHours(12), false); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1254 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1174 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1255 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1175 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1256 is_logged_in_as_kiosk_app_); | 1176 is_logged_in_as_kiosk_app_); |
| 1257 } | 1177 } |
| 1258 | 1178 |
| 1259 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is | 1179 // Chrome is running. The uptime limit is set to 12 hours. The current uptime is |
| 1260 // 18 hours. | 1180 // 18 hours. |
| 1261 // Verifies that when the uptime limit is extended to 24 hours, the grace period | 1181 // Verifies that when the uptime limit is extended to 24 hours, the grace period |
| 1262 // is rescheduled to start in the future. | 1182 // is rescheduled to start in the future. |
| 1263 TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) { | 1183 TEST_P(AutomaticRebootManagerTest, ExtendUptimeLimitInGracePeriod) { |
| 1264 task_runner_->SetUptime(base::TimeDelta::FromHours(18)); | 1184 uptime_provider()->SetUptime(base::TimeDelta::FromHours(18)); |
| 1265 | 1185 |
| 1266 // Verify that no reboot is requested and the device does not reboot | 1186 // Verify that no reboot is requested and the device does not reboot |
| 1267 // immediately. | 1187 // immediately. |
| 1268 ExpectNoRebootRequest(); | 1188 ExpectNoRebootRequest(); |
| 1269 CreateAutomaticRebootManager(false); | 1189 CreateAutomaticRebootManager(false); |
| 1270 VerifyNoRebootRequested(); | 1190 VerifyNoRebootRequested(); |
| 1271 | 1191 |
| 1272 // Set the uptime limit. Verify that a reboot is requested but the device does | 1192 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 1273 // not reboot immediately. | 1193 // not reboot immediately. |
| 1274 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1194 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1293 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1213 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1294 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1214 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1295 is_logged_in_as_kiosk_app_); | 1215 is_logged_in_as_kiosk_app_); |
| 1296 } | 1216 } |
| 1297 | 1217 |
| 1298 // Chrome is running. The uptime limit is set to 18 hours. The current uptime is | 1218 // Chrome is running. The uptime limit is set to 18 hours. The current uptime is |
| 1299 // 12 hours. | 1219 // 12 hours. |
| 1300 // Verifies that when the uptime limit is shortened to 6 hours, the grace period | 1220 // Verifies that when the uptime limit is shortened to 6 hours, the grace period |
| 1301 // is rescheduled to have already started. | 1221 // is rescheduled to have already started. |
| 1302 TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitBeforeToInGracePeriod) { | 1222 TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitBeforeToInGracePeriod) { |
| 1303 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1223 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1304 | 1224 |
| 1305 // Verify that no reboot is requested and the device does not reboot | 1225 // Verify that no reboot is requested and the device does not reboot |
| 1306 // immediately. | 1226 // immediately. |
| 1307 ExpectNoRebootRequest(); | 1227 ExpectNoRebootRequest(); |
| 1308 CreateAutomaticRebootManager(false); | 1228 CreateAutomaticRebootManager(false); |
| 1309 VerifyNoRebootRequested(); | 1229 VerifyNoRebootRequested(); |
| 1310 | 1230 |
| 1311 // Set the uptime limit. Verify that no reboot is requested and the device | 1231 // Set the uptime limit. Verify that no reboot is requested and the device |
| 1312 // does not reboot immediately. | 1232 // does not reboot immediately. |
| 1313 SetUptimeLimit(base::TimeDelta::FromHours(18), false); | 1233 SetUptimeLimit(base::TimeDelta::FromHours(18), false); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1331 // eventually reboots. | 1251 // eventually reboots. |
| 1332 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1252 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1333 is_logged_in_as_kiosk_app_); | 1253 is_logged_in_as_kiosk_app_); |
| 1334 } | 1254 } |
| 1335 | 1255 |
| 1336 // Chrome is running. The uptime limit is set to 24 hours. The current uptime is | 1256 // Chrome is running. The uptime limit is set to 24 hours. The current uptime is |
| 1337 // 36 hours. | 1257 // 36 hours. |
| 1338 // Verifies that when the uptime limit is shortened to 18 hours, the grace | 1258 // Verifies that when the uptime limit is shortened to 18 hours, the grace |
| 1339 // period is rescheduled to have started earlier. | 1259 // period is rescheduled to have started earlier. |
| 1340 TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) { | 1260 TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToInGracePeriod) { |
| 1341 task_runner_->SetUptime(base::TimeDelta::FromHours(36)); | 1261 uptime_provider()->SetUptime(base::TimeDelta::FromHours(36)); |
| 1342 | 1262 |
| 1343 // Verify that no reboot is requested and the device does not reboot | 1263 // Verify that no reboot is requested and the device does not reboot |
| 1344 // immediately. | 1264 // immediately. |
| 1345 ExpectNoRebootRequest(); | 1265 ExpectNoRebootRequest(); |
| 1346 CreateAutomaticRebootManager(false); | 1266 CreateAutomaticRebootManager(false); |
| 1347 VerifyNoRebootRequested(); | 1267 VerifyNoRebootRequested(); |
| 1348 | 1268 |
| 1349 // Set the uptime limit. Verify that a reboot is requested but the device does | 1269 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 1350 // not reboot immediately. | 1270 // not reboot immediately. |
| 1351 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1271 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1371 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1291 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1372 is_logged_in_as_kiosk_app_); | 1292 is_logged_in_as_kiosk_app_); |
| 1373 } | 1293 } |
| 1374 | 1294 |
| 1375 // Chrome is running. The uptime limit is set to 24 hours. The current uptime is | 1295 // Chrome is running. The uptime limit is set to 24 hours. The current uptime is |
| 1376 // 36 hours. | 1296 // 36 hours. |
| 1377 // Verifies that when the uptime limit is shortened to 6 hours, the device | 1297 // Verifies that when the uptime limit is shortened to 6 hours, the device |
| 1378 // reboots immediately if no non-kiosk-app session is in progress because the | 1298 // reboots immediately if no non-kiosk-app session is in progress because the |
| 1379 // grace period ended after 6 + 24 hours of uptime. | 1299 // grace period ended after 6 + 24 hours of uptime. |
| 1380 TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) { | 1300 TEST_P(AutomaticRebootManagerTest, ShortenUptimeLimitInToAfterGracePeriod) { |
| 1381 task_runner_->SetUptime(base::TimeDelta::FromHours(36)); | 1301 uptime_provider()->SetUptime(base::TimeDelta::FromHours(36)); |
| 1382 | 1302 |
| 1383 // Verify that no reboot is requested and the device does not reboot | 1303 // Verify that no reboot is requested and the device does not reboot |
| 1384 // immediately. | 1304 // immediately. |
| 1385 ExpectNoRebootRequest(); | 1305 ExpectNoRebootRequest(); |
| 1386 CreateAutomaticRebootManager(false); | 1306 CreateAutomaticRebootManager(false); |
| 1387 VerifyNoRebootRequested(); | 1307 VerifyNoRebootRequested(); |
| 1388 | 1308 |
| 1389 // Set the uptime limit. Verify that a reboot is requested but the device does | 1309 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 1390 // not reboot immediately. | 1310 // not reboot immediately. |
| 1391 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1311 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1410 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1330 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1411 is_logged_in_as_kiosk_app_); | 1331 is_logged_in_as_kiosk_app_); |
| 1412 } | 1332 } |
| 1413 | 1333 |
| 1414 // Chrome is running. The current uptime is 12 hours. | 1334 // Chrome is running. The current uptime is 12 hours. |
| 1415 // Verifies that when an update is applied, the current uptime is persisted as | 1335 // Verifies that when an update is applied, the current uptime is persisted as |
| 1416 // the time at which a reboot became necessary. Further verifies that when the | 1336 // the time at which a reboot became necessary. Further verifies that when the |
| 1417 // policy to automatically reboot after an update is not enabled, no reboot | 1337 // policy to automatically reboot after an update is not enabled, no reboot |
| 1418 // occurs and no grace period is scheduled. | 1338 // occurs and no grace period is scheduled. |
| 1419 TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) { | 1339 TEST_P(AutomaticRebootManagerTest, UpdateNoPolicy) { |
| 1420 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1340 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1421 | 1341 |
| 1422 // Verify that no reboot is requested and the device does not reboot | 1342 // Verify that no reboot is requested and the device does not reboot |
| 1423 // immediately. | 1343 // immediately. |
| 1424 ExpectNoRebootRequest(); | 1344 ExpectNoRebootRequest(); |
| 1425 CreateAutomaticRebootManager(false); | 1345 CreateAutomaticRebootManager(false); |
| 1426 VerifyNoRebootRequested(); | 1346 VerifyNoRebootRequested(); |
| 1427 | 1347 |
| 1428 // Verify that no grace period has started. | 1348 // Verify that no grace period has started. |
| 1429 VerifyNoGracePeriod(); | 1349 VerifyNoGracePeriod(); |
| 1430 | 1350 |
| 1431 // Notify that an update has been applied and a reboot is necessary. Verify | 1351 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1432 // that no reboot is requested and the device does not reboot immediately. | 1352 // that no reboot is requested and the device does not reboot immediately. |
| 1433 NotifyUpdateRebootNeeded(); | 1353 NotifyUpdateRebootNeeded(); |
| 1434 | 1354 |
| 1435 // Verify that the current uptime has been persisted as the time at which a | 1355 // Verify that the current uptime has been persisted as the time at which a |
| 1436 // reboot became necessary. | 1356 // reboot became necessary. |
| 1437 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1357 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1438 &update_reboot_needed_uptime_)); | 1358 &update_reboot_needed_uptime_)); |
| 1439 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1359 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1440 | 1360 |
| 1441 // Verify that no grace period has started. | 1361 // Verify that no grace period has started. |
| 1442 VerifyNoGracePeriod(); | 1362 VerifyNoGracePeriod(); |
| 1443 | 1363 |
| 1444 // Verify that a reboot is never requested and the device never reboots. | 1364 // Verify that a reboot is never requested and the device never reboots. |
| 1445 FastForwardUntilNoTasksRemain(false); | 1365 FastForwardUntilNoTasksRemain(false); |
| 1446 } | 1366 } |
| 1447 | 1367 |
| 1448 // Chrome is running. The current uptime is 12 hours. | 1368 // Chrome is running. The current uptime is 12 hours. |
| 1449 // Verifies that when an update is applied, the current uptime is persisted as | 1369 // Verifies that when an update is applied, the current uptime is persisted as |
| 1450 // the time at which a reboot became necessary. Further verifies that when the | 1370 // the time at which a reboot became necessary. Further verifies that when the |
| 1451 // policy to automatically reboot after an update is enabled, a reboot is | 1371 // policy to automatically reboot after an update is enabled, a reboot is |
| 1452 // requested and a grace period is started that will end 24 hours from now. | 1372 // requested and a grace period is started that will end 24 hours from now. |
| 1453 TEST_P(AutomaticRebootManagerTest, Update) { | 1373 TEST_P(AutomaticRebootManagerTest, Update) { |
| 1454 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1374 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1455 SetRebootAfterUpdate(true, false); | 1375 SetRebootAfterUpdate(true, false); |
| 1456 | 1376 |
| 1457 // Verify that no reboot is requested and the device does not reboot | 1377 // Verify that no reboot is requested and the device does not reboot |
| 1458 // immediately. | 1378 // immediately. |
| 1459 ExpectNoRebootRequest(); | 1379 ExpectNoRebootRequest(); |
| 1460 CreateAutomaticRebootManager(false); | 1380 CreateAutomaticRebootManager(false); |
| 1461 VerifyNoRebootRequested(); | 1381 VerifyNoRebootRequested(); |
| 1462 | 1382 |
| 1463 // Verify that no grace period has started. | 1383 // Verify that no grace period has started. |
| 1464 VerifyNoGracePeriod(); | 1384 VerifyNoGracePeriod(); |
| 1465 | 1385 |
| 1466 // Notify that an update has been applied and a reboot is necessary. Verify | 1386 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1467 // that a reboot is requested but the device does not reboot immediately. | 1387 // that a reboot is requested but the device does not reboot immediately. |
| 1468 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 1388 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 1469 NotifyUpdateRebootNeeded(); | 1389 NotifyUpdateRebootNeeded(); |
| 1470 | 1390 |
| 1471 // Verify that the current uptime has been persisted as the time at which a | 1391 // Verify that the current uptime has been persisted as the time at which a |
| 1472 // reboot became necessary. | 1392 // reboot became necessary. |
| 1473 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1393 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1474 &update_reboot_needed_uptime_)); | 1394 &update_reboot_needed_uptime_)); |
| 1475 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1395 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1476 | 1396 |
| 1477 // Verify that a grace period has started. | 1397 // Verify that a grace period has started. |
| 1478 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); | 1398 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); |
| 1479 | 1399 |
| 1480 // Verify that unless a non-kiosk-app session is in progress, the device | 1400 // Verify that unless a non-kiosk-app session is in progress, the device |
| 1481 // eventually reboots. | 1401 // eventually reboots. |
| 1482 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1402 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1483 is_logged_in_as_kiosk_app_); | 1403 is_logged_in_as_kiosk_app_); |
| 1484 } | 1404 } |
| 1485 | 1405 |
| 1486 // Chrome is running. The current uptime is 12 hours. | 1406 // Chrome is running. The current uptime is 12 hours. |
| 1487 // Verifies that when Chrome is notified twice that an update has been applied, | 1407 // Verifies that when Chrome is notified twice that an update has been applied, |
| 1488 // the second notification is ignored and the uptime at which it occurred does | 1408 // the second notification is ignored and the uptime at which it occurred does |
| 1489 // not get persisted as the time at which an update became necessary. | 1409 // not get persisted as the time at which an update became necessary. |
| 1490 TEST_P(AutomaticRebootManagerTest, UpdateAfterUpdate) { | 1410 TEST_P(AutomaticRebootManagerTest, UpdateAfterUpdate) { |
| 1491 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1411 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1492 SetRebootAfterUpdate(true, false); | 1412 SetRebootAfterUpdate(true, false); |
| 1493 | 1413 |
| 1494 // Verify that no reboot is requested and the device does not reboot | 1414 // Verify that no reboot is requested and the device does not reboot |
| 1495 // immediately. | 1415 // immediately. |
| 1496 ExpectNoRebootRequest(); | 1416 ExpectNoRebootRequest(); |
| 1497 CreateAutomaticRebootManager(false); | 1417 CreateAutomaticRebootManager(false); |
| 1498 VerifyNoRebootRequested(); | 1418 VerifyNoRebootRequested(); |
| 1499 | 1419 |
| 1500 // Verify that no grace period has started. | 1420 // Verify that no grace period has started. |
| 1501 VerifyNoGracePeriod(); | 1421 VerifyNoGracePeriod(); |
| 1502 | 1422 |
| 1503 // Notify that an update has been applied and a reboot is necessary. Verify | 1423 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1504 // that a reboot is requested but the device does not reboot immediately. | 1424 // that a reboot is requested but the device does not reboot immediately. |
| 1505 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 1425 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 1506 NotifyUpdateRebootNeeded(); | 1426 NotifyUpdateRebootNeeded(); |
| 1507 | 1427 |
| 1508 // Verify that the current uptime has been persisted as the time at which a | 1428 // Verify that the current uptime has been persisted as the time at which a |
| 1509 // reboot became necessary. | 1429 // reboot became necessary. |
| 1510 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1430 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1511 &update_reboot_needed_uptime_)); | 1431 &update_reboot_needed_uptime_)); |
| 1512 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1432 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1513 | 1433 |
| 1514 // Verify that a grace period has started. | 1434 // Verify that a grace period has started. |
| 1515 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); | 1435 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); |
| 1516 | 1436 |
| 1517 // Fast forward the uptime by 20 seconds. Verify that the device does not | 1437 // Fast forward the uptime by 20 seconds. Verify that the device does not |
| 1518 // reboot immediately. | 1438 // reboot immediately. |
| 1519 FastForwardBy(base::TimeDelta::FromSeconds(20), false); | 1439 FastForwardBy(base::TimeDelta::FromSeconds(20), false); |
| 1520 | 1440 |
| 1521 // Notify that an update has been applied and a reboot is necessary. Verify | 1441 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1522 // that the device does not reboot immediately. | 1442 // that the device does not reboot immediately. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1535 is_logged_in_as_kiosk_app_); | 1455 is_logged_in_as_kiosk_app_); |
| 1536 } | 1456 } |
| 1537 | 1457 |
| 1538 // Chrome is running. The current uptime is 10 minutes. | 1458 // Chrome is running. The current uptime is 10 minutes. |
| 1539 // Verifies that when the policy to automatically reboot after an update is | 1459 // Verifies that when the policy to automatically reboot after an update is |
| 1540 // enabled, no reboot occurs and a grace period is scheduled to begin after the | 1460 // enabled, no reboot occurs and a grace period is scheduled to begin after the |
| 1541 // minimum of 1 hour of uptime. Further verifies that when an update is applied, | 1461 // minimum of 1 hour of uptime. Further verifies that when an update is applied, |
| 1542 // the current uptime is persisted as the time at which a reboot became | 1462 // the current uptime is persisted as the time at which a reboot became |
| 1543 // necessary. | 1463 // necessary. |
| 1544 TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) { | 1464 TEST_P(AutomaticRebootManagerTest, UpdateBeforeMinimumUptime) { |
| 1545 task_runner_->SetUptime(base::TimeDelta::FromMinutes(10)); | 1465 uptime_provider()->SetUptime(base::TimeDelta::FromMinutes(10)); |
| 1546 SetRebootAfterUpdate(true, false); | 1466 SetRebootAfterUpdate(true, false); |
| 1547 | 1467 |
| 1548 // Verify that no reboot is requested and the device does not reboot | 1468 // Verify that no reboot is requested and the device does not reboot |
| 1549 // immediately. | 1469 // immediately. |
| 1550 ExpectNoRebootRequest(); | 1470 ExpectNoRebootRequest(); |
| 1551 CreateAutomaticRebootManager(false); | 1471 CreateAutomaticRebootManager(false); |
| 1552 VerifyNoRebootRequested(); | 1472 VerifyNoRebootRequested(); |
| 1553 | 1473 |
| 1554 // Verify that no grace period has started. | 1474 // Verify that no grace period has started. |
| 1555 VerifyNoGracePeriod(); | 1475 VerifyNoGracePeriod(); |
| 1556 | 1476 |
| 1557 // Notify that an update has been applied and a reboot is necessary. Verify | 1477 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1558 // that no reboot is requested and the device does not reboot immediately. | 1478 // that no reboot is requested and the device does not reboot immediately. |
| 1559 NotifyUpdateRebootNeeded(); | 1479 NotifyUpdateRebootNeeded(); |
| 1560 | 1480 |
| 1561 // Verify that the current uptime has been persisted as the time at which a | 1481 // Verify that the current uptime has been persisted as the time at which a |
| 1562 // reboot became necessary. | 1482 // reboot became necessary. |
| 1563 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1483 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1564 &update_reboot_needed_uptime_)); | 1484 &update_reboot_needed_uptime_)); |
| 1565 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1485 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1566 | 1486 |
| 1567 // Verify that a grace period has been scheduled to begin in the future. | 1487 // Verify that a grace period has been scheduled to begin in the future. |
| 1568 VerifyGracePeriod(base::TimeDelta::FromHours(1)); | 1488 VerifyGracePeriod(base::TimeDelta::FromHours(1)); |
| 1569 | 1489 |
| 1570 // Verify that a reboot is requested eventually and unless a non-kiosk-app | 1490 // Verify that a reboot is requested eventually and unless a non-kiosk-app |
| 1571 // session is in progress, the device eventually reboots. | 1491 // session is in progress, the device eventually reboots. |
| 1572 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 1492 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 1573 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1493 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1574 is_logged_in_as_kiosk_app_); | 1494 is_logged_in_as_kiosk_app_); |
| 1575 } | 1495 } |
| 1576 | 1496 |
| 1577 // Chrome is running. An update was applied and a reboot became necessary to | 1497 // Chrome is running. An update was applied and a reboot became necessary to |
| 1578 // complete the update process after 6 hours of uptime. The current uptime is | 1498 // complete the update process after 6 hours of uptime. The current uptime is |
| 1579 // 12 hours. | 1499 // 12 hours. |
| 1580 // Verifies that when the policy to automatically reboot after an update is | 1500 // Verifies that when the policy to automatically reboot after an update is |
| 1581 // enabled, a reboot is requested and a grace period is started that will end | 1501 // enabled, a reboot is requested and a grace period is started that will end |
| 1582 // after 6 + 24 hours of uptime. | 1502 // after 6 + 24 hours of uptime. |
| 1583 TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateInGracePeriod) { | 1503 TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateInGracePeriod) { |
| 1584 task_runner_->SetUptime(base::TimeDelta::FromHours(6)); | 1504 uptime_provider()->SetUptime(base::TimeDelta::FromHours(6)); |
| 1585 | 1505 |
| 1586 // Verify that no reboot is requested and the device does not reboot | 1506 // Verify that no reboot is requested and the device does not reboot |
| 1587 // immediately. | 1507 // immediately. |
| 1588 ExpectNoRebootRequest(); | 1508 ExpectNoRebootRequest(); |
| 1589 CreateAutomaticRebootManager(false); | 1509 CreateAutomaticRebootManager(false); |
| 1590 VerifyNoRebootRequested(); | 1510 VerifyNoRebootRequested(); |
| 1591 | 1511 |
| 1592 // Notify that an update has been applied and a reboot is necessary. Verify | 1512 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1593 // that no reboot is requested and the device does not reboot immediately. | 1513 // that no reboot is requested and the device does not reboot immediately. |
| 1594 NotifyUpdateRebootNeeded(); | 1514 NotifyUpdateRebootNeeded(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1614 is_logged_in_as_kiosk_app_); | 1534 is_logged_in_as_kiosk_app_); |
| 1615 } | 1535 } |
| 1616 | 1536 |
| 1617 // Chrome is running. An update was applied and a reboot became necessary to | 1537 // Chrome is running. An update was applied and a reboot became necessary to |
| 1618 // complete the update process after 6 hours of uptime. The current uptime is | 1538 // complete the update process after 6 hours of uptime. The current uptime is |
| 1619 // 10 days. | 1539 // 10 days. |
| 1620 // Verifies that when the policy to automatically reboot after an update is | 1540 // Verifies that when the policy to automatically reboot after an update is |
| 1621 // enabled, the device reboots immediately if no non-kiosk-app session is in | 1541 // enabled, the device reboots immediately if no non-kiosk-app session is in |
| 1622 // progress because the grace period ended after 6 + 24 hours of uptime. | 1542 // progress because the grace period ended after 6 + 24 hours of uptime. |
| 1623 TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateAfterGracePeriod) { | 1543 TEST_P(AutomaticRebootManagerTest, PolicyAfterUpdateAfterGracePeriod) { |
| 1624 task_runner_->SetUptime(base::TimeDelta::FromHours(6)); | 1544 uptime_provider()->SetUptime(base::TimeDelta::FromHours(6)); |
| 1625 | 1545 |
| 1626 // Verify that no reboot is requested and the device does not reboot | 1546 // Verify that no reboot is requested and the device does not reboot |
| 1627 // immediately. | 1547 // immediately. |
| 1628 ExpectNoRebootRequest(); | 1548 ExpectNoRebootRequest(); |
| 1629 CreateAutomaticRebootManager(false); | 1549 CreateAutomaticRebootManager(false); |
| 1630 VerifyNoRebootRequested(); | 1550 VerifyNoRebootRequested(); |
| 1631 | 1551 |
| 1632 // Notify that an update has been applied and a reboot is necessary. Verify | 1552 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1633 // that no reboot is requested and the device does not reboot immediately. | 1553 // that no reboot is requested and the device does not reboot immediately. |
| 1634 NotifyUpdateRebootNeeded(); | 1554 NotifyUpdateRebootNeeded(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1653 is_logged_in_as_kiosk_app_); | 1573 is_logged_in_as_kiosk_app_); |
| 1654 } | 1574 } |
| 1655 | 1575 |
| 1656 // Chrome is running. An update was applied and a reboot became necessary to | 1576 // Chrome is running. An update was applied and a reboot became necessary to |
| 1657 // complete the update process after 6 hours of uptime. The policy to | 1577 // complete the update process after 6 hours of uptime. The policy to |
| 1658 // automatically reboot after an update is enabled. The current uptime is | 1578 // automatically reboot after an update is enabled. The current uptime is |
| 1659 // 6 hours 20 seconds. | 1579 // 6 hours 20 seconds. |
| 1660 // Verifies that when the policy to automatically reboot after an update is | 1580 // Verifies that when the policy to automatically reboot after an update is |
| 1661 // disabled, the reboot request and grace period are removed. | 1581 // disabled, the reboot request and grace period are removed. |
| 1662 TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) { | 1582 TEST_P(AutomaticRebootManagerTest, PolicyOffAfterUpdate) { |
| 1663 task_runner_->SetUptime(base::TimeDelta::FromHours(6)); | 1583 uptime_provider()->SetUptime(base::TimeDelta::FromHours(6)); |
| 1664 SetRebootAfterUpdate(true, false); | 1584 SetRebootAfterUpdate(true, false); |
| 1665 | 1585 |
| 1666 // Verify that no reboot is requested and the device does not reboot | 1586 // Verify that no reboot is requested and the device does not reboot |
| 1667 // immediately. | 1587 // immediately. |
| 1668 ExpectNoRebootRequest(); | 1588 ExpectNoRebootRequest(); |
| 1669 CreateAutomaticRebootManager(false); | 1589 CreateAutomaticRebootManager(false); |
| 1670 VerifyNoRebootRequested(); | 1590 VerifyNoRebootRequested(); |
| 1671 | 1591 |
| 1672 // Notify that an update has been applied and a reboot is necessary. Verify | 1592 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1673 // that a reboot is requested but the device does not reboot immediately. | 1593 // that a reboot is requested but the device does not reboot immediately. |
| 1674 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 1594 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 1675 NotifyUpdateRebootNeeded(); | 1595 NotifyUpdateRebootNeeded(); |
| 1676 | 1596 |
| 1677 // Verify that a grace period has started. | 1597 // Verify that a grace period has started. |
| 1678 VerifyGracePeriod(task_runner_->Uptime() + uptime_processing_delay_); | 1598 VerifyGracePeriod(uptime_provider()->uptime() + uptime_processing_delay_); |
| 1679 | 1599 |
| 1680 // Fast forward the uptime by 20 seconds. Verify that the device does not | 1600 // Fast forward the uptime by 20 seconds. Verify that the device does not |
| 1681 // reboot immediately. | 1601 // reboot immediately. |
| 1682 FastForwardBy(base::TimeDelta::FromSeconds(20), false); | 1602 FastForwardBy(base::TimeDelta::FromSeconds(20), false); |
| 1683 | 1603 |
| 1684 // Disable automatic rebooting after an update has been applied. Verify that | 1604 // Disable automatic rebooting after an update has been applied. Verify that |
| 1685 // no reboot is requested and the device does not reboot immediately. | 1605 // no reboot is requested and the device does not reboot immediately. |
| 1686 SetRebootAfterUpdate(false, false); | 1606 SetRebootAfterUpdate(false, false); |
| 1687 | 1607 |
| 1688 // Verify that the grace period has been removed. | 1608 // Verify that the grace period has been removed. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1734 FastForwardUntilNoTasksRemain(false); | 1654 FastForwardUntilNoTasksRemain(false); |
| 1735 } | 1655 } |
| 1736 | 1656 |
| 1737 // Chrome is running. The policy to automatically reboot after an update is | 1657 // Chrome is running. The policy to automatically reboot after an update is |
| 1738 // enabled. The current uptime is 12 hours. | 1658 // enabled. The current uptime is 12 hours. |
| 1739 // Verifies that when an uptime limit of 6 hours is set, the availability of an | 1659 // Verifies that when an uptime limit of 6 hours is set, the availability of an |
| 1740 // update does not cause the grace period to be rescheduled. Further verifies | 1660 // update does not cause the grace period to be rescheduled. Further verifies |
| 1741 // that the current uptime is persisted as the time at which a reboot became | 1661 // that the current uptime is persisted as the time at which a reboot became |
| 1742 // necessary. | 1662 // necessary. |
| 1743 TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) { | 1663 TEST_P(AutomaticRebootManagerTest, UptimeLimitBeforeUpdate) { |
| 1744 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1664 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1745 SetRebootAfterUpdate(true, false); | 1665 SetRebootAfterUpdate(true, false); |
| 1746 | 1666 |
| 1747 // Verify that no reboot is requested and the device does not reboot | 1667 // Verify that no reboot is requested and the device does not reboot |
| 1748 // immediately. | 1668 // immediately. |
| 1749 ExpectNoRebootRequest(); | 1669 ExpectNoRebootRequest(); |
| 1750 CreateAutomaticRebootManager(false); | 1670 CreateAutomaticRebootManager(false); |
| 1751 VerifyNoRebootRequested(); | 1671 VerifyNoRebootRequested(); |
| 1752 | 1672 |
| 1753 // Set the uptime limit. Verify that a reboot is requested but the device does | 1673 // Set the uptime limit. Verify that a reboot is requested but the device does |
| 1754 // not reboot immediately. | 1674 // not reboot immediately. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1765 // Notify that an update has been applied and a reboot is necessary. Verify | 1685 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1766 // that a reboot is requested again but the device does not reboot | 1686 // that a reboot is requested again but the device does not reboot |
| 1767 // immediately. | 1687 // immediately. |
| 1768 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1688 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1769 NotifyUpdateRebootNeeded(); | 1689 NotifyUpdateRebootNeeded(); |
| 1770 | 1690 |
| 1771 // Verify that the current uptime has been persisted as the time at which a | 1691 // Verify that the current uptime has been persisted as the time at which a |
| 1772 // reboot became necessary. | 1692 // reboot became necessary. |
| 1773 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1693 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1774 &update_reboot_needed_uptime_)); | 1694 &update_reboot_needed_uptime_)); |
| 1775 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1695 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1776 | 1696 |
| 1777 // Verify that the grace period has not been rescheduled. | 1697 // Verify that the grace period has not been rescheduled. |
| 1778 VerifyGracePeriod(uptime_limit_); | 1698 VerifyGracePeriod(uptime_limit_); |
| 1779 | 1699 |
| 1780 // Verify that unless a non-kiosk-app session is in progress, the device | 1700 // Verify that unless a non-kiosk-app session is in progress, the device |
| 1781 // eventually reboots. | 1701 // eventually reboots. |
| 1782 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1702 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1783 is_logged_in_as_kiosk_app_); | 1703 is_logged_in_as_kiosk_app_); |
| 1784 } | 1704 } |
| 1785 | 1705 |
| 1786 // Chrome is running. The policy to automatically reboot after an update is | 1706 // Chrome is running. The policy to automatically reboot after an update is |
| 1787 // enabled. The current uptime is 12 hours. | 1707 // enabled. The current uptime is 12 hours. |
| 1788 // Verifies that when an uptime limit of 24 hours is set, the availability of an | 1708 // Verifies that when an uptime limit of 24 hours is set, the availability of an |
| 1789 // update causes the grace period to be rescheduled so that it ends 24 hours | 1709 // update causes the grace period to be rescheduled so that it ends 24 hours |
| 1790 // from now. Further verifies that the current uptime is persisted as the time | 1710 // from now. Further verifies that the current uptime is persisted as the time |
| 1791 // at which a reboot became necessary. | 1711 // at which a reboot became necessary. |
| 1792 TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) { | 1712 TEST_P(AutomaticRebootManagerTest, UpdateBeforeUptimeLimit) { |
| 1793 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1713 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1794 SetRebootAfterUpdate(true, false); | 1714 SetRebootAfterUpdate(true, false); |
| 1795 | 1715 |
| 1796 // Verify that no reboot is requested and the device does not reboot | 1716 // Verify that no reboot is requested and the device does not reboot |
| 1797 // immediately. | 1717 // immediately. |
| 1798 ExpectNoRebootRequest(); | 1718 ExpectNoRebootRequest(); |
| 1799 CreateAutomaticRebootManager(false); | 1719 CreateAutomaticRebootManager(false); |
| 1800 VerifyNoRebootRequested(); | 1720 VerifyNoRebootRequested(); |
| 1801 | 1721 |
| 1802 // Set the uptime limit. Verify that no reboot is requested and the device | 1722 // Set the uptime limit. Verify that no reboot is requested and the device |
| 1803 // does not reboot immediately. | 1723 // does not reboot immediately. |
| 1804 SetUptimeLimit(base::TimeDelta::FromHours(24), false); | 1724 SetUptimeLimit(base::TimeDelta::FromHours(24), false); |
| 1805 | 1725 |
| 1806 // Verify that a grace period has been scheduled to start in the future. | 1726 // Verify that a grace period has been scheduled to start in the future. |
| 1807 VerifyGracePeriod(uptime_limit_); | 1727 VerifyGracePeriod(uptime_limit_); |
| 1808 | 1728 |
| 1809 // Fast forward the uptime by 20 seconds. Verify that no reboot is requested | 1729 // Fast forward the uptime by 20 seconds. Verify that no reboot is requested |
| 1810 // and the device does not reboot immediately. | 1730 // and the device does not reboot immediately. |
| 1811 FastForwardBy(base::TimeDelta::FromSeconds(20), false); | 1731 FastForwardBy(base::TimeDelta::FromSeconds(20), false); |
| 1812 | 1732 |
| 1813 // Notify that an update has been applied and a reboot is necessary. Verify | 1733 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1814 // that a reboot is requested but the device does not reboot immediately. | 1734 // that a reboot is requested but the device does not reboot immediately. |
| 1815 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 1735 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 1816 NotifyUpdateRebootNeeded(); | 1736 NotifyUpdateRebootNeeded(); |
| 1817 | 1737 |
| 1818 // Verify that the current uptime has been persisted as the time at which a | 1738 // Verify that the current uptime has been persisted as the time at which a |
| 1819 // reboot became necessary. | 1739 // reboot became necessary. |
| 1820 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1740 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1821 &update_reboot_needed_uptime_)); | 1741 &update_reboot_needed_uptime_)); |
| 1822 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1742 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1823 | 1743 |
| 1824 // Verify that the grace period has been rescheduled to start at the time that | 1744 // Verify that the grace period has been rescheduled to start at the time that |
| 1825 // the update became available. | 1745 // the update became available. |
| 1826 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); | 1746 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); |
| 1827 | 1747 |
| 1828 // Verify that unless a non-kiosk-app session is in progress, the device | 1748 // Verify that unless a non-kiosk-app session is in progress, the device |
| 1829 // eventually reboots. | 1749 // eventually reboots. |
| 1830 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1750 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1831 is_logged_in_as_kiosk_app_); | 1751 is_logged_in_as_kiosk_app_); |
| 1832 } | 1752 } |
| 1833 | 1753 |
| 1834 // Chrome is running. The uptime limit is set to 24 hours. An update was applied | 1754 // Chrome is running. The uptime limit is set to 24 hours. An update was applied |
| 1835 // and a reboot became necessary to complete the update process after 12 hours. | 1755 // and a reboot became necessary to complete the update process after 12 hours. |
| 1836 // The policy to automatically reboot after an update is enabled. The current | 1756 // The policy to automatically reboot after an update is enabled. The current |
| 1837 // uptime is 12 hours 20 seconds. | 1757 // uptime is 12 hours 20 seconds. |
| 1838 // Verifies that when the policy to reboot after an update is disabled, the | 1758 // Verifies that when the policy to reboot after an update is disabled, the |
| 1839 // grace period is rescheduled to start after 12 hours of uptime. Further | 1759 // grace period is rescheduled to start after 12 hours of uptime. Further |
| 1840 // verifies that when the uptime limit is removed, the grace period is removed. | 1760 // verifies that when the uptime limit is removed, the grace period is removed. |
| 1841 TEST_P(AutomaticRebootManagerTest, PolicyOffThenUptimeLimitOff) { | 1761 TEST_P(AutomaticRebootManagerTest, PolicyOffThenUptimeLimitOff) { |
| 1842 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1762 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1843 SetRebootAfterUpdate(true, false); | 1763 SetRebootAfterUpdate(true, false); |
| 1844 | 1764 |
| 1845 // Verify that no reboot is requested and the device does not reboot | 1765 // Verify that no reboot is requested and the device does not reboot |
| 1846 // immediately. | 1766 // immediately. |
| 1847 ExpectNoRebootRequest(); | 1767 ExpectNoRebootRequest(); |
| 1848 CreateAutomaticRebootManager(false); | 1768 CreateAutomaticRebootManager(false); |
| 1849 VerifyNoRebootRequested(); | 1769 VerifyNoRebootRequested(); |
| 1850 | 1770 |
| 1851 // Set the uptime limit. Verify that no reboot is requested and the device | 1771 // Set the uptime limit. Verify that no reboot is requested and the device |
| 1852 // does not reboot immediately. | 1772 // does not reboot immediately. |
| 1853 SetUptimeLimit(base::TimeDelta::FromHours(24), false); | 1773 SetUptimeLimit(base::TimeDelta::FromHours(24), false); |
| 1854 | 1774 |
| 1855 // Verify that a grace period has been scheduled to start in the future. | 1775 // Verify that a grace period has been scheduled to start in the future. |
| 1856 VerifyGracePeriod(uptime_limit_); | 1776 VerifyGracePeriod(uptime_limit_); |
| 1857 | 1777 |
| 1858 // Notify that an update has been applied and a reboot is necessary. Verify | 1778 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1859 // that a reboot is requested but the device does not reboot immediately. | 1779 // that a reboot is requested but the device does not reboot immediately. |
| 1860 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 1780 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 1861 NotifyUpdateRebootNeeded(); | 1781 NotifyUpdateRebootNeeded(); |
| 1862 | 1782 |
| 1863 // Verify that the current uptime has been persisted as the time at which a | 1783 // Verify that the current uptime has been persisted as the time at which a |
| 1864 // reboot became necessary. | 1784 // reboot became necessary. |
| 1865 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1785 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1866 &update_reboot_needed_uptime_)); | 1786 &update_reboot_needed_uptime_)); |
| 1867 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1787 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1868 | 1788 |
| 1869 // Verify that a grace period has been rescheduled to end 24 hours from now. | 1789 // Verify that a grace period has been rescheduled to end 24 hours from now. |
| 1870 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); | 1790 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); |
| 1871 | 1791 |
| 1872 // Fast forward the uptime by 20 seconds. Verify that the device does not | 1792 // Fast forward the uptime by 20 seconds. Verify that the device does not |
| 1873 // reboot immediately. | 1793 // reboot immediately. |
| 1874 FastForwardBy(base::TimeDelta::FromSeconds(20), false); | 1794 FastForwardBy(base::TimeDelta::FromSeconds(20), false); |
| 1875 | 1795 |
| 1876 // Disable automatic reboot after an update has been applied. Verify that the | 1796 // Disable automatic reboot after an update has been applied. Verify that the |
| 1877 // device does not reboot immediately. | 1797 // device does not reboot immediately. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1894 | 1814 |
| 1895 // Chrome is running. The uptime limit is set to 6 hours. An update was applied | 1815 // Chrome is running. The uptime limit is set to 6 hours. An update was applied |
| 1896 // and a reboot became necessary to complete the update process after 12 hours. | 1816 // and a reboot became necessary to complete the update process after 12 hours. |
| 1897 // The policy to automatically reboot after an update is enabled. The current | 1817 // The policy to automatically reboot after an update is enabled. The current |
| 1898 // uptime is 12 hours 20 seconds. | 1818 // uptime is 12 hours 20 seconds. |
| 1899 // Verifies that when the uptime limit is removed, the grace period is | 1819 // Verifies that when the uptime limit is removed, the grace period is |
| 1900 // rescheduled to have started after 12 hours of uptime. Further verifies that | 1820 // rescheduled to have started after 12 hours of uptime. Further verifies that |
| 1901 // when the policy to reboot after an update is disabled, the reboot request and | 1821 // when the policy to reboot after an update is disabled, the reboot request and |
| 1902 // grace period are removed. | 1822 // grace period are removed. |
| 1903 TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) { | 1823 TEST_P(AutomaticRebootManagerTest, UptimeLimitOffThenPolicyOff) { |
| 1904 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1824 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 1905 SetRebootAfterUpdate(true, false); | 1825 SetRebootAfterUpdate(true, false); |
| 1906 | 1826 |
| 1907 // Verify that no reboot is requested and the device does not reboot | 1827 // Verify that no reboot is requested and the device does not reboot |
| 1908 // immediately. | 1828 // immediately. |
| 1909 ExpectNoRebootRequest(); | 1829 ExpectNoRebootRequest(); |
| 1910 CreateAutomaticRebootManager(false); | 1830 CreateAutomaticRebootManager(false); |
| 1911 VerifyNoRebootRequested(); | 1831 VerifyNoRebootRequested(); |
| 1912 | 1832 |
| 1913 // Notify that an update has been applied and a reboot is necessary. Verify | 1833 // Notify that an update has been applied and a reboot is necessary. Verify |
| 1914 // that a reboot is requested but the device does not reboot immediately. | 1834 // that a reboot is requested but the device does not reboot immediately. |
| 1915 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 1835 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 1916 NotifyUpdateRebootNeeded(); | 1836 NotifyUpdateRebootNeeded(); |
| 1917 | 1837 |
| 1918 // Verify that the current uptime has been persisted as the time at which a | 1838 // Verify that the current uptime has been persisted as the time at which a |
| 1919 // reboot became necessary. | 1839 // reboot became necessary. |
| 1920 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 1840 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 1921 &update_reboot_needed_uptime_)); | 1841 &update_reboot_needed_uptime_)); |
| 1922 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 1842 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 1923 | 1843 |
| 1924 // Verify that the grace period has started. | 1844 // Verify that the grace period has started. |
| 1925 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); | 1845 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); |
| 1926 | 1846 |
| 1927 // Set the uptime limit. Verify that a reboot is requested again but the | 1847 // Set the uptime limit. Verify that a reboot is requested again but the |
| 1928 // device does not reboot immediately. | 1848 // device does not reboot immediately. |
| 1929 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1849 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 1930 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 1850 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 1931 | 1851 |
| 1932 // Verify that the grace period has been rescheduled to have started after | 1852 // Verify that the grace period has been rescheduled to have started after |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1955 | 1875 |
| 1956 // Verify that the device never reboots. | 1876 // Verify that the device never reboots. |
| 1957 FastForwardUntilNoTasksRemain(false); | 1877 FastForwardUntilNoTasksRemain(false); |
| 1958 } | 1878 } |
| 1959 | 1879 |
| 1960 // Chrome is running. The uptime limit is 6 hours. The current uptime is | 1880 // Chrome is running. The uptime limit is 6 hours. The current uptime is |
| 1961 // 29 hours 59 minutes 59 seconds. | 1881 // 29 hours 59 minutes 59 seconds. |
| 1962 // Verifies that if no non-kiosk-app session is in progress, the device reboots | 1882 // Verifies that if no non-kiosk-app session is in progress, the device reboots |
| 1963 // immediately when the grace period ends after 6 + 24 hours of uptime. | 1883 // immediately when the grace period ends after 6 + 24 hours of uptime. |
| 1964 TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) { | 1884 TEST_P(AutomaticRebootManagerTest, GracePeriodEnd) { |
| 1965 task_runner_->SetUptime(base::TimeDelta::FromHours(29) + | 1885 uptime_provider()->SetUptime(base::TimeDelta::FromHours(29) + |
| 1966 base::TimeDelta::FromMinutes(59) + | 1886 base::TimeDelta::FromMinutes(59) + |
| 1967 base::TimeDelta::FromSeconds(59)); | 1887 base::TimeDelta::FromSeconds(59)); |
| 1968 | 1888 |
| 1969 // Verify that no reboot is requested and the device does not reboot | 1889 // Verify that no reboot is requested and the device does not reboot |
| 1970 // immediately. | 1890 // immediately. |
| 1971 ExpectNoRebootRequest(); | 1891 ExpectNoRebootRequest(); |
| 1972 CreateAutomaticRebootManager(false); | 1892 CreateAutomaticRebootManager(false); |
| 1973 VerifyNoRebootRequested(); | 1893 VerifyNoRebootRequested(); |
| 1974 | 1894 |
| 1975 // Set the uptime limit. Verify that a reboot is requested but the device does | 1895 // Set the uptime limit. Verify that a reboot is requested but the device does |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1988 // Verify that if a non-kiosk-app session is in progress, the device never | 1908 // Verify that if a non-kiosk-app session is in progress, the device never |
| 1989 // reboots. | 1909 // reboots. |
| 1990 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1910 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 1991 is_logged_in_as_kiosk_app_); | 1911 is_logged_in_as_kiosk_app_); |
| 1992 } | 1912 } |
| 1993 | 1913 |
| 1994 // Chrome is starting. The current uptime is 10 days. | 1914 // Chrome is starting. The current uptime is 10 days. |
| 1995 // Verifies that when no automatic reboot policy is enabled, no reboot occurs | 1915 // Verifies that when no automatic reboot policy is enabled, no reboot occurs |
| 1996 // and no grace period is scheduled. | 1916 // and no grace period is scheduled. |
| 1997 TEST_P(AutomaticRebootManagerTest, StartNoPolicy) { | 1917 TEST_P(AutomaticRebootManagerTest, StartNoPolicy) { |
| 1998 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 1918 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 1999 | 1919 |
| 2000 // Verify that no reboot is requested and the device does not reboot | 1920 // Verify that no reboot is requested and the device does not reboot |
| 2001 // immediately. | 1921 // immediately. |
| 2002 ExpectNoRebootRequest(); | 1922 ExpectNoRebootRequest(); |
| 2003 CreateAutomaticRebootManager(false); | 1923 CreateAutomaticRebootManager(false); |
| 2004 VerifyNoRebootRequested(); | 1924 VerifyNoRebootRequested(); |
| 2005 | 1925 |
| 2006 // Verify that no grace period has started. | 1926 // Verify that no grace period has started. |
| 2007 VerifyNoGracePeriod(); | 1927 VerifyNoGracePeriod(); |
| 2008 | 1928 |
| 2009 // Verify that a reboot is never requested and the device never reboots. | 1929 // Verify that a reboot is never requested and the device never reboots. |
| 2010 FastForwardUntilNoTasksRemain(false); | 1930 FastForwardUntilNoTasksRemain(false); |
| 2011 } | 1931 } |
| 2012 | 1932 |
| 2013 // Chrome is starting. The uptime limit is set to 24 hours. The current uptime | 1933 // Chrome is starting. The uptime limit is set to 24 hours. The current uptime |
| 2014 // is 12 hours. | 1934 // is 12 hours. |
| 2015 // Verifies that no reboot occurs and a grace period is scheduled to begin after | 1935 // Verifies that no reboot occurs and a grace period is scheduled to begin after |
| 2016 // 24 hours of uptime. | 1936 // 24 hours of uptime. |
| 2017 TEST_P(AutomaticRebootManagerTest, StartBeforeUptimeLimitGracePeriod) { | 1937 TEST_P(AutomaticRebootManagerTest, StartBeforeUptimeLimitGracePeriod) { |
| 2018 SetUptimeLimit(base::TimeDelta::FromHours(24), false); | 1938 SetUptimeLimit(base::TimeDelta::FromHours(24), false); |
| 2019 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1939 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 2020 | 1940 |
| 2021 // Verify that no reboot is requested and the device does not reboot | 1941 // Verify that no reboot is requested and the device does not reboot |
| 2022 // immediately. | 1942 // immediately. |
| 2023 ExpectNoRebootRequest(); | 1943 ExpectNoRebootRequest(); |
| 2024 CreateAutomaticRebootManager(false); | 1944 CreateAutomaticRebootManager(false); |
| 2025 VerifyNoRebootRequested(); | 1945 VerifyNoRebootRequested(); |
| 2026 | 1946 |
| 2027 // Verify that a grace period has been scheduled to start in the future. | 1947 // Verify that a grace period has been scheduled to start in the future. |
| 2028 VerifyGracePeriod(uptime_limit_); | 1948 VerifyGracePeriod(uptime_limit_); |
| 2029 | 1949 |
| 2030 // Verify that a reboot is requested eventually and unless a non-kiosk-app | 1950 // Verify that a reboot is requested eventually and unless a non-kiosk-app |
| 2031 // session is in progress, the device eventually reboots. | 1951 // session is in progress, the device eventually reboots. |
| 2032 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1952 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 2033 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1953 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2034 is_logged_in_as_kiosk_app_); | 1954 is_logged_in_as_kiosk_app_); |
| 2035 } | 1955 } |
| 2036 | 1956 |
| 2037 // Chrome is starting. The uptime limit is set to 6 hours. The current uptime is | 1957 // Chrome is starting. The uptime limit is set to 6 hours. The current uptime is |
| 2038 // 10 days. | 1958 // 10 days. |
| 2039 // Verifies that if no non-kiosk-app session is in progress, the device reboots | 1959 // Verifies that if no non-kiosk-app session is in progress, the device reboots |
| 2040 // immediately because the grace period ended after 6 + 24 hours of uptime. | 1960 // immediately because the grace period ended after 6 + 24 hours of uptime. |
| 2041 TEST_P(AutomaticRebootManagerTest, StartAfterUptimeLimitGracePeriod) { | 1961 TEST_P(AutomaticRebootManagerTest, StartAfterUptimeLimitGracePeriod) { |
| 2042 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 1962 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 2043 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 1963 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 2044 | 1964 |
| 2045 // Verify that a reboot is requested and unless a non-kiosk-app session is in | 1965 // Verify that a reboot is requested and unless a non-kiosk-app session is in |
| 2046 // progress, the the device immediately reboots. | 1966 // progress, the the device immediately reboots. |
| 2047 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1967 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 2048 CreateAutomaticRebootManager(!is_user_logged_in_ || | 1968 CreateAutomaticRebootManager(!is_user_logged_in_ || |
| 2049 is_logged_in_as_kiosk_app_); | 1969 is_logged_in_as_kiosk_app_); |
| 2050 VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1970 VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 2051 | 1971 |
| 2052 // Verify that if a non-kiosk-app session is in progress, the device never | 1972 // Verify that if a non-kiosk-app session is in progress, the device never |
| 2053 // reboots. | 1973 // reboots. |
| 2054 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1974 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2055 is_logged_in_as_kiosk_app_); | 1975 is_logged_in_as_kiosk_app_); |
| 2056 } | 1976 } |
| 2057 | 1977 |
| 2058 // Chrome is starting. The uptime limit is set to 6 hours. The current uptime is | 1978 // Chrome is starting. The uptime limit is set to 6 hours. The current uptime is |
| 2059 // 12 hours. | 1979 // 12 hours. |
| 2060 // Verifies that a reboot is requested and a grace period is started that will | 1980 // Verifies that a reboot is requested and a grace period is started that will |
| 2061 // end after 6 + 24 hours of uptime. | 1981 // end after 6 + 24 hours of uptime. |
| 2062 TEST_P(AutomaticRebootManagerTest, StartInUptimeLimitGracePeriod) { | 1982 TEST_P(AutomaticRebootManagerTest, StartInUptimeLimitGracePeriod) { |
| 2063 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 1983 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 2064 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 1984 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 2065 | 1985 |
| 2066 // Verify that a reboot is requested but the device does not reboot | 1986 // Verify that a reboot is requested but the device does not reboot |
| 2067 // immediately. | 1987 // immediately. |
| 2068 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1988 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 2069 CreateAutomaticRebootManager(false); | 1989 CreateAutomaticRebootManager(false); |
| 2070 VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 1990 VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 2071 | 1991 |
| 2072 // Verify that a grace period has started. | 1992 // Verify that a grace period has started. |
| 2073 VerifyGracePeriod(uptime_limit_); | 1993 VerifyGracePeriod(uptime_limit_); |
| 2074 | 1994 |
| 2075 // Verify that unless a non-kiosk-app session is in progress, the device | 1995 // Verify that unless a non-kiosk-app session is in progress, the device |
| 2076 // eventually reboots. | 1996 // eventually reboots. |
| 2077 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 1997 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2078 is_logged_in_as_kiosk_app_); | 1998 is_logged_in_as_kiosk_app_); |
| 2079 } | 1999 } |
| 2080 | 2000 |
| 2081 // Chrome is starting. An update was applied and a reboot became necessary to | 2001 // Chrome is starting. An update was applied and a reboot became necessary to |
| 2082 // complete the update process after 6 hours of uptime. The current uptime is | 2002 // complete the update process after 6 hours of uptime. The current uptime is |
| 2083 // 10 days. | 2003 // 10 days. |
| 2084 // Verifies that when the policy to automatically reboot after an update is | 2004 // Verifies that when the policy to automatically reboot after an update is |
| 2085 // enabled, the device reboots immediately if no non-kiosk-app session is in | 2005 // enabled, the device reboots immediately if no non-kiosk-app session is in |
| 2086 // progress because the grace period ended after 6 + 24 hours of uptime. | 2006 // progress because the grace period ended after 6 + 24 hours of uptime. |
| 2087 TEST_P(AutomaticRebootManagerTest, StartAfterUpdateGracePeriod) { | 2007 TEST_P(AutomaticRebootManagerTest, StartAfterUpdateGracePeriod) { |
| 2088 SetUpdateStatusNeedReboot(); | 2008 SetUpdateStatusNeedReboot(); |
| 2089 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); | 2009 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); |
| 2090 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 2010 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 2091 SetRebootAfterUpdate(true, false); | 2011 SetRebootAfterUpdate(true, false); |
| 2092 | 2012 |
| 2093 // Verify that a reboot is requested and unless a non-kiosk-app session is in | 2013 // Verify that a reboot is requested and unless a non-kiosk-app session is in |
| 2094 // progress, the the device immediately reboots. | 2014 // progress, the the device immediately reboots. |
| 2095 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2015 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2096 CreateAutomaticRebootManager(!is_user_logged_in_ || | 2016 CreateAutomaticRebootManager(!is_user_logged_in_ || |
| 2097 is_logged_in_as_kiosk_app_); | 2017 is_logged_in_as_kiosk_app_); |
| 2098 VerifyRebootRequested( | 2018 VerifyRebootRequested( |
| 2099 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2019 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2100 | 2020 |
| 2101 // Verify that if a non-kiosk-app session is in progress, the device never | 2021 // Verify that if a non-kiosk-app session is in progress, the device never |
| 2102 // reboots. | 2022 // reboots. |
| 2103 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 2023 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2104 is_logged_in_as_kiosk_app_); | 2024 is_logged_in_as_kiosk_app_); |
| 2105 } | 2025 } |
| 2106 | 2026 |
| 2107 // Chrome is starting. An update was applied and a reboot became necessary to | 2027 // Chrome is starting. An update was applied and a reboot became necessary to |
| 2108 // complete the update process after 6 hours of uptime. The current uptime is | 2028 // complete the update process after 6 hours of uptime. The current uptime is |
| 2109 // 12 hours. | 2029 // 12 hours. |
| 2110 // Verifies that when the policy to automatically reboot after an update is | 2030 // Verifies that when the policy to automatically reboot after an update is |
| 2111 // enabled, a reboot is requested and a grace period is started that will end | 2031 // enabled, a reboot is requested and a grace period is started that will end |
| 2112 // after 6 + 24 hours of uptime. | 2032 // after 6 + 24 hours of uptime. |
| 2113 TEST_P(AutomaticRebootManagerTest, StartInUpdateGracePeriod) { | 2033 TEST_P(AutomaticRebootManagerTest, StartInUpdateGracePeriod) { |
| 2114 SetUpdateStatusNeedReboot(); | 2034 SetUpdateStatusNeedReboot(); |
| 2115 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); | 2035 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); |
| 2116 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 2036 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 2117 SetRebootAfterUpdate(true, false); | 2037 SetRebootAfterUpdate(true, false); |
| 2118 | 2038 |
| 2119 // Verify that a reboot is requested but the device does not reboot | 2039 // Verify that a reboot is requested but the device does not reboot |
| 2120 // immediately. | 2040 // immediately. |
| 2121 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2041 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2122 CreateAutomaticRebootManager(false); | 2042 CreateAutomaticRebootManager(false); |
| 2123 VerifyRebootRequested( | 2043 VerifyRebootRequested( |
| 2124 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2044 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2125 | 2045 |
| 2126 // Verify that a grace period has started. | 2046 // Verify that a grace period has started. |
| 2127 VerifyGracePeriod(update_reboot_needed_uptime_); | 2047 VerifyGracePeriod(update_reboot_needed_uptime_); |
| 2128 | 2048 |
| 2129 // Verify that unless a non-kiosk-app session is in progress, the device | 2049 // Verify that unless a non-kiosk-app session is in progress, the device |
| 2130 // eventually reboots. | 2050 // eventually reboots. |
| 2131 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 2051 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2132 is_logged_in_as_kiosk_app_); | 2052 is_logged_in_as_kiosk_app_); |
| 2133 } | 2053 } |
| 2134 | 2054 |
| 2135 // Chrome is starting. An update was applied and a reboot became necessary to | 2055 // Chrome is starting. An update was applied and a reboot became necessary to |
| 2136 // complete the update process after 10 minutes of uptime. The current uptime is | 2056 // complete the update process after 10 minutes of uptime. The current uptime is |
| 2137 // 20 minutes. | 2057 // 20 minutes. |
| 2138 // Verifies that when the policy to automatically reboot after an update is | 2058 // Verifies that when the policy to automatically reboot after an update is |
| 2139 // enabled, no reboot occurs and a grace period is scheduled to begin after the | 2059 // enabled, no reboot occurs and a grace period is scheduled to begin after the |
| 2140 // minimum of 1 hour of uptime. | 2060 // minimum of 1 hour of uptime. |
| 2141 TEST_P(AutomaticRebootManagerTest, StartBeforeUpdateGracePeriod) { | 2061 TEST_P(AutomaticRebootManagerTest, StartBeforeUpdateGracePeriod) { |
| 2142 SetUpdateStatusNeedReboot(); | 2062 SetUpdateStatusNeedReboot(); |
| 2143 SetUpdateRebootNeededUptime(base::TimeDelta::FromMinutes(10)); | 2063 SetUpdateRebootNeededUptime(base::TimeDelta::FromMinutes(10)); |
| 2144 task_runner_->SetUptime(base::TimeDelta::FromMinutes(20)); | 2064 uptime_provider()->SetUptime(base::TimeDelta::FromMinutes(20)); |
| 2145 SetRebootAfterUpdate(true, false); | 2065 SetRebootAfterUpdate(true, false); |
| 2146 | 2066 |
| 2147 // Verify that no reboot is requested and the device does not reboot | 2067 // Verify that no reboot is requested and the device does not reboot |
| 2148 // immediately. | 2068 // immediately. |
| 2149 ExpectNoRebootRequest(); | 2069 ExpectNoRebootRequest(); |
| 2150 CreateAutomaticRebootManager(false); | 2070 CreateAutomaticRebootManager(false); |
| 2151 VerifyNoRebootRequested(); | 2071 VerifyNoRebootRequested(); |
| 2152 | 2072 |
| 2153 // Verify that a grace period has been scheduled to start in the future. | 2073 // Verify that a grace period has been scheduled to start in the future. |
| 2154 VerifyGracePeriod(base::TimeDelta::FromHours(1)); | 2074 VerifyGracePeriod(base::TimeDelta::FromHours(1)); |
| 2155 | 2075 |
| 2156 // Verify that a reboot is requested eventually and unless a non-kiosk-app | 2076 // Verify that a reboot is requested eventually and unless a non-kiosk-app |
| 2157 // session is in progress, the device eventually reboots. | 2077 // session is in progress, the device eventually reboots. |
| 2158 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2078 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2159 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 2079 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2160 is_logged_in_as_kiosk_app_); | 2080 is_logged_in_as_kiosk_app_); |
| 2161 } | 2081 } |
| 2162 | 2082 |
| 2163 // Chrome is starting. An update was applied and a reboot became necessary to | 2083 // Chrome is starting. An update was applied and a reboot became necessary to |
| 2164 // complete the update process after 6 hours of uptime. The current uptime is | 2084 // complete the update process after 6 hours of uptime. The current uptime is |
| 2165 // 10 days. | 2085 // 10 days. |
| 2166 // Verifies that when the policy to automatically reboot after an update is not | 2086 // Verifies that when the policy to automatically reboot after an update is not |
| 2167 // enabled, no reboot occurs and no grace period is scheduled. | 2087 // enabled, no reboot occurs and no grace period is scheduled. |
| 2168 TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicy) { | 2088 TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicy) { |
| 2169 SetUpdateStatusNeedReboot(); | 2089 SetUpdateStatusNeedReboot(); |
| 2170 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); | 2090 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); |
| 2171 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 2091 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 2172 | 2092 |
| 2173 // Verify that no reboot is requested and the device does not reboot | 2093 // Verify that no reboot is requested and the device does not reboot |
| 2174 // immediately. | 2094 // immediately. |
| 2175 ExpectNoRebootRequest(); | 2095 ExpectNoRebootRequest(); |
| 2176 CreateAutomaticRebootManager(false); | 2096 CreateAutomaticRebootManager(false); |
| 2177 VerifyNoRebootRequested(); | 2097 VerifyNoRebootRequested(); |
| 2178 | 2098 |
| 2179 // Verify that no grace period has started. | 2099 // Verify that no grace period has started. |
| 2180 VerifyNoGracePeriod(); | 2100 VerifyNoGracePeriod(); |
| 2181 | 2101 |
| 2182 // Verify that a reboot is never requested and the device never reboots. | 2102 // Verify that a reboot is never requested and the device never reboots. |
| 2183 FastForwardUntilNoTasksRemain(false); | 2103 FastForwardUntilNoTasksRemain(false); |
| 2184 } | 2104 } |
| 2185 | 2105 |
| 2186 // Chrome is starting. An update was applied and a reboot became necessary to | 2106 // Chrome is starting. An update was applied and a reboot became necessary to |
| 2187 // complete the update process but the time at which this happened was lost. The | 2107 // complete the update process but the time at which this happened was lost. The |
| 2188 // current uptime is 10 days. | 2108 // current uptime is 10 days. |
| 2189 // Verifies that the current uptime is persisted as the time at which a reboot | 2109 // Verifies that the current uptime is persisted as the time at which a reboot |
| 2190 // became necessary. Further verifies that when the policy to automatically | 2110 // became necessary. Further verifies that when the policy to automatically |
| 2191 // reboot after an update is enabled, a reboot is requested and a grace period | 2111 // reboot after an update is enabled, a reboot is requested and a grace period |
| 2192 // is started that will end 24 hours from now. | 2112 // is started that will end 24 hours from now. |
| 2193 TEST_P(AutomaticRebootManagerTest, StartUpdateTimeLost) { | 2113 TEST_P(AutomaticRebootManagerTest, StartUpdateTimeLost) { |
| 2194 SetUpdateStatusNeedReboot(); | 2114 SetUpdateStatusNeedReboot(); |
| 2195 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 2115 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 2196 SetRebootAfterUpdate(true, false); | 2116 SetRebootAfterUpdate(true, false); |
| 2197 | 2117 |
| 2198 // Verify that a reboot is requested but the device does not reboot | 2118 // Verify that a reboot is requested but the device does not reboot |
| 2199 // immediately. | 2119 // immediately. |
| 2200 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2120 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2201 CreateAutomaticRebootManager(false); | 2121 CreateAutomaticRebootManager(false); |
| 2202 VerifyRebootRequested( | 2122 VerifyRebootRequested( |
| 2203 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2123 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2204 | 2124 |
| 2205 // Verify that the current uptime has been persisted as the time at which a | 2125 // Verify that the current uptime has been persisted as the time at which a |
| 2206 // reboot became necessary. | 2126 // reboot became necessary. |
| 2207 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 2127 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 2208 &update_reboot_needed_uptime_)); | 2128 &update_reboot_needed_uptime_)); |
| 2209 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 2129 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 2210 | 2130 |
| 2211 // Verify that a grace period has started. | 2131 // Verify that a grace period has started. |
| 2212 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); | 2132 VerifyGracePeriod(update_reboot_needed_uptime_ + uptime_processing_delay_); |
| 2213 | 2133 |
| 2214 // Verify that unless a non-kiosk-app session is in progress, the device | 2134 // Verify that unless a non-kiosk-app session is in progress, the device |
| 2215 // eventually reboots. | 2135 // eventually reboots. |
| 2216 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 2136 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2217 is_logged_in_as_kiosk_app_); | 2137 is_logged_in_as_kiosk_app_); |
| 2218 } | 2138 } |
| 2219 | 2139 |
| 2220 // Chrome is starting. An update was applied and a reboot became necessary to | 2140 // Chrome is starting. An update was applied and a reboot became necessary to |
| 2221 // complete the update process but the time at which this happened was lost. The | 2141 // complete the update process but the time at which this happened was lost. The |
| 2222 // current uptime is 10 days. | 2142 // current uptime is 10 days. |
| 2223 // Verifies that the current uptime is persisted as the time at which a reboot | 2143 // Verifies that the current uptime is persisted as the time at which a reboot |
| 2224 // became necessary. Further verifies that when the policy to automatically | 2144 // became necessary. Further verifies that when the policy to automatically |
| 2225 // reboot after an update is not enabled, no reboot occurs and no grace period | 2145 // reboot after an update is not enabled, no reboot occurs and no grace period |
| 2226 // is scheduled. | 2146 // is scheduled. |
| 2227 TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) { | 2147 TEST_P(AutomaticRebootManagerTest, StartUpdateNoPolicyTimeLost) { |
| 2228 SetUpdateStatusNeedReboot(); | 2148 SetUpdateStatusNeedReboot(); |
| 2229 task_runner_->SetUptime(base::TimeDelta::FromDays(10)); | 2149 uptime_provider()->SetUptime(base::TimeDelta::FromDays(10)); |
| 2230 | 2150 |
| 2231 // Verify that no reboot is requested and the device does not reboot | 2151 // Verify that no reboot is requested and the device does not reboot |
| 2232 // immediately. | 2152 // immediately. |
| 2233 ExpectNoRebootRequest(); | 2153 ExpectNoRebootRequest(); |
| 2234 CreateAutomaticRebootManager(false); | 2154 CreateAutomaticRebootManager(false); |
| 2235 VerifyNoRebootRequested(); | 2155 VerifyNoRebootRequested(); |
| 2236 | 2156 |
| 2237 // Verify that the current uptime has been persisted as the time at which a | 2157 // Verify that the current uptime has been persisted as the time at which a |
| 2238 // reboot became necessary. | 2158 // reboot became necessary. |
| 2239 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( | 2159 EXPECT_TRUE(ReadUpdateRebootNeededUptimeFromFile( |
| 2240 &update_reboot_needed_uptime_)); | 2160 &update_reboot_needed_uptime_)); |
| 2241 EXPECT_EQ(task_runner_->Uptime(), update_reboot_needed_uptime_); | 2161 EXPECT_EQ(uptime_provider()->uptime(), update_reboot_needed_uptime_); |
| 2242 | 2162 |
| 2243 // Verify that no grace period has started. | 2163 // Verify that no grace period has started. |
| 2244 VerifyNoGracePeriod(); | 2164 VerifyNoGracePeriod(); |
| 2245 | 2165 |
| 2246 // Verify that a reboot is never requested and the device never reboots. | 2166 // Verify that a reboot is never requested and the device never reboots. |
| 2247 FastForwardUntilNoTasksRemain(false); | 2167 FastForwardUntilNoTasksRemain(false); |
| 2248 } | 2168 } |
| 2249 | 2169 |
| 2250 // Chrome is starting. No update has been applied. The current uptime is | 2170 // Chrome is starting. No update has been applied. The current uptime is |
| 2251 // 12 hours. | 2171 // 12 hours. |
| 2252 // Verifies that no time is persisted as the time at which a reboot became | 2172 // Verifies that no time is persisted as the time at which a reboot became |
| 2253 // necessary. Further verifies that no reboot occurs and no grace period is | 2173 // necessary. Further verifies that no reboot occurs and no grace period is |
| 2254 // scheduled. | 2174 // scheduled. |
| 2255 TEST_P(AutomaticRebootManagerTest, StartNoUpdate) { | 2175 TEST_P(AutomaticRebootManagerTest, StartNoUpdate) { |
| 2256 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 2176 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 2257 SetRebootAfterUpdate(true, false); | 2177 SetRebootAfterUpdate(true, false); |
| 2258 | 2178 |
| 2259 // Verify that no reboot is requested and the device does not reboot | 2179 // Verify that no reboot is requested and the device does not reboot |
| 2260 // immediately. | 2180 // immediately. |
| 2261 ExpectNoRebootRequest(); | 2181 ExpectNoRebootRequest(); |
| 2262 CreateAutomaticRebootManager(false); | 2182 CreateAutomaticRebootManager(false); |
| 2263 VerifyNoRebootRequested(); | 2183 VerifyNoRebootRequested(); |
| 2264 | 2184 |
| 2265 // Verify that no time is persisted as the time at which a reboot became | 2185 // Verify that no time is persisted as the time at which a reboot became |
| 2266 // necessary. | 2186 // necessary. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2277 // Chrome is starting. The uptime limit is set to 6 hours. Also, an update was | 2197 // Chrome is starting. The uptime limit is set to 6 hours. Also, an update was |
| 2278 // applied and a reboot became necessary to complete the update process after | 2198 // applied and a reboot became necessary to complete the update process after |
| 2279 // 8 hours of uptime. The current uptime is 12 hours. | 2199 // 8 hours of uptime. The current uptime is 12 hours. |
| 2280 // Verifies that when the policy to automatically reboot after an update is | 2200 // Verifies that when the policy to automatically reboot after an update is |
| 2281 // enabled, a reboot is requested and a grace period is started that will end | 2201 // enabled, a reboot is requested and a grace period is started that will end |
| 2282 // after 6 + 24 hours of uptime. | 2202 // after 6 + 24 hours of uptime. |
| 2283 TEST_P(AutomaticRebootManagerTest, StartUptimeLimitBeforeUpdate) { | 2203 TEST_P(AutomaticRebootManagerTest, StartUptimeLimitBeforeUpdate) { |
| 2284 SetUptimeLimit(base::TimeDelta::FromHours(6), false); | 2204 SetUptimeLimit(base::TimeDelta::FromHours(6), false); |
| 2285 SetUpdateStatusNeedReboot(); | 2205 SetUpdateStatusNeedReboot(); |
| 2286 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(8)); | 2206 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(8)); |
| 2287 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 2207 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 2288 SetRebootAfterUpdate(true, false); | 2208 SetRebootAfterUpdate(true, false); |
| 2289 | 2209 |
| 2290 // Verify that a reboot is requested but the device does not reboot | 2210 // Verify that a reboot is requested but the device does not reboot |
| 2291 // immediately. | 2211 // immediately. |
| 2292 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 2212 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 2293 CreateAutomaticRebootManager(false); | 2213 CreateAutomaticRebootManager(false); |
| 2294 VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); | 2214 VerifyRebootRequested(AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC); |
| 2295 | 2215 |
| 2296 // Verify that a grace period has started. | 2216 // Verify that a grace period has started. |
| 2297 VerifyGracePeriod(uptime_limit_); | 2217 VerifyGracePeriod(uptime_limit_); |
| 2298 | 2218 |
| 2299 // Verify that unless a non-kiosk-app session is in progress, the device | 2219 // Verify that unless a non-kiosk-app session is in progress, the device |
| 2300 // eventually reboots. | 2220 // eventually reboots. |
| 2301 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || | 2221 FastForwardUntilNoTasksRemain(!is_user_logged_in_ || |
| 2302 is_logged_in_as_kiosk_app_); | 2222 is_logged_in_as_kiosk_app_); |
| 2303 } | 2223 } |
| 2304 | 2224 |
| 2305 // Chrome is starting. The uptime limit is set to 8 hours. Also, an update was | 2225 // Chrome is starting. The uptime limit is set to 8 hours. Also, an update was |
| 2306 // applied and a reboot became necessary to complete the update process after | 2226 // applied and a reboot became necessary to complete the update process after |
| 2307 // 6 hours of uptime. The current uptime is 12 hours. | 2227 // 6 hours of uptime. The current uptime is 12 hours. |
| 2308 // Verifies that when the policy to automatically reboot after an update is | 2228 // Verifies that when the policy to automatically reboot after an update is |
| 2309 // enabled, a reboot is requested and a grace period is started that will end | 2229 // enabled, a reboot is requested and a grace period is started that will end |
| 2310 // after 6 + 24 hours of uptime. | 2230 // after 6 + 24 hours of uptime. |
| 2311 TEST_P(AutomaticRebootManagerTest, StartUpdateBeforeUptimeLimit) { | 2231 TEST_P(AutomaticRebootManagerTest, StartUpdateBeforeUptimeLimit) { |
| 2312 SetUptimeLimit(base::TimeDelta::FromHours(8), false); | 2232 SetUptimeLimit(base::TimeDelta::FromHours(8), false); |
| 2313 SetUpdateStatusNeedReboot(); | 2233 SetUpdateStatusNeedReboot(); |
| 2314 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); | 2234 SetUpdateRebootNeededUptime(base::TimeDelta::FromHours(6)); |
| 2315 task_runner_->SetUptime(base::TimeDelta::FromHours(12)); | 2235 uptime_provider()->SetUptime(base::TimeDelta::FromHours(12)); |
| 2316 SetRebootAfterUpdate(true, false); | 2236 SetRebootAfterUpdate(true, false); |
| 2317 | 2237 |
| 2318 // Verify that a reboot is requested but the device does not reboot | 2238 // Verify that a reboot is requested but the device does not reboot |
| 2319 // immediately. | 2239 // immediately. |
| 2320 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2240 ExpectRebootRequest(AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2321 CreateAutomaticRebootManager(false); | 2241 CreateAutomaticRebootManager(false); |
| 2322 VerifyRebootRequested( | 2242 VerifyRebootRequested( |
| 2323 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); | 2243 AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE); |
| 2324 | 2244 |
| 2325 // Verify that a grace period has started. | 2245 // Verify that a grace period has started. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2358 INSTANTIATE_TEST_CASE_P( | 2278 INSTANTIATE_TEST_CASE_P( |
| 2359 AutomaticRebootManagerTestInstance, | 2279 AutomaticRebootManagerTestInstance, |
| 2360 AutomaticRebootManagerTest, | 2280 AutomaticRebootManagerTest, |
| 2361 ::testing::Values( | 2281 ::testing::Values( |
| 2362 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, | 2282 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, |
| 2363 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, | 2283 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, |
| 2364 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); | 2284 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); |
| 2365 | 2285 |
| 2366 } // namespace system | 2286 } // namespace system |
| 2367 } // namespace chromeos | 2287 } // namespace chromeos |
| OLD | NEW |