Inventory grid harness: Soul's probes, the un-highlight check and six more mutants

Interact gains what Soul's probes showed the harness did not reach (finding equip-flow-unpinned): a click on another cell after a double click counts 1, one hover handler per grid after repeated Display, the thermal right, top and bottom regions, and the bay-to-hull equip flow. The play capture clicks a second item and asserts the first is un-highlighted (kills unhighlight-dropped). tests/mutation_tests_inventory_grid.py --switch runs Soul's six mutants and a play kind that runs InventoryPanelsPlayCapture, so unhighlight-dropped and pulse-ignored are no longer run by hand. All 15 switch mutants exit 1 on the shipped code with the sheets still present.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-12-01 07:52:07 +01:00
commit 8ee198ef02
3 changed files with 107 additions and 7 deletions

View file

@ -1358,6 +1358,69 @@ public static class InventoryGridParityCapture
if (!hud.Settings) hud.Settings = settings;
hud.Display(ship, true);
Check(!hud.Interactive && hud.Grid.GetComponents<ObservableTriggerBase>().Length == 0, "a HUD panel (Interactive false) adds no trigger component to its grid");
// ---- the handler paths the first checks do not reach: click state, hover subscriptions, thermal edges, the equip flow ----
{
// click on a different cell after a double click starts again at 1
var clicks2 = new List<(int2 cell, int count)>();
equipment.Display(ship);
Layout(equipment);
using (equipment.OnClickAsObservable().Subscribe(e => clicks2.Add((e.data.Position, e.clickCount))))
{
var a2 = itemCells[0];
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, Centre(grid, a2)), ExecuteEvents.pointerClickHandler);
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, Centre(grid, a2)), ExecuteEvents.pointerClickHandler);
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, Centre(grid, other)), ExecuteEvents.pointerClickHandler);
Check(clicks2.Count == 3 && clicks2[1].count == clicks2[0].count + 1 && clicks2[2].cell.Equals(other) && clicks2[2].count == 1, $"a click on another cell after a double click counts 1 (got {string.Join(";", clicks2.Select(c => c.cell.x + "," + c.cell.y + "x" + c.count))})");
}
// subscriptions do not accumulate over Display
int Handlers(InventoryGrid g) => ((Delegate) typeof(InventoryGrid).GetField("HoveredCellChanged", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(g))?.GetInvocationList().Length ?? 0;
equipment.Display(ship); equipment.Display(ship); equipment.Display(ship, false, true); equipment.Display(ship);
cargoPanel.Display(bay); cargoPanel.Display(bay); cargoPanel.Display(bay);
Check(Handlers(grid) == 1 && Handlers(cargoGrid) == 1, $"one hover handler per grid after repeated Display (equipment {Handlers(grid)}, cargo {Handlers(cargoGrid)})");
// thermal: right, up and down regions toggle their neighbours
equipment.Display(ship, false, true);
Layout(equipment);
var t = hull.Shape.AllCoordinates.First(c => hull.Shape[c] && hull.Shape[new int2(c.x + 1, c.y)] && hull.Shape[new int2(c.x, c.y + 1)] && hull.Shape[new int2(c.x, c.y - 1)]);
var cr = grid.CellRect(t);
Vector2 At(float fx, float fy) => ScreenOf(grid, cr.min + new Vector2(cr.width * fx, cr.height * fy));
var rightWas = ship.HullConductivity[t.x, t.y].x; var upWas = ship.HullConductivity[t.x, t.y].y; var downWas = ship.HullConductivity[t.x, t.y - 1].y;
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, At(.9f, .5f)), ExecuteEvents.pointerClickHandler);
Check(ship.HullConductivity[t.x, t.y].x != rightWas, "a thermal click at the right of a cell toggles the right conductivity");
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, At(.5f, .9f)), ExecuteEvents.pointerClickHandler);
Check(ship.HullConductivity[t.x, t.y].y != upWas, "a thermal click at the top of a cell toggles the upward conductivity");
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, At(.5f, .1f)), ExecuteEvents.pointerClickHandler);
Check(ship.HullConductivity[t.x, t.y - 1].y != downWas, "a thermal click at the bottom of a cell toggles the downward conductivity");
equipment.Display(ship);
Layout(equipment);
// the equip flow: an item dragged from the bay onto the equipment panel
var gone = ship.TryUnequip(equipped);
Check(gone != null, "the equipped item unequips");
if (gone != null)
{
bay.TryStore(gone);
cargoPanel.Display(bay); equipment.Display(ship);
Layout(cargoPanel); Layout(equipment);
var pos = bay.Cargo[gone];
var gdata = fixture.Manager.ItemManager.GetData(gone);
var grab = bay.Data.InteriorShape.Inset(gdata.Shape, pos, gone.Rotation).Coordinates[0];
var off = pos - grab;
var landing = equipped.Position - off;
var press2 = Centre(cargoGrid, grab);
ExecuteEvents.Execute(cargoGrid.gameObject, Pointer(cargoGrid.gameObject, press2), ExecuteEvents.beginDragHandler);
Check(fixture.Manager.DragObject is ItemInstanceDragObject && (cargoPanel.IgnoreOccupancy?[grab] ?? false), "a begin drag on the bay's item starts an item-instance drag and ignores its cells");
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, Centre(grid, landing)), ExecuteEvents.pointerMoveHandler);
Check(equipment.FakeItem == gone && equipment.FakeOccupancy != null && equipment.FakeOccupancy.Coordinates.Any(), $"the pointer over a fitting hull cell sets the equipment panel's FakeOccupancy (landing {landing.x},{landing.y})");
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, Centre(grid, landing)), ExecuteEvents.pointerExitHandler);
Check(equipment.FakeItem == null && equipment.FakeOccupancy == null, "leaving the hull clears the equipment panel's FakeOccupancy");
ExecuteEvents.Execute(grid.gameObject, Pointer(grid.gameObject, Centre(grid, landing)), ExecuteEvents.pointerMoveHandler);
ExecuteEvents.Execute(cargoGrid.gameObject, Pointer(cargoGrid.gameObject, Centre(grid, landing), press2), ExecuteEvents.endDragHandler);
Check(cargoPanel.IgnoreOccupancy == null && fixture.Manager.DragObject == null, "an end drag in the bay clears its IgnoreOccupancy and the drag");
Check(ship.Equipment.Any(e => e.EquippableItem == gone) && !bay.Occupancy.Cast<ItemInstance>().Any(i => i == gone), "the drop equipped the item and took it out of the bay");
var back = hull.Shape.Inset(gdata.Shape, ship.Equipment.First(e => e.EquippableItem == gone).Position, gone.Rotation).Coordinates;
Check(back.All(v => grid.RecordAt(v).Item), "the equipment panel draws the dropped item's cells");
}
}
}
finally
{

View file

@ -241,6 +241,14 @@ public static class InventoryPanelsPlayCapture
$"a click on {fitted.Data.Name} highlights its {itemCells.Length} cells");
yield return Snap("highlight");
// a click on a different item un-highlights the first: its cells draw their plain colour again, the second item's the highlight colour
var second = ship.Equipment.Where(e => e.EquippableItem != null && e.EquippableItem != fitted.EquippableItem).OrderBy(e => e.Data.Shape.Coordinates.Length).FirstOrDefault();
Require(second != null, "a second fitted item exists to click");
var secondCells = hull.Shape.Inset(second.Data.Shape, second.Position, second.EquippableItem.Rotation).Coordinates;
ExecuteEvents.Execute(grid.gameObject, Pointer(Centre(grid, secondCells[0])), ExecuteEvents.pointerClickHandler);
Require(itemCells.All(v => Pack(grid.RecordAt(v).Icon) == Pack(equipmentPanel.GetColor(v, false))) && secondCells.All(v => Pack(grid.RecordAt(v).Icon) == Pack(equipmentPanel.GetColor(v, true))),
$"a click on {second.Data.Name} un-highlights {fitted.Data.Name} and highlights its own {secondCells.Length} cells");
// drag: the ghost; hover: the other panel's FakeOccupancy
var press = Centre(grid, itemCells[0]);
ExecuteEvents.Execute(grid.gameObject, Pointer(press), ExecuteEvents.beginDragHandler);