Reduce size of Simulator in todos test
This commit is contained in:
parent
b22a847668
commit
0ad40d0338
4 changed files with 13 additions and 15 deletions
|
|
@ -28,6 +28,7 @@ use crate::window::{Icon, Level, Position};
|
||||||
use crate::Size;
|
use crate::Size;
|
||||||
|
|
||||||
pub use platform::PlatformSpecific;
|
pub use platform::PlatformSpecific;
|
||||||
|
|
||||||
/// The window settings of an application.
|
/// The window settings of an application.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
a7c2ac4b57f84416812e2134e48fe34db55a757d9176beedf5854a2f69532e32
|
b41c73d214894bf5f94f787e5f265cff6500822b2d4a29a4ac0c847a71db7123
|
||||||
|
|
@ -594,11 +594,12 @@ mod tests {
|
||||||
use iced_test::{selector, Error, Simulator};
|
use iced_test::{selector, Error, Simulator};
|
||||||
|
|
||||||
fn simulator(todos: &Todos) -> Simulator<Message> {
|
fn simulator(todos: &Todos) -> Simulator<Message> {
|
||||||
Simulator::with_settings(
|
Simulator::with_size(
|
||||||
Settings {
|
Settings {
|
||||||
fonts: vec![Todos::ICON_FONT.into()],
|
fonts: vec![Todos::ICON_FONT.into()],
|
||||||
..Settings::default()
|
..Settings::default()
|
||||||
},
|
},
|
||||||
|
(512.0, 512.0),
|
||||||
todos.view(),
|
todos.view(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ pub struct Simulator<
|
||||||
> {
|
> {
|
||||||
raw: UserInterface<'a, Message, Theme, Renderer>,
|
raw: UserInterface<'a, Message, Theme, Renderer>,
|
||||||
renderer: Renderer,
|
renderer: Renderer,
|
||||||
window_size: Size,
|
size: Size,
|
||||||
cursor: mouse::Cursor,
|
cursor: mouse::Cursor,
|
||||||
messages: Vec<Message>,
|
messages: Vec<Message>,
|
||||||
}
|
}
|
||||||
|
|
@ -79,19 +79,15 @@ where
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
element: impl Into<Element<'a, Message, Theme, Renderer>>,
|
element: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::with_window_size(
|
Self::with_size(settings, window::Settings::default().size, element)
|
||||||
settings,
|
|
||||||
window::Settings::default().size,
|
|
||||||
element,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_window_size(
|
pub fn with_size(
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
window_size: impl Into<Size>,
|
size: impl Into<Size>,
|
||||||
element: impl Into<Element<'a, Message, Theme, Renderer>>,
|
element: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let window_size = window_size.into();
|
let size = size.into();
|
||||||
|
|
||||||
let default_font = match settings.default_font {
|
let default_font = match settings.default_font {
|
||||||
Font::DEFAULT => Font::with_name("Fira Sans"),
|
Font::DEFAULT => Font::with_name("Fira Sans"),
|
||||||
|
|
@ -107,7 +103,7 @@ where
|
||||||
|
|
||||||
let raw = UserInterface::build(
|
let raw = UserInterface::build(
|
||||||
element,
|
element,
|
||||||
window_size,
|
size,
|
||||||
user_interface::Cache::default(),
|
user_interface::Cache::default(),
|
||||||
&mut renderer,
|
&mut renderer,
|
||||||
);
|
);
|
||||||
|
|
@ -115,7 +111,7 @@ where
|
||||||
Simulator {
|
Simulator {
|
||||||
raw,
|
raw,
|
||||||
renderer,
|
renderer,
|
||||||
window_size,
|
size,
|
||||||
cursor: mouse::Cursor::Unavailable,
|
cursor: mouse::Cursor::Unavailable,
|
||||||
messages: Vec::new(),
|
messages: Vec::new(),
|
||||||
}
|
}
|
||||||
|
|
@ -343,8 +339,8 @@ where
|
||||||
let scale_factor = 2.0;
|
let scale_factor = 2.0;
|
||||||
|
|
||||||
let physical_size = Size::new(
|
let physical_size = Size::new(
|
||||||
(self.window_size.width * scale_factor).round() as u32,
|
(self.size.width * scale_factor).round() as u32,
|
||||||
(self.window_size.height * scale_factor).round() as u32,
|
(self.size.height * scale_factor).round() as u32,
|
||||||
);
|
);
|
||||||
|
|
||||||
let rgba = self.renderer.screenshot(
|
let rgba = self.renderer.screenshot(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue