Take Program by reference in iced_test::screenshot

This commit is contained in:
Héctor Ramón Jiménez 2025-11-12 14:34:10 +01:00
parent 085c8fae8d
commit 54b5c52db2
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -221,7 +221,7 @@ pub fn run(
/// Takes a screenshot of the given [`Program`](program::Program) with the given theme, viewport, /// Takes a screenshot of the given [`Program`](program::Program) with the given theme, viewport,
/// and scale factor after running it for the given [`Duration`]. /// and scale factor after running it for the given [`Duration`].
pub fn screenshot<P: program::Program + 'static>( pub fn screenshot<P: program::Program + 'static>(
program: P, program: &P,
theme: &P::Theme, theme: &P::Theme,
viewport: impl Into<Size>, viewport: impl Into<Size>,
scale_factor: f32, scale_factor: f32,
@ -233,7 +233,7 @@ pub fn screenshot<P: program::Program + 'static>(
let mut emulator = Emulator::new( let mut emulator = Emulator::new(
sender, sender,
&program, program,
emulator::Mode::Immediate, emulator::Mode::Immediate,
viewport.into(), viewport.into(),
); );
@ -244,7 +244,7 @@ pub fn screenshot<P: program::Program + 'static>(
if let Some(event) = receiver.try_next().ok().flatten() { if let Some(event) = receiver.try_next().ok().flatten() {
match event { match event {
emulator::Event::Action(action) => { emulator::Event::Action(action) => {
emulator.perform(&program, action); emulator.perform(program, action);
} }
emulator::Event::Failed(_) => { emulator::Event::Failed(_) => {
unreachable!( unreachable!(
@ -262,5 +262,5 @@ pub fn screenshot<P: program::Program + 'static>(
std::thread::sleep(Duration::from_millis(1)); std::thread::sleep(Duration::from_millis(1));
} }
emulator.screenshot(&program, theme, scale_factor) emulator.screenshot(program, theme, scale_factor)
} }