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
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2488,7 +2488,6 @@ dependencies = [
|
|||
"iced_devtools",
|
||||
"iced_futures",
|
||||
"iced_highlighter",
|
||||
"iced_program",
|
||||
"iced_renderer",
|
||||
"iced_runtime",
|
||||
"iced_wgpu",
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@ time-travel = ["debug", "iced_devtools/time-travel"]
|
|||
# Enables hot reloading (very experimental!)
|
||||
hot = ["debug", "iced_debug/hot"]
|
||||
# Enables the tester developer tool for recording and playing tests (press F12)
|
||||
tester = ["debug", "test", "iced_devtools/tester"]
|
||||
# Enables testing features (e.g. application presets)
|
||||
test = ["iced_program/test"]
|
||||
tester = ["debug", "iced_devtools/tester"]
|
||||
# Enables the `thread-pool` futures executor as the `executor::Default` on native platforms
|
||||
thread-pool = ["iced_futures/thread-pool"]
|
||||
# Enables `tokio` as the `executor::Default` on native platforms
|
||||
|
|
@ -86,7 +84,6 @@ sipper = ["iced_runtime/sipper"]
|
|||
iced_debug.workspace = true
|
||||
iced_core.workspace = true
|
||||
iced_futures.workspace = true
|
||||
iced_program.workspace = true
|
||||
iced_renderer.workspace = true
|
||||
iced_runtime.workspace = true
|
||||
iced_widget.workspace = true
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ edition = "2024"
|
|||
publish = false
|
||||
|
||||
[features]
|
||||
test = ["iced/test"]
|
||||
tester = ["test", "iced/tester"]
|
||||
tester = ["iced/tester"]
|
||||
|
||||
[dependencies]
|
||||
iced.workspace = true
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ use iced::widget::{
|
|||
};
|
||||
use iced::window;
|
||||
use iced::{
|
||||
Center, Element, Fill, Font, Function, Subscription, Task as Command,
|
||||
Center, Element, Fill, Font, Function, Preset, Subscription,
|
||||
Task as Command,
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -19,10 +20,8 @@ pub fn main() -> iced::Result {
|
|||
.subscription(Todos::subscription)
|
||||
.title(Todos::title)
|
||||
.font(Todos::ICON_FONT)
|
||||
.window_size((500.0, 800.0));
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
let todos = todos.presets(presets());
|
||||
.window_size((500.0, 800.0))
|
||||
.presets(presets());
|
||||
|
||||
todos.run()
|
||||
}
|
||||
|
|
@ -579,11 +578,7 @@ impl SavedState {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
fn presets() -> impl Iterator<Item = iced::application::Preset<Todos, Message>>
|
||||
{
|
||||
use iced::application::Preset;
|
||||
|
||||
fn presets() -> impl Iterator<Item = Preset<Todos, Message>> {
|
||||
[
|
||||
Preset::new("Empty", || {
|
||||
(Todos::Loaded(State::default()), Command::none())
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ workspace = true
|
|||
|
||||
[features]
|
||||
time-travel = []
|
||||
test = []
|
||||
|
||||
[dependencies]
|
||||
iced_graphics.workspace = true
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@ pub use iced_runtime as runtime;
|
|||
pub use iced_runtime::core;
|
||||
pub use iced_runtime::futures;
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
mod preset;
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
pub use preset::Preset;
|
||||
|
||||
use crate::core::renderer;
|
||||
|
|
@ -107,7 +105,6 @@ pub trait Program: Sized {
|
|||
1.0
|
||||
}
|
||||
|
||||
#[cfg(feature = "test")]
|
||||
fn presets(&self) -> &[Preset<Self::State, Self::Message>] {
|
||||
&[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@ workspace = true
|
|||
|
||||
[dependencies]
|
||||
iced_runtime.workspace = true
|
||||
iced_selector.workspace = true
|
||||
|
||||
iced_program.workspace = true
|
||||
iced_program.features = ["test"]
|
||||
iced_selector.workspace = true
|
||||
|
||||
iced_renderer.workspace = true
|
||||
iced_renderer.features = ["fira-sans"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue