InputMapper tracks a mouse-down over a placed piece and promotes it to drag mode once the cursor travels past an 8px threshold. Legal drop cells (those where the piece's start→end vector still fits a legal placement) are highlighted in green. Releasing on a legal cell emits a RelocateRequested signal; Main feeds it to MovePieceCommand, which is already undoable via the existing history stack. Escape or releasing on an invalid cell cancels. The harness gains a relocate() helper so UI tests can script drag-and-drop moves without synthesizing motion events.
35 lines
961 B
Python
35 lines
961 B
Python
"""End-to-end smoke test for piece relocation (drag & drop via IPC)."""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
|
|
|
from tools.automation.harness import Harness
|
|
|
|
|
|
def main():
|
|
with Harness.launch(run_name="relocate") as h:
|
|
h.load_mission("campaign_01", 0)
|
|
h.place("Pawn", (0, 0), (0, 1))
|
|
h.screenshot("01_placed")
|
|
|
|
s = h.state()
|
|
pid = s['pieces'][0]['id']
|
|
assert s['pieces'][0]['start'] == [0, 0]
|
|
assert s['pieces'][0]['end'] == [0, 1]
|
|
|
|
# Relocate pawn to (1,0)→(1,1) — vector preserved
|
|
r = h.relocate(pid, (1, 0), (1, 1))
|
|
print(f"[relocate] {r}")
|
|
assert r['relocated'], r
|
|
h.screenshot("02_relocated")
|
|
|
|
s = h.state()
|
|
assert s['pieces'][0]['start'] == [1, 0]
|
|
assert s['pieces'][0]['end'] == [1, 1]
|
|
|
|
print("OK — relocation works")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|