blob: 9466d231de1a9d5af08167f8dc149a1fc67978d5 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_LIB_TIMEKEEPER_MONOTONIC_TEST_CLOCK_BASE_H_
#define SRC_LIB_TIMEKEEPER_MONOTONIC_TEST_CLOCK_BASE_H_
#include <lib/fit/function.h>
#include <lib/timekeeper/clock.h>
#include <limits>
namespace timekeeper {
// Abstract implementation of |Clock| that takes a time_t generator and ensure
// that every clock is strictly increasing.
class MonotonicTestClockBase : public Clock {
public:
MonotonicTestClockBase(fit::function<zx_time_t()> clock);
~MonotonicTestClockBase() override;
private:
zx_status_t GetUtcTime(zx_time_t* time) const final;
zx_time_t GetMonotonicTime() const final;
fit::function<zx_time_t()> clock_;
mutable zx_time_t last_returned_value_ = std::numeric_limits<zx_time_t>::min();
};
} // namespace timekeeper
#endif // SRC_LIB_TIMEKEEPER_MONOTONIC_TEST_CLOCK_BASE_H_