FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    HeadlessUnitTestSession

    struct · ferroui-headless · v0.5.0

    struct HeadlessUnitTestSession
    

    Headless unit test session that needs to be used by the actual testing framework. All UI tests are supposed to be executed from one of the dispatch methods to keep execution flow on the UI thread. Disposing unit test session stops internal dispatcher loop.

    View source

    Members

    dispatch

    fn dispatch(self: &Self, action: impl FnOnce() -> () + Send + 'static, cancellation_token: CancellationToken) -> HeadlessUnitTestTask<()>
    

    Queues an action on the dispatcher thread; see dispatch_task.

    Source

    dispatch_result

    fn dispatch_result<TResult: Send + 'static>(self: &Self, action: impl FnOnce() -> TResult + Send + 'static, cancellation_token: CancellationToken) -> HeadlessUnitTestTask<TResult>
    

    Queues an action with a result on the dispatcher thread; see dispatch_task.

    Source

    dispatch_task

    fn dispatch_task<F, Fut>(self: &Self, action: F, cancellation_token: CancellationToken) -> HeadlessUnitTestTask<<Fut as >::Output>
    where F: FnOnce() -> Fut + Send + 'static,
          Fut: Future + 'static,
          <Fut as >::Output: Send + 'static
    

    Dispatch method queues an async operation on the dispatcher thread, creates a new application instance, setting the application services, and runs action parameter.

    action is the action to execute on the dispatcher thread with the services; the future it returns never leaves the dispatcher thread. cancellation_token is the cancellation token to cancel execution.

    Panics

    If global session was already cancelled and thread killed, it's not possible to dispatch any actions again (ObjectDisposedException).

    Source

    dispose

    fn dispose(self: &Self)
    

    Source

    dispose_async

    async fn dispose_async(self: &Self)
    

    The asynchronous form of dispose. The dispatch thread is joined before the future is returned to its first poll: there is no task to await in its place.

    Source

    start_new

    fn start_new(entry_point_type: fn() -> AppBuilder) -> Arc<HeadlessUnitTestSession>
    

    Creates instance of HeadlessUnitTestSession with the FerroTestIsolationLevel::PerTest isolation.

    entry_point_type is the parameter from which AppBuilder should be created: the function that builds the application (AppBuilder::configure::<TApp> for an application class).

    Source

    start_new_with_isolation

    fn start_new_with_isolation(entry_point_type: fn() -> AppBuilder, isolation_level: FerroTestIsolationLevel) -> Arc<HeadlessUnitTestSession>
    

    Creates instance of HeadlessUnitTestSession.

    entry_point_type is the parameter from which AppBuilder should be created. isolation_level defines the isolation level for headless unit tests.

    Panics

    Raises the panic of the entry point again.

    Source

    get_or_start_for_assembly

    fn get_or_start_for_assembly(assembly: Option<&FerroTestAssembly>) -> Arc<HeadlessUnitTestSession>
    

    Creates a session from the test application attribute of the assembly or reuses any existing. If the attribute doesn't exist, empty application is used.

    None is the assembly of the session itself.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ClassDefaults
    • IDisposable
    • ErasedDestructor
    • IntoEither

    Availability

    Extracted for x86_64-unknown-linux-gnu, aarch64-apple-darwin. Cargo features are listed in the crate index.