class ScopedChild
Defined at line 29 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
A scoped instance of a dynamically created child component. This class
will automatically destroy the child component once it goes out of scope.
Public Methods
ScopedChild New (fuchsia::component::RealmSyncPtr realm_proxy, std::string collection, std::string name, std::string url)
Create a dynamic child component using the fuchsia.component.Realm API.
|realm_proxy| must be bound to a connection to the fuchsia.component.Realm protocol.
|collection| is the name of the collection to create the child under. This
field must refer to a name in the current component's manifest file.
|name| is the name to assign to the child.
|url| is the component component URL of the child component.
Defined at line 43 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
ScopedChild New (fuchsia::component::RealmSyncPtr realm_proxy, std::string collection, std::string url)
Same as above with a randomly generated `name`.
Defined at line 37 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
ScopedChild New (std::string collection, std::string name, std::string url, std::shared_ptr<sys::ServiceDirectory> svc)
Create a dynamic child component using the fuchsia.component.Realm API.
|collection| is the name of the collection to create the child under. This
field must refer to a name in the current component's manifest file.
|name| is the name to assign to the child.
|url| is the component component URL of the child component.
|svc| is used to make a connection to the protocol. If it's not provided,
then the namespace entry will be used.
Defined at line 56 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
void ScopedChild (ScopedChild && )
Defined at line 60 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
ScopedChild & operator= (ScopedChild && )
Defined at line 61 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
void ScopedChild (const ScopedChild & )
Defined at line 63 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
ScopedChild & operator= (const ScopedChild & )
Defined at line 64 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
ScopedChild New (std::string collection, std::string url, std::shared_ptr<sys::ServiceDirectory> svc)
Same as above with a randomly generated `name`.
Defined at line 71 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
void ~ScopedChild ()
Defined at line 86 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
template <typename Interface>
fidl::InterfacePtr<Interface> Connect (const std::string & interface_name)
Connect to an interface in the exposed directory of the child component.
The discovery name of the interface is inferred from the C++ type of the
interface. Callers can supply an interface name explicitly to override
the default name.
This overload panics if the connection operation doesn't return ZX_OK.
Callers that wish to receive that status should use one of the other
overloads that returns a |zx_status_t|.
# Example
```
auto echo = instance.Connect
<test
::placeholders::Echo>();
```
Defined at line 88 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
void Teardown (async_dispatcher_t * dispatcher, TeardownCallback callback)
Calls fuchsia.component/Realm.DestroyChild asynchronously on |dispatcher|.
|callback| will be invoked when Component Manager has completed
the realm teardown.
Defined at line 97 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
template <typename Interface>
fidl::SynchronousInterfacePtr<Interface> ConnectSync (const std::string & interface_name)
SynchronousInterfacePtr method variant of |Connect|. See |Connect| for
more details.
Defined at line 100 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
template <typename Interface>
zx_status_t Connect (fidl::InterfaceRequest<Interface> request)
Connect to exposed directory of the child component.
Defined at line 111 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
template <typename Protocol, typename = std::enable_if_t<fidl::IsProtocolV<Protocol>>>
zx::result<fidl::ClientEnd<Protocol>> Connect (std::string path)
ClientEnd variant of |Connect|. See |Connect| for more details.
Defined at line 121 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
zx_status_t Connect (const std::string & interface_name, zx::channel request)
Connect to an interface in the exposed directory using the supplied
channel.
Defined at line 139 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
fidl::InterfaceHandle<fuchsia::io::Directory> CloneExposedDir ()
Clone the exposed directory.
Defined at line 139 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h
std::string GetChildName ()
Get the child name of this instance.
Defined at line 144 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
const fuchsia::io::DirectorySyncPtr & exposed ()
Returns reference to underlying exposed directory handle.
Defined at line 146 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
ExecutionController Start (fuchsia::component::StartChildArgs )
Starts the component with the provided start arguments (if any).
Defined at line 148 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.cc
void CloneExposedDir (fidl::InterfaceRequest<fuchsia::io::Directory> directory_request)
Clone the exposed directory.
Defined at line 149 of file ../../sdk/lib/sys/component/cpp/testing/scoped_child.h