nexo/packages/messaging_flutter/docs/android-test-environment.md
toki 7d291aa90c feat: client-validation task and update READMEs
- Add m-client-validation task directory
- Update apps/flutter-test/README.md
- Update packages/messaging_flutter/README.md
- Update packages/messaging_flutter/docs/android-test-environment.md
2026-05-28 20:08:15 +09:00

121 lines
3.7 KiB
Markdown

# Android Test Environment
This repository can use `toki@toki-labs.com` as a separate Android test
environment when the local machine does not have an Android SDK, device, or
emulator.
## Remote Host
- SSH target: `toki@toki-labs.com`
- Flutter SDK: `/Users/toki/SDK/flutter/bin/flutter`
- Android SDK: `/Users/toki/Library/Android/sdk`
- Known usable AVD: `Pixel_6_Pro_API_34`
Use these environment variables for every remote Android test session:
```sh
export PATH="$HOME/SDK/flutter/bin:$HOME/Library/Android/sdk/emulator:$HOME/Library/Android/sdk/platform-tools:$HOME/Library/Android/sdk/cmdline-tools/latest/bin:$PATH"
export ANDROID_HOME="$HOME/Library/Android/sdk"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
```
## Local Android Preflight
Before using the remote host, check whether the local machine already has the
Android toolchain needed for integration and Gradle unit tests:
```sh
flutter doctor -v
command -v adb
command -v emulator
command -v sdkmanager
```
`./gradlew testDebugUnitTest` requires either `ANDROID_HOME`/`ANDROID_SDK_ROOT`
or a valid `sdk.dir` entry in `apps/flutter-test/android/local.properties`. If
the command fails with `SDK location not found`, treat it as a local environment
blocker and use the remote flow below instead of changing repository files.
## Sync A Working Copy
From the local repository root, copy the current working tree to an isolated
remote directory. This is useful when local changes are not committed yet.
```sh
REMOTE_DIR='$HOME/tmp/nexo-codex-test'
tar \
--exclude='./.git' \
--exclude='./.dart_tool' \
--exclude='./build' \
--exclude='./apps/flutter-test/.dart_tool' \
--exclude='./apps/flutter-test/build' \
--exclude='./apps/flutter-test/android/.gradle' \
--exclude='./packages/messaging_flutter/android/.gradle' \
--exclude='./.gradle' \
-czf - . \
| ssh toki@toki-labs.com "rm -rf \"$REMOTE_DIR\" && mkdir -p \"$REMOTE_DIR\" && tar -xzf - -C \"$REMOTE_DIR\""
```
## Start The Android Emulator
Connect to the host and start the Android emulator if no Android device is
already connected.
```sh
ssh toki@toki-labs.com
export PATH="$HOME/SDK/flutter/bin:$HOME/Library/Android/sdk/emulator:$HOME/Library/Android/sdk/platform-tools:$HOME/Library/Android/sdk/cmdline-tools/latest/bin:$PATH"
export ANDROID_HOME="$HOME/Library/Android/sdk"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
flutter emulators
flutter emulators --launch Pixel_6_Pro_API_34
```
For non-interactive sessions, a headless launch also works:
```sh
nohup emulator -avd Pixel_6_Pro_API_34 -no-window -no-audio -no-boot-anim -gpu swiftshader_indirect > "$HOME/tmp/pixel6pro-api34-emulator.log" 2>&1 &
```
Wait until the emulator is ready:
```sh
adb wait-for-device
until [ "$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" = "1" ]; do sleep 2; done
adb devices
```
## Run The Checks
Run the deterministic Flutter checks:
```sh
cd "$HOME/tmp/nexo-codex-test/packages/messaging_flutter"
flutter analyze
flutter test
cd "$HOME/tmp/nexo-codex-test/apps/flutter-test"
flutter analyze
flutter test
flutter test integration_test -d emulator-5554
```
Run Android Gradle unit tests:
```sh
cd "$HOME/tmp/nexo-codex-test/apps/flutter-test/android"
./gradlew testDebugUnitTest
```
## Interpreting Results
- `flutter test integration_test -d emulator-5554` verifies plugin registration,
method-channel calls, EventChannel delivery, and opened-routing through the
Android host app.
- `./gradlew testDebugUnitTest` verifies the Android unit-test layer and proves
the Android SDK path is usable.
- Real Firebase FCM delivery, nexo server ACK delivery, inline reply, and dismiss
behavior remain manual smoke checks because they require external service
configuration.