From c323ccd7d4e1497976e493efa4534454ebb0d590 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Sat, 5 Dec 2026 05:48:40 -0800 Subject: [PATCH] Test reopening Pastels in both saved thumbnail sizes --- .../ui-egui/src/panels/library_panel/tests.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/panels/library_panel/tests.rs b/crates/ui-egui/src/panels/library_panel/tests.rs index 593c12e684..fe6976b0cf 100644 --- a/crates/ui-egui/src/panels/library_panel/tests.rs +++ b/crates/ui-egui/src/panels/library_panel/tests.rs @@ -119,12 +119,20 @@ fn library_menu_views_survive_redraw_and_reopening() { draw_frame(&mut app, &ctx, &draw, vec![]); draw_frame(&mut app, &ctx, &draw, vec![]); assert_eq!(settings(&app.ui, "swatches", "pastels").unwrap().view, Some(view), "{label}"); + if matches!(view, View::SmallThumb | View::MediumThumb) { + app.run("window.panel.close", json!({"panel": panel})).unwrap(); + assert!(!is_open(&app.ui, &panel)); + let reopened = panel_of(app.run("window.swatchLibrary", json!({"library": "pastels"})).unwrap()); + assert_eq!(reopened, panel); + // A fresh context excludes browser state cached before the close. + let reopened_ctx = context(); + draw_frame(&mut app, &reopened_ctx, &draw, vec![]); + assert_eq!(settings(&app.ui, "swatches", "pastels").unwrap().view, Some(view), "{label} after reopening"); + let state_id = egui::Id::unique(("library-panel-state", &panel)); + let browser = reopened_ctx.data(|d| d.get_temp::>(state_id)).expect("the reopened Pastels browser drew"); + assert_eq!(saved_view(browser.view, browser.zoom), view, "{label} in the reopened browser"); + } } - - app.run("window.panel.close", json!({"panel": panel})).unwrap(); - app.run("window.swatchLibrary", json!({"library": "pastels"})).unwrap(); - draw_frame(&mut app, &ctx, &draw, vec![]); - assert_eq!(settings(&app.ui, "swatches", "pastels").unwrap().view, Some(View::SmallThumb)); } fn undo_len(app: &VectorcraftApp) -> usize {