#480: test that the Add and Delete Anchor Point tool icons are the Pen's icon with a badge

The Add and Delete Anchor Point tools' icons were drawn apart from the Pen tool's, so the three didn't read as one family. The test checks that both tools' icons contain every shape of the Pen tool's icon plus a badge of their own, and that plus and minus differ. With the tool mapping pointing back at the old dc-pen-add and dc-pen-delete icons it fails: the Add tool's icon lacks the Pen's outline.
This commit is contained in:
skylar taylor-barrick
2026-10-23 03:33:30 +07:00
committed by bflatastic
parent 625cba6f0a
commit 548fad4b59
+25
View File
@@ -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") };