blob: c80a74cd3a2df2170e0e9eecee5258629f0bc524 [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 TESTING_FIDL_ASYNC_LOOP_FOR_TEST_H_
#define TESTING_FIDL_ASYNC_LOOP_FOR_TEST_H_
#include <lib/async/dispatcher.h>
#include <zircon/types.h>
#include <memory>
// Implement this class in order to run the fidl bindings unit tests on top of
// your choice of dispatcher.
namespace fidl {
namespace test {
class AsyncLoopForTestImpl;
class AsyncLoopForTest {
public:
// The AsyncLoopForTest constructor should also call
// async_set_default_dispatcher() with the chosen dispatcher implementation.
AsyncLoopForTest();
~AsyncLoopForTest();
// This call matches the behavior of async_loop_run_until_idle().
zx_status_t RunUntilIdle();
// This call matches the behavior of async_loop_run().
zx_status_t Run();
// Returns the underlying async_dispatcher_t.
async_dispatcher_t* dispatcher();
private:
std::unique_ptr<AsyncLoopForTestImpl> impl_;
};
} // namespace test
} // namespace fidl
#endif // TESTING_FIDL_ASYNC_LOOP_FOR_TEST_H_