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 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/test/test_shell_delegate.h" | 10 #include "ash/test/test_shell_delegate.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 AutomaticRebootManager* automatic_reboot_manger_; | 128 AutomaticRebootManager* automatic_reboot_manger_; |
129 | 129 |
130 DISALLOW_COPY_AND_ASSIGN(MockAutomaticRebootManagerObserver); | 130 DISALLOW_COPY_AND_ASSIGN(MockAutomaticRebootManagerObserver); |
131 }; | 131 }; |
132 | 132 |
133 } // namespace | 133 } // namespace |
134 | 134 |
135 class AutomaticRebootManagerBasicTest : public testing::Test { | 135 class AutomaticRebootManagerBasicTest : public testing::Test { |
136 protected: | 136 protected: |
137 typedef base::OneShotTimer<AutomaticRebootManager> Timer; | |
138 | |
139 AutomaticRebootManagerBasicTest(); | 137 AutomaticRebootManagerBasicTest(); |
140 ~AutomaticRebootManagerBasicTest() override; | 138 ~AutomaticRebootManagerBasicTest() override; |
141 | 139 |
142 // testing::Test: | 140 // testing::Test: |
143 void SetUp() override; | 141 void SetUp() override; |
144 void TearDown() override; | 142 void TearDown() override; |
145 | 143 |
146 void SetUpdateRebootNeededUptime(const base::TimeDelta& uptime); | 144 void SetUpdateRebootNeededUptime(const base::TimeDelta& uptime); |
147 void SetRebootAfterUpdate(bool reboot_after_update, bool expect_reboot); | 145 void SetRebootAfterUpdate(bool reboot_after_update, bool expect_reboot); |
148 void SetUptimeLimit(const base::TimeDelta& limit, bool expect_reboot); | 146 void SetUptimeLimit(const base::TimeDelta& limit, bool expect_reboot); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 base::TimeDelta uptime_processing_delay_; | 181 base::TimeDelta uptime_processing_delay_; |
184 base::TimeDelta update_reboot_needed_uptime_; | 182 base::TimeDelta update_reboot_needed_uptime_; |
185 base::TimeDelta uptime_limit_; | 183 base::TimeDelta uptime_limit_; |
186 | 184 |
187 scoped_refptr<TestAutomaticRebootManagerTaskRunner> task_runner_; | 185 scoped_refptr<TestAutomaticRebootManagerTaskRunner> task_runner_; |
188 | 186 |
189 MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_; | 187 MockAutomaticRebootManagerObserver automatic_reboot_manager_observer_; |
190 scoped_ptr<AutomaticRebootManager> automatic_reboot_manager_; | 188 scoped_ptr<AutomaticRebootManager> automatic_reboot_manager_; |
191 | 189 |
192 private: | 190 private: |
193 void VerifyTimerIsStopped(const Timer* timer) const; | 191 void VerifyTimerIsStopped(const base::OneShotTimer* timer) const; |
194 void VerifyTimerIsRunning(const Timer* timer, | 192 void VerifyTimerIsRunning(const base::OneShotTimer* timer, |
195 const base::TimeDelta& delay) const; | 193 const base::TimeDelta& delay) const; |
196 void VerifyLoginScreenIdleTimerIsRunning() const; | 194 void VerifyLoginScreenIdleTimerIsRunning() const; |
197 | 195 |
198 base::ScopedTempDir temp_dir_; | 196 base::ScopedTempDir temp_dir_; |
199 base::FilePath update_reboot_needed_uptime_file_; | 197 base::FilePath update_reboot_needed_uptime_file_; |
200 | 198 |
201 bool reboot_after_update_; | 199 bool reboot_after_update_; |
202 | 200 |
203 base::ThreadTaskRunnerHandle ui_thread_task_runner_handle_; | 201 base::ThreadTaskRunnerHandle ui_thread_task_runner_handle_; |
204 | 202 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 533 } |
536 } | 534 } |
537 | 535 |
538 void AutomaticRebootManagerBasicTest::SetUpdateStatusNeedReboot() { | 536 void AutomaticRebootManagerBasicTest::SetUpdateStatusNeedReboot() { |
539 UpdateEngineClient::Status client_status; | 537 UpdateEngineClient::Status client_status; |
540 client_status.status = UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; | 538 client_status.status = UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; |
541 update_engine_client_->set_default_status(client_status); | 539 update_engine_client_->set_default_status(client_status); |
542 } | 540 } |
543 | 541 |
544 void AutomaticRebootManagerBasicTest::VerifyTimerIsStopped( | 542 void AutomaticRebootManagerBasicTest::VerifyTimerIsStopped( |
545 const Timer* timer) const { | 543 const base::OneShotTimer* timer) const { |
546 if (timer) | 544 if (timer) |
547 EXPECT_FALSE(timer->IsRunning()); | 545 EXPECT_FALSE(timer->IsRunning()); |
548 } | 546 } |
549 | 547 |
550 void AutomaticRebootManagerBasicTest::VerifyTimerIsRunning( | 548 void AutomaticRebootManagerBasicTest::VerifyTimerIsRunning( |
551 const Timer* timer, | 549 const base::OneShotTimer* timer, |
552 const base::TimeDelta& delay) const { | 550 const base::TimeDelta& delay) const { |
553 ASSERT_TRUE(timer); | 551 ASSERT_TRUE(timer); |
554 EXPECT_TRUE(timer->IsRunning()); | 552 EXPECT_TRUE(timer->IsRunning()); |
555 EXPECT_EQ(delay.ToInternalValue(), | 553 EXPECT_EQ(delay.ToInternalValue(), |
556 timer->GetCurrentDelay().ToInternalValue()); | 554 timer->GetCurrentDelay().ToInternalValue()); |
557 } | 555 } |
558 | 556 |
559 void AutomaticRebootManagerBasicTest:: | 557 void AutomaticRebootManagerBasicTest:: |
560 VerifyLoginScreenIdleTimerIsRunning() const { | 558 VerifyLoginScreenIdleTimerIsRunning() const { |
561 VerifyTimerIsRunning( | 559 VerifyTimerIsRunning( |
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 INSTANTIATE_TEST_CASE_P( | 2279 INSTANTIATE_TEST_CASE_P( |
2282 AutomaticRebootManagerTestInstance, | 2280 AutomaticRebootManagerTestInstance, |
2283 AutomaticRebootManagerTest, | 2281 AutomaticRebootManagerTest, |
2284 ::testing::Values( | 2282 ::testing::Values( |
2285 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, | 2283 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, |
2286 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, | 2284 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, |
2287 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); | 2285 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); |
2288 | 2286 |
2289 } // namespace system | 2287 } // namespace system |
2290 } // namespace chromeos | 2288 } // namespace chromeos |
OLD | NEW |