Add screenshot helpers to iced_test

This commit is contained in:
Héctor Ramón Jiménez 2025-11-12 00:53:10 +01:00
parent ea614387f4
commit 085c8fae8d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
10 changed files with 183 additions and 78 deletions

View file

@ -276,7 +276,7 @@ impl Snapshot {
let mut bytes = vec![0; n];
let info = reader.next_frame(&mut bytes)?;
Ok(self.screenshot.bytes == bytes[..info.buffer_size()])
Ok(self.screenshot.rgba == bytes[..info.buffer_size()])
} else {
if let Some(directory) = path.parent() {
fs::create_dir_all(directory)?;
@ -292,7 +292,7 @@ impl Snapshot {
encoder.set_color(png::ColorType::Rgba);
let mut writer = encoder.write_header()?;
writer.write_image_data(&self.screenshot.bytes)?;
writer.write_image_data(&self.screenshot.rgba)?;
writer.finish()?;
Ok(true)
@ -311,7 +311,7 @@ impl Snapshot {
let hash = {
let mut hasher = Sha256::new();
hasher.update(&self.screenshot.bytes);
hasher.update(&self.screenshot.rgba);
format!("{:x}", hasher.finalize())
};