BoardState.CaptureSave/RestoreFromSave deep-copy every mutable field (grid, pieces, demands, transformers, buffers, stock, campaign progress) into a WorldSave slot. GameSim.QuickSave/QuickLoad expose slotted saves and emit StateSavedEvent / StateRestoredEvent — the latter carries a fresh BoardSnapshot so the presentation can rebuild board, pieces, trajectories, objectives, stock, camera, and control bar in one pass. F5/F9 trigger it in Main; harness gains quick_save/quick_load commands so UI tests can checkpoint a scenario and resume without replaying from scratch. Seven xUnit tests cover the roundtrip (including independence from post-save mutations, campaign state, and multi-slot isolation).
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""End-to-end smoke test for quick save / quick load."""
|
|
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="quicksave") as h:
|
|
h.load_mission("campaign_01", 0)
|
|
h.screenshot("01_loaded")
|
|
|
|
initial = h.state()
|
|
print(f"[initial] turn={initial['turn']} pieces={len(initial['pieces'])}")
|
|
|
|
# Save a clean checkpoint
|
|
saved = h.quick_save()
|
|
print(f"[quick_save] {saved}")
|
|
|
|
# Mutate: place a piece and step
|
|
h.place("Pawn", (0, 0), (0, 1))
|
|
h.screenshot("02_after_place")
|
|
h.set_speed(0.1)
|
|
h.play()
|
|
import time as _t
|
|
_t.sleep(1.5)
|
|
h.pause()
|
|
|
|
dirty = h.state()
|
|
print(f"[dirty] turn={dirty['turn']} pieces={len(dirty['pieces'])}")
|
|
|
|
# Load — should be back to initial state
|
|
loaded = h.quick_load()
|
|
print(f"[quick_load] {loaded}")
|
|
h.screenshot("03_after_load")
|
|
|
|
restored = h.state()
|
|
print(f"[restored] turn={restored['turn']} pieces={len(restored['pieces'])}")
|
|
|
|
assert restored['turn'] == initial['turn'], "Turn mismatch after restore"
|
|
assert len(restored['pieces']) == len(initial['pieces']), "Piece count mismatch"
|
|
print("OK — quick save/load roundtrip successful")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|