diff options
| author | 2024-12-06 04:06:41 +0100 | |
|---|---|---|
| committer | 2024-12-10 04:51:08 +0100 | |
| commit | 1aeb317f2dbfb63215e6226073e67878ffa6503b (patch) | |
| tree | d883266d796360a1e4d883dc82a4fb284f724790 /src | |
| parent | 8e3636d769d96ab5ba49a9647b72c59ae2226dd0 (diff) | |
| download | iced-1aeb317f2dbfb63215e6226073e67878ffa6503b.tar.gz iced-1aeb317f2dbfb63215e6226073e67878ffa6503b.tar.bz2 iced-1aeb317f2dbfb63215e6226073e67878ffa6503b.zip | |
Add image and hash snapshot-based testing to `iced_test`
Diffstat (limited to '')
| -rw-r--r-- | src/application.rs | 9 | ||||
| -rw-r--r-- | src/daemon.rs | 9 | ||||
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/program.rs | 29 | 
4 files changed, 23 insertions, 26 deletions
| diff --git a/src/application.rs b/src/application.rs index 2ba764be..c79ed62b 100644 --- a/src/application.rs +++ b/src/application.rs @@ -31,6 +31,7 @@  //! }  //! ```  use crate::program::{self, Program}; +use crate::theme;  use crate::window;  use crate::{      Element, Executor, Font, Result, Settings, Size, Subscription, Task, @@ -38,8 +39,6 @@ use crate::{  use std::borrow::Cow; -pub use crate::shell::program::{Appearance, DefaultStyle}; -  /// Creates an iced [`Application`] given its title, update, and view logic.  ///  /// # Example @@ -76,7 +75,7 @@ pub fn application<State, Message, Theme, Renderer>(  where      State: 'static,      Message: Send + std::fmt::Debug + 'static, -    Theme: Default + DefaultStyle, +    Theme: Default + theme::Base,      Renderer: program::Renderer,  {      use std::marker::PhantomData; @@ -94,7 +93,7 @@ where          for Instance<State, Message, Theme, Renderer, Update, View>      where          Message: Send + std::fmt::Debug + 'static, -        Theme: Default + DefaultStyle, +        Theme: Default + theme::Base,          Renderer: program::Renderer,          Update: self::Update<State, Message>,          View: for<'a> self::View<'a, State, Message, Theme, Renderer>, @@ -352,7 +351,7 @@ impl<P: Program> Application<P> {      /// Sets the style logic of the [`Application`].      pub fn style(          self, -        f: impl Fn(&P::State, &P::Theme) -> Appearance, +        f: impl Fn(&P::State, &P::Theme) -> theme::Style,      ) -> Application<          impl Program<State = P::State, Message = P::Message, Theme = P::Theme>,      > { diff --git a/src/daemon.rs b/src/daemon.rs index 81254bf9..fd6d0278 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -1,13 +1,12 @@  //! Create and run daemons that run in the background.  use crate::application;  use crate::program::{self, Program}; +use crate::theme;  use crate::window;  use crate::{Element, Executor, Font, Result, Settings, Subscription, Task};  use std::borrow::Cow; -pub use crate::shell::program::{Appearance, DefaultStyle}; -  /// Creates an iced [`Daemon`] given its title, update, and view logic.  ///  /// A [`Daemon`] will not open a window by default, but will run silently @@ -26,7 +25,7 @@ pub fn daemon<State, Message, Theme, Renderer>(  where      State: 'static,      Message: Send + std::fmt::Debug + 'static, -    Theme: Default + DefaultStyle, +    Theme: Default + theme::Base,      Renderer: program::Renderer,  {      use std::marker::PhantomData; @@ -44,7 +43,7 @@ where          for Instance<State, Message, Theme, Renderer, Update, View>      where          Message: Send + std::fmt::Debug + 'static, -        Theme: Default + DefaultStyle, +        Theme: Default + theme::Base,          Renderer: program::Renderer,          Update: application::Update<State, Message>,          View: for<'a> self::View<'a, State, Message, Theme, Renderer>, @@ -201,7 +200,7 @@ impl<P: Program> Daemon<P> {      /// Sets the style logic of the [`Daemon`].      pub fn style(          self, -        f: impl Fn(&P::State, &P::Theme) -> Appearance, +        f: impl Fn(&P::State, &P::Theme) -> theme::Style,      ) -> Daemon<          impl Program<State = P::State, Message = P::Message, Theme = P::Theme>,      > { @@ -688,7 +688,7 @@ pub fn run<State, Message, Theme, Renderer>(  where      State: Default + 'static,      Message: std::fmt::Debug + Send + 'static, -    Theme: Default + program::DefaultStyle + 'static, +    Theme: Default + theme::Base + 'static,      Renderer: program::Renderer + 'static,  {      application(title, update, view).run() diff --git a/src/program.rs b/src/program.rs index 94cb9a7d..ace4da74 100644 --- a/src/program.rs +++ b/src/program.rs @@ -1,11 +1,10 @@  use crate::core::text;  use crate::graphics::compositor;  use crate::shell; +use crate::theme;  use crate::window;  use crate::{Element, Executor, Result, Settings, Subscription, Task}; -pub use crate::shell::program::{Appearance, DefaultStyle}; -  /// The internal definition of a [`Program`].  ///  /// You should not need to implement this trait directly. Instead, use the @@ -19,7 +18,7 @@ pub trait Program: Sized {      type Message: Send + std::fmt::Debug + 'static;      /// The theme of the program. -    type Theme: Default + DefaultStyle; +    type Theme: Default + theme::Base;      /// The renderer of the program.      type Renderer: Renderer; @@ -51,11 +50,11 @@ pub trait Program: Sized {      }      fn theme(&self, _state: &Self::State, _window: window::Id) -> Self::Theme { -        Self::Theme::default() +        <Self::Theme as Default>::default()      } -    fn style(&self, _state: &Self::State, theme: &Self::Theme) -> Appearance { -        DefaultStyle::default_style(theme) +    fn style(&self, _state: &Self::State, theme: &Self::Theme) -> theme::Style { +        theme::Base::base(theme)      }      fn scale_factor(&self, _state: &Self::State, _window: window::Id) -> f64 { @@ -153,7 +152,7 @@ pub trait Program: Sized {                  self.program.theme(&self.state, window)              } -            fn style(&self, theme: &Self::Theme) -> Appearance { +            fn style(&self, theme: &Self::Theme) -> theme::Style {                  self.program.style(&self.state, theme)              } @@ -252,7 +251,7 @@ pub fn with_title<P: Program>(              &self,              state: &Self::State,              theme: &Self::Theme, -        ) -> Appearance { +        ) -> theme::Style {              self.program.style(state, theme)          } @@ -322,7 +321,7 @@ pub fn with_subscription<P: Program>(              &self,              state: &Self::State,              theme: &Self::Theme, -        ) -> Appearance { +        ) -> theme::Style {              self.program.style(state, theme)          } @@ -395,7 +394,7 @@ pub fn with_theme<P: Program>(              &self,              state: &Self::State,              theme: &Self::Theme, -        ) -> Appearance { +        ) -> theme::Style {              self.program.style(state, theme)          } @@ -409,7 +408,7 @@ pub fn with_theme<P: Program>(  pub fn with_style<P: Program>(      program: P, -    f: impl Fn(&P::State, &P::Theme) -> Appearance, +    f: impl Fn(&P::State, &P::Theme) -> theme::Style,  ) -> impl Program<State = P::State, Message = P::Message, Theme = P::Theme> {      struct WithStyle<P, F> {          program: P, @@ -418,7 +417,7 @@ pub fn with_style<P: Program>(      impl<P: Program, F> Program for WithStyle<P, F>      where -        F: Fn(&P::State, &P::Theme) -> Appearance, +        F: Fn(&P::State, &P::Theme) -> theme::Style,      {          type State = P::State;          type Message = P::Message; @@ -430,7 +429,7 @@ pub fn with_style<P: Program>(              &self,              state: &Self::State,              theme: &Self::Theme, -        ) -> Appearance { +        ) -> theme::Style {              (self.style)(state, theme)          } @@ -535,7 +534,7 @@ pub fn with_scale_factor<P: Program>(              &self,              state: &Self::State,              theme: &Self::Theme, -        ) -> Appearance { +        ) -> theme::Style {              self.program.style(state, theme)          } @@ -609,7 +608,7 @@ pub fn with_executor<P: Program, E: Executor>(              &self,              state: &Self::State,              theme: &Self::Theme, -        ) -> Appearance { +        ) -> theme::Style {              self.program.style(state, theme)          } | 
