Files
Aislo/resources/tester/test_cad_touch.py
T
eomsangdonandClaude Opus 5.5 dce63ccc21 feat(486 B07 CAD 화면): 제목줄 · 램프 · 하단 도면 칸 지움 · ↶ ↷ = 리본 탭 줄 오른쪽 · 손가락 단추 = 자판 없는 기기만 · 탭 줄 빈 자리 변수
- 제목줄(Aislo CAD · 부제 · 「현재 도면」 램프) 지움 · --cad-title-height 0 · 💾 · JSON 내보내기 = DOM 두고 숨김(QUICK_ACCESS_HIDDEN)
- 빠른 실행 = 리본 탭 줄 빈 자리 뒤 · 접기 단추 앞(줄 높이 26 그대로 · M02 hostSave 면 안 그림)
- 빈 자리([출력] 오른쪽 ~ ↶ 왼쪽) → .cad-host 에 --cad-tab-slot-left/right(iframe 끝 기준 px) — 부모 탭 줄 겹침 자리
- ☰ 비키기 패딩 = 리본 탭 줄로 · 손가락 단추 = (hover: none) and (pointer: coarse) 만
- 하단 도면 이름 · ‹ › · 확정 칸(QuantityPanel) · 이동 요청 지움
- 시험 test_cad_touch(미디어 조건) · test_cad_host_tabs(머리줄 · 빈 자리 변수) 고쳐 씀

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 22:07:35 +09:00

95 lines
3.8 KiB
Python

"""B07 CAD 손가락(PLAN_기기대응 4-1 · `openwebcad/src/inputController/input-touch.ts`) — 빌드된 CAD 화면.
① 자판 없는 기기(hover:none · pointer:coarse) = 명령 단추 6개(44px) · 마우스 · 터치 노트북 = 안 보임(요구 280-6)
② 확대 막기(user-scalable=no) 없음
③ 캔버스 touch-action none · 두 손가락 벌림 · 한 손가락 끌기가 페이지를 확대 · 밀지 않음(페이지 오류 0)
"""
import os
import urllib.request
import pytest
URL = os.environ.get("CAD_TOUCH_URL", "http://localhost:5174/b07-cad/")
def _up() -> bool:
try:
urllib.request.urlopen(URL, timeout=2)
return True
except Exception:
return False
def _touch(cdp, kind, points):
cdp.send(
"Input.dispatchTouchEvent",
{
"type": kind,
"touchPoints": [{"x": x, "y": y, "id": i} for i, (x, y) in enumerate(points)],
},
)
@pytest.mark.skipif(not _up(), reason="sub1 화면 서버(5174) 꺼짐")
def test_cad_touch_bar_and_gestures():
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(channel="msedge", headless=True)
mouse = browser.new_page(viewport={"width": 1440, "height": 900})
mouse.goto(URL)
mouse.wait_for_selector(".cad-touch-bar", state="attached", timeout=20000)
assert (
mouse.evaluate("getComputedStyle(document.querySelector('.cad-touch-bar')).display")
== "none"
)
# 터치 노트북(any-pointer: coarse · 주 입력 마우스) — 단추는 hover:none 일 때만(에뮬은 터치 노트북을 못 꾸밈)
media = mouse.evaluate(
"[...document.styleSheets].flatMap(s => [...s.cssRules]).filter(r => r.media"
" && [...r.cssRules].some(c => c.selectorText === '.cad-touch-bar')).map(r => r.media.mediaText)"
)
assert media == ["(hover: none) and (pointer: coarse)"], media
ctx = browser.new_context(
viewport={"width": 1180, "height": 820}, has_touch=True, is_mobile=True
)
page = ctx.new_page()
errors = []
page.on("pageerror", lambda e: errors.append(str(e)))
page.goto(URL)
page.wait_for_selector(".cad-touch-bar", timeout=20000)
sizes = page.evaluate(
"[...document.querySelectorAll('.cad-touch-bar > button')].map(b => [b.offsetWidth, b.offsetHeight])"
)
assert len(sizes) == 6 and all(w >= 44 and h >= 44 for w, h in sizes), sizes
assert "user-scalable" not in page.evaluate(
"document.querySelector('meta[name=viewport]').content"
)
assert (
page.evaluate(
"getComputedStyle(document.querySelector('canvas[data-id=canvas]')).touchAction"
)
== "none"
)
box = page.evaluate(
"(() => { const r = document.querySelector('canvas[data-id=canvas]').getBoundingClientRect();"
" return [r.left + r.width / 2, r.top + r.height / 2]; })()"
)
cx, cy = box
cdp = ctx.new_cdp_session(page)
_touch(cdp, "touchStart", [(cx, cy)]) # 한 손가락 끌기 = 화면 옮기기
for i in range(1, 6):
_touch(cdp, "touchMove", [(cx + i * 20, cy + i * 10)])
_touch(cdp, "touchEnd", [])
_touch(cdp, "touchStart", [(cx - 30, cy), (cx + 30, cy)]) # 벌림 = 도면 확대
for i in range(1, 8):
_touch(cdp, "touchMove", [(cx - 30 - i * 10, cy), (cx + 30 + i * 10, cy)])
_touch(cdp, "touchEnd", [])
page.locator(".cad-touch-bar > button").first.tap() # Esc
page.wait_for_timeout(300)
assert page.evaluate("visualViewport.scale") == 1
assert page.evaluate("[scrollX, scrollY]") == [0, 0]
assert not errors, errors
browser.close()