class TestEnvironment

Defined at line 32 of file ../../sdk/lib/driver/testing/cpp/internal/test_environment.h

The |TestEnvironment| manages the mocked test environment that the driver being tested uses.

It provides the server backing the driver's incoming namespace. This incoming namespace can

be customized by the user through the |incoming_directory| method. The |TestEnvironment|

uses a fdf::OutgoingDirectory which can support driver transport. Therefore it must be used

with an fdf_dispatcher.

# Thread safety

This class is thread-unsafe. Instances must be managed and used from a synchronized dispatcher.

See

https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/thread-safe-async#synchronized-dispatcher

If the dispatcher used for it is the foreground dispatcher, the TestEnvironment does not need to

be wrapped in a DispatcherBound.

If the dispatcher is a background dispatcher, the suggestion is to wrap this inside of an

|async_patterns::TestDispatcherBound|.

Public Methods

void TestEnvironment (fdf_dispatcher_t * dispatcher)

Defined at line 14 of file ../../sdk/lib/driver/testing/cpp/internal/test_environment.cc

zx::result<> Initialize (fidl::ServerEnd<fuchsia_io::Directory> incoming_directory_server_end)

Defined at line 20 of file ../../sdk/lib/driver/testing/cpp/internal/test_environment.cc

fdf::OutgoingDirectory & incoming_directory ()

Get the fdf::OutgoingDirectory that backs the driver's incoming namespace.

Defined at line 37 of file ../../sdk/lib/driver/testing/cpp/internal/test_environment.h

const fdf::OutgoingDirectory & incoming_directory ()

Defined at line 42 of file ../../sdk/lib/driver/testing/cpp/internal/test_environment.h

template <typename Callback>
zx::result<> AddLogSink (Callback callback)

Adds LogSink to the incoming directory. If required, this *must* be called before calling

`Initialize`.

Defined at line 50 of file ../../sdk/lib/driver/testing/cpp/internal/test_environment.h