| 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> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 // A SingleThreadTaskRunner that mocks the current time and allows it to be | 54 // A SingleThreadTaskRunner that mocks the current time and allows it to be |
| 55 // fast-forwarded. The current time in ticks is returned by Now(). The | 55 // fast-forwarded. The current time in ticks is returned by Now(). The |
| 56 // corresponding device uptime is written to |uptime_file_|, providing a mock | 56 // corresponding device uptime is written to |uptime_file_|, providing a mock |
| 57 // for /proc/uptime. | 57 // for /proc/uptime. |
| 58 class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { | 58 class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { |
| 59 public: | 59 public: |
| 60 MockTimeSingleThreadTaskRunner(); | 60 MockTimeSingleThreadTaskRunner(); |
| 61 | 61 |
| 62 // base::SingleThreadTaskRunner: | 62 // base::SingleThreadTaskRunner: |
| 63 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | 63 virtual bool RunsTasksOnCurrentThread() const override; |
| 64 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 64 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 65 const base::Closure& task, | 65 const base::Closure& task, |
| 66 base::TimeDelta delay) OVERRIDE; | 66 base::TimeDelta delay) override; |
| 67 virtual bool PostNonNestableDelayedTask( | 67 virtual bool PostNonNestableDelayedTask( |
| 68 const tracked_objects::Location& from_here, | 68 const tracked_objects::Location& from_here, |
| 69 const base::Closure& task, | 69 const base::Closure& task, |
| 70 base::TimeDelta delay) OVERRIDE; | 70 base::TimeDelta delay) override; |
| 71 | 71 |
| 72 void SetUptimeFile(const base::FilePath& uptime_file); | 72 void SetUptimeFile(const base::FilePath& uptime_file); |
| 73 void SetUptime(const base::TimeDelta& uptime); | 73 void SetUptime(const base::TimeDelta& uptime); |
| 74 | 74 |
| 75 const base::TimeDelta& Uptime() const; | 75 const base::TimeDelta& Uptime() const; |
| 76 const base::TimeTicks& Now() const; | 76 const base::TimeTicks& Now() const; |
| 77 | 77 |
| 78 void FastForwardBy(const base::TimeDelta& delta); | 78 void FastForwardBy(const base::TimeDelta& delta); |
| 79 void FastForwardUntilNoTasksRemain(); | 79 void FastForwardUntilNoTasksRemain(); |
| 80 void RunUntilIdle(); | 80 void RunUntilIdle(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 100 DISALLOW_COPY_AND_ASSIGN(MockTimeSingleThreadTaskRunner); | 100 DISALLOW_COPY_AND_ASSIGN(MockTimeSingleThreadTaskRunner); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 class MockTimeTickClock : public base::TickClock { | 103 class MockTimeTickClock : public base::TickClock { |
| 104 public: | 104 public: |
| 105 explicit MockTimeTickClock( | 105 explicit MockTimeTickClock( |
| 106 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner); | 106 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner); |
| 107 virtual ~MockTimeTickClock(); | 107 virtual ~MockTimeTickClock(); |
| 108 | 108 |
| 109 // base::TickClock: | 109 // base::TickClock: |
| 110 virtual base::TimeTicks NowTicks() OVERRIDE; | 110 virtual base::TimeTicks NowTicks() override; |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_; | 113 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(MockTimeTickClock); | 115 DISALLOW_COPY_AND_ASSIGN(MockTimeTickClock); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 class AutomaticRebootManagerBasicTest : public testing::Test { | 120 class AutomaticRebootManagerBasicTest : public testing::Test { |
| 121 protected: | 121 protected: |
| 122 typedef base::OneShotTimer<AutomaticRebootManager> Timer; | 122 typedef base::OneShotTimer<AutomaticRebootManager> Timer; |
| 123 | 123 |
| 124 AutomaticRebootManagerBasicTest(); | 124 AutomaticRebootManagerBasicTest(); |
| 125 virtual ~AutomaticRebootManagerBasicTest(); | 125 virtual ~AutomaticRebootManagerBasicTest(); |
| 126 | 126 |
| 127 // testing::Test: | 127 // testing::Test: |
| 128 virtual void SetUp() OVERRIDE; | 128 virtual void SetUp() override; |
| 129 virtual void TearDown() OVERRIDE; | 129 virtual void TearDown() override; |
| 130 | 130 |
| 131 void SetUpdateRebootNeededUptime(const base::TimeDelta& uptime); | 131 void SetUpdateRebootNeededUptime(const base::TimeDelta& uptime); |
| 132 void SetRebootAfterUpdate(bool reboot_after_update, bool expect_reboot); | 132 void SetRebootAfterUpdate(bool reboot_after_update, bool expect_reboot); |
| 133 void SetUptimeLimit(const base::TimeDelta& limit, bool expect_reboot); | 133 void SetUptimeLimit(const base::TimeDelta& limit, bool expect_reboot); |
| 134 void NotifyUpdateRebootNeeded(); | 134 void NotifyUpdateRebootNeeded(); |
| 135 void NotifyResumed(bool expect_reboot); | 135 void NotifyResumed(bool expect_reboot); |
| 136 void NotifyTerminating(bool expect_reboot); | 136 void NotifyTerminating(bool expect_reboot); |
| 137 | 137 |
| 138 void FastForwardBy(const base::TimeDelta& delta, bool expect_reboot); | 138 void FastForwardBy(const base::TimeDelta& delta, bool expect_reboot); |
| 139 void FastForwardUntilNoTasksRemain(bool expect_reboot); | 139 void FastForwardUntilNoTasksRemain(bool expect_reboot); |
| (...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2052 INSTANTIATE_TEST_CASE_P( | 2052 INSTANTIATE_TEST_CASE_P( |
| 2053 AutomaticRebootManagerTestInstance, | 2053 AutomaticRebootManagerTestInstance, |
| 2054 AutomaticRebootManagerTest, | 2054 AutomaticRebootManagerTest, |
| 2055 ::testing::Values( | 2055 ::testing::Values( |
| 2056 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, | 2056 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_LOGIN_SCREEN, |
| 2057 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, | 2057 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_KIOSK_APP_SESSION, |
| 2058 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); | 2058 AUTOMATIC_REBOOT_MANAGER_TEST_SCENARIO_NON_KIOSK_APP_SESSION)); |
| 2059 | 2059 |
| 2060 } // namespace system | 2060 } // namespace system |
| 2061 } // namespace chromeos | 2061 } // namespace chromeos |
| OLD | NEW |