Move tester to a new iced_tester subcrate
This commit is contained in:
parent
9e81c2b9e8
commit
4f7444bddf
28 changed files with 392 additions and 355 deletions
|
|
@ -4,6 +4,8 @@ pub use iced_runtime as runtime;
|
|||
pub use iced_runtime::core;
|
||||
pub use iced_runtime::futures;
|
||||
|
||||
pub mod message;
|
||||
|
||||
mod preset;
|
||||
|
||||
pub use preset::Preset;
|
||||
|
|
@ -13,7 +15,7 @@ use crate::core::text;
|
|||
use crate::core::theme;
|
||||
use crate::core::window;
|
||||
use crate::core::{Element, Font, Settings};
|
||||
use crate::futures::{Executor, Subscription};
|
||||
use crate::futures::{Executor, MaybeSend, Subscription};
|
||||
use crate::graphics::compositor;
|
||||
use crate::runtime::Task;
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ pub trait Program: Sized {
|
|||
type State;
|
||||
|
||||
/// The message of the program.
|
||||
type Message: Message + 'static;
|
||||
type Message: MaybeSend + 'static;
|
||||
|
||||
/// The theme of the program.
|
||||
type Theme: Default + theme::Base;
|
||||
|
|
@ -43,6 +45,8 @@ pub trait Program: Sized {
|
|||
|
||||
fn settings(&self) -> Settings;
|
||||
|
||||
fn window(&self) -> Option<window::Settings>;
|
||||
|
||||
fn boot(&self) -> (Self::State, Task<Self::Message>);
|
||||
|
||||
fn update(
|
||||
|
|
@ -143,6 +147,10 @@ pub fn with_title<P: Program>(
|
|||
self.program.settings()
|
||||
}
|
||||
|
||||
fn window(&self) -> Option<window::Settings> {
|
||||
self.program.window()
|
||||
}
|
||||
|
||||
fn boot(&self) -> (Self::State, Task<Self::Message>) {
|
||||
self.program.boot()
|
||||
}
|
||||
|
|
@ -229,6 +237,10 @@ pub fn with_subscription<P: Program>(
|
|||
self.program.settings()
|
||||
}
|
||||
|
||||
fn window(&self) -> Option<window::Settings> {
|
||||
self.program.window()
|
||||
}
|
||||
|
||||
fn boot(&self) -> (Self::State, Task<Self::Message>) {
|
||||
self.program.boot()
|
||||
}
|
||||
|
|
@ -316,6 +328,10 @@ pub fn with_theme<P: Program>(
|
|||
self.program.settings()
|
||||
}
|
||||
|
||||
fn window(&self) -> Option<window::Settings> {
|
||||
self.program.window()
|
||||
}
|
||||
|
||||
fn boot(&self) -> (Self::State, Task<Self::Message>) {
|
||||
self.program.boot()
|
||||
}
|
||||
|
|
@ -399,6 +415,10 @@ pub fn with_style<P: Program>(
|
|||
self.program.settings()
|
||||
}
|
||||
|
||||
fn window(&self) -> Option<window::Settings> {
|
||||
self.program.window()
|
||||
}
|
||||
|
||||
fn boot(&self) -> (Self::State, Task<Self::Message>) {
|
||||
self.program.boot()
|
||||
}
|
||||
|
|
@ -478,6 +498,10 @@ pub fn with_scale_factor<P: Program>(
|
|||
self.program.settings()
|
||||
}
|
||||
|
||||
fn window(&self) -> Option<window::Settings> {
|
||||
self.program.window()
|
||||
}
|
||||
|
||||
fn boot(&self) -> (Self::State, Task<Self::Message>) {
|
||||
self.program.boot()
|
||||
}
|
||||
|
|
@ -565,6 +589,10 @@ pub fn with_executor<P: Program, E: Executor>(
|
|||
self.program.settings()
|
||||
}
|
||||
|
||||
fn window(&self) -> Option<window::Settings> {
|
||||
self.program.window()
|
||||
}
|
||||
|
||||
fn boot(&self) -> (Self::State, Task<Self::Message>) {
|
||||
self.program.boot()
|
||||
}
|
||||
|
|
@ -683,17 +711,3 @@ impl<P: Program> Instance<P> {
|
|||
self.program.scale_factor(&self.state, window)
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait alias for the [`Message`](Program::Message) of a [`Program`].
|
||||
#[cfg(feature = "time-travel")]
|
||||
pub trait Message: Send + std::fmt::Debug + Clone {}
|
||||
|
||||
#[cfg(feature = "time-travel")]
|
||||
impl<T: Send + std::fmt::Debug + Clone> Message for T {}
|
||||
|
||||
/// A trait alias for the [`Message`](Program::Message) of a [`Program`].
|
||||
#[cfg(not(feature = "time-travel"))]
|
||||
pub trait Message: Send + std::fmt::Debug {}
|
||||
|
||||
#[cfg(not(feature = "time-travel"))]
|
||||
impl<T: Send + std::fmt::Debug> Message for T {}
|
||||
|
|
|
|||
33
program/src/message.rs
Normal file
33
program/src/message.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//! Traits for the message type of a [`Program`](crate::Program).
|
||||
|
||||
/// A trait alias for [`Clone`], but only when the `time-travel`
|
||||
/// feature is enabled.
|
||||
#[cfg(feature = "time-travel")]
|
||||
pub trait MaybeClone: Clone {}
|
||||
|
||||
#[cfg(feature = "time-travel")]
|
||||
impl<T> MaybeClone for T where T: Clone {}
|
||||
|
||||
/// A trait alias for [`Clone`], but only when the `time-travel`
|
||||
/// feature is enabled.
|
||||
#[cfg(not(feature = "time-travel"))]
|
||||
pub trait MaybeClone {}
|
||||
|
||||
#[cfg(not(feature = "time-travel"))]
|
||||
impl<T> MaybeClone for T {}
|
||||
|
||||
/// A trait alias for [`Debug`](std::fmt::Debug), but only when the
|
||||
/// `debug` feature is enabled.
|
||||
#[cfg(feature = "debug")]
|
||||
pub trait MaybeDebug: std::fmt::Debug {}
|
||||
|
||||
#[cfg(feature = "debug")]
|
||||
impl<T> MaybeDebug for T where T: std::fmt::Debug {}
|
||||
|
||||
/// A trait alias for [`Debug`](std::fmt::Debug), but only when the
|
||||
/// `debug` feature is enabled.
|
||||
#[cfg(not(feature = "debug"))]
|
||||
pub trait MaybeDebug {}
|
||||
|
||||
#[cfg(not(feature = "debug"))]
|
||||
impl<T> MaybeDebug for T {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue