test(ui): D.5.3/B.1 — strengthen toolbar drag-handler test coverage
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) <noreply@anthropic.com>
This commit is contained in:
parent
3d04f61451
commit
35ebb3c8f0
1 changed files with 21 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>OnDragOver accepts a real item (ObjId != 0). Eligibility (IsShortcutEligible)
|
||||
|
|
@ -462,6 +466,20 @@ public class ToolbarControllerTests
|
|||
Assert.True(ctrl.OnDragOver(list, list.Cell, payload));
|
||||
}
|
||||
|
||||
/// <summary>OnDragOver rejects a ghost payload with ObjId 0 (the guard against an
|
||||
/// empty cell that somehow produced a payload). Complements OnDragOver_acceptsRealItem.</summary>
|
||||
[Fact]
|
||||
public void OnDragOver_rejectsZeroObjId()
|
||||
{
|
||||
var (layout, slots, _) = FakeToolbar();
|
||||
var ctrl = ToolbarController.Bind(layout, new ClientObjectTable(),
|
||||
() => Array.Empty<PlayerDescriptionParser.ShortcutEntry>(),
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary>HandleDropRelease is a logging stub (TS-33): it must not throw and must not
|
||||
/// mutate the target slot (no wire / no store yet).</summary>
|
||||
[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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue