David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_FAKE_CLOCK_H_ |
| 6 | #define UPDATE_ENGINE_FAKE_CLOCK_H_ |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 7 | |
| 8 | #include "update_engine/clock_interface.h" |
| 9 | |
| 10 | namespace chromeos_update_engine { |
| 11 | |
| 12 | // Implements a clock that can be made to tell any time you want. |
| 13 | class FakeClock : public ClockInterface { |
| 14 | public: |
| 15 | FakeClock() {} |
| 16 | |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame^] | 17 | base::Time GetWallclockTime() override { |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 18 | return wallclock_time_; |
| 19 | } |
| 20 | |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame^] | 21 | base::Time GetMonotonicTime() override { |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 22 | return monotonic_time_; |
| 23 | } |
| 24 | |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame^] | 25 | base::Time GetBootTime() override { |
David Zeuthen | 3c55abd | 2013-10-14 12:48:03 -0700 | [diff] [blame] | 26 | return boot_time_; |
| 27 | } |
| 28 | |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 29 | void SetWallclockTime(const base::Time &time) { |
| 30 | wallclock_time_ = time; |
| 31 | } |
| 32 | |
| 33 | void SetMonotonicTime(const base::Time &time) { |
| 34 | monotonic_time_ = time; |
| 35 | } |
| 36 | |
David Zeuthen | 3c55abd | 2013-10-14 12:48:03 -0700 | [diff] [blame] | 37 | void SetBootTime(const base::Time &time) { |
| 38 | boot_time_ = time; |
| 39 | } |
| 40 | |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 41 | private: |
| 42 | base::Time wallclock_time_; |
| 43 | base::Time monotonic_time_; |
David Zeuthen | 3c55abd | 2013-10-14 12:48:03 -0700 | [diff] [blame] | 44 | base::Time boot_time_; |
David Zeuthen | f413fe5 | 2013-04-22 14:04:39 -0700 | [diff] [blame] | 45 | |
| 46 | DISALLOW_COPY_AND_ASSIGN(FakeClock); |
| 47 | }; |
| 48 | |
| 49 | } // namespace chromeos_update_engine |
| 50 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 51 | #endif // UPDATE_ENGINE_FAKE_CLOCK_H_ |