blob: c717bdf68bf230ae457c4a90ce2cb643bcfe1505 [file] [log] [blame]
David Zeuthenf413fe52013-04-22 14:04:39 -07001// 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 Arnoldcf175a02014-07-10 16:48:47 -07005#ifndef UPDATE_ENGINE_FAKE_CLOCK_H_
6#define UPDATE_ENGINE_FAKE_CLOCK_H_
David Zeuthenf413fe52013-04-22 14:04:39 -07007
8#include "update_engine/clock_interface.h"
9
10namespace chromeos_update_engine {
11
12// Implements a clock that can be made to tell any time you want.
13class FakeClock : public ClockInterface {
14 public:
15 FakeClock() {}
16
Alex Deymo610277e2014-11-11 21:18:11 -080017 base::Time GetWallclockTime() override {
David Zeuthenf413fe52013-04-22 14:04:39 -070018 return wallclock_time_;
19 }
20
Alex Deymo610277e2014-11-11 21:18:11 -080021 base::Time GetMonotonicTime() override {
David Zeuthenf413fe52013-04-22 14:04:39 -070022 return monotonic_time_;
23 }
24
Alex Deymo610277e2014-11-11 21:18:11 -080025 base::Time GetBootTime() override {
David Zeuthen3c55abd2013-10-14 12:48:03 -070026 return boot_time_;
27 }
28
David Zeuthenf413fe52013-04-22 14:04:39 -070029 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 Zeuthen3c55abd2013-10-14 12:48:03 -070037 void SetBootTime(const base::Time &time) {
38 boot_time_ = time;
39 }
40
David Zeuthenf413fe52013-04-22 14:04:39 -070041 private:
42 base::Time wallclock_time_;
43 base::Time monotonic_time_;
David Zeuthen3c55abd2013-10-14 12:48:03 -070044 base::Time boot_time_;
David Zeuthenf413fe52013-04-22 14:04:39 -070045
46 DISALLOW_COPY_AND_ASSIGN(FakeClock);
47};
48
49} // namespace chromeos_update_engine
50
Gilad Arnoldcf175a02014-07-10 16:48:47 -070051#endif // UPDATE_ENGINE_FAKE_CLOCK_H_