pub struct HeadlessUnitTestSession { /* private fields */ }Expand description
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.
Implementations§
Source§impl HeadlessUnitTestSession
impl HeadlessUnitTestSession
Sourcepub fn dispatch(
&self,
action: impl FnOnce() + Send + 'static,
cancellation_token: CancellationToken,
) -> HeadlessUnitTestTask<()>
pub fn dispatch( &self, action: impl FnOnce() + Send + 'static, cancellation_token: CancellationToken, ) -> HeadlessUnitTestTask<()>
Queues an action on the dispatcher thread; see
dispatch_task.
Sourcepub fn dispatch_result<TResult: Send + 'static>(
&self,
action: impl FnOnce() -> TResult + Send + 'static,
cancellation_token: CancellationToken,
) -> HeadlessUnitTestTask<TResult>
pub fn dispatch_result<TResult: Send + 'static>( &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.
Sourcepub fn dispatch_task<F, Fut>(
&self,
action: F,
cancellation_token: CancellationToken,
) -> HeadlessUnitTestTask<Fut::Output>
pub fn dispatch_task<F, Fut>( &self, action: F, cancellation_token: CancellationToken, ) -> HeadlessUnitTestTask<Fut::Output>
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).
pub fn dispose(&self)
Sourcepub async fn dispose_async(&self)
pub async fn dispose_async(&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.
Sourcepub fn start_new(
entry_point_type: fn() -> AppBuilder,
) -> Arc<HeadlessUnitTestSession> ⓘ
pub 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).
Sourcepub fn start_new_with_isolation(
entry_point_type: fn() -> AppBuilder,
isolation_level: FerroTestIsolationLevel,
) -> Arc<HeadlessUnitTestSession> ⓘ
pub 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.
Sourcepub fn get_or_start_for_assembly(
assembly: Option<&FerroTestAssembly>,
) -> Arc<HeadlessUnitTestSession> ⓘ
pub 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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HeadlessUnitTestSession
impl RefUnwindSafe for HeadlessUnitTestSession
impl Send for HeadlessUnitTestSession
impl Sync for HeadlessUnitTestSession
impl Unpin for HeadlessUnitTestSession
impl UnsafeUnpin for HeadlessUnitTestSession
impl UnwindSafe for HeadlessUnitTestSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more