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 | |
| 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_FAKE_CLOCK_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_FAKE_CLOCK_H__ |
| 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 | |
| 25 | void SetWallclockTime(const base::Time &time) { |
| 26 | wallclock_time_ = time; |
| 27 | } |
| 28 | |
| 29 | void SetMonotonicTime(const base::Time &time) { |
| 30 | monotonic_time_ = time; |
| 31 | } |
| 32 | |
| 33 | private: |
| 34 | base::Time wallclock_time_; |
| 35 | base::Time monotonic_time_; |
| 36 | |
| 37 | DISALLOW_COPY_AND_ASSIGN(FakeClock); |
| 38 | }; |
| 39 | |
| 40 | } // namespace chromeos_update_engine |
| 41 | |
| 42 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_FAKE_CLOCK_H__ |