Merge main into fix/test-lint-platform-only-tests

This commit is contained in:
dotCooCoo committed 2026-12-01 19:54:15 -08:00
commit 5e271bcf66
45 files changed
+366 -217

No files matched your search

+3 -4
View File
@@ -553,10 +553,9 @@ fn the_saved_engine_preference_is_found() {
let saved = prefs.to_json();
assert_eq!(power_preference(saved.get("gpuPreference").and_then(serde_json::Value::as_str), None), power);
}
// Every choice Preferences offer means something here.
for (value, _) in vectorcraft_engine::cmd::prefscmds::GPU_PREFERENCES {
assert!(["automatic", "lowPower", "highPerformance"].contains(value), "{value}");
}
// Preferences offer the three choices read above, and no other.
let offered: Vec<&str> = vectorcraft_engine::cmd::prefscmds::GPU_PREFERENCES.iter().map(|(value, _)| *value).collect();
assert_eq!(offered, ["automatic", "lowPower", "highPerformance"]);
}
#[test]
+7 -1
View File
@@ -2220,7 +2220,10 @@ fn brushes_without_modes_vary_randomly_as_before() {
serde_json::to_value(Variation::ALL).unwrap(),
serde_json::json!(["fixed", "random", "pressure", "tilt", "bearing", "rotation", "stylusWheel"])
);
assert!(Variation::ALL.iter().all(|v| Variation::parse(v.id()) == Some(*v) && serde_json::to_value(v).unwrap() == v.id()));
let ids: Vec<&str> = Variation::ALL.iter().map(|v| v.id()).collect();
assert_eq!(serde_json::to_value(Variation::ALL).unwrap(), serde_json::json!(ids), "saved names are the ids");
assert_eq!(Variation::parse("stylusWheel"), Some(Variation::StylusWheel));
assert_eq!(Variation::parse("wheel"), None);
assert!(!Variation::offered(false).contains(&Variation::StylusWheel) && Variation::offered(true).contains(&Variation::StylusWheel));
}
@@ -2228,6 +2231,7 @@ fn brushes_without_modes_vary_randomly_as_before() {
#[test]
fn junk_pressure_brushes_draw_finite_art() {
let bp = preview_path(120.0, 24.0);
let mut drawn = 0;
for (size, var) in [(1e308, 1e308), (-1e308, 1e308), (0.0, -1e308), (f64::MAX, f64::MAX)] {
for profile in [vec![], vec![(0.0, 2.0), (0.0, -1.0), (5.0, 0.5)], vec![(1.0, 1.0), (0.0, 0.0)]] {
let out = stroke_pieces(&Document::new(1.0, 1.0), &pressure_calli(size, var), &bp, &pressed(profile));
@@ -2236,8 +2240,10 @@ fn junk_pressure_brushes_draw_finite_art() {
all_points(n, &mut pts);
}
assert!(pts.iter().all(|p| p.x.is_finite() && p.y.is_finite()), "{size} {var}");
drawn += usize::from(!pts.is_empty());
}
}
assert_eq!(drawn, 12, "brushes that draw");
}
/// A scatter brush of 10 × 4 pt rectangles whose size goes from `lo` % to `hi` % as `mode` says.
+1 -1
View File
@@ -131,7 +131,7 @@ fn pens_pick_colors_and_widths() {
let i = plot("IN;SP1;PW1;PD0,0,10,0;PU;PW2,2;SP2;PD0,10,10,10;PU;SP1;PD0,20,10,20;PU;IN;SP1;PD0,30,10,30;");
let widths: Vec<f64> = leaves(&i.document).iter().map(|n| stroke(n).width).collect();
let want = [MM, 2.0 * MM, MM, 0.35 * MM];
assert!(widths.iter().zip(want).all(|(a, b)| (a - b).abs() < 1e-9), "{widths:?}");
assert!(widths.len() == want.len() && widths.iter().zip(want).all(|(a, b)| (a - b).abs() < 1e-9), "{widths:?}");
}
#[test]
+2 -1
View File
@@ -1448,7 +1448,8 @@ fn crop_keeps_an_instance_whose_art_reaches_the_region() {
let art = path(&mut d, shapes::rectangle(Rect::new(100.0, 50.0, 140.0, 90.0)), Paint::solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 0.0);
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Far".into(), art: Arc::new(art) });
let o = DxfOptions { crop: true, ..opts(&d) };
assert!(!kinds(&export(&d, &o).unwrap()).is_empty());
// The red fill: its outline and its hatch.
assert_eq!(kinds(&export(&d, &o).unwrap()), ["LWPOLYLINE", "HATCH"]);
}
/// An instance stained blue by its fill writes its symbol's red art in blue, as the canvas draws it.
@@ -816,11 +816,14 @@ mod tests {
// Squaring these lengths overflows f64.
let (a, b) = (circle(0.0, 0.0, 5e153), circle(1.5e154, 0.0, 5e153));
let sp = smooth_bridge(a, b, 5e153).unwrap();
// At least one anchor for each of the two circles and the two arcs.
assert!(sp.closed && sp.anchors.len() >= 4, "{}", sp.anchors.len());
assert!(sp.anchors.iter().all(|q| [q.p, q.h_in, q.h_out].iter().all(|p| p.x.is_finite() && p.y.is_finite())));
assert_smooth(&sp);
// The two radius sums fit in f64, but not their total.
let (a, b) = (circle(-5e307, 0.0, 1e307), circle(5e307, 0.0, 1e307));
let sp = smooth_bridge(a, b, 1.5e308).unwrap();
assert!(sp.closed && sp.anchors.len() >= 4, "{}", sp.anchors.len());
assert!(sp.anchors.iter().all(|q| [q.p, q.h_in, q.h_out].iter().all(|p| p.x.is_finite() && p.y.is_finite())));
// The arcs' centers would lie beyond the largest f64.
let (a, b) = (circle(0.0, 0.0, 1e308), circle(1.5e308, 0.0, 1e308));
@@ -609,12 +609,12 @@ mod tests {
fn each_kind_draws_a_closed_outline_in_its_box() {
for kind in ShapeKind::ALL {
let s = shape(kind);
assert_eq!(ShapeKind::parse(kind.id()), Some(kind));
assert_eq!(s.check(), Ok(()), "{kind:?}");
let p = s.path().unwrap();
assert!(closed(&p) && within_box(&p, &s), "{kind:?}: {:?}", p.bounds());
assert!(p.anchors().all(|(_, _, a)| a.p.x.is_finite() && a.p.y.is_finite()));
}
assert_eq!(ShapeKind::parse("gear"), Some(ShapeKind::Gear));
assert_eq!(ShapeKind::parse("cloud"), None);
}
@@ -262,9 +262,7 @@ fn a_smooth_end_whose_handles_part_turns_into_a_corner() {
}
#[test]
fn follow_names_round_trip() {
for f in Follow::ALL {
assert_eq!(Follow::parse(f.id()), Some(f));
}
fn follow_names_parse() {
assert_eq!(Follow::parse("b"), Some(Follow::Second));
assert_eq!(Follow::parse("up"), None);
}
+4 -2
View File
@@ -738,6 +738,8 @@ fn simplify_levels_and_auto_simplify() {
#[test]
fn smooth_rounds_corners() {
let s = smooth(&rect(0.0, 0.0, 10.0, 10.0), 1.0);
// The four corners stay, each made smooth.
assert_eq!(s.anchor_count(), 4, "{s:?}");
assert!(s.anchors().all(|(_, _, a)| a.has_in() && a.has_out()));
let same = smooth(&rect(0.0, 0.0, 10.0, 10.0), 0.0);
assert_eq!(same, rect(0.0, 0.0, 10.0, 10.0));
@@ -959,7 +961,7 @@ fn grid_split() {
}
#[test]
#[ignore]
#[ignore = "benchmark: prints how long Unite takes on 1000 circles; run by hand with --ignored"]
fn timing_unite_1000_circles() {
let mut seed = 0x1234_5678_u64;
let mut rnd = || {
@@ -971,8 +973,8 @@ fn timing_unite_1000_circles() {
let circles: Vec<Shape> = (0..1000).map(|i| shape(circle(rnd() * 1000.0, rnd() * 1000.0, 5.0 + rnd() * 30.0), i)).collect();
let t = std::time::Instant::now();
let r = pathfinder(PathfinderOp::Unite, &circles);
assert_eq!(r.len(), 1, "Unite gives one compound shape");
println!("unite 1000 circles: {} ms, {} anchors", t.elapsed().as_millis(), r[0].path.anchor_count());
assert!(!r.is_empty());
}
#[test]
+4 -6
View File
@@ -330,13 +330,11 @@ mod tests {
use super::*;
#[test]
fn names_round_trip_and_serialize_as_names() {
for p in ALL {
assert_eq!(Permission::parse(p.name()), Some(p));
assert_eq!(serde_json::to_value(p).unwrap(), serde_json::json!(p.name()));
}
fn names_parse_and_serialize_as_names() {
assert_eq!(serde_json::to_value(ALL).unwrap(), serde_json::json!(names(&ALL)), "saved names are the names");
assert_eq!(Permission::parse("doc.write"), Some(Permission::DocWrite));
assert_eq!(Permission::parse("document.read"), None);
assert!(RESERVED.iter().all(|r| Permission::parse(r).is_none()), "reserved names are not granted");
assert!(!RESERVED.is_empty() && RESERVED.iter().all(|r| Permission::parse(r).is_none()), "reserved names are not granted");
}
#[test]
+1
View File
@@ -133,6 +133,7 @@ fn greys_and_impossible_combinations() {
let px = art(w, h);
for depth in [8, 24] {
let img = decode(&bmp(&px, w, h, &BmpOptions { depth, gray: true, ..Default::default() }), craft_image_codecs::Format::Bmp);
assert_eq!(img.dimensions(), (w, h), "depth {depth}");
assert!(img.pixels().all(|p| p[0] == p[1] && p[1] == p[2]), "depth {depth}: greys");
}
let bad = [
+10 -7
View File
@@ -164,15 +164,18 @@ fn colour_models_write_their_components_and_profiles() {
#[test]
fn model_and_method_ids_round_trip() {
for m in ColorModel::ALL {
assert_eq!(ColorModel::from_id(m.id()), Some(m));
assert_eq!(ColorModel::from_id(m.label()), Some(m));
}
// Saved options name a model or a method by id or label, in any case.
assert_eq!(ColorModel::from_id("cmyk"), Some(ColorModel::Cmyk));
assert_eq!(ColorModel::from_id("RGB"), Some(ColorModel::Rgb));
assert_eq!(ColorModel::from_id("gray"), Some(ColorModel::Gray));
assert_eq!(ColorModel::from_id("Grayscale"), Some(ColorModel::Gray));
assert_eq!(ColorModel::from_id("grey"), Some(ColorModel::Gray));
for m in Method::ALL {
assert_eq!(Method::from_id(m.id()), Some(m));
}
assert_eq!(ColorModel::from_id("lab"), None);
assert_eq!(Method::from_id("optimized"), Some(Method::Optimized));
assert_eq!(Method::from_id("baseline optimized"), Some(Method::Optimized));
assert_eq!(Method::from_id("Progressive"), Some(Method::Progressive));
assert_eq!(Method::from_id("bogus"), None);
assert_eq!(Method::from_id(""), None);
}
/// A 20×10 pt document: a black-ink rectangle on the left half, an RGB red one on the right.
+11 -6
View File
@@ -245,12 +245,17 @@ fn gif_decodes() {
#[test]
fn ids_round_trip() {
for r in Reduction::ALL {
assert_eq!(Reduction::from_id(r.id()), Some(r));
}
for d in Dither::ALL {
assert_eq!(Dither::from_id(d.id()), Some(d));
}
// Saved options name a reduction or a dither by id or label, in any case.
assert_eq!(Reduction::from_id("blackWhite"), Some(Reduction::BlackWhite));
assert_eq!(Reduction::from_id("blackwhite"), Some(Reduction::BlackWhite));
assert_eq!(Reduction::from_id("Black & White"), Some(Reduction::BlackWhite));
assert_eq!(Reduction::from_id("selective"), Some(Reduction::Selective));
assert_eq!(Reduction::from_id("restrictive"), None);
assert_eq!(Dither::from_id("none"), Some(Dither::None));
assert_eq!(Dither::from_id("No Dither"), Some(Dither::None));
assert_eq!(Dither::from_id("PATTERN"), Some(Dither::Pattern));
assert_eq!(Dither::from_id("bayer"), None);
assert_eq!(Dither::from_id(""), None);
}
/// A `w`×`h` red image whose pixels have the opacity `alpha(x, y)`.
+19 -17
View File
@@ -371,9 +371,16 @@ fn per_stroke_raster_effects_use_the_single_threaded_pipeline() {
}
d.remove(id).unwrap();
d.insert(Some(l), 0, n).unwrap();
let mut r = Renderer::new();
r.threads = 4;
let _ = r.render(&d, 100, 100, Affine::IDENTITY, &RenderOptions::default());
let draw = |threads| {
let mut r = Renderer::new();
r.threads = threads;
r.render(&d, 100, 100, Affine::IDENTITY, &RenderOptions::default())
};
let (threaded, single) = (draw(4), draw(1));
// The stroke's glow shows outside it: red, where nothing else is drawn.
let glow = threaded.pixel(40, 14);
assert!(glow[3] > 0 && glow[0] > glow[1] && glow[0] > glow[2], "{glow:?}");
assert!(threaded.pixels == single.pixels, "four threads draw what one does");
}
#[test]
@@ -1966,7 +1973,7 @@ fn rasters_made_over_moved_rasters_count_as_moved() {
/// Reproduce #1257's moving, filtered rectangle: the first frame renders as before a drag,
/// and the next eight render as the canvas renders a drag's frames (`interacting`). Then the
/// eighth position renders as the canvas renders the frame after the drag, and that frame
/// renders once more with every raster cached.
/// renders once more with every raster cached. Both draw what a fresh renderer draws.
/// Run with `cargo test -p vectorcraft-render texture_drag_perf -- --ignored --nocapture`.
#[test]
#[ignore = "manual timing probe; wall-clock performance depends on machine load"]
@@ -2004,10 +2011,12 @@ fn texture_drag_perf() {
}
let mut time = |o: &RenderOptions| {
let start = std::time::Instant::now();
std::hint::black_box(r.render(&doc, 1800, 1500, view, o));
start.elapsed().as_secs_f64() * 1000.0
let image = r.render(&doc, 1800, 1500, view, o);
(start.elapsed().as_secs_f64() * 1000.0, image.pixels)
};
let (after, again) = (time(&opts), time(&opts));
let ((after, after_px), (again, again_px)) = (time(&opts), time(&opts));
let fresh = Renderer::new().render(&doc, 1800, 1500, view, &opts).pixels;
assert!(after_px == fresh && again_px == fresh, "{effect}: the frame after the drag draws what a fresh renderer draws");
ms.sort_by(f64::total_cmp);
println!(
"{effect}: moved CMYK rounded rectangle at 190.07%, DPI 1.5, 1800x1500: median {:.2} ms; samples {ms:?}; the frame after the drag {after:.2} ms, that frame again {again:.2} ms",
@@ -2020,7 +2029,7 @@ fn texture_drag_perf() {
/// view centered on the rectangle: the first frame renders as before a drag, and the next eight
/// render as a drag's frames, once with `interacting` alone and once with `dragging` as well (as
/// the canvas renders them). Then the eighth position renders as the canvas renders the frame
/// after the drag. The hashes of that frame and of a fresh renderer's frame compare builds.
/// after the drag, which draws what a fresh renderer draws.
/// Run with `cargo test -p vectorcraft-render zoomed_drag_perf -- --ignored --nocapture`.
#[test]
#[ignore = "manual timing probe; wall-clock performance depends on machine load"]
@@ -2030,12 +2039,6 @@ fn zoomed_drag_perf() {
("Gaussian Blur 8 pt", vec![("blur.gaussian", json!({"radius": 8}))]),
("Drop Shadow and Craquelure", vec![("stylize.dropShadow", json!({"blur": 7})), ("texture.craquelure", json!({}))]),
];
let hash = |px: &[u8]| {
use std::hash::{Hash, Hasher};
let mut h = std::hash::DefaultHasher::new();
px.hash(&mut h);
h.finish()
};
for (name, effects) in sets {
for zoom in [1.0, 4.0, 16.0, 64.0] {
let base = doc_with(Rect::new(100.0, 100.0, 300.0, 250.0), Color::rgb(0.9, 0.4, 0.1), effects.clone());
@@ -2062,15 +2065,14 @@ fn zoomed_drag_perf() {
let still = r.render(&doc, 2560, 1440, view, &opts);
let after = start.elapsed().as_secs_f64() * 1000.0;
let fresh = Renderer::new().render(&doc, 2560, 1440, view, &opts);
assert!(still.pixels == fresh.pixels, "{name} at {zoom}x, dragging {dragging}: the frame after the drag");
ms.sort_by(f64::total_cmp);
println!(
"{name} at {:.0}%, dragging {dragging}: drag frames median {:.1} ms (min {:.1}, max {:.1}), {previewed} previewed; the frame after the drag {after:.1} ms; hashes {:016x} {:016x}",
"{name} at {:.0}%, dragging {dragging}: drag frames median {:.1} ms (min {:.1}, max {:.1}), {previewed} previewed; the frame after the drag {after:.1} ms",
zoom * 100.0,
(ms[3] + ms[4]) * 0.5,
ms[0],
ms[7],
hash(&still.pixels),
hash(&fresh.pixels)
);
}
}
+11 -3
View File
@@ -275,12 +275,19 @@ fn short_dashed_strokes_are_outlined_whole() {
let one = BezPath::from_vec(vec![kurbo::PathEl::MoveTo(Point::new(100.0, 100.0))]);
let mut dot = one.clone();
dot.line_to((100.0, 100.0));
for (what, bp) in
[("empty", BezPath::new()), ("one anchor", one), ("one anchor, closed on itself", dot), ("a ring of 40 anchors", ring(40, 80.0))]
{
// The ring is outlined once; the degenerate paths only have to draw what a whole outline draws.
for (what, bp, ring_of_40) in [
("empty", BezPath::new(), false),
("one anchor", one, false),
("one anchor, closed on itself", dot, false),
("a ring of 40 anchors", ring(40, 80.0), true),
] {
let d = doc(&bp, st.clone());
let mut r = Renderer::new();
let img = render(&mut r, &d, Point::new(100.0, 100.0));
if ring_of_40 {
assert_eq!(r.strokes.len(), 1, "{what}: one outline");
}
assert!(r.strokes.values().all(|e| e.crop.is_none()), "{what}: outlined whole");
assert!(img.pixels == whole(&d, Point::new(100.0, 100.0)).pixels, "{what}: the same pixels");
}
@@ -393,6 +400,7 @@ fn a_stroke_a_wide_stroke_crosses_over_stays_whole() {
let at = Point::new(20_000.0, 2.0);
let mut r = Renderer::new();
let img = render(&mut r, &d, at);
assert_eq!(r.strokes.len(), 1, "one outline");
assert!(r.strokes.values().all(|e| e.crop.is_none()));
assert!(img.pixels == whole(&d, at).pixels);
}
+2
View File
@@ -2662,6 +2662,7 @@ fn a_reduced_cmyk_image_paints_its_own_inks() {
let d = cmyk_doc_with("inks", blob, 8, 8);
let on = RenderOptions { image_mips: true, ..Default::default() };
let inks = Renderer::new().render_region_inks(&d, Rect::new(0.0, 0.0, 8.0, 8.0), 0.25, &on);
assert_eq!(inks.len(), 2 * 2 * 4, "2 × 2 pixels of four inks");
for px in inks.as_chunks::<4>().0 {
assert!(px.iter().zip(ink).all(|(a, b)| a.abs_diff(b) <= 1), "{px:?} vs {ink:?}");
}
@@ -2805,6 +2806,7 @@ fn a_tiled_image_draws_what_the_whole_image_draws() {
let plane = |ink| ink::ink_image(&key, &full, ink, d.images.get("seams"), false).1;
let bytes = |pm: &Pixmap| pm.data().iter().flat_map(|p| [p.r, p.g, p.b, p.a]).collect::<Vec<u8>>();
let whole = ink::amounts(&bytes(&plane(Ink::Cmy)), &bytes(&plane(Ink::K)));
assert_eq!(drawn.len(), 300 * 40 * 4, "300 × 40 pixels of four inks");
for (i, got) in drawn.as_chunks::<4>().0.iter().enumerate() {
let (x, y) = (x0 as usize + i % 300, i / 300);
let want = &whole[(y * w as usize + x) * 4..][..4];
+3 -11
View File
@@ -420,18 +420,11 @@ fn a_shadow_over_a_cropped_shadow_keeps_to_the_earlier_ones_margin() {
/// Time a drag of the square over each backdrop in a 2560 × 1440 view: the first frame renders as
/// before a drag, the next eight as a drag's frames (`interacting` and `dragging`, as the canvas
/// renders them), then the frame after the drag. The hashes of that frame and of a fresh renderer's
/// frame compare builds.
/// renders them), then the frame after the drag, which draws what a fresh renderer draws.
/// Run with `cargo test --release -p vectorcraft-render backdrop_drag_perf -- --ignored --nocapture`.
#[test]
#[ignore = "manual timing probe; wall-clock performance depends on machine load"]
fn backdrop_drag_perf() {
let hash = |px: &[u8]| {
use std::hash::{Hash, Hasher};
let mut h = std::hash::DefaultHasher::new();
px.hash(&mut h);
h.finish()
};
let size = (2560, 1440);
for (name, effects, zoom) in cases() {
let (base, id) = backdrop(&effects);
@@ -455,15 +448,14 @@ fn backdrop_drag_perf() {
let still = r.render(&doc, size.0, size.1, xf, &opts);
let after = start.elapsed().as_secs_f64() * 1000.0;
let fresh = Renderer::new().render(&doc, size.0, size.1, xf, &opts);
assert!(still.pixels == fresh.pixels, "{name} at {zoom}x: the frame after the drag");
ms.sort_by(f64::total_cmp);
println!(
"{name} at {:.0}%: first frame {first:.1} ms; drag frames median {:.1} ms (min {:.1}, max {:.1}), {previewed} previewed; the frame after the drag {after:.1} ms; hashes {:016x} {:016x}",
"{name} at {:.0}%: first frame {first:.1} ms; drag frames median {:.1} ms (min {:.1}, max {:.1}), {previewed} previewed; the frame after the drag {after:.1} ms",
zoom * 100.0,
(ms[3] + ms[4]) * 0.5,
ms[0],
ms[7],
hash(&still.pixels),
hash(&fresh.pixels)
);
}
}
+2
View File
@@ -2697,6 +2697,8 @@ fn a_file_two_branches_include_is_followed_from_the_shallower_one() {
]);
let limits = Limits { include_depth: 3, ..Limits::default() };
let r = check("main.jsx", b"#include 'a.jsxinc'\n#include 'b.jsxinc'\n", Some(&mut m), &limits);
// One row per #include line: main's two, a's, b's, c's and shared's.
assert_eq!(r.includes.len(), 6, "{:?}", includes(&r));
assert!(r.includes.iter().all(|i| i.status == IncludeStatus::Checked), "{:?}", includes(&r));
assert_eq!(r.outside.iter().map(|o| o.id).collect::<Vec<_>>(), ["network"]);
}
+1 -1
View File
@@ -209,7 +209,7 @@ fn every_effect_casts_a_shadow() {
assert!(plane.path(Shadow::default()).is_some());
let mut inflate = ShadowCaster::new();
let results = inflate.inflate(&[(&path, FillRule::NonZero)], &[true], bounds, Inflate::default(), View::default());
assert!(results.iter().all(Result::is_ok));
assert!(results.len() == 1 && results[0].is_ok(), "one result for the one path");
assert!(inflate.path(Shadow::default()).is_some());
let mut revolve = ShadowCaster::new();
revolve.revolve(&path, FillRule::NonZero, bounds, Revolve::default()).unwrap();
+1 -1
View File
@@ -880,7 +880,7 @@ fn inflate_cells_across_a_hole_edge_are_cut_to_the_shape() {
let (p, r) = shape(&b);
let v = View { rotation_x: -21.88, rotation_y: -23.4, rotation_z: 9.06, ..front() };
let f = inflate(&p, FillRule::EvenOdd, r, Inflate::default(), v).unwrap();
assert!(f.iter().all(|f| f.contours.len() == 1), "every facet is one piece of the surface");
assert!(!f.is_empty() && f.iter().all(|f| f.contours.len() == 1), "every facet is one piece of the surface");
// Straight on, the facets still cover exactly the shape.
let flat = inflate(&p, FillRule::EvenOdd, r, Inflate::default(), front()).unwrap();
assert!(close(area(&flat), 220.0 * 220.0 - 100.0 * 90.0, 1e-3), "{}", area(&flat));
+2 -1
View File
@@ -77,7 +77,8 @@ fn a_plane_has_only_a_front_and_a_hollow_solid_none() {
let hollow = Extrude { cap: false, ..Extrude::default() };
assert_eq!(extrude_face_map(bounds, hollow, view, PlanarFace::Front), None);
let facets = extrude(&path, FillRule::NonZero, bounds, hollow, view).unwrap();
assert!(facets.iter().all(|f| f.end.is_none()));
// A hollow extrusion still draws its sides, and none of them is an end.
assert!(!facets.is_empty() && facets.iter().all(|f| f.end.is_none()));
}
#[test]
+1 -1
View File
@@ -181,7 +181,7 @@ fn perspective_runs_0_to_160_degrees_with_the_eye_outside_the_object() {
assert!(eyes.windows(2).all(|w| w[0] > w[1]), "{eyes:?}");
let (p, b) = cylinder();
let wide = revolve(&p, b, Revolve { rotation_x: -30.0, perspective: 160.0, ..Default::default() }).unwrap();
assert!(wide.iter().flat_map(|f| &f.points).all(|q| q.x.is_finite() && q.y.is_finite()));
assert!(!wide.is_empty() && wide.iter().flat_map(|f| &f.points).all(|q| q.x.is_finite() && q.y.is_finite()));
assert_eq!(wide, revolve(&p, b, Revolve { rotation_x: -30.0, perspective: 400.0, ..Default::default() }).unwrap());
}
#[test]
+2 -4
View File
@@ -87,10 +87,8 @@ fn blend_steps_round_the_shading_to_that_many_levels() {
}
#[test]
fn surfaces_round_trip_through_their_ids() {
for surface in ClassicSurface::ALL {
assert_eq!(ClassicSurface::parse(surface.id()), Some(surface));
}
fn surfaces_parse_from_their_ids() {
assert_eq!(ClassicSurface::parse("none"), Some(ClassicSurface::NoShading));
assert_eq!(ClassicSurface::parse("glossy"), None);
assert_eq!(ClassicSurface::default(), ClassicSurface::Plastic);
}
+2 -1
View File
@@ -758,11 +758,12 @@ mod tests {
};
// One pin, held at 0.4 rad: the whole shape turns rigidly around it.
let d = deform(&m, &[Pin { angle: Some(0.4), ..Pin::new(c, c) }]);
assert!(!m.verts.is_empty() && d.len() == m.verts.len(), "{} of {}", d.len(), m.verts.len());
let err = m.verts.iter().zip(&d).map(|(a, b)| rot(*a).distance(*b)).fold(0.0, f64::max);
assert!(err < 0.05, "{err}");
// A free pin alone leaves the shape where it is.
let d = deform(&m, &[Pin::new(c, c)]);
assert!(m.verts.iter().zip(&d).all(|(a, b)| a.distance(*b) < 1e-3));
assert!(d.len() == m.verts.len() && m.verts.iter().zip(&d).all(|(a, b)| a.distance(*b) < 1e-3));
// Held ends: the turned end turns, the other end stays.
let left = Point::new(10.0, 50.0);
let pins = [Pin { angle: Some(0.5), ..Pin::new(left, left) }, Pin::new(Point::new(190.0, 50.0), Point::new(190.0, 50.0))];
+2 -1
View File
@@ -3752,7 +3752,8 @@ fn the_eraser_drag_area_matches_the_release_when_pressure_or_a_mode_starts_durin
press(&mut t, upright, 0.5, PointerKind::Drag, 150.0);
near(bounds(&t), (40.0, 147.5, 160.0, 152.5));
let released = t.stroke_json();
assert!(released.as_array().is_some_and(|a| a.iter().all(|p| p.as_array().is_some_and(|p| p.len() == 3))), "{released}");
// One entry per press so far (the press and two drags), each of three numbers.
assert!(released.as_array().is_some_and(|a| a.len() == 3 && a.iter().all(|p| p.as_array().is_some_and(|p| p.len() == 3))), "{released}");
press(&mut t, upright, 0.5, PointerKind::Up, 150.0);
}
+1 -3
View File
@@ -139,9 +139,7 @@ fn actions_cycle_and_name_themselves() {
assert_eq!(Stroke::Line.next(), Stroke::ContinuousArc);
assert_eq!(Stroke::ContinuousArc.next(), Stroke::SharpArc);
assert_eq!(Stroke::SharpArc.next(), Stroke::Line);
for s in Stroke::ALL {
assert_eq!(Stroke::parse(s.name()), Some(s));
}
assert_eq!(Stroke::parse("sharpArc"), Some(Stroke::SharpArc));
assert_eq!(Stroke::parse("arc"), None);
}
+3 -1
View File
@@ -451,7 +451,9 @@ mod tests {
let want = parents_by_pairs(&paths, 200, 200, stacked);
let pairs = BOX_TESTS.with(std::cell::Cell::get);
assert_eq!(found, want, "stacked {stacked}");
assert!(want.iter().skip(1).all(Option::is_some), "stacked {stacked}: {want:?}");
// Each disc lies inside the one below it, the smallest that holds it.
let chain: Vec<Option<usize>> = (0..paths.len()).map(|i| i.checked_sub(1)).collect();
assert_eq!(want, chain, "stacked {stacked}");
assert!(tests <= pairs, "stacked {stacked}: {tests} box tests, {pairs} by pairs");
}
}
+7 -1
View File
@@ -189,7 +189,13 @@ mod tests {
}
let (r, step) = resample_closed(&pts, 0.12).expect("resample");
let s0 = smooth_closed(&r, 0.18 / step);
let _ = restore_corners(&r, &s0, step, &RestoreParams { min_turn: 30.0, ..RestoreParams::default() });
// The bend at (20, 0) is a candidate (turn 10), and only the minimum turn decides it.
let bend = |min_turn: f64| {
let (out, forced) = restore_corners(&r, &s0, step, &RestoreParams { turn: 10.0, min_turn, ..RestoreParams::default() });
forced.iter().map(|&i| out[i].distance(Point::new(20.0, 0.0))).fold(f64::MAX, f64::min)
};
assert!(bend(30.0) > 1.0, "a 20 degree bend under a 30 degree minimum: {} px from a corner", bend(30.0));
assert!(bend(10.0) < 0.1, "under a 10 degree minimum it is one: {} px off", bend(10.0));
}
#[test]
+5 -5
View File
@@ -912,11 +912,11 @@ fn snap_curves_to_lines_straightens_near_lines() {
#[test]
fn presets_resolve() {
assert_eq!(presets().len(), 15);
for n in PRESET_NAMES {
assert!(preset(n).is_some(), "{n}");
}
assert!(preset("[Default]").is_some());
// Every name resolves: `presets` leaves out a name `preset` does not know.
assert_eq!(PRESET_NAMES.len(), 15);
assert_eq!(presets().len(), PRESET_NAMES.len());
assert_eq!(preset("[Default]"), preset("Default"));
assert_eq!(preset(" Line Art "), preset("line art"));
assert_eq!(preset("16 colors").unwrap().colors, 16);
assert_eq!(preset("Shades of Gray").unwrap().mode, Mode::Grayscale);
assert_eq!(preset("flat logo").unwrap().mode, Mode::Logo);
@@ -53,12 +53,24 @@ fn browser_picks_load_and_replace_action_sets_without_a_file_reader() {
}
}
/// Each built-in action plays on a selection it applies to (text for Outline Text, two
/// overlapping rectangles otherwise) and edits the drawing, so its commands and their
/// parameters are ones the engine accepts.
#[test]
fn defaults_are_valid_commands() {
for a in default_sets().actions {
for step in a.steps {
assert!(vectorcraft_engine::find_command(&step.command).is_some(), "{}", step.command);
}
fn built_in_actions_play_and_edit_the_drawing() {
for (idx, a) in default_sets().actions.iter().enumerate() {
let mut app = new_app();
app.run("file.new", json!({"width": 400, "height": 400})).unwrap();
let ids: Vec<Value> = if a.steps.iter().any(|s| s.command.starts_with("type.")) {
vec![app.run("text.create", json!({"x": 20, "y": 40, "text": "Ab"})).unwrap()["id"].clone()]
} else {
[10, 30].iter().map(|x| app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 40, "height": 40})).unwrap()["id"].clone()).collect()
};
app.run("select.set", json!({ "ids": ids })).unwrap();
app.ui.actions = default_list();
let before = undo_steps(&app);
play(&mut app, 0, idx).unwrap_or_else(|e| panic!("{}: {e}", a.name));
assert!(undo_steps(&app) > before, "{} edits the drawing", a.name);
}
}
+32 -16
View File
@@ -7,6 +7,18 @@ use vectorcraft_doc::text::TypeAntiAlias;
use vectorcraft_doc::{CharStyle, NodeId, NodeKind};
use vectorcraft_engine::Session;
/// The different values in `items`, in the order they first appear: `[v]` when every item is `v`,
/// and empty when there are no items.
fn distinct<T: PartialEq>(items: impl IntoIterator<Item = T>) -> Vec<T> {
let mut out = Vec::new();
for item in items {
if !out.contains(&item) {
out.push(item);
}
}
out
}
/// `value` is `want` (the panel's fields are single precision).
fn near(value: Option<f32>, want: f64) -> bool {
value.is_some_and(|v| (f64::from(v) - want).abs() < 1e-6)
@@ -844,14 +856,16 @@ fn underline_command_underlines_a_mixed_selection() {
let id = app.run("text.create", json!({"x": 20, "y": 50, "text": "AB", "size": 12})).unwrap()["id"].as_u64().unwrap();
app.run("text.setRangeStyle", json!({"id": id, "start": 0, "end": 1, "underline": true})).unwrap();
app.run("select.set", json!({"ids": [id]})).unwrap();
// The underlined characters, in order.
let underlined = |app: &VectorcraftApp| match &app.session.active().unwrap().doc.node(NodeId(id)).unwrap().kind {
NodeKind::Text(t) => t.runs.iter().map(|r| r.style.underline).collect::<Vec<_>>(),
NodeKind::Text(t) => t.runs.iter().filter(|r| r.style.underline).map(|r| r.text.as_str()).collect::<String>(),
_ => panic!("text"),
};
assert_eq!(underlined(&app), "A");
assert_eq!(super::toggle_underline(&mut app), Ok(json!(true)));
assert!(underlined(&app).iter().all(|u| *u), "{:?}", underlined(&app));
assert_eq!(underlined(&app), "AB");
assert_eq!(super::toggle_underline(&mut app), Ok(json!(false)));
assert!(underlined(&app).iter().all(|u| !*u), "{:?}", underlined(&app));
assert_eq!(underlined(&app), "");
}
/// At a caret in text the Type tool edits, with no characters selected, the Character
@@ -902,15 +916,15 @@ fn kashidas_menu_item_handles_default_and_mixed_ranges() {
assert!(!state(&app, &row).1);
fire(&mut app, &row);
assert!(state(&app, &row).1);
let kashidas = |app: &VectorcraftApp| story_frame(app, id).runs.iter().map(|r| r.style.kashidas).collect::<Vec<_>>();
assert!(kashidas(&app).iter().all(|v| *v));
let kashidas = |app: &VectorcraftApp| distinct(story_frame(app, id).runs.iter().map(|r| r.style.kashidas));
assert_eq!(kashidas(&app), [true]);
app.select_tool("type");
app.session.apply_actions(vec![vectorcraft_tools::Action::Notify("text.editNew".into())]).unwrap();
app.session.set_tool_option("select", &json!({"start": 1, "end": 1}));
assert!(!state(&app, &row).0, "disabled at an empty caret");
// The result is not the point: a disabled row must leave the text as it was.
let _ = run(&mut app, &row.id, &row.params);
assert!(kashidas(&app).iter().all(|v| *v), "an empty caret leaves all characters unchanged");
assert_eq!(kashidas(&app), [true], "an empty caret leaves all characters unchanged");
}
/// Reset Panel sets every character attribute the panel shows, except the font family, style
@@ -1112,7 +1126,7 @@ fn select_all_in_threaded_text_formats_and_copies_the_whole_story() {
crate::panels::paragraph::run_on_paragraphs(&mut app, "text.setFormat", json!({"spaceBefore": 4})).unwrap();
for id in [a, b] {
let t = frame(&app, id);
assert!(t.runs.iter().all(|r| (r.style.size - 9.0).abs() < 1e-9), "every character of frame {id} is 9 pt");
assert_eq!(distinct(t.runs.iter().map(|r| r.style.size)), [9.0], "every character of frame {id} is 9 pt");
assert!((t.para_at(0).space_before - 4.0).abs() < 1e-9, "frame {id}'s paragraphs take the space");
}
assert!(intercept_text_command(&mut app, "edit.copy").is_some());
@@ -1174,9 +1188,9 @@ fn story_changes_follow_the_edited_frames_thread_after_the_first_saved_frame_lea
assert_eq!(text_story(&app), Some(vec![NodeId(b), NodeId(c)]));
format(&mut app, json!({"size": 9}));
assert!(story_sizes(&app, a).iter().all(|s| (*s - 12.0).abs() < 1e-9), "the frame that left keeps its size");
assert_eq!(distinct(story_sizes(&app, a)), [12.0], "the frame that left keeps its size");
for id in [b, c] {
assert!(story_sizes(&app, id).iter().all(|s| (*s - 9.0).abs() < 1e-9), "frame {id} takes the size");
assert_eq!(distinct(story_sizes(&app, id)), [9.0], "frame {id} takes the size");
}
}
@@ -1262,26 +1276,28 @@ fn selection_tool_changes_reach_every_frame_of_the_story() {
style(&mut app, json!({"size": 9}));
assert_eq!(undo_steps(&app), steps + 1, "one undo step");
for id in frames {
assert!(story_sizes(&app, id).iter().all(|s| (*s - 9.0).abs() < 1e-9), "frame {id} takes the size");
assert_eq!(distinct(story_sizes(&app, id)), [9.0], "frame {id} takes the size");
}
assert!(story_sizes(&app, other).iter().all(|s| (*s - 12.0).abs() < 1e-9), "other type keeps its size");
assert_eq!(distinct(story_sizes(&app, other)), [12.0], "other type keeps its size");
app.run("edit.undo", json!({})).unwrap();
for id in frames {
assert!(story_sizes(&app, id).iter().all(|s| (*s - 12.0).abs() < 1e-9), "undo gives frame {id} its size back");
assert_eq!(distinct(story_sizes(&app, id)), [12.0], "undo gives frame {id} its size back");
}
format(&mut app, json!({"underline": true}));
let underline = |app: &VectorcraftApp, id: u64| distinct(story_frame(app, id).runs.iter().map(|r| r.style.underline));
for id in frames {
assert!(story_frame(&app, id).runs.iter().all(|r| r.style.underline), "frame {id} is underlined");
assert_eq!(underline(&app, id), [true], "frame {id} is underlined");
}
assert!(story_frame(&app, other).runs.iter().all(|r| !r.style.underline));
assert_eq!(underline(&app, other), [false]);
// Tate-chu-yoko Settings and Warichu Settings set their values through `run_format`.
run_format(&mut app, json!({"tcyUpDown": 2})).unwrap();
let up_down = |app: &VectorcraftApp, id: u64| distinct(story_frame(app, id).runs.iter().map(|r| r.style.tcy_up_down));
for id in frames {
assert!(story_frame(&app, id).runs.iter().all(|r| (r.style.tcy_up_down - 2.0).abs() < 1e-9), "frame {id} takes Up/Down");
assert_eq!(up_down(&app, id), [2.0], "frame {id} takes Up/Down");
}
assert!(story_frame(&app, other).runs.iter().all(|r| r.style.tcy_up_down.abs() < 1e-9));
assert_eq!(up_down(&app, other), [0.0]);
}
/// The fields show a value only when every frame of the selected story has it: a hidden frame that
+10 -7
View File
@@ -208,9 +208,7 @@ fn east_asian_glyph_forms_in_the_panel_menu_set_the_selected_characters_form() {
assert!(!rows(&app).contains(&form_ref(GlyphForm::Jis78)), "hidden without Show East Asian Options");
app.session.prefs.show_east_asian_options = true;
let shown = rows(&app);
for form in GlyphForm::ALL {
assert!(shown.contains(&form_ref(form)), "{form:?} in {shown:?}");
}
assert!(shown.contains(&form_ref(GlyphForm::Jis78)), "shown with Show East Asian Options: {shown:?}");
const FAMILY: &str = "BIZ UDMincho";
if FontDb::global().face(FAMILY, "Regular").is_none_or(|f| f.family != FAMILY) {
eprintln!("skipped: built without craft-fonts (set CRAFT_FONTS_DIR to a craft-fonts checkout to run it)");
@@ -231,7 +229,7 @@ fn east_asian_glyph_forms_in_the_panel_menu_set_the_selected_characters_form() {
app.run("text.setRangeStyle", json!({"id": id, "start": 0, "end": 3, "font": fallback})).unwrap();
select(&mut app, 0, 6);
choose(&mut app, GlyphForm::Jis83);
assert!(forms(&app).iter().all(|(_, f)| *f == GlyphForm::Jis83), "{:?}", forms(&app));
assert_eq!(in_form(&forms(&app), GlyphForm::Jis83), "亜唖", "{:?}", forms(&app));
app.run("text.setRangeStyle", json!({"id": id, "start": 0, "end": 3, "font": FAMILY})).unwrap();
app.run("text.setRangeStyle", json!({"id": id, "glyphForm": "default"})).unwrap();
select(&mut app, 3, 6);
@@ -244,7 +242,12 @@ fn east_asian_glyph_forms_in_the_panel_menu_set_the_selected_characters_form() {
assert_eq!(undo_len(&app), n);
assert_eq!(forms(&app)[1].1, GlyphForm::Jis78);
choose(&mut app, GlyphForm::Default);
assert!(forms(&app).iter().all(|(_, f)| *f == GlyphForm::Default), "{:?}", forms(&app));
assert_eq!(in_form(&forms(&app), GlyphForm::Default), "亜唖", "{:?}", forms(&app));
}
/// The characters of `runs` (text and form) drawn in `form`, in order.
fn in_form(runs: &[(String, GlyphForm)], form: GlyphForm) -> String {
runs.iter().filter(|(_, f)| *f == form).map(|(text, _)| text.as_str()).collect()
}
/// At a caret the glyph form rows act on all the text of the object, so they are checked, and skipped as changing nothing, by
@@ -256,14 +259,14 @@ fn glyph_form_items_at_a_caret_follow_all_the_text() {
app.session.prefs.show_east_asian_options = true;
let node = NodeId(id.as_u64().unwrap_or(0));
let forms = |app: &VectorcraftApp| match &app.session.active().unwrap().doc.node(node).unwrap().kind {
NodeKind::Text(t) => t.runs.iter().map(|r| r.style.glyph_form).collect::<Vec<_>>(),
NodeKind::Text(t) => t.runs.iter().map(|r| (r.text.clone(), r.style.glyph_form)).collect::<Vec<_>>(),
_ => panic!("text"),
};
app.run("text.setRangeStyle", json!({"id": id, "start": 0, "end": 3, "glyphForm": "jis78"})).unwrap();
select(&mut app, 6, 6);
assert_eq!(selection_glyph_form(&app), None, "the caret's form is not every character's");
choose(&mut app, GlyphForm::Default);
assert!(forms(&app).iter().all(|f| *f == GlyphForm::Default), "{:?}", forms(&app));
assert_eq!(in_form(&forms(&app), GlyphForm::Default), "亜唖", "{:?}", forms(&app));
app.run("text.setRangeStyle", json!({"id": id, "glyphForm": "jis78"})).unwrap();
select(&mut app, 6, 6);
assert_eq!(selection_glyph_form(&app), Some(GlyphForm::Jis78));
+2 -1
View File
@@ -1756,7 +1756,8 @@ mod tests {
let app = panel.app();
let names: Vec<Vec<String>> =
app.session.documents().iter().map(|st| st.doc.graphic_styles.iter().map(|g| g.name.clone()).collect()).collect();
assert!(names.iter().all(|n| n.iter().any(|g| g == "Mine")), "no style is renamed: {names:?}");
let kept = names.iter().filter(|n| n.iter().any(|g| g == "Mine")).count();
assert_eq!(kept, 2, "both documents keep their style named Mine: {names:?}");
}
/// The New and Delete buttons name what an Alt-click does, and an Alt-click does it: New asks for a name, Delete
+14 -5
View File
@@ -292,6 +292,15 @@ mod tests {
use crate::tests::panel_harness::Panel;
use craft::ui::contract::Role;
/// English and two translated interface languages, one of them with another script.
fn some_languages() -> [crate::i18n::Lang; 3] {
[
crate::i18n::Lang::EN,
crate::i18n::Lang::from_code("de").expect("de registered"),
crate::i18n::Lang::from_code("ja").expect("ja registered"),
]
}
/// A step named after a style lists the template's translation with the style's name in it as
/// the document holds it, also when the name looks like a template, like a step with a row of
/// its own (`Apply Brush`) or like another template's name; the Normal style's name is
@@ -338,7 +347,7 @@ mod tests {
/// plain row, else the menu item's row without the ellipsis; a name with no row has none.
#[test]
fn plain_steps_read_the_menu_row_and_unknown_steps_have_no_name() {
for lang in crate::i18n::Lang::all() {
for lang in some_languages() {
let menu_row = crate::i18n::has(lang, "Clean Up…").then(|| crate::i18n::tr(lang, "Clean Up…").trim_end_matches('…').to_string());
let plain_row = crate::i18n::has(lang, "Clean Up").then(|| crate::i18n::tr(lang, "Clean Up").to_string());
assert_eq!(step_name(lang, "Clean Up"), plain_row.or(menu_row), "{}", lang.code());
@@ -347,7 +356,7 @@ mod tests {
assert_eq!(step_name(ja, "No Such Step"), None);
}
/// Every built-in effect has one name in each language: History (and Edit › Undo and Redo)
/// Every built-in effect has one name in each language checked: History (and Edit › Undo and Redo)
/// names the step that applied it, and the Appearance panel its row, with the text of its
/// Effect menu item without the ellipsis, which is the effect's `@id` row or the row of its
/// menu label with the ellipsis.
@@ -366,7 +375,7 @@ mod tests {
}
assert!(steps.len() * 2 > vectorcraft_effects::effect_catalog().len(), "only {} effects applied", steps.len());
let mut differ = Vec::new();
for lang in crate::i18n::Lang::all() {
for lang in some_languages() {
crate::i18n::set_current(lang);
for (e, h) in &steps {
let cmd = if e.defaults.as_object().is_some_and(|o| o.is_empty()) { "effect.apply" } else { "effect.dialog" };
@@ -385,14 +394,14 @@ mod tests {
}
/// A step another command names like an effect (Object › Transform's `Transform`, the name of
/// Distort & Transform › Transform) keeps its own name in every language.
/// Distort & Transform › Transform) keeps its own name in each language checked.
#[test]
fn a_step_named_like_an_effect_keeps_its_own_name() {
let mut app = app_with_two_rectangles();
app.session.execute("object.transform", &json!({ "matrix": [1, 0, 0, 1, 5, 0] })).unwrap();
let h = app.session.active().unwrap().history.undo.last().cloned().unwrap();
assert_eq!((h.label.as_str(), h.effect()), ("Transform", None));
for lang in crate::i18n::Lang::all() {
for lang in some_languages() {
assert_eq!(entry_name(lang, &h), step_name(lang, "Transform"), "{}", lang.code());
}
}
@@ -1280,11 +1280,7 @@ fn a_trace_off_the_ui_thread_is_adopted_when_it_lands() {
assert_eq!(undo(&panel.app()), steps, "not traced yet");
{
let mut app = panel.app();
let t0 = std::time::Instant::now();
while !app.trace_runs.running.is_empty() && t0.elapsed() < std::time::Duration::from_secs(30) {
crate::trace_runs::poll(&mut app);
std::thread::sleep(std::time::Duration::from_millis(5));
}
crate::trace_runs::finish_all(&mut app);
assert_eq!(undo(&app), steps + 1, "one undo step");
assert_eq!(param(&app, "strokes"), Some(json!(true)));
let st = &app.ui.image_trace_panel.shown;
+15 -6
View File
@@ -887,6 +887,7 @@ mod tests {
let r = toggle_ref(tag);
assert!(rows.iter().any(|row| matches!(row, PanelRow::Submenu(_, sub) if has_row(sub, &r))), "the submenu has a row for {tag}");
}
// Only an installed face without bundled fonts can offer no set; the rows above are checked.
let Some((first, flag, _)) = sets.first() else { return };
let (label, tag) = (set_label(first), flag.tag().unwrap());
set(&mut app, OtFeatures { small_caps: true, ..Default::default() });
@@ -972,7 +973,9 @@ mod tests {
assert_eq!(state_of(&app, &toggle_ref(tag)), Some(toggled(label, false)), "{label}");
run(&mut app, TOGGLE, &json!({"tag": tag})).unwrap().unwrap();
let runs = run_features(&mut app, &id, 8);
assert!(runs.iter().all(|(_, f)| f.as_array().is_some_and(|f| f.iter().any(|x| x == tag))), "{label}: {runs:?}");
let tagged: String =
runs.iter().filter(|(_, f)| f.as_array().is_some_and(|f| f.iter().any(|x| x == tag))).map(|(t, _)| t.as_str()).collect();
assert_eq!(tagged, "かなAB", "{label}: {runs:?}");
}
}
@@ -1023,6 +1026,11 @@ mod tests {
}
}
/// The characters of `runs` ([`metrics_runs`]) whose Proportional Metrics and features `keep` accepts.
fn text_where(runs: &[(String, bool, Vec<String>)], keep: impl Fn(bool, &[String]) -> bool) -> String {
runs.iter().filter(|(_, on, f)| keep(*on, f)).map(|(t, _, _)| t.as_str()).collect()
}
/// Where the panel menu's top-level rows list the command `r`.
fn row_index(rows: &[PanelRow], r: &CommandRef) -> Option<usize> {
rows.iter().position(|row| matches!(row, PanelRow::Command(c) if c == r))
@@ -1068,13 +1076,14 @@ mod tests {
assert_eq!(run(&mut app, METRICS, &json!({})), Some(Ok(json!({"on": true}))));
assert_eq!(undo_steps(&app), undo + 1);
let runs = metrics_runs(&app, &id);
assert!(runs.iter().all(|(_, on, _)| *on), "{runs:?}");
assert_eq!(runs.iter().map(|(t, _, f)| (t.as_str(), f.clone())).collect::<Vec<_>>(), [("か", vec!["smcp".to_string()]), ("なAB", vec![])]);
assert_eq!(runs, [("か".to_string(), true, vec!["smcp".to_string()]), ("なAB".to_string(), true, vec![])]);
assert_eq!(state_of(&app, &metrics), Some(toggled("Proportional Metrics", true)));
assert_eq!(run(&mut app, METRICS, &json!({})), Some(Ok(json!({"on": false}))));
assert_eq!(undo_steps(&app), undo + 2);
let runs = metrics_runs(&app, &id);
assert!(runs.iter().all(|(_, on, f)| !*on && (f.is_empty() || *f == ["smcp"])), "{runs:?}");
assert_eq!(text_where(&runs, |on, _| on), "", "{runs:?}");
assert_eq!(text_where(&runs, |_, f| f == ["smcp"]), "か", "each run keeps its features: {runs:?}");
assert_eq!(text_where(&runs, |_, f| f.is_empty()), "なAB", "{runs:?}");
}
/// With the Selection tool, Proportional Metrics turns on for the whole selected object. At a
@@ -1089,7 +1098,7 @@ mod tests {
let id = app.session.execute("text.create", &json!({"x": 10, "y": 40, "text": "かなAB"})).unwrap()["id"].clone();
app.session.execute("select.set", &json!({"ids": [id]})).unwrap();
run(&mut app, METRICS, &json!({})).unwrap().unwrap();
assert!(metrics_runs(&app, &id).iter().all(|(_, on, _)| *on), "{:?}", metrics_runs(&app, &id));
assert_eq!(text_where(&metrics_runs(&app, &id), |on, _| on), "かなAB");
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
app.session.prefs.show_east_asian_options = true;
@@ -1104,7 +1113,7 @@ mod tests {
assert_eq!(state_of(&app, &CommandRef::new(METRICS)), Some(toggled("Proportional Metrics", false)));
run(&mut app, METRICS, &json!({})).unwrap().unwrap();
let runs = metrics_runs(&app, &id);
assert!(runs.iter().all(|(_, on, _)| *on), "{runs:?}");
assert_eq!(text_where(&runs, |on, _| on), "かなAB", "{runs:?}");
}
/// With Real-time Drawing off, Proportional Metrics and H or V Style decide from the text with
+4 -6
View File
@@ -282,7 +282,7 @@ fn kinsoku_set_shows_a_custom_set_by_name() {
}
/// The Mojikumi Set menu lists None, the four other predefined sets and Line-end Punctuation Half
/// Width, each under its own label in every interface language. Each entry sets the selected
/// Width, each under its own label in English and in Japanese. Each entry sets the selected
/// paragraphs' set in one undo step and is shown as the current set; paragraphs with different
/// sets show a blank menu, and Reset Panel gives them Line-end Punctuation Half Width.
#[test]
@@ -290,7 +290,7 @@ fn mojikumi_menu_offers_and_sets_every_predefined_set() {
let keys: Vec<&str> = mojikumi_sets().iter().map(|s| s.2).collect();
assert_eq!(keys, ["none", "yakumonoHankaku", "gyomatsuYakumonoHankaku", "gyomatsuYakumonoZenkaku", "yakumonoZenkaku", "lineEndHalf"]);
use crate::i18n::LangExt as _;
for lang in crate::i18n::Lang::all() {
for lang in [crate::i18n::Lang::EN, crate::i18n::Lang::from_code("ja").expect("ja registered")] {
crate::i18n::set_current(lang);
let labels: std::collections::BTreeSet<&str> = mojikumi_sets().iter().map(|s| s.0).collect();
crate::i18n::set_current(crate::i18n::Lang::EN);
@@ -680,10 +680,8 @@ fn the_numbered_list_button_and_its_presets_set_the_list_and_reset_panel_clears_
assert_eq!(lists(&app), (numbered(NumberStyle::Arabic), None), "the caret's paragraph");
assert_eq!(numbers_shown(&app), Some(Some(NumberStyle::Arabic)), "the button shows pressed");
assert_eq!(number_sample(NumberStyle::UpperRoman, 3), "I, II, III");
for style in NumberStyle::ALL {
set_number_style(&mut app, Some(style));
assert_eq!(lists(&app), (numbered(style), None), "{}", number_sample(style, 3));
}
set_number_style(&mut app, Some(NumberStyle::UpperRoman));
assert_eq!(lists(&app), (numbered(NumberStyle::UpperRoman), None), "a preset picks its style");
set_number_style(&mut app, None);
assert_eq!(lists(&app), (None, None));
app.session.set_tool_option("selectAll", &json!(true));
+20 -3
View File
@@ -29,6 +29,10 @@ pub struct PropertiesUi {
quick_actions: Option<(u64, Vec<QuickAction>)>,
/// The [`content_key`] the sections were last shown for.
content: Option<u64>,
/// The document (uid, revision) the sections were last shown for.
revision: Option<(u64, u64)>,
/// An edit made during a drag whose sections are not measured yet.
measure_pending: bool,
}
/// The key of [`PropertiesUi::edited_profiled`]: (document uid, revision, active Appearance row).
@@ -66,7 +70,16 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let guides = super::transform::selected_guides(app);
let header = heading(first.as_deref(), n_sel, editing_artboards, guides.is_some());
let content = content_key(app);
let changed = app.ui.properties_panel.content.replace(content) != Some(content);
let revision = app.session.active().map(|st| (st.uid, st.revision));
let content_changed = app.ui.properties_panel.content.replace(content) != Some(content);
let edited = std::mem::replace(&mut app.ui.properties_panel.revision, revision) != revision;
// A drag on the canvas, or a scrubbed field, moves the revision on every pointer move without changing which
// sections show: the sections are measured again for an edit once the drag ends, not on each move. The edit stays
// pending until then, also when the release itself does not move the revision.
let dragging = app.session.active().is_some_and(|st| st.interaction.is_some() || st.undo_group.is_some());
let pending = app.ui.properties_panel.measure_pending || edited;
let changed = content_changed || (pending && !dragging);
app.ui.properties_panel.measure_pending = pending && !changed;
let mut sections = |ui: &mut Ui, _: &mut BodyCx<'_>| {
// The reference panel's labels end in a colon beside fields that keep their own width.
Stack::new().fill_width().labels(LabelScheme::Form).show(ui, |ui, _| {
@@ -87,19 +100,21 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let mut panel = Panel::new(header).titled().strength(HeaderStrength::Quiet).labels(LabelScheme::Inspector).pad(Pad::None);
panel = panel.id_salt(egui::IdSalt::new(key));
if changed {
#[cfg(test)]
SECTION_MEASURES.with(|n| n.set(n.get() + 1));
let _ = panel.measure_in(ui, Proposal::Size(ui.available_size()), &mut sections);
}
panel.show(ui, sections);
}
/// What the sections show: the document and its revision, the selection, the tool and isolation mode.
/// What the sections show besides the document's revision: the document, the selection, the tool and isolation mode.
fn content_key(app: &VectorcraftApp) -> u64 {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
app.session.tool_id().hash(&mut h);
if let Some(st) = app.session.active() {
let selection = &st.selection;
(st.uid, st.revision, st.isolation, &selection.objects, selection.key, selection.target, &selection.slices).hash(&mut h);
(st.uid, st.isolation, &selection.objects, selection.key, selection.target, &selection.slices).hash(&mut h);
for (id, anchors) in &selection.anchors {
(id, anchors.len()).hash(&mut h);
}
@@ -223,6 +238,8 @@ fn quick_actions_key(app: &VectorcraftApp) -> u64 {
thread_local! {
/// How many times this thread has listed the Quick Actions.
pub(crate) static QUICK_ACTION_LISTS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
/// How many times this thread has measured the panel's sections before showing them.
pub(crate) static SECTION_MEASURES: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
}
/// [`quick_actions`], listed again only when [`quick_actions_key`] changed.
@@ -190,6 +190,94 @@ fn a_selection_change_draws_the_window_in_one_pass() {
}
}
/// Dragging the selected object with the Selection tool, with the Properties panel docked, does not measure the
/// panel's sections on each pointer move, and each frame of the drag takes one pass. The release measures them once
/// for the moved object, and so does an edit made without a drag.
#[test]
fn a_drag_does_not_measure_the_sections_on_each_move() {
let measures = || SECTION_MEASURES.with(std::cell::Cell::get);
let mut app = new_app();
let a = rect(&mut app, 100.0, 100.0, 80.0, 80.0);
app.run("select.set", json!({"ids": [a]})).unwrap();
app.run("window.panel", json!({"panel": "properties"})).unwrap();
app.select_tool("selection");
let ctx = crate::testing::ui_context();
let mut time = 0.0;
// One frame with `events` → (the passes it took, the section measures it made).
let mut frame = |app: &mut VectorcraftApp, events: Vec<Event>| {
time += 1.0 / 60.0;
let raw = egui::RawInput {
time: Some(time),
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))),
focused: true,
events,
..Default::default()
};
let (pass, measured) = (ctx.cumulative_pass_nr(), measures());
let _ = crate::testing::app_frame(app, &ctx, raw);
(ctx.cumulative_pass_nr() - pass, measures() - measured)
};
for _ in 0..4 {
frame(&mut app, vec![]);
}
let x = |app: &VectorcraftApp| {
let st = app.session.active().unwrap();
st.selection.objects.first().and_then(|id| st.doc.node(*id)).and_then(|n| n.geometric_bounds()).unwrap().x0
};
let start_x = x(&app);
let start = app.canvas_view().unwrap().to_screen(craft::behavior::kurbo::Point::new(140.0, 140.0));
let button = |pos, pressed| Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
frame(&mut app, vec![Event::PointerMoved(start)]);
assert_eq!(frame(&mut app, vec![button(start, true)]), (1, 0), "the press");
let mut at = start;
for step in 1..=6 {
at = start + egui::vec2(8.0 * step as f32, 5.0 * step as f32);
assert_eq!(frame(&mut app, vec![Event::PointerMoved(at)]), (1, 0), "move {step} of the drag");
}
assert_eq!(frame(&mut app, vec![button(at, false)]), (1, 1), "the release measures the moved object's sections once");
assert!(x(&app) > start_x, "the drag moved the object");
assert_eq!(frame(&mut app, vec![]).1, 0, "a settled frame");
app.run("object.move", json!({"dx": 5, "dy": 0})).unwrap();
assert_eq!(frame(&mut app, vec![]).1, 1, "an edit without a drag measures the sections");
}
/// An edit made while an undo group is open, as a scrubbed field's drag makes, is measured once the group ends, also
/// when ending it does not move the document's revision.
#[test]
fn an_edit_during_a_drag_is_measured_when_the_drag_ends_without_a_new_revision() {
let measures = || SECTION_MEASURES.with(std::cell::Cell::get);
let mut app = new_app();
let a = rect(&mut app, 100.0, 100.0, 80.0, 80.0);
app.run("select.set", json!({"ids": [a]})).unwrap();
app.run("window.panel", json!({"panel": "properties"})).unwrap();
let ctx = crate::testing::ui_context();
let mut time = 0.0;
let mut frame = |app: &mut VectorcraftApp| {
time += 1.0 / 60.0;
let raw = egui::RawInput {
time: Some(time),
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))),
focused: true,
..Default::default()
};
let measured = measures();
let _ = crate::testing::app_frame(app, &ctx, raw);
measures() - measured
};
for _ in 0..4 {
frame(&mut app);
}
app.run("edit.undoGroup.begin", json!({})).unwrap();
assert_eq!(frame(&mut app), 0, "opening the group");
app.run("object.move", json!({"dx": 5, "dy": 0})).unwrap();
assert_eq!(frame(&mut app), 0, "an edit inside the group");
let revision = app.session.active().unwrap().revision;
app.run("edit.undoGroup.end", json!({})).unwrap();
assert_eq!(app.session.active().unwrap().revision, revision, "ending the group keeps the revision");
assert_eq!(frame(&mut app), 1, "the end of the group measures the edit");
assert_eq!(frame(&mut app), 0, "a settled frame");
}
/// Start Global Edit in Quick Actions starts it on the one selected path, the button then reads
/// Stop Global Edit, and Escape stops it. Selected type has no Start Global Edit button.
#[test]
+7 -3
View File
@@ -903,11 +903,15 @@ mod tests {
let r = Rect::from_min_size(pos2(10.0, 10.0), egui::vec2(80.0, 16.0));
let (top, bottom) = profile_outline(r, 1.0, Some(&[(0.0, 1.0, 1.0), (0.5, 10.0, 10.0), (1.0, 1.0, 1.0)]));
let all: Vec<_> = top.iter().chain(&bottom).collect();
assert!(all.iter().all(|p| p.y >= r.top() && p.y <= r.bottom()), "{all:?}");
let middle = all.iter().map(|p| (p.y - r.center().y).abs()).fold(0.0, f32::max);
let (highest, lowest) = all.iter().fold((f32::INFINITY, f32::NEG_INFINITY), |(lo, hi), p| (lo.min(p.y), hi.max(p.y)));
assert!(highest >= r.top() && lowest <= r.bottom(), "the outline stays in its box: {all:?}");
// How far the outline reaches from the box's middle line.
let reach = |top: &[egui::Pos2], bottom: &[egui::Pos2]| top.iter().chain(bottom).map(|p| (p.y - r.center().y).abs()).fold(0.0, f32::max);
let middle = reach(&top, &bottom);
assert!((middle - (r.height() / 2.0 - 1.0)).abs() < 1e-3, "the widest point fills the box ({middle})");
let (top, bottom) = profile_outline(r, 1.0, None);
assert!(top.iter().chain(&bottom).all(|p| (p.y - r.center().y).abs() <= 0.35 * (r.height() / 2.0 - 1.0) + 1e-3));
let plain = reach(&top, &bottom);
assert!(plain > 0.0 && plain <= 0.35 * (r.height() / 2.0 - 1.0) + 1e-3, "the plain bar keeps its look ({plain})");
}
#[test]
@@ -23,7 +23,9 @@ fn item_commands_run_on_the_clicked_swatch_and_paint_nothing() {
let mut app = app();
select_rows(&mut app, &["Black"]);
let (before, paint, undo) = (doc(&app), app.session.paint.fill.clone(), undo_steps(&app));
assert!(enabled(&app, "Red").iter().all(|(_, on)| *on), "every item is enabled on a user swatch");
let items = enabled(&app, "Red");
assert_eq!(items.len(), ITEMS.len(), "{items:?}");
assert!(items.iter().all(|(_, on)| *on), "every item is enabled on a user swatch: {items:?}");
menu(&mut app, "Red", "options");
assert_eq!(dialog_field(&app, KIND, "name"), json!("Red"));
assert_eq!((doc(&app), undo_steps(&app)), (before.clone(), undo), "opening the dialog changes nothing");
@@ -103,23 +103,21 @@ fn ui_color_wheel_sets_and_reads_the_view_and_the_channel() {
assert_eq!(ui["ui"]["color_wheel"], with(json!({"view": "box", "channel": "green"})));
}
/// The command's errors are translated in the catalogs that translate status and error messages,
/// and each translation keeps the accepted values.
/// The command's errors are shown in the interface language (German and Japanese here), and each
/// translation keeps the accepted values.
#[test]
fn ui_color_wheel_errors_are_translated() {
let errors = [
("`view` must be wheel or box", &["wheel", "box"][..]),
("`channel` must be hue, saturation, brightness, red, green or blue", &["hue", "saturation", "brightness", "red", "green", "blue"][..]),
];
for code in [
"cs", "de", "el", "es", "fr", "hi", "hu", "it", "ja", "ka", "ko", "pl", "pt-br", "ru", "sv", "uk", "vi", "zh-hans", "zh-hant", "fi", "tr",
"ca", "nl", "bs", "da", "id",
] {
for code in ["de", "ja"] {
let lang = crate::i18n::Lang::from_code(code).expect("registered");
for (error, values) in errors {
let shown = crate::i18n::message(lang, error);
assert_ne!(shown, error, "{code}");
assert!(values.iter().all(|v| shown.contains(v)), "{code}: {shown}");
let missing: Vec<&str> = values.iter().copied().filter(|v| !shown.contains(v)).collect();
assert!(missing.is_empty(), "{code}: {shown} lacks {missing:?}");
}
}
}
@@ -147,16 +145,6 @@ fn ui_color_wheel_rejects_other_params() {
assert_eq!(app.ui.color_wheel, Settings { view: View::Box, channel: Channel::Red, ..Default::default() }, "an error changes nothing");
}
/// `ui.colorWheel` answers every junk parameter without a panic.
#[test]
fn ui_color_wheel_answers_junk_params_without_a_panic() {
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == "ui.colorWheel").expect("registered").3;
let mut app = app(json!("#336699"), "hue");
for p in vectorcraft_testkit::strategies::junk_params(doc, "/nonexistent").into_iter().chain(vectorcraft_testkit::strategies::junk_values()) {
let _ = app.run("ui.colorWheel", p);
}
}
/// The settings survive a JSON round trip of the preferences, and a saved value this build does
/// not know reads as the key's default without losing the other preferences.
#[test]
@@ -38,44 +38,20 @@ fn uncalibrated_cmyk_marks_nothing() {
});
}
/// A profile loaded again under the same name can change which colors are printable while the
/// color settings stay the same; the panel keeps drawing through the change.
/// In the wheel's square and in the box, Show Out-of-Gamut Colors changes what the panel draws,
/// and turning it off again draws the panel as it was.
#[test]
fn the_grid_is_computed_again_after_a_profile_is_loaded() {
if !crate::testing::in_own_process("panels::tests_color_wheel_gamut::the_grid_is_computed_again_after_a_profile_is_loaded") {
return;
fn the_setting_shades_the_wheel_and_the_box() {
for view in ["wheel", "box"] {
let mut p = Panel::new(app("#3366cc", view, false));
let off = p.fx.frame_shapes();
p.run("ui.colorWheel", json!({"gamut": true}));
let on = p.fx.frame_shapes();
// Compared without printing: a frame holds thousands of shapes.
assert!(on != off, "{view}: the shading is drawn");
p.run("ui.colorWheel", json!({"gamut": false}));
assert!(p.fx.frame_shapes() == off, "{view}: off draws no shading");
}
let mut p = Panel::new(app("#3366cc", "box", true));
/// Unregisters the profile when dropped, also after a failed assertion.
struct Unregister(&'static str);
impl Drop for Unregister {
fn drop(&mut self) {
cms::unregister_icc(self.0);
}
}
let name = "Color Wheel Gamut Reload CMYK";
let bytes = cms::icc_bytes(cms::GENERIC_CMYK).unwrap();
cms::register_icc(&bytes, Some(name.into())).unwrap();
let _unregister = Unregister(name);
p.fx.idle(2);
assert!(p.fx.by_label("Color box").is_some());
}
/// The wheel's square and the Hue box both show with the setting on.
#[test]
fn the_wheel_and_the_hue_box_shade_the_same_cells() {
let mut p = Panel::new(app("#3366cc", "wheel", true));
assert!(p.fx.by_label("Saturation and brightness").is_some());
p.run("ui.colorWheel", json!({"view": "box"}));
assert!(p.fx.by_label("Color box").is_some());
}
/// With Show Out-of-Gamut Colors off, the panel still draws and the setting reads off.
#[test]
fn with_the_setting_off_no_grid_is_computed() {
let p = Panel::new(app("#3366cc", "box", false));
assert!(!p.app().ui.color_wheel.gamut);
assert!(p.fx.by_label("Color box").is_some());
}
/// `ui.colorWheel {gamut}` sets the setting and keeps the others; a key set to null keeps its value
@@ -114,17 +114,14 @@ fn ui_color_wheel_sets_the_harmony_and_its_rule() {
assert_eq!(got["harmonyRule"], json!("splitComplementary"));
}
/// The errors are translated in the catalogs that translate status and error messages, and each
/// The errors are shown in the interface language (German and Japanese here), and each
/// translation keeps the key and the accepted values.
#[test]
fn ui_color_wheel_harmony_errors_are_translated() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let flag = app.run("ui.colorWheel", json!({"harmony": 1})).unwrap_err();
let rule = app.run("ui.colorWheel", json!({"harmonyRule": "shades"})).unwrap_err();
for code in [
"cs", "de", "el", "es", "fr", "hi", "hu", "it", "ja", "ka", "ko", "pl", "pt-br", "ru", "sv", "uk", "vi", "zh-hans", "zh-hant", "fi", "tr",
"ca", "nl", "bs", "da", "id",
] {
for code in ["de", "ja"] {
let lang = crate::i18n::Lang::from_code(code).expect("registered");
let shown = crate::i18n::message(lang, &flag);
assert!(shown != flag && shown.contains("`harmony`"), "{code}: {shown}");
@@ -433,14 +433,3 @@ fn the_row_is_gray_with_nothing_selected_and_on_type() {
let p = Panel::new(app);
assert!(disabled(&p));
}
/// `ui.colorWheel` answers every junk parameter, with and without a document, without a panic.
#[test]
fn ui_color_wheel_answers_junk_params_without_a_panic() {
let doc = crate::menus::UI_COMMANDS.iter().find(|c| c.0 == "ui.colorWheel").expect("registered").3;
for mut app in [app(), VectorcraftApp::new(Session::new(), Default::default())] {
for p in vectorcraft_testkit::strategies::junk_params(doc, "/nonexistent").into_iter().chain(vectorcraft_testkit::strategies::junk_values()) {
let _ = app.run("ui.colorWheel", p);
}
}
}
+21 -6
View File
@@ -153,15 +153,30 @@ pub fn poll(app: &mut VectorcraftApp) {
}
Err(TryRecvError::Disconnected) => None,
};
let r = app.trace_runs.running.remove(i);
// The status bar no longer says it is tracing.
if app.ui.status == format!("{}…", crate::i18n::msg(LABEL)) {
app.ui.status.clear();
}
finish(app, r, done);
land(app, i, done);
}
}
/// Waits for each trace running to end, in the order they were started, and applies it as
/// [`poll`] does once it is done.
#[cfg(test)]
pub(crate) fn finish_all(app: &mut VectorcraftApp) {
while let Some(r) = app.trace_runs.running.first() {
let done = r.done.recv().ok();
land(app, 0, done);
}
}
/// Takes trace `i`, which has ended with `done`, off the list and applies it.
fn land(app: &mut VectorcraftApp, i: usize, done: Option<Done>) {
let r = app.trace_runs.running.remove(i);
// The status bar no longer says it is tracing.
if app.ui.status == format!("{}…", crate::i18n::msg(LABEL)) {
app.ui.status.clear();
}
finish(app, r, done);
}
/// Applies trace `r`'s result in its document, which becomes the active one again, as its command
/// would while the object, its image and the settings are as they were and the document was not
/// reverted; else why it has none, in the status bar.