1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 23:13:13 -04:00
Files
egui/crates/egui_demo_lib/tests/image_blending.rs
Lucas Meurer de907612b7 Enforce consistent snapshot updates (#7744)
* Closes https://github.com/emilk/egui/issues/7647


This collects SnapshotResults within the Harness and adds a check to
enforce snapshot results are merged in case multiple Harnesses are
constructed within a test.

This should make snapshot updates via kitdiff/accept_snapshots.sh way
more useful since it should now always update all snapshots instead of
only the first one per test.
2025-11-26 14:56:19 +01:00

28 lines
990 B
Rust

use egui::{hex_color, include_image};
use egui_kittest::Harness;
#[test]
fn test_image_blending() {
let mut results = egui_kittest::SnapshotResults::new();
for pixels_per_point in [1.0, 2.0] {
let mut harness = Harness::builder()
.with_pixels_per_point(pixels_per_point)
.build_ui(|ui| {
egui_extras::install_image_loaders(ui.ctx());
egui::Frame::new()
.fill(hex_color!("#5981FF"))
.show(ui, |ui| {
ui.add(
egui::Image::new(include_image!("../data/ring.png"))
.max_height(18.0)
.tint(egui::Color32::GRAY),
);
});
});
harness.run();
harness.fit_contents();
harness.snapshot(format!("image_blending/image_x{pixels_per_point}"));
results.extend_harness(&mut harness);
}
}