summaryrefslogtreecommitdiffstats
path: root/examples/todos
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-14 03:49:24 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-14 03:49:24 +0100
commit2cf4abf25bb5702635c19a22353399db8cef7be3 (patch)
tree3859d0fede59e92864c66c2ace89bc1d401769d6 /examples/todos
parent6572909ab5b004176f6d261b67b4caa99f1f54bb (diff)
downloadiced-2cf4abf25bb5702635c19a22353399db8cef7be3.tar.gz
iced-2cf4abf25bb5702635c19a22353399db8cef7be3.tar.bz2
iced-2cf4abf25bb5702635c19a22353399db8cef7be3.zip
Support custom renderers in `iced_test` through `renderer::Headless` trait
Diffstat (limited to 'examples/todos')
-rw-r--r--examples/todos/snapshots/creates_a_new_task.sha2562
-rw-r--r--examples/todos/src/main.rs19
2 files changed, 15 insertions, 6 deletions
diff --git a/examples/todos/snapshots/creates_a_new_task.sha256 b/examples/todos/snapshots/creates_a_new_task.sha256
index 75d5f2ce..15efcd77 100644
--- a/examples/todos/snapshots/creates_a_new_task.sha256
+++ b/examples/todos/snapshots/creates_a_new_task.sha256
@@ -1 +1 @@
-b41c73d214894bf5f94f787e5f265cff6500822b2d4a29a4ac0c847a71db7123 \ No newline at end of file
+a7c2ac4b57f84416812e2134e48fe34db55a757d9176beedf5854a2f69532e32 \ No newline at end of file
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 1d4aa8a4..fe23cbc9 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -590,16 +590,25 @@ impl SavedState {
mod tests {
use super::*;
- use iced_test::{interface, load_font, selector, Error};
+ use iced::Settings;
+ use iced_test::{selector, Error, Simulator};
+
+ fn simulator(todos: &Todos) -> Simulator<Message> {
+ Simulator::with_settings(
+ Settings {
+ fonts: vec![Todos::ICON_FONT.into()],
+ ..Settings::default()
+ },
+ todos.view(),
+ )
+ }
#[test]
fn it_creates_a_new_task() -> Result<(), Error> {
- load_font(Todos::ICON_FONT)?;
-
let (mut todos, _command) = Todos::new();
let _command = todos.update(Message::Loaded(Err(LoadError::File)));
- let mut ui = interface(todos.view());
+ let mut ui = simulator(&todos);
let _input = ui.click("new-task")?;
ui.typewrite("Create the universe");
@@ -609,7 +618,7 @@ mod tests {
let _command = todos.update(message);
}
- let mut ui = interface(todos.view());
+ let mut ui = simulator(&todos);
let _ = ui.find(selector::text("Create the universe"))?;
let snapshot = ui.snapshot()?;