pub struct PiconetHarness {
pub builder: RealmBuilder,
pub ps_moniker: String,
/* private fields */
}
Expand description
Represents the topology of a piconet set up by an integration test.
Provides an API to add members to the piconet, define Bluetooth profiles to be run under test, and specify capability routing in the topology. Bluetooth profiles specified in the topology must be v2 components.
§Example Usage:
let harness = PiconetHarness::new().await;
// Add a mock piconet member to be driven by test code. let spec = harness.add_mock_piconet_member(“mock-peer”.to_string()).await?; // Add a Bluetooth Profile (AVRCP) to the topology. let profile_observer = harness.add_profile(“bt-avrcp-profile”, AVRCP_URL_V2).await?;
// The topology has been defined and can be built. After this step, it cannot be // modified (e.g Can’t add a new mock piconet member). let test_topology = test_harness.build().await?;
// Get the test-driven peer from the topology. let test_driven_peer = PiconetMember::new_from_spec(spec, &test_topology)?;
// Manipulate the test-driven peer to indirectly interact with the profile-under-test. let search_results = test_driven_peer.register_service_search(..)?; // Expect some behavior from the profile-under-test. let req = profile_observer.expect_observer_request().await?; assert_eq!(req, ..);
Fields§
§builder: RealmBuilder
§ps_moniker: String
Implementations§
Source§impl PiconetHarness
impl PiconetHarness
pub async fn new() -> Self
pub async fn add_mock_piconet_members( &mut self, mocks: &mut Vec<PiconetMemberSpec>, ) -> Result<(), Error>
pub async fn add_mock_piconet_member( &mut self, name: String, rfcomm_url: Option<String>, ) -> Result<PiconetMemberSpec, Error>
pub async fn build(self) -> Result<RealmInstance, Error>
Sourcepub async fn add_profile(
&mut self,
name: String,
profile_url: String,
) -> Result<BtProfileComponent, Error>
pub async fn add_profile( &mut self, name: String, profile_url: String, ) -> Result<BtProfileComponent, Error>
Add a profile with moniker name
to the test topology. The profile should be
accessible via the provided profile_url
and will be launched during the test.
Returns an observer for the launched profile.
Sourcepub async fn add_profile_with_capabilities(
&mut self,
name: String,
profile_url: String,
rfcomm_url: Option<String>,
use_capabilities: Vec<Capability>,
expose_capabilities: Vec<Capability>,
) -> Result<BtProfileComponent, Error>
pub async fn add_profile_with_capabilities( &mut self, name: String, profile_url: String, rfcomm_url: Option<String>, use_capabilities: Vec<Capability>, expose_capabilities: Vec<Capability>, ) -> Result<BtProfileComponent, Error>
Add a profile with moniker name
to the test topology.
profile_url
specifies the component URL of the profile under test.
rfcomm_url
specifies the optional hermetic RFCOMM component URL to be used as an
intermediary in the test topology.
use_capabilities
specifies any capabilities used by the profile that will be
provided outside the test realm.
expose_capabilities
specifies any protocol capabilities provided by the profile to be
available in the outgoing directory of the test realm root.
Returns an observer for the launched profile.