summaryrefslogtreecommitdiff
path: root/docker/scripts/ciq-env.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docker/scripts/ciq-env.sh')
-rwxr-xr-xdocker/scripts/ciq-env.sh29
1 files changed, 25 insertions, 4 deletions
diff --git a/docker/scripts/ciq-env.sh b/docker/scripts/ciq-env.sh
index a52db78..6216321 100755
--- a/docker/scripts/ciq-env.sh
+++ b/docker/scripts/ciq-env.sh
@@ -87,6 +87,9 @@ ciq_start_simulator() {
# often reuses that process ID for something else, and the simulator then
# believes it is already running and never opens its port. Each container
# runs exactly one simulator, so the stale lock is safe to remove.
+ # A simulator this container already started is reused: a second one
+ # would open a second window, and input could go to the wrong one.
+ ciq_simulator_listening && return 0
rm -f "${HOME}"/Sim-*
simulator >/tmp/simulator.log 2>&1 &
local pid=$! _
@@ -109,19 +112,37 @@ ciq_simulator_window() {
# Longest wait for an app's first frame after launching it.
FIRST_FRAME_TIMEOUT_S=60
-# Launch the debug build of the app on DEVICE and wait for its first frame,
+# Launch the app on DEVICE (the debug build, or MODE's build: uitest) and
+# wait for its first frame,
# which the app reports with a "DIAG first_frame" console line. The console
# goes to LOG, followed by a "HARNESS first_frame wall_ms=N" line: the
# wall-clock time from launch to first frame, including the JVM start of
# monkeydo and the program load the app can't time itself. The app keeps
# running (for screenshots) until ciq_stop_app or the next launch.
-# Returns 1 if no first frame appeared in time.
+# Apps with a glance start in it; the glance is opened with START or a tap,
+# so the wall time includes that. Returns 1 if no first frame appeared in time.
ciq_launch_app() {
- local device="$1" app_log="$2" start _
+ local device="$1" app_log="$2" mode="${3:-debug}" start _
start="$(date +%s%3N)"
- monkeydo "${BUILD_DIR}/debug/${device}.prg" "${device}" >"${app_log}" 2>&1 &
+ # Both monkeydo and the HARNESS line below append, so neither overwrites
+ # the other's output.
+ : >"${app_log}"
+ monkeydo "${BUILD_DIR}/${mode}/${device}.prg" "${device}" >>"${app_log}" 2>&1 &
CIQ_MONKEYDO_PID=$!
+ local presses=0 glance_seen_at=0 tick=0
for _ in $(seq 1 $((FIRST_FRAME_TIMEOUT_S * 20))); do
+ tick=$((tick + 1))
+ # The simulator starts apps that have a glance in the glance. Open the
+ # app from it, as a user would: 2 s after the glance appears (earlier
+ # presses get lost), again every 8 s if the app hasn't opened.
+ if ((glance_seen_at == 0)) && grep -q "DIAG shown glance" "${app_log}"; then
+ glance_seen_at=${tick}
+ fi
+ if ((glance_seen_at > 0 && presses < 3 && tick - glance_seen_at == 40 + presses * 160)); then
+ presses=$((presses + 1))
+ python3 /work/tools/ui_flow.py --open-from-glance --device-dir "${CIQ_HOME}/Devices/${device}" \
+ --window "$(ciq_simulator_window)" --out "${BUILD_DIR}/ui-input" >&2 || return 1
+ fi
if grep -q "DIAG first_frame" "${app_log}"; then
echo "HARNESS first_frame wall_ms=$(($(date +%s%3N) - start))" >>"${app_log}"
return 0