class RealmBuilder
Defined at line 237 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.h
Use this Builder class to construct a Realm object.
Public Methods
void RealmBuilder (RealmBuilder && )
Defined at line 251 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.h
RealmBuilder & operator= (RealmBuilder && )
Defined at line 252 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.h
void RealmBuilder (const RealmBuilder & )
Defined at line 254 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.h
RealmBuilder & operator= (const RealmBuilder & )
Defined at line 255 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.h
RealmBuilder Create (std::shared_ptr<sys::ServiceDirectory> svc)
Factory method to create a new Realm::Builder object.
|svc| must outlive the RealmBuilder object and created Realm object.
If it's nullptr, then the current process' "/svc" namespace entry is used.
Defined at line 298 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder CreateFromRelativeUrl (std::string_view fragment_only_url, std::shared_ptr<sys::ServiceDirectory> svc)
Same as above but the Realm will contain the contents of the manifest
located in the test package at the path indicated by the fragment-only URL
(for example, `#meta/other-component.cm`; see
https://fuchsia.dev/fuchsia-src/reference/components/url#relative-fragment-only).
Defined at line 302 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & AddChild (const std::string & child_name, const std::string & url, const ChildOptions & options)
Add a v2 component (.cm) to the root realm being constructed.
See |Realm.AddChild| for more details.
Defined at line 344 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & AddLocalChild (const std::string & child_name, LocalComponent * local_impl, const ChildOptions & options)
This method signature is DEPRECATED. Use the LocalComponentFactory
implementation of AddLocalChild instead.
Add a component by raw pointer to a LocalComponent-derived instance.
See |Realm.AddLocalChild| for more details.
TODO(https://fxbug.dev/296292544): Remove this method when build support
for API level 16 is removed.
RealmBuilder & StartOnBuild (bool start_on_build)
Sets whether or not the realm will be started when `Build` is called.
Defined at line 348 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.h
RealmBuilder & AddLocalChild (const std::string & child_name, LocalComponentFactory local_impl, const ChildOptions & options)
Add a component by LocalComponentFactory.
See |Realm.AddLocalChild| for more details.
Defined at line 366 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
Realm AddChildRealm (const std::string & child_name, const ChildOptions & options)
Create a sub realm as child of the root realm. The constructed
Realm is returned.
See |Realm.AddChildRealm| for more details.
Defined at line 374 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
Realm AddChildRealmFromDecl (const std::string & child_name, fuchsia::component::decl::Component & decl, const ChildOptions & options)
Create a sub realm as child of the root realm initialized with |decl|. The constructed
Realm is returned.
See |Realm.AddChildRealm| for more details.
Defined at line 379 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & AddRoute (Route route)
Route a capability for the root realm being constructed.
See |Realm.AddRoute| for more details.
Defined at line 386 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & RouteReadOnlyDirectory (const std::string & name, std::vector<Ref> to, DirectoryContents directory)
Offers a directory capability to a component for the root realm.
See |Realm.RouteReadOnlyDirectory| for more details.
Defined at line 394 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & InitMutableConfigFromPackage (const std::string & name)
Load the packaged configuration of the component if available.
Defined at line 400 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & InitMutableConfigToEmpty (const std::string & name)
Allow setting configuration values without loading packaged configuration.
Defined at line 405 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & AddConfiguration (std::vector<ConfigCapability> configurations)
Adds Configuration Capabilities to the root realm.
Defined at line 410 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & AddCapability (fuchsia::component::decl::Capability capability)
Adds a capability to the root realm.
Defined at line 415 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & SetConfigValue (const std::string & name, const std::string & key, ConfigValue value)
Replaces the value of a given configuration field for the root realm.
Defined at line 420 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
fuchsia::component::decl::Component GetComponentDecl (const std::string & child_name)
Fetches the Component decl of the given child of the root realm.
See |Realm.GetComponentDecl| for more details.
Defined at line 435 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
fuchsia::component::decl::Component GetRealmDecl ()
Fetches the Component decl of this root realm.
Defined at line 439 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
void ReplaceComponentDecl (const std::string & child_name, fuchsia::component::decl::Component decl)
Updates the Component decl of the given child of the root realm.
See |Realm.GetRealmDecl| for more details.
Defined at line 426 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
void ReplaceRealmDecl (fuchsia::component::decl::Component decl)
Updates the Component decl of this root realm.
Defined at line 431 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & SetRealmCollection (const std::string & collection)
Set the name of the collection that the realm will be added to.
By default this is set to |kDefaultCollection|.
Note that this collection name is referenced in the Realm Builder
shard (//sdk/lib/sys/component/realm_builder_base.shard.cml) under the
collection name |kDefaultCollection|. To retain the same routing, component
authors that override the collection name should make the appropriate
changes in the test component's manifest.
Defined at line 441 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmBuilder & SetRealmName (const std::string & name)
Set the name for the constructed realm. By default, a randomly
generated string is used.
Defined at line 446 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
RealmRoot Build (async_dispatcher_t * dispatcher)
Build the realm root prepared by the associated builder methods, e.g. |AddComponent|.
|dispatcher| must be non-null, or |async_get_default_dispatcher| must be
configured to return a non-null value
This function can only be called once per Realm::Builder instance.
Multiple invocations will result in a panic.
|dispatcher| must outlive the lifetime of the constructed |RealmRoot|.
Defined at line 451 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc
Realm & root ()
A reference to the root `Realm` object.
Defined at line 478 of file ../../sdk/lib/sys/component/cpp/testing/realm_builder.cc