Files
iron-arc/docs/testing.md
T
SoftwareApp 92b5ef16cb m7c: brand splash instead of the white startup screen
- LaunchTheme/NormalTheme on #05070A (was the stock light theme + white
  windowBackground) and the Android 12 splash API in values-v31
- splash icon is a padded 512x512 canvas: Android masks everything outside the
  inner 192dp of the 288dp icon area, which clipped the wordmark at the top;
  the icon plate is set to the icon navy
- Flutter splash (lib/src/ui/splash_screen.dart): logo pulses (scale 0.96-1.04,
  opacity 0.72-1.0, 1100 ms) plus a thin progress line, min 700 ms measured
  from the first Flutter frame
- boot work (session, FFI library, ad SDK) now runs after the first frame and
  the game fades in over the splash: no blocking work before the first frame
- numbers (Redmi Note 10, API 31): debug 3053 ms, profile/AOT 2040 ms on the
  first start, 850-960 ms on later cold starts, ready log ~1030 ms
- fixed: top-level Stopwatch only started on first access (Dart lazily
  initialises top-level finals), so the boot log always showed 0 ms
- tools/device/startup.sh measures cold start + boot log; testing.md documents
  the splash chain and the MIUI release-install trap
2026-10-25 02:34:09 +02:00

132 lines
6.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Teststrategie
| Feld | Wert |
|---|---|
| Stand | 2026-10-24 |
| Bezug | [ADR 0002](ADR/0002-determinismus-fixed-point.md) · [roadmap.md](roadmap.md) |
---
## 1. Testpyramide
```
/\ Gerät (manuell/geskriptet) – Feel, Perf, Insets, Ads/Billing
/ \ Server-Integration – HTTP, Tamper, Last
/----\ Flame-Golden-Tests – Canvas/Rendering (headless)
/------\ Dart-Widget-Tests – UI-Logik
/--------\ Rust-Unit/Property – Sim, Determinismus, Content
```
Ziel: **80 % der Logik** sind ohne Gerät und ohne Emulator prüfbar. Das Gerät ist Abnahme,
kein Entwicklungswerkzeug.
## 2. Rust (`crates/sim`, `crates/content`, `crates/server`)
| Testart | Datei | Prüft |
|---|---|---|
| Unit | `sim/src/**/tests` | Ballistik, Schadensformel, Kollaps, Terrain-Carve |
| Property | `sim/tests/proptest_invariants.rs` | HP ∈ [0,100], Samples ∈ [0,Höhe], Munition ≥ 0, Tick-Monotonie |
| Determinismus | `sim/tests/determinism.rs` | 10k Seeds: Replay zweimal ⇒ gleicher `final_hash` |
| Replay-Roundtrip | `sim/tests/replay_roundtrip.rs` | `decode(encode(replay))` byte-identisch |
| Golden | `sim/tests/golden/*.json` | 3 Referenz-Matches inkl. Hash, bei Balance-Änderung bewusst regenerieren |
| Content-Validierung | `content/tests/validation.rs` | fehlende Referenzen, Wertebereiche, `content_hash` stabil |
| Server-Integration | `server/tests/api.rs` | alle Endpoints, Fehlercodes, `expect_hash`-Konflikt |
| Tamper | `server/tests/tamper.rs` | HP-/Munitions-Manipulation ⇒ `409 hash_mismatch` |
| Last | `server/tests/load.rs` (ignored) | 200 req/s, p99 < 50 ms |
**Befehle**
```bash
cargo test --workspace
cargo test -p sim --release -- --nocapture determinism
cargo run -p balance -- --matches 100000 --out report.csv
```
## 3. Determinismus über Targets
| Stufe | Mechanik |
|---|---|
| Host (x86_64) | Referenz-Hash aus Golden-Replay |
| Gerät (arm64) | Debug-Menü „Self-Check" rechnet Golden-Replay nach und loggt `state_hash`; `tools/device/logs.sh` vergleicht mit Host-Erwartung |
| WASM (optional, CI) | `wasm32-wasip1` + `wasmtime run` auf demselben Golden-Replay |
| CI-Regel | Abweichung ⇒ Build rot, kein Merge |
## 4. Flutter
| Testart | Prüft |
|---|---|
| Widget-Tests | Menü-Navigation, Garage-Zustände, Settings-Persistenz |
| **Flame-Golden-Tests** | Canvas-Rendering von Terrain/Panzern/HUD in 3 Szenen – läuft **headless** (`flutter test`), kein Display nötig |
| Bridge-Tests | `MatchHandle`-API: neue Sim, 10 Ticks, Snapshot-Felder plausibel |
| Integration (optional) | `integration_test` auf Gerät: App-Start → Match → Sieger-Screen |
```bash
flutter test # inkl. Golden-Tests
flutter test --update-goldens # nur nach bewusster UI-Änderung, im PR begründen
```
## 5. Gerät (`tools/device/`)
| Skript | Zweck |
|---|---|
| `connect.sh` | `adb connect`, Geräteseriennummer, Verbindung prüfen |
| `steckbrief.sh` | Modell, API-Level, Auflösung/Dichte, GPU, RAM, Refresh-Rate |
| `install.sh` | Deinstallieren, installieren, starten, PID prüfen |
| `smoke.sh` | Start → Menü → Match → 3 Schüsse → Ergebnis; 20 Screenshots nach `/tmp/shots` |
| `perf.sh` | **SurfaceFlinger-Frame-Timestamps** (Flutter rendert nicht über HWUI, `gfxinfo` liefert 0 Frames): p50/p90/p99 + Jank gegen 1,2 × Vsync |
| `startup.sh` | Kaltstart: `am start -W` (`TotalTime`) plus `iron_arc: ready after N ms` aus dem Log – läuft nur sinnvoll, **nachdem** der Consent einmal erteilt wurde (sonst zählt der UMP-Dialog mit) |
| `logs.sh` | Filter: Rust-Panic, `wgpu`/`Vulkan`, JNI, Billing, Consent |
**Wichtig:** Screenshots werden als PNG abgelegt und im Review **angesehen**; `perf.sh`-Report
landet in `docs/perf/<datum>-<gerät>.md` und ist Release-Voraussetzung.
### Startzeit & Splash-Kette
Gemessen auf dem Redmi Note 10 (Android 12, API 31), Consent bereits erteilt:
| Build | `TotalTime` (erster Frame) | `iron_arc: ready after` |
|---|---|---|
| Debug (JIT) | 3053 ms | ~1740 ms |
| Profile/AOT, erster Start nach Installation | 2040 ms | ~1040 ms |
| Profile/AOT, weitere Kaltstarts (Caches warm) | **850–960 ms** | ~1030 ms |
`TotalTime` ist der Zeitpunkt, ab dem der Splash steht – die Partie erscheint gut 1 s später
(700 ms Mindeststandzeit + 280 ms Fade).
Die Startstrecke ist bewusst dreiteilig, damit zu keinem Zeitpunkt ein weißer Screen zu sehen ist:
1. **Nativer Splash** (ab Prozessstart): `LaunchTheme` mit `windowBackground` = `@color/launch_bg`
(`#05070A`), darunter zentriert das Logo. Ab API 31 übernimmt die System-Splash-API
(`values-v31`): Markenfarbe + `launch_logo_splash` auf einer Icon-Platte in Icon-Navy.
Die 512×512-Vorlage hat das Motiv nur auf 59 % Breite, weil Android alles außerhalb der
inneren 192 dp des 288-dp-Icon-Bereichs **wegmaskiert** (sonst wird „IRON“ abgeschnitten).
2. **Flutter-Splash** (`lib/src/ui/splash_screen.dart`): pulsierendes Logo (Scale 0,96→1,04,
Deckkraft 0,72→1,0, 1100 ms) plus dünne Fortschrittslinie. Mindeststandzeit 700 ms,
gemessen ab dem ersten Flutter-Frame – nicht ab Prozessstart, sonst überspringt ein langsamer
Enginestart die Animation komplett.
3. **Fade** (280 ms) über die bereits gebaute Partie, danach wird der Splash aus dem Baum entfernt.
Erst danach startet das Ad-SDK (`_ads.initialize()`), damit UMP-Dialog und SDK-Init niemals
vor dem ersten Frame liegen. Video-Nachweis: 6-fps-Aufnahme des Kaltstarts, Frames bei
0,4 s (nativer Splash), 1,5–1,8 s (pulsierendes Logo), ab 2,1 s Partie.
**MIUI-Falle:** `adb install` eines **release**-signierten APKs scheitert mit
`INSTALL_FAILED_USER_RESTRICTED`. Für Messungen auf dem Gerät daher `flutter build apk --profile`
(AOT wie Release, aber debug-signiert); die echte Release-Prüfung läuft über die Split-APKs aus
dem AAB.
## 6. CI-Gates (Definition of Done für jeden PR)
1. `cargo fmt --check`
2. `cargo clippy --workspace --all-targets -- -D warnings`
3. `cargo test --workspace`
4. Grep: kein `f32`/`f64` in `crates/sim/src`
5. `flutter analyze` (keine Warnings)
6. `flutter test` (inkl. Goldens)
7. `flutter build appbundle --release` (nur bei Release-PRs)
## 7. Was bewusst NICHT automatisiert wird
- Game-Feel (Wucht, Timing, Haptik) → menschliches Playtest-Video + Notizen.
- Ads-Fill und echte Käufe → manuell mit Test-Accounts (nicht automatisierbar ohne Play Console).
- Store-Review-Ergebnis → nur durch Einreichung.