joeylib2/scripts/verify-web-input.sh
2026-10-13 14:01:46 -05:00

42 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# verify-web-input.sh - Typed-character acceptance gate for the web port.
# Runs KEYS's page in headless Chromium at one canvas pixel per stage pixel
# (KEYS.html?scale=1&aspect=square), types the RetroNet definition-of-done
# string as browser key events carrying their text (scripts/lib/webDriver.mjs,
# over the DevTools protocol), takes the canvas, and decodes the example's
# verification scanline (row 198) with scripts/lib/keysRow.py, as the SDL3
# and DVX gates do.
#
# Usage: scripts/verify-web-input.sh
# Requires: Chromium, emsdk's node, python3 + PIL; build/web/bin/KEYS (make web).
set -euo pipefail
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
source "$repo/scripts/lib/joeyEnv.sh"
source "$repo/scripts/lib/webGate.sh"
webNeed
target="192.168.1.10:6510"
dir=$repo/build/web/bin/KEYS
[ -f "$dir/KEYS.html" ] || { echo "verify-web-input: build KEYS first (make web)" >&2; exit 2; }
work=$(mktemp -d -t joeylib-web-input.XXXXXX)
cleanup() {
webStop
rm -rf "$work"
}
trap cleanup EXIT
webServe "$dir"
webDrive "KEYS.html?scale=1&aspect=square" --step wait:3 --step "type:$target" --step wait:2 --screenshot "$work/keys.png"
# The stage at one pixel a pixel: the row must be exactly at (0,198).
if python3 "$repo/scripts/lib/keysRow.py" "$work/keys.png" "$target" --size 320x200 --at 0,198 --scale 1; then
echo "verify-web-input: PASS (typed \"$target\", all ${#target} chars arrived via jlInputGetChar)"
else
echo "verify-web-input: FAIL" >&2
exit 1
fi