Skip to main content

TestHarness

Struct TestHarness 

Source
pub struct TestHarness<D> { /* private fields */ }
Expand description

The main test harness for running a driver unit test.

Implementations§

Source§

impl<D: Driver> TestHarness<D>

Source

pub fn new() -> Self

Creates a new TestHarness without a customized driver incoming ServiceFs.

Source

pub fn set_driver_incoming( self, driver_incoming: ServiceFs<ServiceObj<'static, ()>>, ) -> Self

Sets the driver incoming ServiceFs. Consumes and returns self to allow chaining.

Source

pub fn set_config(self, config: Vmo) -> Self

Sets the configuration vmo for the driver. Consumes and returns self to allow chaining.

Source

pub fn set_url(self, url: &str) -> Self

Sets the url for the driver. Consumes and returns self to allow chaining.

Source

pub fn set_node_name(self, name: impl Into<String>) -> Self

Sets the node name for the driver. Consumes and returns self to allow chaining.

Source

pub fn add_offer(self, offer: Offer) -> Self

Adds an offer to the driver’s start args. Consumes and returns self to allow chaining.

Source

pub fn set_power_element_args(self, args: impl IntoPowerElementArgs) -> Self

Sets the power element args for the driver. Accepts both fidl_next_fuchsia_driver_framework::PowerElementArgs and, for drivers that haven’t migrated yet, the legacy fidl_fuchsia_driver_framework::PowerElementArgs. Consumes and returns self to allow chaining.

Source

pub fn set_node_token(self, token: Event) -> Self

Sets the node token for the driver. Consumes and returns self to allow chaining.

Source

pub fn set_power_element_token(self, token: Event) -> Self

Sets the power element dependency token for the driver, as returned by crate::DriverContext::take_power_element_token. This only populates the token of the power element args; use Self::set_power_element_args to also provide the power broker endpoints. Consumes and returns self to allow chaining.

Source

pub fn add_node_property( self, parent: &str, key: impl Into<String>, value: impl Into<PropertyValue>, ) -> Self

Adds a property of the parent node named parent to the driver’s start args, as reported by crate::DriverContext::node_properties. Drivers bound to a single node see their properties under the parent name default. Consumes and returns self to allow chaining.

Source

pub fn dispatcher(&self) -> AsyncDispatcher

Gets a driver dispatcher that can be used to run test side driver transport client/servers.

Source

pub async fn start_driver(&mut self) -> Result<DriverUnderTest<'_, D>, Status>

Starts the driver under test.

Trait Implementations§

Source§

impl<D: Driver> Default for TestHarness<D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<D> Drop for TestHarness<D>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<D> !RefUnwindSafe for TestHarness<D>

§

impl<D> !Sync for TestHarness<D>

§

impl<D> !UnwindSafe for TestHarness<D>

§

impl<D> Freeze for TestHarness<D>
where PhantomData<D>: Freeze,

§

impl<D> Send for TestHarness<D>
where PhantomData<D>: Send,

§

impl<D> Unpin for TestHarness<D>
where PhantomData<D>: Unpin,

§

impl<D> UnsafeUnpin for TestHarness<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<F, N> FidlIntoNative<Box<N>> for F
where F: FidlIntoNative<N>,

§

fn fidl_into_native(self) -> Box<N>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InstanceFromServiceTransport<T> for T

Source§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to Self
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<E> RunsTransport<Mpsc> for E

Source§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.