From 28fb23328624d0d7d67c5c3dc94b65f5ac10fb4b Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Thu, 27 Nov 2025 10:01:46 +0000 Subject: [PATCH] docs(test): add Phase 3 boot recovery testing infrastructure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds documentation and test harness for Phase 3 (Boot-Time Recovery). Changes: - Update android-implementation-directive-phase3.md with concise boot recovery flow - Add PHASE3-EMULATOR-TESTING.md with detailed test procedures - Add PHASE3-VERIFICATION.md with test matrix and verification template - Add test-phase3.sh automated test harness Test harness features: - 4 test cases: future alarms, past alarms, no schedules, silent recovery - Automatic emulator reboot handling - Log parsing for boot recovery scenario and results - UI prompts for plugin configuration and scheduling - Verifies silent recovery without app launch Related: - Directive: android-implementation-directive-phase3.md - Requirements: docs/alarms/03-plugin-requirements.md §3.1.1 - Testing: docs/alarms/PHASE3-EMULATOR-TESTING.md - Verification: docs/alarms/PHASE3-VERIFICATION.md --- docs/alarms/PHASE3-EMULATOR-TESTING.md | 325 ++++++++ docs/alarms/PHASE3-VERIFICATION.md | 201 +++++ ...android-implementation-directive-phase3.md | 714 ++++-------------- test-apps/android-test-app/test-phase3.sh | 578 ++++++++++++++ 4 files changed, 1258 insertions(+), 560 deletions(-) create mode 100644 docs/alarms/PHASE3-EMULATOR-TESTING.md create mode 100644 docs/alarms/PHASE3-VERIFICATION.md create mode 100755 test-apps/android-test-app/test-phase3.sh diff --git a/docs/alarms/PHASE3-EMULATOR-TESTING.md b/docs/alarms/PHASE3-EMULATOR-TESTING.md new file mode 100644 index 0000000..20c3165 --- /dev/null +++ b/docs/alarms/PHASE3-EMULATOR-TESTING.md @@ -0,0 +1,325 @@ +# PHASE 3 – EMULATOR TESTING + +**Boot-Time Recovery (Device Reboot / System Restart)** + +--- + +## 1. Purpose + +Phase 3 verifies that the Daily Notification Plugin correctly: + +1. Reconstructs **AlarmManager** alarms after a full device/emulator reboot. +2. Handles **past** scheduled times by marking them as missed and scheduling the next occurrence. +3. Handles **empty DB / no schedules** without misfiring recovery. +4. Performs **silent boot recovery** (recreate alarms) even when the app is never opened after reboot. + +This testing is driven by the script: + +```bash +test-apps/android-test-app/test-phase3.sh +``` + +--- + +## 2. Prerequisites + +* Android emulator or device, e.g.: + * Pixel 8 / API 34 (recommended baseline) +* ADB available in `PATH` (or `ADB_BIN` exported) +* Project with: + * Daily Notification Plugin integrated + * Test app at `test-apps/android-test-app` +* Debug APK path: + * `app/build/outputs/apk/debug/app-debug.apk` +* Phase 1 and Phase 2 behaviors already implemented: + * Cold start detection + * Force-stop detection + * Missed / rescheduled / verified / errors summary fields + +> ⚠️ **Important:** +> This script will reboot the emulator multiple times. Each reboot may take 30–60 seconds. + +--- + +## 3. How to Run + +From the `android-test-app` directory: + +```bash +cd test-apps/android-test-app +chmod +x test-phase3.sh # first time only +./test-phase3.sh +``` + +The script will: + +1. Run pre-flight checks (ADB / emulator readiness). +2. Build and install the debug APK. +3. Guide you through four tests: + * **TEST 1:** Boot with Future Alarms + * **TEST 2:** Boot with Past Alarms + * **TEST 3:** Boot with No Schedules + * **TEST 4:** Silent Boot Recovery (App Never Opened) +4. Parse and display `DNP-REACTIVATION` logs, including: + * `scenario` + * `missed` + * `rescheduled` + * `verified` + * `errors` + +--- + +## 4. Test Cases (Script-Driven Flow) + +### 4.1 TEST 1 – Boot with Future Alarms + +**Goal:** + +Verify alarms are recreated on boot when schedules have **future run times**. + +**Script flow:** + +1. **Launch app & check plugin status** + * Script calls `launch_app`. + * UI prompt: Confirm plugin status shows: + * `⚙️ Plugin Settings: ✅ Configured` + * `🔌 Native Fetcher: ✅ Configured` + * If not, click **Configure Plugin**, wait until both show ✅, then continue. + +2. **Schedule at least one future notification** + * UI prompt: Click e.g. **Test Notification** to schedule a notification a few minutes in the future. + +3. **Verify alarms are scheduled (pre-boot)** + * Script calls `show_alarms` and `count_alarms`. + * You should see at least one `RTC_WAKEUP` entry for `com.timesafari.dailynotification`. + +4. **Reboot emulator** + * Script calls `reboot_emulator`: + * `adb reboot` + * `adb wait-for-device` + * Polls `getprop sys.boot_completed` until `1`. + * You are warned that reboot will take 30–60 seconds. + +5. **Collect boot recovery logs** + * Script calls `get_recovery_logs`: + ```bash + adb logcat -d | grep "DNP-REACTIVATION" + ``` + * It parses: + * `missed`, `rescheduled`, `verified`, `errors` + * `scenario` via: + * `Starting boot recovery`/`boot recovery` → `scenario=BOOT` + * or `Detected scenario: ` + +6. **Verify alarms were recreated (post-boot)** + * Script calls `show_alarms` and `count_alarms` again. + * Checks `scenario` and `rescheduled`. + +**Expected log patterns:** + +```text +DNP-REACTIVATION: Starting boot recovery +DNP-REACTIVATION: Loaded schedules from DB +DNP-REACTIVATION: Rescheduled alarm: daily_ for