From 35ebb3c8f00c713284441cf1589867a6586e905f Mon Sep 17 00:00:00 2001 From: Erik Date: Sat, 20 Jun 2026 13:06:00 +0200 Subject: [PATCH] =?UTF-8?q?test(ui):=20D.5.3/B.1=20=E2=80=94=20strengthen?= =?UTF-8?q?=20toolbar=20drag-handler=20test=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cover OnDragOver ObjId==0 reject branch, make HandleDropRelease inertness assertion meaningful (populate first), and assert DragHandler/SourceKind on the bottom row too. Test-only; addresses code-review coverage gaps. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../UI/Layout/ToolbarControllerTests.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/AcDream.App.Tests/UI/Layout/ToolbarControllerTests.cs b/tests/AcDream.App.Tests/UI/Layout/ToolbarControllerTests.cs index 6a599ecd..7401eb93 100644 --- a/tests/AcDream.App.Tests/UI/Layout/ToolbarControllerTests.cs +++ b/tests/AcDream.App.Tests/UI/Layout/ToolbarControllerTests.cs @@ -442,9 +442,13 @@ public class ToolbarControllerTests Assert.Equal(i, slots[Row1[i]].Cell.SlotIndex); Assert.Equal(ItemDragSource.ShortcutBar, slots[Row1[i]].Cell.SourceKind); } - // Bottom row slots are indices 9..17. + // Bottom row slots are indices 9..17; same handler + source kind as the top row. for (int j = 0; j < Row2.Length; j++) + { + Assert.Same(ctrl, slots[Row2[j]].DragHandler); Assert.Equal(9 + j, slots[Row2[j]].Cell.SlotIndex); + Assert.Equal(ItemDragSource.ShortcutBar, slots[Row2[j]].Cell.SourceKind); + } } /// OnDragOver accepts a real item (ObjId != 0). Eligibility (IsShortcutEligible) @@ -462,6 +466,20 @@ public class ToolbarControllerTests Assert.True(ctrl.OnDragOver(list, list.Cell, payload)); } + /// OnDragOver rejects a ghost payload with ObjId 0 (the guard against an + /// empty cell that somehow produced a payload). Complements OnDragOver_acceptsRealItem. + [Fact] + public void OnDragOver_rejectsZeroObjId() + { + var (layout, slots, _) = FakeToolbar(); + var ctrl = ToolbarController.Bind(layout, new ClientObjectTable(), + () => Array.Empty(), + iconIds: (_,_,_,_,_) => 0u, useItem: _ => { }); + var list = slots[Row1[0]]; + var payload = new ItemDragPayload(0u, ItemDragSource.Inventory, 0, new UiItemSlot()); + Assert.False(ctrl.OnDragOver(list, list.Cell, payload)); + } + /// HandleDropRelease is a logging stub (TS-33): it must not throw and must not /// mutate the target slot (no wire / no store yet). [Fact] @@ -473,9 +491,10 @@ public class ToolbarControllerTests iconIds: (_,_,_,_,_) => 0u, useItem: _ => { }); var list = slots[Row1[2]]; + list.Cell.SetItem(0x5001u, 0x77u); // populate so "unchanged" is a meaningful assertion var payload = new ItemDragPayload(0x5001u, ItemDragSource.ShortcutBar, 0, new UiItemSlot()); var ex = Record.Exception(() => ctrl.HandleDropRelease(list, list.Cell, payload)); Assert.Null(ex); - Assert.Equal(0u, list.Cell.ItemId); // unchanged — inert stub + Assert.Equal(0x5001u, list.Cell.ItemId); // unchanged — inert stub did not clear/mutate } }