Skip to content

Commit

Permalink
Try to debug CI
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Dec 17, 2024
1 parent 326c585 commit 4a2fd9a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/todos/snapshots/creates_a_new_task-linux.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e0b1f2e0c0af6324eb45fde8e82384d16acc2a80a9e157bdf3f42ac6548181cf
a7c2ac4b57f84416812e2134e48fe34db55a757d9176beedf5854a2f69532e32
4 changes: 2 additions & 2 deletions examples/todos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ impl SavedState {
mod tests {
use super::*;

use iced::Settings;
use iced::{Settings, Theme};
use iced_test::{selector, Error, Simulator};

fn simulator(todos: &Todos) -> Simulator<Message> {
Expand Down Expand Up @@ -621,7 +621,7 @@ mod tests {
let mut ui = simulator(&todos);
let _ = ui.find(selector::text("Create the universe"))?;

let snapshot = ui.snapshot()?;
let snapshot = ui.snapshot(&Theme::Dark)?;
assert!(
snapshot.matches_hash("snapshots/creates_a_new_task")?,
"snapshots should match!"
Expand Down
2 changes: 2 additions & 0 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ workspace = true

[dependencies]
iced_runtime.workspace = true

iced_renderer.workspace = true
iced_renderer.features = ["fira-sans"]

png.workspace = true
sha2.workspace = true
21 changes: 15 additions & 6 deletions test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use crate::core::theme;
use crate::core::time;
use crate::core::widget;
use crate::core::window;
use crate::core::{Element, Event, Point, Rectangle, Settings, Size, SmolStr};
use crate::core::{
Element, Event, Font, Point, Rectangle, Settings, Size, SmolStr,
};
use crate::runtime::user_interface;
use crate::runtime::UserInterface;

Expand All @@ -31,7 +33,7 @@ pub fn simulator<'a, Message, Theme, Renderer>(
element: impl Into<Element<'a, Message, Theme, Renderer>>,
) -> Simulator<'a, Message, Theme, Renderer>
where
Theme: Default + theme::Base,
Theme: theme::Base,
Renderer: core::Renderer + core::renderer::Headless,
{
Simulator::new(element)
Expand Down Expand Up @@ -65,7 +67,7 @@ pub struct Target {

impl<'a, Message, Theme, Renderer> Simulator<'a, Message, Theme, Renderer>
where
Theme: Default + theme::Base,
Theme: theme::Base,
Renderer: core::Renderer + core::renderer::Headless,
{
pub fn new(
Expand All @@ -88,12 +90,19 @@ where
) -> Self {
let size = size.into();

let default_font = match settings.default_font {
Font::DEFAULT => Font::with_name("Fira Sans"),
_ => settings.default_font,
};

dbg!(default_font);

for font in settings.fonts {
load_font(font).expect("Font must be valid");
}

let mut renderer =
Renderer::new(settings.default_font, settings.default_text_size);
Renderer::new(default_font, settings.default_text_size);

let raw = UserInterface::build(
element,
Expand Down Expand Up @@ -307,8 +316,7 @@ where
statuses
}

pub fn snapshot(&mut self) -> Result<Snapshot, Error> {
let theme = Theme::default();
pub fn snapshot(&mut self, theme: &Theme) -> Result<Snapshot, Error> {
let base = theme.base();

let _ = self.raw.update(
Expand Down Expand Up @@ -409,6 +417,7 @@ impl Snapshot {

if path.exists() {
let saved_hash = fs::read_to_string(&path)?;
dbg!(&path, &hash, &saved_hash);

Ok(hash == saved_hash)
} else {
Expand Down

0 comments on commit 4a2fd9a

Please sign in to comment.