VectorCraft: An open-source, vector art tool written by scratch in pure Rust
#480: test that the Add and Delete Anchor Point tool icons are the Pen's icon with a badge
skylar taylor-barrick548fad4b59df
diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rsindex 52476db6f..8987cc64c 100644--- a/crates/ui-egui/src/icons.rs+++ b/crates/ui-egui/src/icons.rs@@ -187,6 +187,31 @@ mod tests {assert!(appearance.contains("<circle") && !pathfinder.contains("<circle"), "appearance should read as a list, not overlapping squares");}+ // Regression test for #479: the Add and Delete Anchor Point tools' icons were drawn apart from+ // the Pen tool's, so the three tools didn't read as one family. They are the Pen's pen with a+ // plus or a minus beside it.+ #[test]+ fn the_add_and_delete_anchor_tool_icons_are_the_pen_icon_with_a_badge() {+ let svg = |tool: &str| {+ let name = tool_icon(tool);+ let (_, bytes) =+ crate::icon_data::ICONS.iter().find(|(n, _)| *n == name).unwrap_or_else(|| panic!("{tool} maps to {name}, which isn't an icon"));+ String::from_utf8_lossy(bytes).into_owned()+ };+ let shapes =+ |svg: &str| svg.lines().map(|l| l.trim().to_string()).filter(|l| l.starts_with("<path") || l.starts_with("<circle")).collect::<Vec<_>>();+ let pen = shapes(&svg("tool-pen"));+ assert!(!pen.is_empty(), "the Pen's icon has shapes");+ let (add, delete) = (shapes(&svg("tool-pen-add")), shapes(&svg("tool-pen-delete")));+ for (tool, icon) in [("tool-pen-add", &add), ("tool-pen-delete", &delete)] {+ for shape in &pen {+ assert!(icon.contains(shape), "{tool}'s icon lacks the Pen's {shape}");+ }+ assert!(icon.len() > pen.len(), "{tool}'s icon has a badge of its own");+ }+ assert_ne!(add, delete, "plus and minus differ");+ }+#[test]fn shared_catalog_preserves_fallback_and_tool_aliases() {let ImageSource::Bytes { uri, bytes } = source("missing-icon") else { panic!("expected SVG bytes") };