Remove test feature and expose Preset unconditionally
This commit is contained in:
parent
1923d1db1e
commit
0b00fcfff5
11 changed files with 41 additions and 43 deletions
|
|
@ -35,7 +35,7 @@ use crate::shell;
|
|||
use crate::theme;
|
||||
use crate::window;
|
||||
use crate::{
|
||||
Element, Executor, Font, Result, Settings, Size, Subscription, Task,
|
||||
Element, Executor, Font, Preset, Result, Settings, Size, Subscription, Task,
|
||||
};
|
||||
|
||||
use iced_debug as debug;
|
||||
|
|
@ -44,8 +44,6 @@ use std::borrow::Cow;
|
|||
|
||||
pub mod timed;
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
pub use program::Preset;
|
||||
pub use timed::timed;
|
||||
|
||||
/// Creates an iced [`Application`] given its boot, update, and view logic.
|
||||
|
|
@ -158,8 +156,6 @@ where
|
|||
},
|
||||
settings: Settings::default(),
|
||||
window: window::Settings::default(),
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
presets: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
|
@ -176,8 +172,6 @@ pub struct Application<P: Program> {
|
|||
raw: P,
|
||||
settings: Settings,
|
||||
window: window::Settings,
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
presets: Vec<Preset<P::State, P::Message>>,
|
||||
}
|
||||
|
||||
|
|
@ -348,7 +342,6 @@ impl<P: Program> Application<P> {
|
|||
}),
|
||||
settings: self.settings,
|
||||
window: self.window,
|
||||
#[cfg(feature = "test")]
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
|
@ -366,7 +359,6 @@ impl<P: Program> Application<P> {
|
|||
}),
|
||||
settings: self.settings,
|
||||
window: self.window,
|
||||
#[cfg(feature = "test")]
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
|
@ -384,7 +376,6 @@ impl<P: Program> Application<P> {
|
|||
}),
|
||||
settings: self.settings,
|
||||
window: self.window,
|
||||
#[cfg(feature = "test")]
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
|
@ -402,7 +393,6 @@ impl<P: Program> Application<P> {
|
|||
}),
|
||||
settings: self.settings,
|
||||
window: self.window,
|
||||
#[cfg(feature = "test")]
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
|
@ -420,7 +410,6 @@ impl<P: Program> Application<P> {
|
|||
}),
|
||||
settings: self.settings,
|
||||
window: self.window,
|
||||
#[cfg(feature = "test")]
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
|
@ -438,7 +427,6 @@ impl<P: Program> Application<P> {
|
|||
raw: program::with_executor::<P, E>(self.raw),
|
||||
settings: self.settings,
|
||||
window: self.window,
|
||||
#[cfg(feature = "test")]
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
|
@ -448,7 +436,6 @@ impl<P: Program> Application<P> {
|
|||
/// Presets can be used to override the default booting strategy
|
||||
/// of your application during testing to create reproducible
|
||||
/// environments.
|
||||
#[cfg(feature = "test")]
|
||||
pub fn presets(
|
||||
self,
|
||||
presets: impl IntoIterator<Item = Preset<P::State, P::Message>>,
|
||||
|
|
@ -519,7 +506,6 @@ impl<P: Program> Program for Application<P> {
|
|||
self.raw.scale_factor(state, window)
|
||||
}
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
fn presets(&self) -> &[Preset<Self::State, Self::Message>] {
|
||||
&self.presets
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,8 +147,6 @@ where
|
|||
},
|
||||
settings: Settings::default(),
|
||||
window: window::Settings::default(),
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
presets: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ use crate::program::{self, Program};
|
|||
use crate::shell;
|
||||
use crate::theme;
|
||||
use crate::window;
|
||||
use crate::{Element, Executor, Font, Result, Settings, Subscription, Task};
|
||||
use crate::{
|
||||
Element, Executor, Font, Preset, Result, Settings, Subscription, Task,
|
||||
};
|
||||
|
||||
use iced_debug as debug;
|
||||
|
||||
|
|
@ -101,6 +103,7 @@ where
|
|||
_renderer: PhantomData,
|
||||
},
|
||||
settings: Settings::default(),
|
||||
presets: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,6 +118,7 @@ where
|
|||
pub struct Daemon<P: Program> {
|
||||
raw: P,
|
||||
settings: Settings,
|
||||
presets: Vec<Preset<P::State, P::Message>>,
|
||||
}
|
||||
|
||||
impl<P: Program> Daemon<P> {
|
||||
|
|
@ -187,6 +191,7 @@ impl<P: Program> Daemon<P> {
|
|||
debug::hot(|| title.title(state, window))
|
||||
}),
|
||||
settings: self.settings,
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,6 +207,7 @@ impl<P: Program> Daemon<P> {
|
|||
debug::hot(|| f(state))
|
||||
}),
|
||||
settings: self.settings,
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,6 +223,7 @@ impl<P: Program> Daemon<P> {
|
|||
debug::hot(|| f(state, window))
|
||||
}),
|
||||
settings: self.settings,
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -232,6 +239,7 @@ impl<P: Program> Daemon<P> {
|
|||
debug::hot(|| f(state, theme))
|
||||
}),
|
||||
settings: self.settings,
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,6 +255,7 @@ impl<P: Program> Daemon<P> {
|
|||
debug::hot(|| f(state, window))
|
||||
}),
|
||||
settings: self.settings,
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,6 +271,22 @@ impl<P: Program> Daemon<P> {
|
|||
Daemon {
|
||||
raw: program::with_executor::<P, E>(self.raw),
|
||||
settings: self.settings,
|
||||
presets: self.presets,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the boot presets of the [`Daemon`].
|
||||
///
|
||||
/// Presets can be used to override the default booting strategy
|
||||
/// of your application during testing to create reproducible
|
||||
/// environments.
|
||||
pub fn presets(
|
||||
self,
|
||||
presets: impl IntoIterator<Item = Preset<P::State, P::Message>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
presets: presets.into_iter().collect(),
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -324,6 +349,10 @@ impl<P: Program> Program for Daemon<P> {
|
|||
fn scale_factor(&self, state: &Self::State, window: window::Id) -> f64 {
|
||||
self.raw.scale_factor(state, window)
|
||||
}
|
||||
|
||||
fn presets(&self) -> &[Preset<Self::State, Self::Message>] {
|
||||
&self.presets
|
||||
}
|
||||
}
|
||||
|
||||
/// The title logic of some [`Daemon`].
|
||||
|
|
|
|||
|
|
@ -475,11 +475,11 @@
|
|||
)]
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
use iced_program as program;
|
||||
use iced_widget::graphics;
|
||||
use iced_widget::renderer;
|
||||
use iced_winit as shell;
|
||||
use iced_winit::core;
|
||||
use iced_winit::program;
|
||||
use iced_winit::runtime;
|
||||
|
||||
pub use iced_futures::futures;
|
||||
|
|
@ -525,6 +525,7 @@ pub use crate::core::{
|
|||
Function, Gradient, Length, Padding, Pixels, Point, Radians, Rectangle,
|
||||
Rotation, Settings, Shadow, Size, Theme, Transformation, Vector, never,
|
||||
};
|
||||
pub use crate::program::Preset;
|
||||
pub use crate::runtime::exit;
|
||||
pub use iced_futures::Subscription;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue