summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-17 02:27:13 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-17 03:03:07 +0100
commit41a822c6fb6dd15c9e2246a6f0d136d83c6c7d00 (patch)
tree98e44bef144d5985b1fb57771f19304bd36c06a9 /test
parent326c5852aad35eb16d4621325b1d5cb0055c49c4 (diff)
downloadiced-41a822c6fb6dd15c9e2246a6f0d136d83c6c7d00.tar.gz
iced-41a822c6fb6dd15c9e2246a6f0d136d83c6c7d00.tar.bz2
iced-41a822c6fb6dd15c9e2246a6f0d136d83c6c7d00.zip
Use proper hash for `creates_a_new_task` snapshot
Diffstat (limited to 'test')
-rw-r--r--test/Cargo.toml2
-rw-r--r--test/src/lib.rs29
2 files changed, 16 insertions, 15 deletions
diff --git a/test/Cargo.toml b/test/Cargo.toml
index 47e9be11..ff6cb38a 100644
--- a/test/Cargo.toml
+++ b/test/Cargo.toml
@@ -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
diff --git a/test/src/lib.rs b/test/src/lib.rs
index fa802dea..e5ed040d 100644
--- a/test/src/lib.rs
+++ b/test/src/lib.rs
@@ -16,12 +16,13 @@ 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;
use std::borrow::Cow;
-use std::env;
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
@@ -31,7 +32,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)
@@ -65,7 +66,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(
@@ -88,12 +89,17 @@ where
) -> Self {
let size = size.into();
+ let default_font = match settings.default_font {
+ Font::DEFAULT => Font::with_name("Fira Sans"),
+ _ => settings.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,
@@ -307,8 +313,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(
@@ -323,7 +328,7 @@ where
let _ = self.raw.draw(
&mut self.renderer,
- &theme,
+ theme,
&core::renderer::Style {
text_color: base.text_color,
},
@@ -493,11 +498,5 @@ impl From<png::EncodingError> for Error {
}
fn snapshot_path(path: impl AsRef<Path>, extension: &str) -> PathBuf {
- let path = path.as_ref();
-
- path.with_file_name(format!(
- "{file_stem}-{os}.{extension}",
- file_stem = path.file_stem().unwrap_or_default().to_string_lossy(),
- os = env::consts::OS,
- ))
+ path.as_ref().with_extension(extension)
}