#!/usr/bin/env bash # Author: cirakg & claude ai # Summary: Screenshot the app on each device in the headless simulator and compare with the approved golden images. # # Usage: screenshots.sh DEVICE [DEVICE ...] (APPROVE=1 saves new goldens) # Output: build/screenshots/.png (the watch screen only), plus a # -diff.png when it differs from test/golden/.png. set -euo pipefail # shellcheck source=ciq-env.sh source "$(dirname "${BASH_SOURCE[0]}")/ciq-env.sh" # Pause after the first frame, so animations and late redraws settle. readonly SETTLE_S=1 (($# > 0)) || die "usage: screenshots.sh DEVICE [DEVICE ...]" ciq_require_sdk ciq_require_key for device in "$@"; do build-app.sh debug "${device}" done ciq_start_display ciq_start_simulator out="${BUILD_DIR}/screenshots" mkdir -p "${out}" approve=() [[ "${APPROVE:-0}" == 1 ]] && approve=(--approve) failed=0 for device in "$@"; do if ! ciq_launch_app "${device}" "${out}/${device}.log"; then ciq_stop_app log "no first frame on ${device}; see build/screenshots/${device}.log" failed=1 continue fi sleep "${SETTLE_S}" mkdir -p "${out}/raw" import -window "$(ciq_simulator_window)" "${out}/raw/${device}-window.png" ciq_stop_app python3 /work/tools/sim_screenshot.py --raw "${out}/raw/${device}-window.png" \ --device-dir "${CIQ_HOME}/Devices/${device}" --out "${out}/${device}.png" \ --golden "/work/test/golden/${device}.png" "${approve[@]}" || failed=1 done ((failed == 0)) || die "screenshot checks failed; see build/screenshots/" log "screenshots checked on: $*"