From 7fe83e2bb99d467f97e0cf40ca099c2d4e4bcc8e Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 17 Aug 2026 10:51:15 +0200 Subject: [PATCH] =?UTF-8?q?test(ui):=20vitals=20=E2=80=94=20toggle=20verif?= =?UTF-8?q?ied=20through=20the=20real=20UiRoot=20mouse=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two end-to-end additions to the fixture toggle suite: a body press through UiRoot.OnMouseDown's actual hit test + bubble (left toggles, right toggles), and a press on the authored top drag bar (0x1000063C) arming the window move WITHOUT toggling — the retail Dragbar-consumes-the-press semantics proven against the real input path, not just injected OnEvent calls. Co-Authored-By: Claude Fable 5 --- .../UI/Layout/VitalsDetailToggleTests.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/AcDream.App.Tests/UI/Layout/VitalsDetailToggleTests.cs b/tests/AcDream.App.Tests/UI/Layout/VitalsDetailToggleTests.cs index 75fb4e4f..33bc7009 100644 --- a/tests/AcDream.App.Tests/UI/Layout/VitalsDetailToggleTests.cs +++ b/tests/AcDream.App.Tests/UI/Layout/VitalsDetailToggleTests.cs @@ -189,6 +189,58 @@ public class VitalsDetailToggleTests Assert.NotEqual(RetailUiStateIds.ShowDetail, rootB.ActiveRetailStateId); } + // ── End-to-end: the REAL mouse path (hit test + bubble) ────────────────── + + [Fact] + public void MouseDown_OnWindowBody_TogglesThroughTheRealHitPath() + { + var (root, vitalsRoot) = MountedWindow(); + + // Body press: the stamina meter's center (meters are ClickThrough, so + // the hit lands on the window content and bubbles to the vitals root). + root.OnMouseDown(UiMouseButton.Left, 90, 59); + root.OnMouseUp(UiMouseButton.Left, 90, 59); + Assert.Equal(RetailUiStateIds.HideDetail, vitalsRoot.ActiveRetailStateId); + + // Right press toggles too (retail dwParam1 0xA). + root.OnMouseDown(UiMouseButton.Right, 90, 59); + root.OnMouseUp(UiMouseButton.Right, 90, 59); + Assert.Equal(RetailUiStateIds.ShowDetail, vitalsRoot.ActiveRetailStateId); + } + + [Fact] + public void MouseDown_OnTopDragBar_MovesArmWithoutToggling() + { + var (root, vitalsRoot) = MountedWindow(); + + // The authored top drag bar (0x1000063C) spans content-local + // (5,0)-(155,5) → canvas y just below the window top. Retail's + // Dragbar consumes the press; the toggle must not fire. + root.OnMouseDown(UiMouseButton.Left, 90, 32); + root.OnMouseUp(UiMouseButton.Left, 90, 32); + Assert.NotEqual(RetailUiStateIds.HideDetail, vitalsRoot.ActiveRetailStateId); + Assert.NotEqual(RetailUiStateIds.ShowDetail, vitalsRoot.ActiveRetailStateId); + } + + private static (UiRoot Root, UiVitalsRoot VitalsRoot) MountedWindow() + { + var root = new UiRoot { Width = 800, Height = 600 }; + var layout = FixtureLoader.LoadVitals(); + RetailWindowFrame.Mount(root, layout.Root, static _ => (0u, 0, 0), + new RetailWindowFrame.Options + { + WindowName = WindowNames.Vitals, + Chrome = RetailWindowChrome.Imported, + Left = 10f, + Top = 30f, + ResizeX = true, + ResizeY = false, + MinWidth = 40f, + ContentClickThrough = false, + }); + return (root, Assert.IsType(layout.Root)); + } + // ── Helpers ────────────────────────────────────────────────────────────── /// Delivers a press to as UiRoot's bubble