Skip to content

Commit

Permalink
Set fixed date in widget_gallery test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmerlin committed Oct 9, 2024
1 parent d0a307d commit 0d4cebf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions crates/egui_demo_lib/src/demo/demo_app_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,17 @@ mod tests {
let mut errors = Vec::new();

for mut demo in demos.demos {
// Remove the emoji from the demo name
let name = demo
.name()
.split_once(' ')
.map_or(demo.name(), |(_, name)| name);

// Widget Gallery needs to be customized (to set a specific date) and has its own test
if name == "Widget Gallery" {
continue;
}

let mut harness = Harness::new(|ctx| {
demo.show(ctx, &mut true);
});
Expand Down
6 changes: 5 additions & 1 deletion crates/egui_demo_lib/src/demo/widget_gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ mod tests {

#[test]
pub fn should_match_screenshot() {
let mut demo = WidgetGallery::default();
let mut demo = WidgetGallery {
// If we don't set a fixed date, the snapshot test will fail.
date: Some(chrono::NaiveDate::from_ymd_opt(2024, 1, 1).unwrap()),
..Default::default()
};
let app = |ctx: &Context| {
CentralPanel::default().show(ctx, |ui| {
demo.ui(ui);
Expand Down
3 changes: 0 additions & 3 deletions crates/egui_demo_lib/tests/snapshots/demos/Widget Gallery.png

This file was deleted.

4 changes: 2 additions & 2 deletions crates/egui_demo_lib/tests/snapshots/widget_gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0d4cebf

Please sign in to comment.