- resize 가 px 이동량을 그대로 두고 지도 틀만 다시 잡아 지도가 밀림 → 밀린 자리가 보던 화면으로 저장돼 다시 열어도 빈 화면 - 63-1 로 편집 창이 화면 크기를 따라가게 되면서 창 크기 변경마다 밀림 - 창을 열 때 기억한 화면에 노선이 한 점도 없으면 노선 전체 맞춤으로 엶(이미 밀려 저장된 값 복구) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
76 lines
2.9 KiB
Python
76 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""계획노선 편집 창 — **보던 화면 기억**(계획서 18 ③)과 노드 끼우기·빼기 회귀검증.
|
|
|
|
화면은 창 크기와 무관한 꼴(가운데 m · 1m 당 픽셀 · 회전각)로 기억한다. 창 크기가 바뀌어도
|
|
같은 자리를 같은 배율로 다시 열어야 한다. 자리는 화면 취향 통(`aislo:pref:`)의 프로젝트 칸.
|
|
|
|
Node 헬퍼(`helper_b05_routeedit_view.cjs`)가 TS 를 트랜스파일해 돌리고, 여기서 값을 판정한다.
|
|
"""
|
|
|
|
import json
|
|
import math
|
|
import os
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def results():
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_b05_routeedit_view.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_다른_창_크기에서도_같은_가운데와_배율(results):
|
|
saved, again = results["saved"], results["again"]
|
|
assert again["cx"] == pytest.approx(saved["cx"], abs=1e-6)
|
|
assert again["cy"] == pytest.approx(saved["cy"], abs=1e-6)
|
|
assert again["pxPerMeter"] == pytest.approx(saved["pxPerMeter"], rel=1e-9)
|
|
assert saved["rotationDeg"] == pytest.approx(30.0)
|
|
|
|
|
|
def test_저장소_왕복은_프로젝트마다(results):
|
|
assert results["readBack"] == pytest.approx(results["saved"])
|
|
assert results["otherProject"] is None
|
|
assert results["storedKeys"] == ["aislo:pref:routeedit-view:p-1"]
|
|
|
|
|
|
def test_보던_화면이_없으면_노선에_맞추고_회전_0(results):
|
|
assert results["fresh"]["rotationRad"] == 0
|
|
assert results["fresh"]["scale"] > 0
|
|
assert results["withSaved"]["rotationRad"] == pytest.approx(math.radians(30))
|
|
|
|
|
|
def test_노선이_안_보이는_기억은_버리고_노선에_맞춤(results):
|
|
assert results["stray"]["rotationRad"] == 0
|
|
assert results["stray"]["onScreen"] is True
|
|
|
|
|
|
def test_창_크기가_바뀌어도_가운데와_배율_그대로(results):
|
|
before, after = results["keptBefore"], results["keptAfter"]
|
|
assert after["cx"] == pytest.approx(before["cx"], abs=1e-6)
|
|
assert after["cy"] == pytest.approx(before["cy"], abs=1e-6)
|
|
assert after["pxPerMeter"] == pytest.approx(before["pxPerMeter"], rel=1e-9)
|
|
|
|
|
|
def test_노드_끼우기_빼기는_편집값이_같은_자리로(results):
|
|
inserted = results["afterInsert"]
|
|
assert inserted["planned"][1] == [5, 5]
|
|
assert inserted["curveOn"] == [True, True, False, True]
|
|
assert inserted["curveRadius"] == [None, None, 30, None]
|
|
assert inserted["curveLock"] == [None, None, "radius", None]
|
|
assert inserted["curveArc"] == [None, None, 12, None]
|
|
assert inserted["apexLock"] == [False, False, True, False]
|
|
removed = results["afterRemove"]
|
|
assert removed["planned"] == [[0, 0], [10, 0], [20, 0]]
|
|
assert removed["curveRadius"] == [None, 30, None]
|
|
assert removed["apexLock"] == [False, True, False]
|