From b11ad9ff5e7aacfb06202d94dadca0c20abf1cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 7 Dec 2025 21:24:57 +0100 Subject: [PATCH] Fix standalone compilation of `iced_test` subcrate --- Cargo.lock | 1 + core/src/renderer/null.rs | 26 ++++++++++++++++++++++++++ test/Cargo.toml | 3 +++ test/src/lib.rs | 7 ++++--- test/src/simulator.rs | 2 +- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d78f1a12..730314bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2502,6 +2502,7 @@ dependencies = [ name = "iced_test" version = "0.14.0-dev" dependencies = [ + "iced_futures", "iced_program", "iced_renderer", "iced_runtime", diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index 3ec6de6a..289fbe79 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -259,3 +259,29 @@ impl svg::Renderer for () { ) { } } + +impl renderer::Headless for () { + async fn new( + _default_font: Font, + _default_text_size: Pixels, + _backend: Option<&str>, + ) -> Option + where + Self: Sized, + { + Some(()) + } + + fn name(&self) -> String { + "null renderer".to_owned() + } + + fn screenshot( + &mut self, + _size: Size, + _scale_factor: f32, + _background_color: Color, + ) -> Vec { + Vec::new() + } +} diff --git a/test/Cargo.toml b/test/Cargo.toml index fcf05878..52871002 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -19,6 +19,9 @@ iced_runtime.workspace = true iced_program.workspace = true iced_selector.workspace = true +iced_futures.workspace = true +iced_futures.features = ["thread-pool"] + iced_renderer.workspace = true iced_renderer.features = ["fira-sans"] diff --git a/test/src/lib.rs b/test/src/lib.rs index 7704d477..df67ba1f 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -83,6 +83,7 @@ //! [`typewrite`](Simulator::typewrite)—and even perform [_snapshot testing_](Simulator::snapshot)! //! //! [the classical counter interface]: https://book.iced.rs/architecture.html#dissecting-an-interface +pub use iced_futures as futures; pub use iced_program as program; pub use iced_renderer as renderer; pub use iced_runtime as runtime; @@ -122,9 +123,9 @@ pub fn run( program: impl program::Program + 'static, tests_dir: impl AsRef, ) -> Result<(), Error> { - use crate::runtime::futures::futures::StreamExt; - use crate::runtime::futures::futures::channel::mpsc; - use crate::runtime::futures::futures::executor; + use crate::futures::futures::StreamExt; + use crate::futures::futures::channel::mpsc; + use crate::futures::futures::executor; use std::ffi::OsStr; use std::fs; diff --git a/test/src/simulator.rs b/test/src/simulator.rs index 4d31345b..63fbe3f7 100644 --- a/test/src/simulator.rs +++ b/test/src/simulator.rs @@ -76,7 +76,7 @@ where let mut renderer = { let backend = env::var("ICED_TEST_BACKEND").ok(); - iced_runtime::futures::futures::executor::block_on(Renderer::new( + crate::futures::futures::executor::block_on(Renderer::new( default_font, settings.default_text_size, backend.as_deref(),