Files
lmxopcua/docs/ui-consistency/ot07-touch/baseline.py
T

18 lines
1.8 KiB
Python

"""Measured pre-change synthetic Raw hierarchy and toolbars; no backend operations."""
from playwright.sync_api import sync_playwright
from pathlib import Path
import json
out=Path(__file__).resolve().parent;data=[]
with sync_playwright() as p:
b=p.chromium.launch()
for width,coarse in [(1440,False),(390,False),(195,False),(390,True)]:
context=b.new_context(viewport={'width':width,'height':900},has_touch=coarse,is_mobile=coarse)
page=context.new_page();page.goto('http://127.0.0.1:18139/raw-pilot');page.wait_for_selector('#raw-scroller input[type=checkbox]');page.evaluate('document.fonts.ready');page.wait_for_timeout(500)
data.append(page.evaluate('''()=>({width:innerWidth,coarse:matchMedia('(pointer:coarse)').matches,scrollWidth:document.documentElement.scrollWidth,renderedTags:document.querySelectorAll('#raw-scroller input[type=checkbox]').length,expand:[...document.querySelectorAll('#raw-scroller .tree-twist')].slice(0,2).map(e=>({width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height})),menu:[...document.querySelectorAll('#raw-scroller .ctx-ellipsis')].slice(0,2).map(e=>({width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height})),checkbox:[...document.querySelectorAll('#raw-scroller input[type=checkbox]')].slice(0,2).map(e=>({width:e.getBoundingClientRect().width,height:e.getBoundingClientRect().height})),rowHeight:document.querySelector('#raw-scroller input[type=checkbox]').closest('div').getBoundingClientRect().height})'''))
context.close()
b.close()
(out/'baseline-measurements.json').write_text(json.dumps(data,indent=2)+'\n');print(json.dumps(data))
assert all(abs(r["rowHeight"]-30)<1 for r in data), "Raw row heights must match ItemSize30 before density support"
assert all(r["expand"][0]["width"]>=44 and r["expand"][0]["height"]>=44 for r in data if r["coarse"]), "Coarse expand target must be44px"