""" RIA_VirtualControls: touches on the pad and its edit toolbar must never reach the game's own touch handling (RPG Maker's TouchInput listens for touchstart/mousedown on document; some games add earlier, capture-phase listeners). Otherwise resizing a control or tapping −/+ also "taps the screen" and advances the dialogue. Runs the real plugin in headless Chrome: python3 tests/test_virtual_controls_touch.py """ import json import re import shutil import subprocess import tempfile from pathlib import Path from _t import ROOT, run PLUGIN = ROOT / "android-template/app/src/main/assets/www/js/plugins/RIA_VirtualControls.js" HARNESS = """
pending
""" def _run_harness() -> dict: tmp = Path(tempfile.mkdtemp()) shutil.copy(PLUGIN, tmp / PLUGIN.name) (tmp / "index.html").write_text(HARNESS, encoding="utf-8") dom = subprocess.run( ["timeout", "60", "google-chrome", "--headless=new", "--no-sandbox", "--disable-gpu", "--allow-file-access-from-files", "--dump-dom", (tmp / "index.html").as_uri()], capture_output=True, text=True, check=False, ).stdout found = re.search(r'id="out">([^<]*)<', dom) assert found and found.group(1) != "pending", dom[-2000:] return json.loads(found.group(1).replace(""", '"')) def test_controls_keep_touches_from_the_game(): if not shutil.which("google-chrome"): print("ATLANDI: google-chrome yok") return r = _run_harness() assert r["aPressed"], r assert r["bPressed"], r assert r["normal"] == {"game": [], "early": []}, r["normal"] assert r["edit"] == {"game": [], "early": []}, r["edit"] assert r["toolbarClick"], r assert r["elsewhere"]["game"] == ["touchstart", "mousedown", "pointerdown"], r["elsewhere"] assert r["elsewhere"]["early"] == ["touchstart", "mousedown"], r["elsewhere"] if __name__ == "__main__": run(globals())