Skip to main content

ferroui_headless/
ferro_test_application_attribute.rs

1//! Port of the test application attribute of the upstream headless project.
2//!
3//! The original is an assembly attribute, read through reflection by the
4//! session of a test assembly. There are no assembly attributes: the value
5//! is a field of the [`FerroTestAssembly`](crate::FerroTestAssembly) that a
6//! test crate hands to
7//! [`HeadlessUnitTestSession::get_or_start_for_assembly`](crate::HeadlessUnitTestSession::get_or_start_for_assembly).
8
9use ferroui_controls::AppBuilder;
10
11/// Sets up global test framework using the application builder passed as a
12/// parameter.
13#[derive(Clone, Copy, Debug)]
14pub struct FerroTestApplicationAttribute {
15    app_builder_entry_point_type: fn() -> AppBuilder,
16}
17
18impl FerroTestApplicationAttribute {
19    /// Creates instance of [`FerroTestApplicationAttribute`].
20    ///
21    /// `app_builder_entry_point_type` is the parameter from which
22    /// [`AppBuilder`] should be created. The original takes a type that has
23    /// a method which builds the application or that inherits the
24    /// application class, and finds the method through reflection; here it
25    /// is that method (`AppBuilder::configure::<TApp>` for a type that
26    /// inherits the application class).
27    pub const fn new(app_builder_entry_point_type: fn() -> AppBuilder) -> Self {
28        Self { app_builder_entry_point_type }
29    }
30
31    pub fn app_builder_entry_point_type(&self) -> fn() -> AppBuilder {
32        self.app_builder_entry_point_type
33    }
34}