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 | |
Alex Deymo | 759c275 | 2014-03-17 21:09:36 -0700 | [diff] [blame] | 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_FAKE_CLOCK_H_ |
| 6 | #define CHROMEOS_PLATFORM_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 | |
| 17 | virtual base::Time GetWallclockTime() { |
| 18 | return wallclock_time_; |
| 19 | } |
| 20 | |
| 21 | virtual base::Time GetMonotonicTime() { |
| 22 | return monotonic_time_; |
| 23 | } |
| 24 | |
David Zeuthen | 3c55abd | 2013-10-14 12:48:03 -0700 | [diff] [blame] | 25 | virtual base::Time GetBootTime() { |
| 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 | |
Alex Deymo | 759c275 | 2014-03-17 21:09:36 -0700 | [diff] [blame] | 51 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_FAKE_CLOCK_H_ |