fix(m161-r1): 崩溃/静默失败不再冒充「启动进程失败」;补三处假绿的守卫

复审 P1-1(用户可见假文案):`LaunchEnd` 在 `failure == None`(跑起来之后崩的)时
临时造了 `Stage::Spawn + format!("exit {:?}")`,于是磁贴写「启动失败 · 启动游戏进程」、
详情页漏出 `exit Some(1)`、静默失败丢掉「exit 0 却没起来」,而同一时刻 Toast 说「崩溃」。
- 新增 `LaunchFailureCause{Stage|Crashed|SilentFailure}`(dto/launch_failure.rs),
  `LaunchFailureCause::of(outcome, failure, exit_code)` 是唯一组装点;`InstanceRuntime::Failed{cause}`。
  `LaunchFailureStage` 保持「只装装配阶段」(文档那句「崩溃是结局不是阶段」现在成立)。
- 界面:`InstancesFailed`(框架)+ `InstancesCrashed` + `InstancesSilentFailed`;
  删掉 `InstancesFailedStage`。退出码按数字出词,不再有 Debug 文本。
- 用例:presenter 断言**枚举变体**(三种形状逐条)、app 断言**具体句子**
  (「不许出现 Some(」「进程起来了不许说启动游戏进程」「静默失败要点出没起来」)。
  mock 夹具与 launch_state_tests 的期望值同步;launch-error 三张图重拍。

复审 P2-1(`convert::failure_stage` 零覆盖):新增 `convert/stage_tests.rs` 5 条(三档 +
「既没回滚也没宣称干净」+ 非致命无阶段 + `failed_report_with` ⇒ NotStarted)。
变异实测:改成恒 `RolledBack` ⇒ 3 条红。

复审 P2-2(矮窗口用例的算式三个数全错、`body_height` 零测试):用例改成直接调
`frame::body_height`,chrome 从 `Ui::metrics` + `WidthClass::gutter` 现取,并把门槛与真实
chrome 绑死(chrome+MIN ⇒ Split、-1px ⇒ ScrollWhole);新增 `frame` 自己的 `body_height` 用例。
变异实测:`2.0 * gutter` → `gutter` ⇒ 2 条红。

复审 P2-3(源指纹闸门 / `Refused` 零覆盖):新增两条 core 用例——闸门(原地留着 prefs.json
+ 预先写好的同源收据 ⇒ Nothing 且收据未被重写,反证:源变了允许重放)、`Refused`
(`$schema` 1.7.0 ⇒ ReadOnly ⇒ 不动旧文件、不写收据、理由含「不可写」)。
变异实测:删闸门 ⇒ 1 条红;`can_save` 守卫改 `if false` ⇒ 1 条红。

顺手收:
- CLI `pack import` 那句「已整包回滚」也按三档出词(`RollbackStage` + `rollback_line`),
  加 2 条单测。CLI 不依赖 presenter,判定暂与 presenter 各一份 → 已 file finding 建议下沉 core。
- 设置页 `status_text()` 抽出 applying 档,用例断言「正在安装…」且非错误色。

金表:新 key 加在 `golden.rs`(81 行),未动 `golden/tail.rs`(211 行),避免与 M162 的拆分冲突。
This commit is contained in:
AskaEth committed 2026-11-07 17:01:13 +08:00
1 parent 6804b0ad1d
commit 79b796fd58
21 files changed
+894 -168

No files matched your search

+60 -8
View File
@@ -270,18 +270,70 @@ mod body_mode_tests {
assert!(!BodyMode::of(300.0).list_scrolls());
}
/// 窗口最小尺寸(880×560)落在**矮**档:这是本条债的真实场景,别让它悄悄变回 `Split`。
/// 最小窗口(880×560)落在**矮**档,验收到 760 不换版面——**正文可用高按真实外壳算**。
///
/// 复审 P2-2:早先这里是 `560 − 56 − 88 − 32` 反推的(三个数全错:真实是 titlebar 48 /
/// 两行页头 84 / Expanded 页边距 2×24 = chrome 180),结论碰巧对、但抓不住 metrics 漂移。
/// 现在直接调 [`crate::pages::frame::body_height`],chrome 从 token 现取。
#[test]
fn the_minimum_window_size_uses_the_scrolling_body() {
// 560 窗口 − 顶栏 56 − 页头 88(两行标题 + 留白)− 上下页边距 2×16 ≈ 384
let body = 560.0 - 56.0 - 88.0 - 32.0;
use unlucky_design::color::SchemeFlavor;
use unlucky_design::typography::Platform;
use crate::pages::frame;
use crate::pages::layout::{frame_metrics, PaneKit};
use crate::theme::{Families, Ui};
let ui = Ui::with_platform(
SchemeFlavor::Light,
Platform::Windows,
Families {
text: "Segoe UI",
display: "Segoe UI",
mono: "Consolas",
},
);
// 880 宽 = 窗口最小尺寸(`app::MIN_SIZE.width`),属 Expanded。
let metrics = frame_metrics(PaneKit::Single, 880.0);
let chrome =
ui.metrics().titlebar_height + ui.metrics().header_height(true) + 2.0 * metrics.gutter;
// 真值:48 + 84 + 48 = 180。这条会随 token 改而红——那时请重看一眼两档版面。
assert_eq!(chrome, 180.0, "外壳 chrome 与 design token 不一致");
// 最小窗口 560 高:正文只剩 380 < 460 ⇒ 整列滚动(本条债的真实场景)。
let short = frame::body_height(&ui, metrics, 560.0, true);
assert_eq!(short, 560.0 - chrome);
assert_eq!(
BodyMode::of(body),
BodyMode::of(short),
BodyMode::ScrollWhole,
"最小窗口(560 高)必须走整列滚动:正文只剩 {body}"
"正文只剩 {short}"
);
// 验收尺寸 760 高:580 ≥ 460 ⇒ 列表自己滚(不换版面)。
let tall = frame::body_height(&ui, metrics, 760.0, true);
assert_eq!(BodyMode::of(tall), BodyMode::Split);
// 把门槛和**真实 chrome** 绑死:窗口高 = chrome + MIN 时必须还是 Split,
// 少 1px 就翻成整列滚动。chrome 涨到 100/页边距 40 这类漂移会让这条立刻红
// (而不是像旧用例那样拿反推数字自说自话)。
assert_eq!(
BodyMode::of(frame::body_height(
&ui,
metrics,
chrome + MIN_BODY_HEIGHT,
true
)),
BodyMode::Split
);
assert_eq!(
BodyMode::of(frame::body_height(
&ui,
metrics,
chrome + MIN_BODY_HEIGHT - 1.0,
true
)),
BodyMode::ScrollWhole
);
// 验收尺寸 760 高 → 约 584,仍走「列表自己滚」。
let body = 760.0 - 56.0 - 88.0 - 32.0;
assert_eq!(BodyMode::of(body), BodyMode::Split, "验收尺寸不该换版面");
}
}