Merge pull request #10434 from dotCooCoo/fix/tight-ui-test-values

Tests: check exact values in panel and dialog tests
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-01 14:21:50 -08:00
commit f05e30191a
8 files changed
+16 -14

No files matched your search

+1 -2
View File
@@ -248,6 +248,5 @@ fn properties_and_the_control_bar_remove_the_background_at_once() {
assert!(closed(&app), "it runs at once");
assert_eq!(steps(&app), n + 1, "one undo step");
// The defaults (tolerance and softness 10): the white goes, the near-white ring fades.
let [corner, ring, block] = alphas(&app);
assert!(corner == 0 && ring > 0 && ring < 255 && block == 255, "{:?}", alphas(&app));
assert_eq!(alphas(&app), [0, 95, 255]);
}
@@ -84,13 +84,14 @@ fn remove_strokes_runs_the_delete_and_cancel_changes_nothing() {
let name = "10 pt. Oval";
app.run("brush.apply", json!({"name": name})).unwrap();
let before = app.session.active().unwrap().history.undo.len();
let width = app.session.active().unwrap().doc.node(path).and_then(|n| n.appearance.stroke()).unwrap().width;
ask(&mut app, json!({"name": name}), true);
answer::<BrushDeleteQuestion>(&mut app, choice, pump);
assert_eq!(open_question(&app), None);
assert_eq!(app.session.active().unwrap().history.undo.len(), before + usize::from(choice.is_some()));
let stroke = app.session.active().unwrap().doc.node(path).and_then(|n| n.appearance.stroke()).unwrap();
assert_eq!(stroke.brush.as_deref(), choice.is_none().then_some(name));
assert!(stroke.width > 0.0);
assert_eq!(stroke.width, width, "the stroke keeps its width");
}
}
+2 -2
View File
@@ -437,8 +437,8 @@ mod tests {
confirm(&mut app, &ctx);
assert!(!app.session.in_interaction());
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo + 1);
let lighter = vectorcraft_color::Color::from_hex(&fill_hex(&app, id)).unwrap().to_rgb()[0];
assert!(lighter > 0.6, "{lighter}");
// #808080 holds less than 50% black, so taking 50% away leaves none.
assert_eq!(fill_hex(&app, id), "#ffffff");
}
#[test]
+1 -1
View File
@@ -950,7 +950,7 @@ mod tests {
app.canvas.doc_info.clone().unwrap().1
};
let all = shown(&mut app, "");
assert!(all["pathArea"].as_f64().is_some_and(|a| a > 0.0), "{}", all["pathArea"]);
assert!(all["pathArea"].as_f64().is_some_and(|a| (a - 200.0).abs() < 1e-6), "{}", all["pathArea"]);
assert!(Arc::ptr_eq(&all, &shown(&mut app, "objects")), "Objects reuses All Categories' result");
for category in ["document", "fonts"] {
let other = shown(&mut app, category);
+3 -3
View File
@@ -217,10 +217,10 @@ fn ramp_and_shift_edit_every_selected_blend_and_keep_their_other_options() {
assert_eq!(undo_depth(&p.app()), depth + 1, "one undo step for both blends");
// The value typed goes to both; each keeps its own spacing, type and the other value.
if name == "Ramp:" {
assert!(after_a.ease.ramp > 0.0 && after_a.ease.ramp == after_b.ease.ramp, "{after_a:?} {after_b:?}");
assert!((after_a.ease.ramp - 0.75).abs() < 1e-9 && (after_b.ease.ramp - 0.75).abs() < 1e-9, "{after_a:?} {after_b:?}");
assert_eq!((after_a.color_shift, after_b.color_shift), (before_a.color_shift, before_b.color_shift));
} else {
assert!(after_a.color_shift > 0.0 && after_a.color_shift == after_b.color_shift, "{after_a:?} {after_b:?}");
assert_eq!((after_a.color_shift, after_b.color_shift), (75.0, 75.0), "{after_a:?} {after_b:?}");
assert_eq!((after_a.ease.ramp, after_b.ease.ramp), (before_a.ease.ramp, before_b.ease.ramp));
}
assert_eq!((after_a.spacing, after_b.spacing), (BlendSpacing::Steps(3), BlendSpacing::Distance(12.0)));
@@ -238,7 +238,7 @@ fn ramp_is_dimmed_while_a_selected_blend_has_no_spine() {
assert!(!p.enabled("Ramp:") && p.enabled("Shift:"));
p.type_into("Shift:", "75");
let app = p.app();
assert!(spec(&app, a).color_shift > 0.0 && spec(&app, b).color_shift == spec(&app, a).color_shift);
assert_eq!((spec(&app, a).color_shift, spec(&app, b).color_shift), (75.0, 75.0));
}
#[test]
@@ -452,7 +452,7 @@ fn an_opacity_click_in_one_frame_keeps_its_opacity_over_a_typed_alpha() {
quick_click(&mut p, rail.rect.center());
let (hex, opacity) = first_stop(&p);
assert_eq!(hex, "#336699", "the text applies");
assert!(opacity > 0.2 && opacity < 0.8, "the press sets the opacity: {opacity}");
assert!((opacity - 0.5).abs() < 0.005, "the press sets the opacity: {opacity}");
}
/// A press on the opacity slider that takes the focus from an edited field applies the text and
@@ -94,7 +94,7 @@ fn the_row_shows_under_the_box_view() {
let at = along(&slider(&p), 0.5);
p.fx.click_at(at).idle(2);
let o = fill_opacity(&p.app());
assert!((o - 0.5).abs() < 0.05, "{o}");
assert!((o - 0.5).abs() < 0.005, "{o}");
}
/// A value this build does not read keeps the rest of the preferences and reads as the default.
@@ -122,7 +122,7 @@ fn the_slider_sets_the_fill_opacity_and_takes_the_arrow_keys() {
let at = along(&slider(&p), 0.5);
p.fx.click_at(at).idle(2);
let o = fill_opacity(&p.app());
assert!((o - 0.5).abs() < 0.05, "{o}");
assert!((o - 0.5).abs() < 0.005, "{o}");
let labels = undo_labels(&p.app());
assert_eq!((labels.len(), labels.last().map(String::as_str)), (undo + 1, Some("Opacity")));
assert_eq!(crate::panels::current_paints(&p.app()).0.color().unwrap().to_hex(), "#ff0000");
+4 -2
View File
@@ -215,8 +215,10 @@ fn filter_dialog_previews_and_commits_one_undo_step() {
set_field(&mut h, "amount", json!(50)).unwrap();
step(&mut h);
assert!(h.state().session.in_interaction(), "previewing");
let [r, g, _] = fill_rgb(h.state(), id);
assert!(r < 1.0 && g > 0.0, "half desaturated on the canvas: {r} {g}");
let [r, g, b] = fill_rgb(h.state(), id);
for (got, want) in [(r, 0.6063), (g, 0.1063), (b, 0.1063)] {
assert!((got - want).abs() < 1e-4, "half desaturated on the canvas: {r} {g} {b}");
}
step(&mut h);
let (shown, _) = h.state().canvas.shown.as_ref().expect("a rendered canvas frame");
let shown_fill = shown.node(id).unwrap().appearance.fill_paint().color().unwrap().to_rgb_uncalibrated();