blob: c5a1e89b3bf3c3aa5e11a59bf15e210e71952b10 [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.
#include <lib/async-testutils/test_loop.h>
#include <memory>
#include "src/ledger/bin/testing/loop_controller.h"
namespace ledger {
// Implementation of a LoopController that uses a test loop. The test loop
// simulates the time in a deterministic way and does not rely on the real
// (physical) clock.
class LoopControllerTestLoop : public LoopController {
LoopControllerTestLoop(async::TestLoop* loop);
~LoopControllerTestLoop() override;
void RunLoop() override;
void StopLoop() override;
std::unique_ptr<SubLoop> StartNewLoop() override;
std::unique_ptr<CallbackWaiter> NewWaiter() override;
async_dispatcher_t* dispatcher() override;
bool RunLoopUntil(fit::function<bool()> condition) override;
void RunLoopFor(zx::duration duration) override;
async::TestLoop& test_loop() { return *loop_; }
async::TestLoop* const loop_;
} // namespace ledger