Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QND7Co43B24zK2P937rdxt
77 lines
2.9 KiB
Python
77 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""돋보기 휠 배율(계획서 220-1) 회귀검증 — 지름 360 · 켜진 동안 휠 = 배율 ± 0.25(1.5 ~ 6) ·
|
||
그동안 휠 기본 동작(스크롤 · 그래프 줌) 막음 · 꺼지면 그대로 · 다음 켤 때 2배 · 원 아래 배율 글.
|
||
|
||
218-1 헬퍼(`helper_218_1_loupe.cjs`)의 휠 · 배율 글 장면을 판정함.
|
||
"""
|
||
|
||
import json
|
||
import os
|
||
import subprocess
|
||
|
||
import pytest
|
||
|
||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||
ROOT = os.path.dirname(os.path.dirname(HERE))
|
||
|
||
|
||
@pytest.fixture(scope="module")
|
||
def r():
|
||
proc = subprocess.run(
|
||
["node", os.path.join(HERE, "helper_218_1_loupe.cjs")],
|
||
capture_output=True,
|
||
text=True,
|
||
encoding="utf-8",
|
||
timeout=60,
|
||
)
|
||
assert proc.returncode == 0, proc.stderr
|
||
return json.loads(proc.stdout)
|
||
|
||
|
||
def test_지름_360_배율_한도(r):
|
||
c = r["consts"]
|
||
assert c["d"] == 360 and r["capture"]["rootSize"] == ["360px", "360px"]
|
||
assert (c["zoom"], c["zoomMin"], c["zoomMax"], c["zoomStep"]) == (2, 1.5, 6, 0.25)
|
||
|
||
|
||
def test_휠_위_크게_아래_작게_한도(r):
|
||
w = r["wheel"]
|
||
assert w["up"]["zoom"] == 2.25 # 위로 한 칸
|
||
assert w["down"] == 1.75 # 아래로 두 칸
|
||
assert w["flat"] == 1.75 # 가로 굴림은 그대로
|
||
assert w["max"] == 6 and w["min"] == 1.5
|
||
assert w["pure"] == [2.25, 1.75, 6, 1.5]
|
||
|
||
|
||
def test_켜진_동안_휠_기본_동작_막음(r):
|
||
w = r["wheel"]
|
||
assert w["up"]["prevented"] and w["up"]["stopped"] # 스크롤 · 그래프 휠 줌 안 받음
|
||
assert w["press"] == {"prevented": True, "zoom": ["zoom", 2.25]} # 우클릭 길게 누름도
|
||
assert ["wheel", {"capture": True, "passive": False}] in r["listeners"]
|
||
|
||
|
||
def test_꺼지면_스크롤_그대로(r):
|
||
w = r["wheel"]
|
||
assert w["off"] == {"prevented": False, "stopped": False, "log": 0}
|
||
assert w["afterOff"] == {"prevented": False, "stopped": False, "zoomed": False}
|
||
|
||
|
||
def test_다음_켤_때_2배(r):
|
||
assert r["wheel"]["reopen"] == 2.25 # 1.5 에서 껐다 켜면 2배에서 한 칸
|
||
h = r["hide"]
|
||
assert h["reopenLabel"] == ["×2", False, "translate(-820px, -620px) scale(2)"]
|
||
|
||
|
||
def test_배율_글_원_아래(r):
|
||
lb = r["label"]
|
||
assert lb["cls"] == "ui-loupe__zoom" and lb["ariaHidden"] == "true" and not lb["hidden"]
|
||
assert lb["text"] == "×2"
|
||
# 원(320,220 · 지름 360) 아래 가운데 — 원 끝 580 + 4
|
||
assert lb["at"] == "translate(500px, 584px) translateX(-50%)"
|
||
assert lb["zoom3"] == ["×3", "translate(-1320px, -1020px) scale(3)", "translate(320px, 220px)"]
|
||
assert lb["bottom"] == "translate(500px, 778px) translateX(-50%)" # 화면 아래 끝에서 안 잘림
|
||
assert r["hide"]["labelHidden"]
|
||
with open(os.path.join(ROOT, "ui_template", "ui_template_loupe.css"), encoding="utf-8") as f:
|
||
css = f.read()
|
||
assert ".ui-loupe__zoom" in css and ".ui-loupe__zoom[hidden]" in css
|