summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-17 02:17:07 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-17 02:17:07 +0100
commit2f98a7e2032715409891e6d2c9f8529cfed59569 (patch)
tree47801cfce52e6e3870ba483727bb8be0a21de396
parent0ad40d03387a8127b445305a1c63fa3d2ac45ed7 (diff)
downloadiced-2f98a7e2032715409891e6d2c9f8529cfed59569.tar.gz
iced-2f98a7e2032715409891e6d2c9f8529cfed59569.tar.bz2
iced-2f98a7e2032715409891e6d2c9f8529cfed59569.zip
Append `env::consts::OS` to snapshot filenames
-rw-r--r--examples/todos/snapshots/creates_a_new_task-linux.sha2561
-rw-r--r--examples/todos/snapshots/creates_a_new_task.sha2561
-rw-r--r--examples/todos/src/main.rs3
-rw-r--r--test/Cargo.toml2
-rw-r--r--test/src/lib.rs28
5 files changed, 18 insertions, 17 deletions
diff --git a/examples/todos/snapshots/creates_a_new_task-linux.sha256 b/examples/todos/snapshots/creates_a_new_task-linux.sha256
new file mode 100644
index 00000000..9291711e
--- /dev/null
+++ b/examples/todos/snapshots/creates_a_new_task-linux.sha256
@@ -0,0 +1 @@
+e0b1f2e0c0af6324eb45fde8e82384d16acc2a80a9e157bdf3f42ac6548181cf \ No newline at end of file
diff --git a/examples/todos/snapshots/creates_a_new_task.sha256 b/examples/todos/snapshots/creates_a_new_task.sha256
deleted file mode 100644
index 75d5f2ce..00000000
--- a/examples/todos/snapshots/creates_a_new_task.sha256
+++ /dev/null
@@ -1 +0,0 @@
-b41c73d214894bf5f94f787e5f265cff6500822b2d4a29a4ac0c847a71db7123 \ No newline at end of file
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 0b80f002..1cc47782 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -594,12 +594,11 @@ mod tests {
use iced_test::{selector, Error, Simulator};
fn simulator(todos: &Todos) -> Simulator<Message> {
- Simulator::with_size(
+ Simulator::with_settings(
Settings {
fonts: vec![Todos::ICON_FONT.into()],
..Settings::default()
},
- (512.0, 512.0),
todos.view(),
)
}
diff --git a/test/Cargo.toml b/test/Cargo.toml
index ff6cb38a..47e9be11 100644
--- a/test/Cargo.toml
+++ b/test/Cargo.toml
@@ -15,9 +15,7 @@ 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 00126e64..fa802dea 100644
--- a/test/src/lib.rs
+++ b/test/src/lib.rs
@@ -16,16 +16,15 @@ use crate::core::theme;
use crate::core::time;
use crate::core::widget;
use crate::core::window;
-use crate::core::{
- Element, Event, Font, Point, Rectangle, Settings, Size, SmolStr,
-};
+use crate::core::{Element, Event, 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;
+use std::path::{Path, PathBuf};
use std::sync::Arc;
pub fn simulator<'a, Message, Theme, Renderer>(
@@ -89,17 +88,12 @@ 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(default_font, settings.default_text_size);
+ Renderer::new(settings.default_font, settings.default_text_size);
let raw = UserInterface::build(
element,
@@ -369,7 +363,7 @@ pub struct Snapshot {
impl Snapshot {
pub fn matches_image(&self, path: impl AsRef<Path>) -> Result<bool, Error> {
- let path = path.as_ref().with_extension("png");
+ let path = snapshot_path(path, "png");
if path.exists() {
let file = fs::File::open(&path)?;
@@ -405,7 +399,7 @@ impl Snapshot {
pub fn matches_hash(&self, path: impl AsRef<Path>) -> Result<bool, Error> {
use sha2::{Digest, Sha256};
- let path = path.as_ref().with_extension("sha256");
+ let path = snapshot_path(path, "sha256");
let hash = {
let mut hasher = Sha256::new();
@@ -497,3 +491,13 @@ impl From<png::EncodingError> for Error {
Self::PngEncodingFailed(Arc::new(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,
+ ))
+}