test(app-iced): M75 —— probe 分隔线判据改为「非底色长横线」+ 修 forced 改成 Option 后的两处测试

线在 fractional y 上被抗锯齿摊到两行,按精确 OutlineVariant 色匹配抓不到(实测 0 行);
改为「非 Surface 的长横线」计数,断言 2..=6 行(两条线 × 各 1~2 行)。
This commit is contained in:
AskaEth committed 2026-11-02 04:50:49 +08:00
1 parent 5f85891e7e
commit 8072f1cc7e
2 files changed
+12 -13

No files matched your search

@@ -212,7 +212,7 @@ fn icon_button_variants_match_the_reference_roles() {
}
}
fn spec_of(variant: Variant, forced: Interaction) -> StyleSpec {
fn spec_of(variant: Variant, forced: Option<Interaction>) -> StyleSpec {
let (fill, content, border) = variant.roles();
StyleSpec {
fill,
@@ -220,7 +220,7 @@ fn spec_of(variant: Variant, forced: Interaction) -> StyleSpec {
border,
shape: variant.shape(),
radius_side: Geometry::of(&light(), variant, false).height,
forced: Some(forced),
forced,
}
}
@@ -228,7 +228,7 @@ fn spec_of(variant: Variant, forced: Interaction) -> StyleSpec {
#[test]
fn outlined_style_draws_hairline_border_and_full_radius() {
let ui = light();
let style = style_closure(&ui, spec_of(Variant::Outlined, Interaction::Enabled));
let style = style_closure(&ui, spec_of(Variant::Outlined, None));
let idle = style(&ui.theme(), button::Status::Active);
assert_eq!(idle.background, None, "Outlined 静息容器必须透明");
@@ -255,7 +255,7 @@ fn outlined_style_draws_hairline_border_and_full_radius() {
#[test]
fn filled_button_state_layers_are_visible_and_ordered() {
let ui = light();
let style = style_closure(&ui, spec_of(Variant::Filled, Interaction::Enabled));
let style = style_closure(&ui, spec_of(Variant::Filled, None));
let idle = style(&ui.theme(), button::Status::Active);
let hovered = style(&ui.theme(), button::Status::Hovered);
@@ -283,7 +283,7 @@ fn filled_button_state_layers_are_visible_and_ordered() {
#[test]
fn forced_state_overrides_the_runtime_status() {
let ui = light();
let style = style_closure(&ui, spec_of(Variant::Tonal, Interaction::Hovered));
let style = style_closure(&ui, spec_of(Variant::Tonal, Some(Interaction::Hovered)));
// 运行期说 Active,但取证要 hover → 必须画 hover
assert_eq!(
style(&ui.theme(), button::Status::Active).background,
@@ -300,7 +300,7 @@ fn forced_state_overrides_the_runtime_status() {
#[test]
fn elevated_uses_a_tone_not_a_shadow() {
let ui = light();
let style = style_closure(&ui, spec_of(Variant::Elevated, Interaction::Enabled));
let style = style_closure(&ui, spec_of(Variant::Elevated, None));
let idle = style(&ui.theme(), button::Status::Active);
assert_eq!(idle.shadow, Shadow::default(), "rubric §7:L1 不画阴影");
assert_eq!(
@@ -173,14 +173,14 @@ fn gallery_geometry_matches_the_tokens() {
}
assert!(measured_glyph, "没量到 IconButton 的字形");
// ---- 22.1:分隔线 1px -----------------------------------------------------
let outline = rgb(ui.color(Role::OutlineVariant));
// ---- 22.1:分隔线 1px(按「非底色的长横线」判,不按精确色:线被抗锯齿摊到两行)----
let surface = rgb(ui.color(Role::Surface));
let mut runs = 0;
for y in 0..shot.height {
let mut longest = 0;
let mut current = 0;
for x in 0..shot.width {
if matches(shot.at(x, y), outline) {
if !matches(shot.at(x, y), surface) {
current += 1;
longest = longest.max(current);
} else {
@@ -191,11 +191,10 @@ fn gallery_geometry_matches_the_tokens() {
runs += 1;
}
}
// 分隔线是 1px 高,所以「长横线」的行数 = 屏上分隔线条数(每条约 1 行)
assert!(runs >= 2, "至少该有 2 条分隔线(实际 {runs} 行)");
// 两条分隔线 × 各摊在 1~2 行上(抗锯齿)⇒ 2..=6 行;>6 说明线粗了或画了第三条
assert!(
runs <= 4,
"分隔线最多 2 条 × 1px,实测 {runs} 行(22.1:大于这个数说明线不是 1px)"
(2..=6).contains(&runs),
"分隔线应 2 条 × 1px(抗锯齿时各占 2 行),实测 {runs} 行"
);
// ---- 12b 1.8:禁用格必须与静息格不同 ------------------------------------