mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 04:25:52 -05:00
Tests: engine tests that check every item also check the items exist
Engine tests in crates/engine/src/tests that asserted something of every item in a list passed when the list was empty. They now pin the count or the exact value: - keyguide, menucmds, recolor: the guide positions, the smart punctuation counts and the theme picker's colors are compared whole. - overprint, script_text, stylepanel, textedit, typearea: the text is checked first, and character runs must exist; the Graphic Styles test checks the red fill itself, not only some fill. - package, pattern, perspgrid, pixelalign, recolor, swatchcmds, symbollib, xform: the links, stored graph paints, corners, anchors, map rows, group colors, gradient stops and symbol sizes are counted. - rastersettings: the white-background image has the size of the clear one. - textcombos: both paragraphs take the composer and justification. - textedit: a character style range past u32 leaves the text object unchanged.
This commit is contained in:
1 parent
50608f3cdf
commit
c21cc4f3ff
17 files changed
+71
-29
No files matched your search
@@ -174,10 +174,10 @@ fn guides_align_to_a_key_object_among_others_and_parallel_ones_to_a_key_guide()
|
||||
s.execute("select.key", &json!({"id": b.0})).unwrap();
|
||||
s.execute("object.align", &json!({"horizontal": "left"})).unwrap();
|
||||
assert_eq!(bounds(&s, a).x0, 300.0);
|
||||
assert!(positions(&s).iter().all(|p| *p == 300.0));
|
||||
assert_eq!(positions(&s), [300.0, 300.0], "both guides");
|
||||
// Aligning to the selection leaves guides alone.
|
||||
s.execute("object.align", &json!({"horizontal": "right", "to": "selection"})).unwrap();
|
||||
assert!(positions(&s).iter().all(|p| *p == 300.0));
|
||||
assert_eq!(positions(&s), [300.0, 300.0]);
|
||||
// A key guide stays put, and the other vertical guide lines up on it.
|
||||
s.execute("guide.move", &json!({"index": 1, "pos": 700})).unwrap();
|
||||
s.execute("select.key", &json!({"guide": 1})).unwrap();
|
||||
|
||||
@@ -4113,7 +4113,8 @@ fn smart_punctuation_with_nothing_to_change_records_no_undo_step() {
|
||||
let before = history(&s);
|
||||
let r = s.execute("type.smartPunctuation", &json!({})).unwrap();
|
||||
assert_eq!(r["changed"], 0, "{id:?}");
|
||||
assert!(r["replaced"].as_object().unwrap().values().all(|n| n == 0), "{id:?}: {r}");
|
||||
let none = json!({"fiLigatures": 0, "flLigatures": 0, "quotes": 0, "spaces": 0, "dashes": 0, "ellipses": 0, "fractions": 0});
|
||||
assert_eq!(r["replaced"], none, "{id:?}: {r}");
|
||||
assert_eq!(history(&s), before, "{id:?}");
|
||||
}
|
||||
assert_eq!(plain(&s, t), "“Hi” it’s 1–2 and 3—4…");
|
||||
|
||||
@@ -269,7 +269,8 @@ fn overprint_black_covers_type_gradients_spots_and_groups() {
|
||||
|
||||
s.execute("edit.colors.overprintBlack", &json!({})).unwrap();
|
||||
let NodeKind::Text(tx) = &node(&s, t).kind else { panic!() };
|
||||
assert!(tx.runs.iter().all(|r| r.style.overprint_fill), "type characters, inside the selected group");
|
||||
assert_eq!(tx.plain_text(), "Hi");
|
||||
assert!(!tx.runs.is_empty() && tx.runs.iter().all(|r| r.style.overprint_fill), "type characters, inside the selected group");
|
||||
let fill = |s: &Session, id| node(s, id).appearance.fill().unwrap().overprint;
|
||||
assert!(!fill(&s, g), "a gradient with a rich-black stop");
|
||||
assert!(!fill(&s, spot), "spot blacks need includeSpotBlacks");
|
||||
|
||||
@@ -78,7 +78,9 @@ fn two_links_and_a_font_are_collected_and_relinked() {
|
||||
s.doc().unwrap().doc.visit_images(|_, im| paths.push(im.link.clone().unwrap()));
|
||||
paths
|
||||
};
|
||||
assert!(link(&s).iter().all(|l| l.path.contains("art")));
|
||||
let links = link(&s);
|
||||
assert_eq!(links.len(), 2, "{links:?}");
|
||||
assert!(links.iter().all(|l| l.path.contains("art")), "{links:?}");
|
||||
// The packaged one opens with the copies, even with the originals gone.
|
||||
std::fs::remove_dir_all(dir.0.join("art")).unwrap();
|
||||
let r = open(&mut s, &root.join("poster.vectorcraft").to_string_lossy());
|
||||
|
||||
@@ -1087,13 +1087,17 @@ fn delete_and_rename_reach_a_graphs_stored_paints() {
|
||||
let mut s = session();
|
||||
make_dots(&mut s);
|
||||
let g = graph_painted_with(&mut s, "Dots");
|
||||
assert_eq!(stored_graph_paints(&s, g).len(), 4, "the series fill and stroke and the value labels' fill and stroke");
|
||||
s.execute("pattern.options", &json!({"name": "Dots", "newName": "Spots"})).unwrap();
|
||||
assert!(stored_graph_paints(&s, g).iter().all(|p| is_pattern(p, "Spots")), "the rename reaches the graph");
|
||||
let renamed = stored_graph_paints(&s, g);
|
||||
assert!(renamed.len() == 4 && renamed.iter().all(|p| is_pattern(p, "Spots")), "the rename reaches the graph: {renamed:?}");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(stored_graph_paints(&s, g).iter().all(|p| is_pattern(p, "Dots")));
|
||||
let back = stored_graph_paints(&s, g);
|
||||
assert!(back.len() == 4 && back.iter().all(|p| is_pattern(p, "Dots")), "{back:?}");
|
||||
let v = s.execute("pattern.delete", &json!({"name": "Dots"})).unwrap();
|
||||
assert_eq!(v["unpainted"], 4, "the series fill and stroke and the value labels' fill and stroke");
|
||||
assert!(stored_graph_paints(&s, g).iter().all(Paint::is_none));
|
||||
let cleared = stored_graph_paints(&s, g);
|
||||
assert!(cleared.len() == 4 && cleared.iter().all(Paint::is_none), "{cleared:?}");
|
||||
s.execute("graph.setData", &json!({"id": g.0, "rows": [[2], [4]]})).unwrap();
|
||||
assert_eq!(pattern_uses(doc(&s), "Dots"), 0, "the redrawn graph holds no paint of the deleted pattern");
|
||||
}
|
||||
|
||||
@@ -496,12 +496,14 @@ fn snap_to_grid_lands_drawn_and_moved_art_on_gridlines() {
|
||||
let n = s.doc().unwrap().doc.node(id).unwrap().path_data().unwrap().clone();
|
||||
n.anchors().map(|(_, _, an)| g.to_plane(Plane::Left, an.p).unwrap()).collect()
|
||||
};
|
||||
assert!(corners(&s).iter().all(|q| on_line(q.x) && on_line(q.y)), "{:?}", corners(&s));
|
||||
let drawn = corners(&s);
|
||||
assert!(drawn.len() == 4 && drawn.iter().all(|q| on_line(q.x) && on_line(q.y)), "{drawn:?}");
|
||||
// Moved a cell and a bit: it lands a whole cell over.
|
||||
let from = g.to_page(Plane::Left, Point::new(3.0 * g.cell, 2.0 * g.cell)).unwrap();
|
||||
let to = g.to_page(Plane::Left, Point::new(4.0 * g.cell + 2.0, 2.0 * g.cell)).unwrap();
|
||||
run(&mut s, "perspective.move", json!({"ids": [id.0], "from": [from.x, from.y], "to": [to.x, to.y]}));
|
||||
assert!(corners(&s).iter().all(|q| on_line(q.x) && on_line(q.y)), "{:?}", corners(&s));
|
||||
let moved = corners(&s);
|
||||
assert!(moved.len() == 4 && moved.iter().all(|q| on_line(q.x) && on_line(q.y)), "{moved:?}");
|
||||
// Without snapping it moves exactly.
|
||||
let before = corners(&s);
|
||||
run(&mut s, "perspective.move", json!({"ids": [id.0], "from": [from.x, from.y], "to": [to.x, to.y], "snap": false}));
|
||||
|
||||
@@ -205,6 +205,7 @@ fn stroke_edits_keep_it_aligned() {
|
||||
assert!(whole(&points(&s, id)), "{:?}", points(&s, id));
|
||||
s.execute("stroke.set", &json!({"weight": 3})).unwrap();
|
||||
let pts = points(&s, id);
|
||||
assert_eq!(pts.len(), 4, "{pts:?}");
|
||||
assert!(pts.iter().all(|(x, y)| (x - x.floor() - 0.5).abs() < 1e-9 && (y - y.floor() - 0.5).abs() < 1e-9), "{pts:?}");
|
||||
// Inside alignment puts the stroke within the path, so the anchors go back to whole points.
|
||||
s.execute("stroke.set", &json!({"align": "inside"})).unwrap();
|
||||
@@ -763,8 +764,10 @@ fn objects_on_path_members_stay_on_the_grid() {
|
||||
// Editing the path places the member again, and it goes back on the grid.
|
||||
let anchors = json!([{"x": 0.6, "y": 120.7}, {"x": 300.6, "y": 120.7}]);
|
||||
s.execute("path.setAnchors", &json!({"id": spine, "subpaths": [{"anchors": anchors, "closed": false}]})).unwrap();
|
||||
assert!(whole(&points(&s, a)), "path edited: {:?}", points(&s, a));
|
||||
assert!(points(&s, a).iter().all(|(_, y)| *y > 105.0), "followed the path: {:?}", points(&s, a));
|
||||
let placed = points(&s, a);
|
||||
assert_eq!(placed.len(), 4, "{placed:?}");
|
||||
assert!(whole(&placed), "path edited: {placed:?}");
|
||||
assert!(placed.iter().all(|(_, y)| *y > 105.0), "followed the path: {placed:?}");
|
||||
}
|
||||
|
||||
fn align_new(s: &Session) -> bool {
|
||||
@@ -1465,6 +1468,7 @@ fn an_instance_snapped_to_the_grid_moves_its_linked_mask() {
|
||||
assert!(whole(&[(e, f)]) && (e, f) != (e0, f0), "{e} {f}");
|
||||
let moved: Vec<_> = mask_before.iter().map(|(x, y)| (x + e - e0, y + f - f0)).collect();
|
||||
let after = mask_points(&s, linked);
|
||||
assert!(!moved.is_empty() && after.len() == moved.len(), "{after:?} != {moved:?}");
|
||||
assert!(moved.iter().zip(&after).all(|(a, b)| close(*a, *b)), "{after:?} != {moved:?}");
|
||||
assert!(whole(&placed_points(&s, unlinked)));
|
||||
assert_eq!(mask_points(&s, unlinked), unlinked_before);
|
||||
|
||||
@@ -99,6 +99,7 @@ fn a_white_background_makes_effect_images_opaque() {
|
||||
assert_eq!(clear.get_pixel(0, 0)[3], 0, "transparent by default");
|
||||
s.execute(C, &json!({"background": "white"})).unwrap();
|
||||
let white = effect_image(&s.doc().unwrap().doc);
|
||||
assert_eq!(white.dimensions(), clear.dimensions(), "the same image, on white");
|
||||
assert!(white.pixels().all(|p| p[3] == 255), "every pixel is opaque");
|
||||
assert_eq!(white.get_pixel(0, 0).0, [255, 255, 255, 255]);
|
||||
// With a clipping mask, the white stays under the art only.
|
||||
|
||||
@@ -250,7 +250,8 @@ fn used_colors_give_no_swatch_for_a_stop_that_mixes_its_ink_with_process_inks()
|
||||
assert_eq!(entry("cmyk 0 50 30 0")["swatch"], "Ink", "{r}");
|
||||
// recolor.colors keeps the swatch it lists.
|
||||
let listed = run(&mut s, "recolor.colors", json!({}));
|
||||
assert!(listed["colors"].as_array().unwrap().iter().all(|c| c["swatch"] == "Ink"), "{listed}");
|
||||
let colors = listed["colors"].as_array().unwrap();
|
||||
assert!(!colors.is_empty() && colors.iter().all(|c| c["swatch"] == "Ink"), "{listed}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -446,7 +447,9 @@ fn limit_to_library_snaps_new_colours() {
|
||||
let c = color_value(k).unwrap();
|
||||
c.to_rgb().iter().all(|v| ((v * 5.0).round() - v * 5.0).abs() < 1e-3)
|
||||
};
|
||||
assert!(r["map"].as_array().unwrap().iter().all(|row| web(&row["to"])), "{r}");
|
||||
let map = r["map"].as_array().unwrap();
|
||||
assert_eq!(map.len(), 2, "a row for each color: {r}");
|
||||
assert!(map.iter().all(|row| web(&row["to"])), "{r}");
|
||||
run(&mut s, "recolor.apply", json!({"map": {"#f01020": "#f01020"}, "limitTo": "Web Safe 216"}));
|
||||
let hexes: Vec<Value> = run(&mut s, "recolor.colors", json!({}))["colors"].as_array().unwrap().iter().map(|c| c["hex"].clone()).collect();
|
||||
assert!(hexes.contains(&json!("#ff0033")) && !hexes.contains(&json!("#f01020")), "{hexes:?}");
|
||||
@@ -1333,10 +1336,11 @@ fn document_model_converts_the_colours_of_a_group_too() {
|
||||
g.swatches.iter().filter_map(|w| w.paint.color()).collect()
|
||||
};
|
||||
// Group-only edit from the rows, and with explicit group colours.
|
||||
let cmyk = |cs: &[Color]| cs.len() == 1 && cs.iter().all(|c| c.model() == vectorcraft_color::cms::Model::Cmyk);
|
||||
run(&mut s, "recolor.apply", json!({"map": {"cmyk 0 0 0 50": "#ff0000"}, "group": "Theme", "model": "document"}));
|
||||
assert!(group(&s).iter().all(|c| c.model() == vectorcraft_color::cms::Model::Cmyk), "{:?}", group(&s));
|
||||
assert!(cmyk(&group(&s)), "{:?}", group(&s));
|
||||
run(&mut s, "recolor.apply", json!({"map": [], "group": "Theme", "groupColors": ["#00ff00"], "model": "document"}));
|
||||
assert!(group(&s).iter().all(|c| c.model() == vectorcraft_color::cms::Model::Cmyk), "{:?}", group(&s));
|
||||
assert!(cmyk(&group(&s)), "{:?}", group(&s));
|
||||
}
|
||||
|
||||
fn stroke(s: &Session, id: NodeId) -> Color {
|
||||
@@ -1620,7 +1624,7 @@ fn theme_picker_leaves_out_clear_pixels_and_unreadable_images() {
|
||||
let cut = super::menucmds::place_undecodable_png(&mut s);
|
||||
let cb = s.doc().unwrap().doc.node(cut).unwrap().visual_bounds().unwrap();
|
||||
let r = run(&mut s, "recolor.pickTheme", json!({"picks": [{"rect": [cb.x0, cb.y0, cb.x1, cb.y1]}]}));
|
||||
assert!(r["colors"].as_array().unwrap().iter().all(|k| k == "rgb 255 0 0"), "the undecodable image adds nothing: {r}");
|
||||
assert_eq!(r["colors"], json!(["rgb 255 0 0"]), "the undecodable image adds nothing to the red under it: {r}");
|
||||
}
|
||||
|
||||
/// A large image is read through about 65,536 pixels: its palette still holds both halves.
|
||||
|
||||
@@ -260,7 +260,10 @@ fn a_leading_equal_to_the_auto_leading_turns_auto_leading_off() {
|
||||
assert_eq!(out, vec![json!([false, 14.4])]);
|
||||
assert_eq!(undo_steps(&s), before + 1);
|
||||
match &s.active().unwrap().doc.node(id).unwrap().kind {
|
||||
NodeKind::Text(t) => assert!(t.runs.iter().all(|r| r.style.leading.is_some_and(|l| (l - 14.4).abs() < 1e-9)), "{:?}", t.runs),
|
||||
NodeKind::Text(t) => {
|
||||
assert_eq!(t.plain_text(), "abc");
|
||||
assert!(!t.runs.is_empty() && t.runs.iter().all(|r| r.style.leading.is_some_and(|l| (l - 14.4).abs() < 1e-9)), "{:?}", t.runs);
|
||||
}
|
||||
_ => panic!("not text"),
|
||||
}
|
||||
// A fixed leading set to its own value is still no change.
|
||||
@@ -371,7 +374,10 @@ fn turning_auto_leading_off_keeps_each_characters_leading() {
|
||||
assert!(e.contains("autoLeading cannot be turned off"), "{e}");
|
||||
assert_eq!(undo_steps(&s), before);
|
||||
match &s.active().unwrap().doc.node(id).unwrap().kind {
|
||||
NodeKind::Text(t) => assert!(t.runs.iter().all(|r| r.style.leading.is_none())),
|
||||
NodeKind::Text(t) => {
|
||||
assert_eq!(t.plain_text(), "ab\ncd");
|
||||
assert!(!t.runs.is_empty() && t.runs.iter().all(|r| r.style.leading.is_none()), "{:?}", t.runs);
|
||||
}
|
||||
_ => panic!("not text"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,9 +125,12 @@ fn override_character_color_clears_the_run_fill() {
|
||||
assert_eq!(run(&mut s, "graphicStyle.setOptions", json!({}))["overrideCharColor"], true);
|
||||
let a = text(&mut s, 100.0);
|
||||
run(&mut s, "paint.setFill", json!({"color": "#ff0000", "ids": [a.0]}));
|
||||
assert!(runs(&s, a).iter().all(|(f, _)| *f != Paint::None));
|
||||
let red = Paint::solid(Color::from_hex("#ff0000").unwrap());
|
||||
let painted = runs(&s, a);
|
||||
assert!(!painted.is_empty() && painted.iter().all(|(f, _)| *f == red), "{painted:?}");
|
||||
run(&mut s, "graphicStyle.apply", json!({"name": "Blue", "ids": [a.0]}));
|
||||
assert!(runs(&s, a).iter().all(|(f, st)| *f == Paint::None && *st == Paint::None));
|
||||
let styled = runs(&s, a);
|
||||
assert!(styled.len() == painted.len() && styled.iter().all(|(f, st)| *f == Paint::None && *st == Paint::None), "{styled:?}");
|
||||
assert_eq!(s.doc().unwrap().doc.node(a).unwrap().appearance.fill_paint(), Paint::solid(Color::from_hex("#0000ff").unwrap()));
|
||||
// Off: they keep it (the style's paint draws over them).
|
||||
assert_eq!(run(&mut s, "graphicStyle.setOptions", json!({"overrideCharColor": false}))["overrideCharColor"], false);
|
||||
|
||||
@@ -722,7 +722,8 @@ fn a_cmyk_document_starts_with_cmyk_swatches_and_stores_new_colours_as_cmyk() {
|
||||
json!({"ids": [a.0], "gradient": {"stops": [{"offset": 0, "color": "#ffffff"}, {"offset": 1, "color": "#0000ff"}]}}),
|
||||
);
|
||||
let Paint::Gradient(g) = fill(&s, a) else { panic!("a gradient") };
|
||||
assert!(g.gradient.stops.iter().all(|st| matches!(st.color, Color::Cmyk { .. })));
|
||||
assert_eq!(g.gradient.stops.len(), 2, "{:?}", g.gradient.stops);
|
||||
assert!(g.gradient.stops.iter().all(|st| matches!(st.color, Color::Cmyk { .. })), "{:?}", g.gradient.stops);
|
||||
// A swatch made from a hex colour is CMYK as well; the document round-trips natively.
|
||||
let name = run(&mut s, "swatch.new", json!({"color": "#00ff00"}))["name"].as_str().unwrap().to_string();
|
||||
assert_eq!(doc(&s).swatch(&name).and_then(|w| w.paint.color()), Some(managed(Color::rgb(0.0, 1.0, 0.0))));
|
||||
|
||||
@@ -265,6 +265,7 @@ fn nature_icons_library_places_and_survives_save() {
|
||||
for (i, name) in names.iter().enumerate() {
|
||||
let symbol = &library["symbols"][i];
|
||||
let size = symbol["size"].as_array().unwrap();
|
||||
assert_eq!(size.len(), 2, "{name}: width and height");
|
||||
assert!(size.iter().all(|n| n.as_f64().is_some_and(|n| n.is_finite() && n > 0.0)), "{name}");
|
||||
let added = run(
|
||||
&mut s,
|
||||
|
||||
@@ -161,7 +161,11 @@ fn auto_height_x_composer() {
|
||||
}
|
||||
s.execute("text.setFormat", &json!({"ids": [id.0], "composer": "singleLine"})).unwrap();
|
||||
s.execute("text.setStyle", &json!({"id": id.0, "justify": "justifyAll"})).unwrap();
|
||||
assert!(text(&s, id).paragraph_styles().iter().all(|p| p.composer == Composer::SingleLine && p.justify == Justify::JustifyAll));
|
||||
let t = text(&s, id);
|
||||
assert_eq!(t.paragraph_count(), 2);
|
||||
for k in 0..2 {
|
||||
assert_eq!((t.para_at(k).composer, t.para_at(k).justify), (Composer::SingleLine, Justify::JustifyAll), "paragraph {k}");
|
||||
}
|
||||
assert_tight(&s, id, "justified");
|
||||
}
|
||||
|
||||
|
||||
@@ -323,7 +323,8 @@ fn optical_set_format_clears_existing_pair_override() {
|
||||
let result = s.execute("text.setFormat", &json!({"ids": [id.0], "kerning": "optical"})).unwrap();
|
||||
assert_eq!(result["kerning"], "optical");
|
||||
let t = obj(&s, id);
|
||||
assert!(t.runs.iter().all(|r| r.style.optical_kerning));
|
||||
assert_eq!(t.plain_text(), "III");
|
||||
assert!(!t.runs.is_empty() && t.runs.iter().all(|r| r.style.optical_kerning), "{:?}", t.runs);
|
||||
assert!(t.runs.iter().all(|r| r.style.kerning.is_none()), "choosing Optical clears the manual value");
|
||||
}
|
||||
|
||||
@@ -488,8 +489,10 @@ fn char_style_range_past_u32_styles_nothing() {
|
||||
let mut s = session();
|
||||
let id = text(&mut s, "Hello world");
|
||||
s.execute("charStyle.new", &json!({"name": "Big", "attrs": {"size": 40.0}})).unwrap();
|
||||
let before = obj(&s, id);
|
||||
assert!(!before.runs.is_empty() && before.runs.iter().all(|r| r.style.size == 20.0 && r.style.style_name.is_none()), "{:?}", before.runs);
|
||||
s.execute("charStyle.apply", &json!({"name": "Big", "id": id.0, "start": 1u64 << 32, "end": (1u64 << 32) + 5})).unwrap();
|
||||
assert!(obj(&s, id).runs.iter().all(|r| r.style.size == 20.0 && r.style.style_name.is_none()), "{:?}", obj(&s, id).runs);
|
||||
assert_eq!(obj(&s, id), before, "no character is styled");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2008,7 +2011,8 @@ fn the_eyedropper_styles_the_whole_story_that_select_all_selected() {
|
||||
let r = s.execute("appearance.copyFrom", &json!({"source": source})).unwrap();
|
||||
assert_eq!(r, json!({"ids": [a.0, b.0]}));
|
||||
for id in [a, b] {
|
||||
assert!(obj(&s, id).runs.iter().all(|r| (r.style.size - 30.0).abs() < 1e-9), "every character of frame {} takes the size", id.0);
|
||||
let runs = obj(&s, id).runs;
|
||||
assert!(!runs.is_empty() && runs.iter().all(|r| (r.style.size - 30.0).abs() < 1e-9), "every character of frame {} takes the size", id.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2223,7 +2227,8 @@ fn a_type_step_keeps_a_story_that_left_the_edited_frame_selected() {
|
||||
let c = selected_story_moved_into_a_new_frame(&mut s, a, b);
|
||||
// Alt+Right steps the tracking of the selected text, not the kerning at a caret.
|
||||
key(&mut s, ToolKey::Right, Mods { alt: true, ..Mods::default() });
|
||||
assert!(obj(&s, c).runs.iter().all(|r| r.style.tracking > 0.0), "every character of the story takes the step");
|
||||
let runs = obj(&s, c).runs;
|
||||
assert!(!runs.is_empty() && runs.iter().all(|r| r.style.tracking > 0.0), "every character of the story takes the step: {runs:?}");
|
||||
// A key that does nothing leaves it selected as well.
|
||||
key(&mut s, ToolKey::BracketLeft, Mods::default());
|
||||
assert!(third_frame_highlighted(&mut s));
|
||||
@@ -2567,6 +2572,7 @@ fn convert_to_text_in_one_frame_leaves_the_other_frames() {
|
||||
let (ta, tb) = (obj(&s, a), obj(&s, b));
|
||||
assert_eq!(ta.plain_text(), in_a, "the first frame's text is as it was");
|
||||
assert!(ta.para_at(0).list.is_some(), "the first frame stays a list");
|
||||
assert!(tb.paragraph_count() > 1, "{:?}", tb.plain_text());
|
||||
assert!((0..tb.paragraph_count()).all(|k| tb.para_at(k).list.is_none()), "the edited frame leaves its list");
|
||||
assert!(tb.plain_text().contains("\u{2022}\t"), "the edited frame holds its bullets as characters");
|
||||
}
|
||||
@@ -3765,7 +3771,7 @@ fn the_glyph_query_shapes_an_overflowing_character_in_its_paragraph_direction()
|
||||
|
||||
let boxed = create(&mut s, text, rtl, char_ltr, 30.0);
|
||||
let lay = vectorcraft_text::layout(db, &obj(&s, boxed));
|
||||
assert!(lay.glyphs.iter().all(|g| g.byte < 2), "{text:?}: the second paragraph overflows");
|
||||
assert!(!lay.glyphs.is_empty() && lay.glyphs.iter().all(|g| g.byte < 2), "{text:?}: only the first paragraph is laid out");
|
||||
let r = s.execute("text.glyphAlternates", &json!({"id": boxed.0, "start": at})).unwrap();
|
||||
assert_eq!(r["chosen"], json!(face.glyph_for(drawn)), "{text:?}: the glyph drawn when it fits");
|
||||
}
|
||||
|
||||
@@ -123,7 +123,8 @@ fn transform_again_after_a_handle_drag_resizes_the_type_area_again() {
|
||||
assert!(near(r.origin(), Point::ZERO) && (r.width() - 640.0 / 3.0).abs() < 1e-6 && (r.height() - 250.0).abs() < 1e-6, "{r:?}");
|
||||
let t = text(&s, id);
|
||||
assert_eq!(t.xf, Affine::translate((40.0, 40.0)), "the type isn't scaled");
|
||||
assert!(t.runs.iter().all(|r| r.style.size == 12.0));
|
||||
assert_eq!(t.plain_text(), STORY);
|
||||
assert!(!t.runs.is_empty() && t.runs.iter().all(|r| r.style.size == 12.0), "{:?}", t.runs);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1367,6 +1367,7 @@ fn distort_refuses_corners_type_and_symbol_instances_cannot_follow() {
|
||||
let want = [(0.4, 0.0), (0.6, 0.0), (1.0, 1.0), (0.0, 1.0)].map(|(u, v)| Point::new(b.x0 + u * b.width(), b.y0 + v * b.height()));
|
||||
s.execute("object.distort", &json!({ "corners": want.map(|p| [p.x, p.y]) })).unwrap();
|
||||
let got = drawn_corners(&s, id);
|
||||
assert_eq!(got.len(), 4, "{got:?}");
|
||||
assert!(got.iter().zip(want).all(|(g, w)| g.distance(w) < 1e-3), "{got:?} against {want:?}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user