Android app
# Test Plan — XamIoT Android
App version: v1.2
---
## 1. Authentication
### TC-AND-AUTH-01 — Valid Login
Prerequisites: existing and activated account
Steps:
1. Open the app
2. Enter a valid email address and password
3. Tap "Log in"
Expected result: JWT token stored via TokenManager (SharedPreferences), redirect to MainActivity
---
### TC-AND-AUTH-02 — Login with incorrect password
Steps:
1. Enter a valid email address and an incorrect password
2. Tap "Log in"
Expected result: error message displayed, no navigation
---
### TC-AND-AUTH-03 — Session persistence
Steps:
1. Log in
2. Close the app completely
3. Reopen the app
Expected result: user remains logged in, MainActivity displayed immediately
---
### TC-AND-AUTH-04 — Logout
Steps:
1. Menu → Log out
2. Confirm
Expected result: token deleted, return to LoginActivity, local data cleared
---
### TC-AND-AUTH-05 — Forgotten Password
Steps:
1. Tap "Forgot password" on the login screen
2. Enter the email address
3. Submit
Expected result: Reset email received, confirmation message displayed
---
### TC-AND-AUTH-06 — Account Creation
Steps:
1. Click "Create an account"
2. Enter email, password (+ confirmation), first name, last name, phone number with country code
3. Submit
Expected result: confirmation email sent, message displayed
---
### TC-AND-AUTH-07 — Permission notifications (Android 13+)
Steps:
1. Log in for the first time on Android 13+
Expected result: system permission dialog POST_NOTIFICATIONS displayed
---
### TC-AND-AUTH-08 — Server selector (Easter egg)
Steps:
1. On the login screen, tap the logo 5 times
2. Switch servers
Expected result: server stored in SharedPreferences, API calls made to the correct server after restart
---
## 2. BLE Enrollment
### TC-AND-BLE-01 — BLE Permissions
Prerequisites: first use
Steps:
1. Tap the "+" FAB in MainActivity
Expected result: Bluetooth + location permission dialog displayed (BLUETOOTH_SCAN, BLUETOOTH_CONNECT, ACCESS_FINE_LOCATION)
---
### TC-AND-BLE-02 — Sensor Scan
Prerequisites: permissions granted, Bluetooth enabled, SoundSense sensor powered
Steps:
1. Start enrollment
Expected result: "SOUND-SENSOR-xxx" sensor appears in the spinner, auto-selection of the first one found
---
### TC-AND-BLE-03 — Enrollment complete
Steps:
1. Select the sensor or let it be auto-selected
2. Enter the SSID and Wi-Fi password
3. Confirm
4. Wait for the WiFi status to become positive
5. Enter a name for the sensor
6. Confirm
Expected result:
- BLE states: IDLE → SCANNING → CONNECTING → DISCOVERING → READING_INFO → SENDING_WIFI → WAITING_WIFI → SENDING_MQTT → READY_TO_CREATE → SUCCESS
- MQTT credentials (host, port, user, pass) sent via BLE
- Sensor created on the API
- Return to MainActivity with the sensor visible
---
### TC-AND-BLE-04 — Incorrect WiFi
Steps:
1. Enter an incorrect WiFi SSID/password
Expected result: timeout (15s), ERROR status displayed, retry option available (canRetry = true)
---
### TC-AND-BLE-05 — Bluetooth disabled
Steps:
1. Disable Bluetooth
2. Attempt to add a sensor
Expected result: system dialog to enable Bluetooth, or explicit message
---
### TC-AND-BLE-06 — BLE disconnection during enrollment
Steps:
1. Start enrollment
2. Move the sensor away during the SENDING_MQTT phase
Expected result: ERROR status, message displayed, no duplicate sensor created on the API
---
### TC-AND-BLE-07 — Auto-selection disabled
Steps:
1. Multiple sensors within range
2. Tap the spinner to select manually
Expected result: auto-selection canceled, user can manually choose from the list
---
## 3. Sensor and MQTT data
### TC-AND-MQTT-01 — Sensor list display
Prerequisites: at least one sensor enrolled and connected to MQTT
Steps:
1. Open MainActivity
Expected result: each sensor displays its name, status of the last alert, and elapsed time since the last activity
---
### TC-AND-MQTT-02 — Update elapsed time
Steps:
1. Observe the list for a few seconds
Expected result: the relative times ("2 seconds ago," "1 minute ago") update every second via the time ticker
---
### TC-AND-MQTT-03 — Automatic refresh
Steps:
1. Enable auto-refresh via the menu
2. Wait 10 seconds
Expected result: data reloaded automatically, menu icon indicates active status
---
### TC-AND-MQTT-04 — Manual Refresh
Steps:
1. Menu → Refresh
Expected result: immediate API call, list updated
---
### TC-AND-MQTT-05 — Sensor offline
Steps:
1. Turn off a sensor
2. View the list
Expected result: Last value displayed with exact relative time, no crash
---
## 4. Alert Rules
### TC-AND-RULES-01 — Creating a rule from a template
Steps:
1. Open a sensor’s details (DeviceDetailActivity)
2. Tap "Add a rule"
3. Select a template in RuleCreateBottomSheet
4. Configure the operator, threshold (stepper + text input), cooldown, and user label
5. Activate and save
Expected result: rule created via POST /esp-rules, visible in the sensor list
---
### TC-AND-RULES-02 — Out-of-range threshold
Steps:
1. Create a rule
2. Attempt to exceed field_max via the stepper or direct input
Expected result: threshold locked at field_min / field_max
---
### TC-AND-RULES-03 — Cooldown Below Minimum
Steps:
1. Attempt to enter a cooldown < cooldown_min_sec
Expected result: cooldown locked at cooldown_min_sec
---
### TC-AND-RULES-04 — Enabling / Disabling a Rule
Steps:
1. In the list of rules, toggle the switch
Expected result: PATCH /esp-rules/{id} with "enabled" updated, UI reflects the change
---
### TC-AND-RULES-05 — Editing an existing rule
Steps:
1. Tap on a rule
2. Edit threshold, cooldown, label
3. Save
Expected result: changes persisted via PATCH on the API
---
### TC-AND-RULES-06 — Deleting a rule
Steps:
1. Drag the rule to the left
2. Confirm deletion
Expected result: DELETE /esp-rules/{id}, rule removed from the list
---
## 5. Sensor Management
### TC-AND-DEV-01 — Deleting a sensor
Steps:
1. Drag the sensor to the left in MainActivity
2. Confirm deletion
Expected result: DELETE /esp-devices/{id}, sensor removed from the list
---
### TC-AND-DEV-02 — Sensor Details
Steps:
1. Tap a sensor in the list
Expected result: DeviceDetailActivity displays: sensor information, list of rules, alert history
---
### TC-AND-DEV-03 — Parallel loading of alerts
Prerequisites: multiple sensors in the list
Steps:
1. Open MainActivity
Expected result: the latest alerts from each sensor are loaded in parallel (awaitAll), no UI blocking
---
## 6. Push notifications
### TC-AND-NOTIF-01 — FCM token registration
Steps:
1. Log in to the app
Expected result: FCM token registered via POST /devices (RegisterMobileDeviceRequest)
---
### TC-AND-NOTIF-02 — Receiving a foreground alert
Prerequisites: rule active, sensor triggers threshold
Steps:
1. Keep the app open
Expected result: system notification displayed via NotificationHelper (with sound and vibration), channel created if Android 8+
---
### TC-AND-NOTIF-03 — Receiving a background alert
Steps:
1. Put the app in the background or close the app
2. The sensor triggers an alert
Expected result: notification received in the status bar; tapping opens the app
---
### TC-AND-NOTIF-04 — FCM token renewal
Steps:
1. Simulate an FCM token renewal (onNewToken)
Expected result: new token saved locally + sent to the API if user is logged in
---
### TC-AND-NOTIF-05 — Notification channel (Android 8+)
Steps:
1. Check in System Settings → Notifications → XamIoT
Expected result: notification channel visible with sound and vibration configured
---
## 7. Settings and Configuration
### TC-AND-CFG-01 — Account Deletion
Steps:
1. Menu → Delete Account
2. Enter the email address in the confirmation dialog
3. Confirm
Expected result: DELETE /me with body {"confirm": "DELETE"}, button disabled during the operation, return to LoginActivity
---
### TC-AND-CFG-02 — Saving WiFi credentials
Steps:
1. Enroll a sensor with an SSID/password
2. Initiate a second enrollment
Expected result: SSID and password pre-filled via WifiCredentialsStore
---
### TC-AND-CFG-03 — Auto-refresh stops in the background
Steps:
1. Enable auto-refresh
2. Move the app to the background
3. Return to the app
Expected result: auto-refresh stops in the background (onStop), restarts in the foreground (onStart)
---
## 8. Robustness tests
### TC-AND-ROB-01 — Network loss during use
Steps:
1. Switch to airplane mode while the app is open
Expected result: network error displayed via ApiError.toUserMessage(), no crash
---
### TC-AND-ROB-02 — Token expired
Steps:
1. Let the token expire
2. Perform an API action
Expected result: HTTP 401 code detected, redirect to LoginActivity
---
### TC-AND-ROB-03 — Screen rotation during enrollment
Steps:
1. Start BLE enrollment
2. Rotate the phone
Expected result: BLE state preserved via ViewModel (StateFlow), no enrollment reset
---
### TC-AND-ROB-04 — BLE permission denied
Steps:
1. Deny Bluetooth permissions on first launch
2. Attempt to add a sensor
Expected result: explicit message, prompt to go to system settings
---
### TC-AND-ROB-05 — Simultaneous loading (device meta + rules + alerts)
Steps:
1. Open DeviceDetailActivity on a sensor with multiple rules and alerts
Expected result: loading without UI blocking; ViewModel handles Loading/Success/Error states correctly
---


