#!/usr/bin/env bash # Smoke Crkl circle flows (integrations need tokens configured separately). set -euo pipefail ADB="${ANDROID_HOME:-/opt/homebrew/share/android-commandlinetools}/platform-tools/adb" export ADB_BIN="$ADB" SHOTS="$(cd "$(dirname "$0")/.." && pwd)/docs/demo-shots/workflows" mkdir -p "$SHOTS" tap() { "$ADB" shell input tap "$1" "$2"; } swipe() { "$ADB" shell input swipe "$1" "$2" "$3" "$4" "$5"; } shot() { "$ADB" exec-out screencap -p > "$SHOTS/$1.png"; echo " shot $1"; } log_clear() { "$ADB" logcat -c || true; } log_has() { "$ADB" logcat -d 2>/dev/null | grep -E "$1" >/dev/null; } enable_a11y() { "$ADB" shell settings put secure enabled_accessibility_services \ com.example.crkl/com.example.crkl.accessibility.CrklAccessibilityService "$ADB" shell settings put secure accessibility_enabled 1 sleep 2 } circle() { python3 - "$1" "$2" "$3" "$4" <<'PY' import math, subprocess, sys, os, time ADB=os.environ["ADB_BIN"] cx,cy,rx,ry=map(float,sys.argv[1:5]) n=36 pts=[(cx+rx*math.cos(2*math.pi*i/n), cy+ry*math.sin(2*math.pi*i/n)) for i in range(n+1)] def me(a,x,y): subprocess.check_call([ADB,"shell","input","motionevent",a,str(int(x)),str(int(y))]) me("DOWN",*pts[0]); time.sleep(0.02) for p in pts[1:]: me("MOVE",*p); time.sleep(0.01) me("UP",*pts[-1]) PY } pass_n=0; fail_n=0 ok() { echo "PASS $1"; pass_n=$((pass_n+1)); } bad() { echo "FAIL $1"; fail_n=$((fail_n+1)); } echo "== prep ==" enable_a11y "$ADB" shell am start -n com.example.crkl/.MainActivity >/dev/null sleep 1 shot "00-home" echo "== email extract ==" log_clear "$ADB" shell am start -n com.example.crkl/.fixtures.TestFixturesActivity >/dev/null enable_a11y swipe 540 1600 540 900 300; sleep 0.4 tap 964 2200; sleep 1 circle 540 1700 400 350 sleep 3 shot "01-email" log_has "Selection ready|Floating button clicked" && ok "email" || bad "email" tap 900 1600; sleep 0.3 echo "== audio ==" log_clear for _ in 1 2; do swipe 540 1900 540 500 300; sleep 0.2; done tap 964 2200; sleep 1 circle 540 1750 400 280 sleep 6 shot "03-audio" log_has "MediaAssistPipeline|audio_grocery" && ok "audio" || bad "audio" echo "== mail inbox fixture ==" log_clear "$ADB" shell am start -n com.example.crkl/.fixtures.TestFixturesActivity >/dev/null enable_a11y sleep 1 # Open mail inbox card if present; otherwise circle fixtures screen tap 540 900; sleep 0.5 tap 964 2200; sleep 1 circle 540 1100 450 550 sleep 3 shot "05-mail-fixture" log_has "Selection ready|Floating button clicked" && ok "mail-fixture" || bad "mail-fixture" echo "== integrations screen ==" "$ADB" shell am start -n com.example.crkl/.IntegrationsActivity >/dev/null sleep 1 shot "08-integrations" ok "integrations-ui" echo echo "== results: $pass_n passed, $fail_n failed ==" echo "Configure Vikunja token + calendar permission in Integrations for live todo/calendar." exit 0