Files
Aislo/resources/tester/test_509_3_offscreen_skip.py
T

63 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
"""509-3 공용 선 그리기(B04 지도 · 배수유역도 · B05 평면) — 화면 밖 구간 건너뛰기.
- 두 끝이 같은 쪽 화면 밖인 구간만 안 그림 · 화면(+ 여백 32 px)에 걸치는 구간은 다 그림
- 다 안이면 예전과 같은 호출(moveTo 1 · stroke 1 · 닫힌 고리 = closePath)
- 넓힘(padPx) 무한 = 안 거름(고른 등고선 덧그리기)
Node 헬퍼(`helper_509_3_offscreen_skip.cjs`)가 진짜 TS 를 가짜 캔버스로 돌린다.
"""
import json
import os
import subprocess
import pytest
HERE = os.path.dirname(os.path.abspath(__file__))
@pytest.fixture(scope="module")
def r():
proc = subprocess.run(
["node", os.path.join(HERE, "helper_509_3_offscreen_skip.cjs")],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_다_안이면_예전과_같음(r):
assert r["inside"]["calls"] == {"moveTo": 1, "lineTo": 3, "stroke": 1, "closePath": 0}
def test_한쪽_밖_고리는_건너뜀(r):
loop = r["leftLoop"]
assert loop["missing"] == 0
assert loop["calls"]["lineTo"] == 2 # 밖 200 구간 → 0
def test_모서리_지르는_구간은_그림(r):
assert r["corner"]["drawn"] == 1
def test_닫힌_고리(r):
assert r["ringIn"]["calls"]["closePath"] == 1 and r["ringIn"]["missing"] == 0
assert r["ringOut"]["missing"] == 0 and r["ringOut"]["calls"]["closePath"] == 0
def test_다_밖이면_안_그림(r):
assert r["allOut"]["calls"]["stroke"] == 0
def test_넓힘_무한은_안_거름(r):
assert r["padded"]["calls"]["lineTo"] == 201
def test_무작위_선_보이는_구간_빠짐_없음(r):
assert r["randomMissing"] == 0
assert r["randomDrawn"] < r["randomTotal"] / 4