#!/bin/sh # test-android.sh — anti-régression Android : installe le build courant, # lance une séquence de touches réelles sur l'émulateur et vérifie les logs # GameLog attendus (tir, mélée, pouvoirs, wall glide). # # Usage : scripts/test-android.sh [version] (défaut : titre du commit) # # Prérequis : émulateur Android démarré + adb accessible, APK déjà construit # (./gradlew :android-app:assembleDebug). # # Ce que la séquence vérifie (logs logcat) : # - "tir primaire" -> bouton FIRE -> MOUSE_RIGHT (anti-régression # feedback v4.0.0 : tir injoignable) # - "touch button" -> hit-test des boutons du HUD tactile # - "TouchControls" -> HUD attaché # - "glyphe" absent -> tolérance des caractères manquants # # Sortie : PASS/FAIL par check, code retour 1 si un check échoue. # Idempotent : relançable à volonté (force-stop avant chaque lancement). set -eu PKG="fr.siphonight.lostsectorport" ACTIVITY="$PKG/com.ezardlabs.lostsector.AndroidGameActivity" ROOT="$(cd "$(dirname "$0")/.." && pwd)" # --- Pré-vol --------------------------------------------------------------- adb get-state >/dev/null 2>&1 || { echo "ERREUR : aucun émulateur/device adb" >&2 exit 1 } [ -f "$ROOT/android-app/build/outputs/apk/debug/android-app-debug.apk" ] || { echo "ERREUR : APK absent — lancer './gradlew :android-app:assembleDebug'" >&2 exit 1 } # --- Installation et lancement --------------------------------------------- echo "==> Installation de l'APK" adb install -r "$ROOT/android-app/build/outputs/apk/debug/android-app-debug.apk" >/dev/null adb logcat -c adb shell am force-stop "$PKG" 2>/dev/null || true adb shell am start -n "$ACTIVITY" >/dev/null sleep 14 # menu principal chargé fails=0 check() { if grep -q "$2" /tmp/test-android.log 2>/dev/null; then echo "PASS : $1" else echo "FAIL : $1 (motif '$2' absent des logs)" >&2 fails=$((fails + 1)) fi } # --- Test 1 : le menu se charge sans crash --------------------------------- adb logcat -d >/tmp/test-android.log check "menu principal chargé sans crash" "LS-LEVEL: Level 'main_menu' fully loaded" # --- Test 2 : Defend -> tir primaire via FIRE ------------------------------ # (FIRE = bas droite, MOUSE_RIGHT maintenu -> "tir primaire : cadence engagée") adb shell input swipe 1055 375 1055 375 300 # Defend sleep 14 (adb shell input swipe 2235 900 2235 900 1200 &) sleep 3 adb logcat -d >/tmp/test-android.log check "HUD tactile attaché (9 boutons)" "TouchControls attached" check "tir primaire déclenché via FIRE" "tir primaire" # --- Test 3 : pouvoir 1 (rangée horizontale bas centre) -------------------- adb shell input swipe 1080 1000 1080 1000 200 # bouton 1 sleep 2 adb logcat -d >/tmp/test-android.log check "pouvoir 1 déclenché" "pouvoir 1" # --- Test 4 : pause (II) dans la mission ----------------------------------- adb shell input swipe 1080 120 1080 120 200 # bouton II sleep 3 adb logcat -d >/tmp/test-android.log check "menu pause via II (pas de crash)" "LS-GAMEPLAY\|LS-LEVEL" # --- Bilan ----------------------------------------------------------------- if [ "$fails" -eq 0 ]; then echo "==> ANTI-RÉGRESSION : PASS (4/4)" else echo "==> ANTI-RÉGRESSION : FAIL ($fails échec(s))" >&2 exit 1 fi