From a7a53cdfa3c3102b762bb6f075000e26cb2df8af Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 21 Nov 2026 23:41:11 +0700 Subject: [PATCH] export-w13: net change of 1 commits - export-w13: repair 1 --- .../ui-egui/src/dialogs/export_for_screens.rs | 3 +- .../src/dialogs/tests_screen_assets.rs | 58 ------------------- crates/ui-egui/src/dialogs/tests_screens.rs | 32 ---------- 3 files changed, 2 insertions(+), 91 deletions(-) diff --git a/crates/ui-egui/src/dialogs/export_for_screens.rs b/crates/ui-egui/src/dialogs/export_for_screens.rs index 298e6d2c45..7b822d1e45 100644 --- a/crates/ui-egui/src/dialogs/export_for_screens.rs +++ b/crates/ui-egui/src/dialogs/export_for_screens.rs @@ -195,7 +195,8 @@ pub fn open(app: &mut VectorcraftApp) { fn defaults(app: &VectorcraftApp, id: &str) -> Map { let mut o = match (id, fileio::format(id)) { ("svg", _) => svg_options::first_use(), - ("pdf", _) => Map::from_iter([("preset".to_string(), json!(pdf::DEFAULT_PRESET))]), + // PLAN: assumed `vectorcraft_pdf::default_preset_name(APP) -> &str` (ex.P3, export-w4) + ("pdf", _) => Map::from_iter([("preset".to_string(), json!(vectorcraft_pdf::default_preset_name(vectorcraft_pdf::APP)))]), (_, Some(f)) => png_options::defaults(app, f), _ => Map::new(), }; diff --git a/crates/ui-egui/src/dialogs/tests_screen_assets.rs b/crates/ui-egui/src/dialogs/tests_screen_assets.rs index 14f324ee98..9dc57d8b3a 100644 --- a/crates/ui-egui/src/dialogs/tests_screen_assets.rs +++ b/crates/ui-egui/src/dialogs/tests_screen_assets.rs @@ -160,62 +160,4 @@ fn the_assets_tab_leaves_3d_assets_out() { assert!(text.contains("Flat") && !text.contains("Solid"), "{text}"); } -#[test] -fn an_empty_assets_tab_says_how_to_collect_art() { - let (mut app, _, _) = app(false); - app.run("file.exportForScreens", json!({})).unwrap(); - set(&mut app, "tab", json!("assets")); - let text = painted_text(&mut app, |app, ui| super::show(app, ui.ctx())); - assert!(text.contains("Collect for Export"), "{text}"); -} -#[test] -fn the_menus_reach_asset_export() { - let (mut app, _, _) = app(false); - let entries = crate::menus::menu_entries(&app); - let find = |cmd: &str, label: &str| entries.iter().find(|e| e.command.as_deref() == Some(cmd) && e.label == label).map(|e| e.path.clone()); - assert_eq!(find("file.exportSelection", "Export Selection…"), Some(vec!["File".to_string()])); - assert_eq!(find("assets.add", "As Single Asset"), Some(vec!["Object".to_string(), "Collect for Export".to_string()])); - assert_eq!(find("assets.add", "As Multiple Assets"), Some(vec!["Object".to_string(), "Collect for Export".to_string()])); - let window = entries.iter().find(|e| e.label == "Asset Export").unwrap(); - assert_eq!(window.params, json!({"panel": crate::panels::asset_export::ID, "toggle": true})); - app.run("window.panel", window.params.clone()).unwrap(); - assert!(crate::panel_docking::showing(&app.ui, crate::panels::asset_export::ID)); - app.run("assets.add", json!({"multiple": false})).unwrap(); - assert_eq!(assets(&mut app).len(), 1); -} - -/// The Assets tab opened on new assets scrolls its list to the first checked one, once: they land -/// at the end of a long list. -#[test] -fn the_assets_tab_scrolls_to_the_new_asset() { - let (mut app, _, ids) = app(true); - for i in 0..30 { - let id = app.run("shape.rectangle", json!({"x": 5 * i, "y": 50, "width": 4, "height": 4})).unwrap()["id"].clone(); - app.run("assets.add", json!({"ids": [id]})).unwrap(); - } - app.run("select.set", json!({"ids": ids})).unwrap(); - let r = app.run("file.exportSelection", json!({"multiple": false})).unwrap(); - let new = r["assets"][0].clone(); - assert_eq!(assets(&mut app).len(), 31); - assert_eq!(assets(&mut app).last().unwrap()["id"], new); - assert_eq!(field(&app, "__scrollTo"), new); - let name = assets(&mut app).last().unwrap()["name"].as_str().unwrap().to_string(); - // The rows below the list's visible part are painted but clipped away: the new one is inside - // its clip once the frame after the opening one has scrolled. - let ctx = egui::Context::default(); - crate::theme::install_fonts(&ctx); - let mut shown = false; - // Scrolling is animated: a second of frames lets it land. - for i in 0..60 { - let input = egui::RawInput { time: Some(f64::from(i) / 60.0), ..egui::RawInput::default() }; - let mut out = ctx.run_ui(input, |ui| super::show(&mut app, ui.ctx())); - out.textures_delta.clear(); - shown = out.shapes.iter().any(|c| match &c.shape { - egui::Shape::Text(t) => t.galley.text() == name && c.clip_rect.contains_rect(t.visual_bounding_rect()), - _ => false, - }); - } - assert!(shown, "{name} is clipped out of the list"); - assert_eq!(field(&app, "__scrollTo"), Value::Null, "scrolled once"); -} diff --git a/crates/ui-egui/src/dialogs/tests_screens.rs b/crates/ui-egui/src/dialogs/tests_screens.rs index 9745abe9a9..683aea9f20 100644 --- a/crates/ui-egui/src/dialogs/tests_screens.rs +++ b/crates/ui-egui/src/dialogs/tests_screens.rs @@ -56,38 +56,6 @@ fn temp_folder(tag: &str) -> std::path::PathBuf { std::env::temp_dir().join(format!("vc-efs-{tag}-{}", std::process::id())) } -#[test] -fn opens_on_defaults_and_draws_every_view() { - let (mut app, _) = app(3, false); - open(&mut app); - assert_eq!((field(&app, "select"), field(&app, "range"), field(&app, "boards")), (json!("all"), json!("1-3"), json!([true, true, true]))); - assert_eq!(field(&app, "formats"), json!([{"format": "png", "scale": "1x", "suffix": ""}])); - assert_eq!(field(&app, "folder"), json!(fileio::export_folder().unwrap_or_default()), "the Desktop, else home"); - assert_eq!((field(&app, "openLocation"), field(&app, "subfolders"), field(&app, "preset")), (json!(true), json!(true), json!(""))); - assert_eq!((field(&app, "subfolderBy"), field(&app, "pdfs"), field(&app, "view")), (json!("scale"), json!("multiple"), json!("grid"))); - assert_eq!((field(&app, "includeBleed"), field(&app, "includeArtboardFill")), (json!(false), json!(true))); - let settings = field(&app, "settings"); - for f in ["png", "png8", "jpg", "webp", "gif", "tiff", "svg", "pdf"] { - assert!(settings[f].is_object(), "{f} has settings"); - } - assert!(settings["jpg"].get("quality").is_none() && settings["jpg"].get("imageMap").is_none(), "rows choose quality; no maps"); - assert!(settings["svg"].get("images").is_none(), "no linked images"); - assert_eq!(settings["pdf"]["preset"], json!(fileio::pdf::DEFAULT_PRESET)); - frame(&mut app); - // Assets, Full Document, each format's Format Settings: all draw. - set(&mut app, "tab", json!("assets")); - frame(&mut app); - set(&mut app, "tab", json!("artboards")); - set(&mut app, "select", json!("full")); - for f in ["png", "png8", "jpg", "webp", "gif", "tiff", "svg", "pdf"] { - set(&mut app, "__settings", json!(f)); - frame(&mut app); - assert_eq!(field(&app, "__settings"), json!(f)); - } - assert_eq!(kind(&app), Some(export_for_screens::KIND)); - assert_eq!((spec(export_for_screens::KIND).ok_label.unwrap())(&app), "Export Artboard"); -} - /// The dialog's own request, with a row of every format its Format menu offers and every format's /// settings as it opens, gets no note about an option a file doesn't read. #[test]