summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-17 01:53:39 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-12-17 01:53:39 +0100
commit0ad40d03387a8127b445305a1c63fa3d2ac45ed7 (patch)
tree412d77a00dd9eea74a81c128a9db5ecef8951477
parentb22a847668f3b59e1de77c2beee03134795f9380 (diff)
downloadiced-0ad40d03387a8127b445305a1c63fa3d2ac45ed7.tar.gz
iced-0ad40d03387a8127b445305a1c63fa3d2ac45ed7.tar.bz2
iced-0ad40d03387a8127b445305a1c63fa3d2ac45ed7.zip
Reduce size of `Simulator` in `todos` test
-rw-r--r--core/src/window/settings.rs1
-rw-r--r--examples/todos/snapshots/creates_a_new_task.sha2562
-rw-r--r--examples/todos/src/main.rs3
-rw-r--r--test/src/lib.rs22
4 files changed, 13 insertions, 15 deletions
diff --git a/core/src/window/settings.rs b/core/src/window/settings.rs
index fbbf86ab..c1f36a6c 100644
--- a/core/src/window/settings.rs
+++ b/core/src/window/settings.rs
@@ -28,6 +28,7 @@ use crate::window::{Icon, Level, Position};
use crate::Size;
pub use platform::PlatformSpecific;
+
/// The window settings of an application.
#[derive(Debug, Clone)]
pub struct Settings {
diff --git a/examples/todos/snapshots/creates_a_new_task.sha256 b/examples/todos/snapshots/creates_a_new_task.sha256
index 15efcd77..75d5f2ce 100644
--- a/examples/todos/snapshots/creates_a_new_task.sha256
+++ b/examples/todos/snapshots/creates_a_new_task.sha256
@@ -1 +1 @@
-a7c2ac4b57f84416812e2134e48fe34db55a757d9176beedf5854a2f69532e32 \ No newline at end of file
+b41c73d214894bf5f94f787e5f265cff6500822b2d4a29a4ac0c847a71db7123 \ No newline at end of file
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 1cc47782..0b80f002 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -594,11 +594,12 @@ mod tests {
use iced_test::{selector, Error, Simulator};
fn simulator(todos: &Todos) -> Simulator<Message> {
- Simulator::with_settings(
+ Simulator::with_size(
Settings {
fonts: vec![Todos::ICON_FONT.into()],
..Settings::default()
},
+ (512.0, 512.0),
todos.view(),
)
}
diff --git a/test/src/lib.rs b/test/src/lib.rs
index 44594a4d..00126e64 100644
--- a/test/src/lib.rs
+++ b/test/src/lib.rs
@@ -55,7 +55,7 @@ pub struct Simulator<
> {
raw: UserInterface<'a, Message, Theme, Renderer>,
renderer: Renderer,
- window_size: Size,
+ size: Size,
cursor: mouse::Cursor,
messages: Vec<Message>,
}
@@ -79,19 +79,15 @@ where
settings: Settings,
element: impl Into<Element<'a, Message, Theme, Renderer>>,
) -> Self {
- Self::with_window_size(
- settings,
- window::Settings::default().size,
- element,
- )
+ Self::with_size(settings, window::Settings::default().size, element)
}
- pub fn with_window_size(
+ pub fn with_size(
settings: Settings,
- window_size: impl Into<Size>,
+ size: impl Into<Size>,
element: impl Into<Element<'a, Message, Theme, Renderer>>,
) -> Self {
- let window_size = window_size.into();
+ let size = size.into();
let default_font = match settings.default_font {
Font::DEFAULT => Font::with_name("Fira Sans"),
@@ -107,7 +103,7 @@ where
let raw = UserInterface::build(
element,
- window_size,
+ size,
user_interface::Cache::default(),
&mut renderer,
);
@@ -115,7 +111,7 @@ where
Simulator {
raw,
renderer,
- window_size,
+ size,
cursor: mouse::Cursor::Unavailable,
messages: Vec::new(),
}
@@ -343,8 +339,8 @@ where
let scale_factor = 2.0;
let physical_size = Size::new(
- (self.window_size.width * scale_factor).round() as u32,
- (self.window_size.height * scale_factor).round() as u32,
+ (self.size.width * scale_factor).round() as u32,
+ (self.size.height * scale_factor).round() as u32,
);
let rgba = self.renderer.screenshot(