Terminal App Test Cases

This document defines manual and high-level test cases for the Android Terminal application (packages/modules/Virtualization/android/TerminalApp). These test cases are designed for QA engineers or automated agents to verify the application's functionality, including boundary conditions, exception handling, and negative scenarios.

General Test Preconditions

  • For Group 1: Requires a clean install state (app data cleared) unless specified otherwise.
  • For Groups 2-5: Unless otherwise specified, all test cases assume that the Terminal app is already fully installed and the Linux VM is set up and bootable (i.e. successfully completed TC001 or TC004).

Group 1: Installation and Booting

TC001: Initial Installation over Wi-Fi

  • Preconditions:
    • Terminal app data is cleared (Clean install state).
    • Device is connected to an active Wi-Fi network.
  • Test Steps:
    1. Launch the Terminal app.
    2. Grant any requested mandatory permissions (e.g., Notifications, Nearby devices).
    3. Verify the installation screen is shown with the description: “To launch Linux terminal, you need to download...”.
    4. Ensure the “Download using Wi-Fi only” switch is enabled by default.
    5. Tap the “Install” button.
  • Expected Result:
    • The download and installation progress bar starts moving.
    • After installation completes, the VM boots up automatically, showing a circular progress indicator.
    • Finally, the terminal screen (command line prompt) is displayed.

TC002: Initial Installation Blocked by Mobile Data (Wi-Fi Only Enabled)

  • Preconditions:
    • Terminal app data is cleared.
    • Device is connected only to mobile data (Wi-Fi is turned off).
  • Test Steps:
    1. Launch the Terminal app.
    2. Ensure the “Download using Wi-Fi only” switch is enabled.
    3. Tap the “Install” button.
  • Expected Result:
    • The installation is suspended.
    • A status message “Waiting for network reconnection...” or similar network warning is displayed.
    • The progress bar does not advance.

TC003: Resume Installation by Disabling Wi-Fi Only Switch

  • Preconditions:
    • The test is in the state of TC002 (Installation suspended waiting for Wi-Fi).
  • Test Steps:
    1. Toggle the “Download using Wi-Fi only” switch to Disabled (Off).
  • Expected Result:
    • A message “Continuing download using mobile data...” is displayed.
    • The download and installation resume immediately.
    • After installation completes, the VM boots and shows the terminal prompt.

TC004: Custom Image Installation (Local / Debug Build)

  • Preconditions:
    • Terminal app data is cleared.
    • Using a debuggable Android build.
    • A valid custom image archive (e.g. downloaded from https://dl.google.com/android/ferrochrome/5100000/aarch64/images.tar.gz) is placed at /sdcard/linux/images.tar.gz on the device storage.
  • Test Steps:
    1. Launch the Terminal app.
  • Expected Result:
    • The app detects the local custom image.
    • The installation screen displays “Auto installing from /sdcard/linux”.
    • The installation proceeds locally without network download.
    • Upon completion, the VM boots into the custom Linux environment.

TC001A: Android System Settings Toggle Integration

  • Preconditions:
    • Using a userdebug/developer Android build.
  • Test Steps:
    1. Enable Developer options by tapping the Build Number 5 times.
    2. Navigate to Settings -> System -> Developer options -> Linux development environment.
    3. Enable “(Experimental) Run Linux terminal on Android” (or use adb shell pm enable com.android.virtualization.terminal as fallback).
    4. Verify launcher app drawer.
    5. Go back to settings and disable the option (or use adb shell pm disable ...).
    6. Verify launcher app drawer again.
  • Expected Result:
    • When enabled, the “Terminal” app icon ((>_)) is visible in the app drawer.
    • When disabled, the “Terminal” app icon is removed from the app drawer.

TC001B: Enterprise Work Profile Restriction

  • Preconditions:
    • Device has an active Work Profile.
      • How to setup a test Work Profile using TestDPC:
        1. Install TestDPC app (com.afwsamples.testdpc) from Google Play Store or via adb install.
        2. Launch Set up TestDPC app on the device.
        3. Follow the setup wizard: Tap Accept & Continue -> Tap Skip on adding account -> Tap Finish.
        4. Verify that “Personal” and “Work” tabs appear in the launcher app drawer.
  • Test Steps:
    1. Try to execute TC001A inside the “Work” profile tab under “Linux development environment” menu.
    2. Verify the warning message.
    3. Enable terminal app from work profile, do the setup.
    4. Remove the work profile.
  • Expected Result:
    • Enabling in work profile prompts an IT Admin block dialog.
    • If allowed, the Terminal icon shows a work profile badge.
    • Removing the profile immediately deletes the associated Terminal app instance.

TC001C: Linux Toggle Deactivation State Reset

  • Preconditions:
    • Terminal app is fully installed and VM has booted before (TC001).
  • Test Steps:
    1. Go to Developer options -> Linux development environment.
    2. Toggle off the “Run Linux terminal” switch and toggle it back on.
    3. Launch the Terminal app from launcher.
  • Expected Result:
    • Disabling the toggle clears the app's internal cache and image state.
    • Launching the app shows the “Install Linux Terminal” setup screen again instead of the shell prompt (State is cleanly reset).

Group 2: VM Lifecycle and Control

TC006: VM Stop Confirmation and Dismissal

  • Preconditions:
    • The VM is running, and the terminal screen is visible.
    • Only one terminal tab is open.
  • Test Steps:
    1. Press the system Back button (or perform back gesture).
    2. Verify that the “Close terminal?” confirmation dialog appears.
    3. Verify the warning message: “Closing the terminal will stop all running Linux background processes.”.
    4. Tap “Cancel”.
  • Expected Result:
    • The dialog disappears.
    • The VM continues to run, and the terminal screen remains active.

TC007: VM Stop Execution and App Exit

  • Preconditions:
    • The VM is running, and the terminal screen is visible.
  • Test Steps:
    1. Press the system Back button to show the “Close terminal?” dialog.
    2. Tap the “Close” button in the dialog.
  • Expected Result:
    • The VM is shut down.
    • The Terminal app closes and its task is removed from the recent apps screen.

TC007A: Hard Kill and System Service Cleanup

  • Preconditions:
    • The VM is running and terminal is visible.
  • Test Steps:
    1. Inside the terminal, execute sudo shutdown -h now and hit enter.
    2. Verify app window state.
    3. Restart VM, then swipe out the Terminal app from Recents/App Switcher.
    4. Observe system notifications.
  • Expected Result:
    • shutdown command immediately closes the app window; no residual foreground notifications remain.
    • Swiping out the app immediately raises a “Terminal is closing” persistent notification, which automatically disappears after a few seconds when VM services cleanly shut down.

Group 3: Terminal UI and Input

TC009: Tab Management (Add and Switch Tabs)

  • Preconditions:
    • The VM is running, and the terminal screen is visible.
  • Test Steps:
    1. Tap the “+” (Add tab) button on the top toolbar.
    2. Verify that a new tab is created next to the first tab.
    3. Type a command (e.g., echo "Tab 2") in the second tab.
    4. Tap the first tab to switch back.
    5. Verify the terminal content of the first tab remains intact.
    6. Tap the second tab again.
    7. Verify the terminal content of the second tab is displayed.
  • Expected Result:
    • Tabs can be added, and switching between them retains their respective terminal sessions.

TC010: Tab Close and Termination

  • Preconditions:
    • Multiple tabs are open (e.g., State after TC009).
  • Test Steps:
    1. Tap the “x” (Close tab) button on the active tab.
    2. Verify the confirmation dialog “Close Tab?” appears.
    3. Tap “Close”.
  • Expected Result:
    • The selected tab is closed, and the view switches to the remaining tab.

TC009A: Multi-tab Background Process Isolation

  • Preconditions:
    • The VM is running, and multiple tabs are open (e.g. 2 tabs).
  • Test Steps:
    1. In Tab 1, run nano editor.
    2. Switch to Tab 2, run ps -A | grep nano to verify the process is visible in the guest system.
    3. Close Tab 1 (confirm tab closure if prompted).
    4. In Tab 2, run ps -A | grep nano again.
  • Expected Result:
    • nano is initially visible running underpts/0 or pts/1.
    • After closing Tab 1, its corresponding nano process is immediately terminated and no longer listed under active processes.

TC009B: Mouse Pointer Capture and Lock (CTRL+ALT)

  • Preconditions:
    • A bluetooth mouse and keyboard are paired and connected to the device.
  • Test Steps:
    1. Tap the “Monitor” icon and “Mouse” icon on the top right toolbar to request mouse capture.
    2. Observe the helper message on screen.
    3. Press CTRL+ALT keys simultaneously on the physical bluetooth keyboard.
  • Expected Result:
    • Enabling capture locks the mouse pointer to the VM window, showing a helper message about the key combination to unlock.
    • Pressing CTRL+ALT successfully releases the cursor back to Android OS, and the “Mouse” icon becomes deactivated.

TC009C: Keyboard Font Size Shortcut

  • Preconditions:
    • A physical keyboard is connected, and terminal focus is active.
  • Test Steps:
    1. Press CTRL+= (or CTRL++) key on the physical keyboard.
    2. Press CTRL+- key.
    3. Press CTRL+0 key.
  • Expected Result:
    • CTRL+= increases the font size.
    • CTRL+- decreases the font size.
    • CTRL+0 resets the font size back to the default option.

Group 4: Settings Customization

TC012: Settings Adaptive Layout (Mobile vs Large Screen)

  • Preconditions:
    • The VM is running, and the terminal screen is visible.
  • Test Steps:
    1. Tap the “More options” (three vertical dots) button on the top toolbar.
    2. Select “Settings”.
    3. Observe the layout.
    4. (Optional) If testing on a foldable or tablet, rotate the device or resize the app window.
  • Expected Result:
    • On Compact screens (Mobile): The settings list is shown first. Tapping an item navigates to a new screen.
    • On Large screens (Tablet/Desktop/Freeform): A split-pane layout is shown with the settings list on the left and the detailed page on the right.

TC013: Graphics Acceleration Change and Restart

  • Preconditions:
    • In the Settings screen, navigate to the “Advanced” page.
    • Device supports graphics acceleration.
  • Test Steps:
    1. Tap on “Graphics Acceleration”.
    2. Select the alternative option (e.g., switch from GPU to Software or vice-versa).
    3. Tap “OK”.
    4. Verify that the “Restart Required” dialog appears.
    5. Tap “Restart Now”.
  • Expected Result:
    • The VM restarts immediately.
    • The new graphics acceleration setting is applied upon reboot.

TC014: Memory Size Minimum Boundary Check (200 MiB)

  • Preconditions:
    • In the Settings screen, navigate to the “Advanced” page.
  • Test Steps:
    1. Tap on “Memory size”.
    2. Type 200 in the text field (Boundary value). Tap “OK”.
    3. Verify the dialog closes and prompts for restart.
    4. Open the dialog again, try to type 199 (Below minimum).
  • Expected Result:
    • 200 MiB is accepted.
    • 199 MiB is rejected with the validation error message: “Valid range: ...”. The “OK” button is disabled.

TC015: Memory Size Maximum Boundary Check (70% of System RAM)

  • Preconditions:
    • Determine the maximum memory limit shown in the Memory size dialog (dynamically calculated as 70% of system RAM, e.g., 5600 MB).
  • Test Steps:
    1. In the Memory size dialog, enter the exact maximum limit value (e.g., 5600). Tap “OK”.
    2. Verify it is accepted.
    3. Open the dialog again, enter a value 1MB higher (e.g., 5601).
  • Expected Result:
    • The maximum limit value is accepted.
    • The value exceeding the limit is rejected, showing the validation error “Valid range: ...”, and the “OK” button is disabled.

TC016: Memory Size Invalid Input Handling (Negative)

  • Preconditions:
    • In the Settings screen, navigate to the “Advanced” page and open “Memory size”.
  • Test Steps:
    1. Try to input a negative value (e.g., -1004 or just type -).
    2. Verify if the text field accepts non-numeric characters.
  • Expected Result:
    • The text field does not allow typing non-digit characters like -.
    • If pasted or bypassed, validation fails, showing an error and disabling the “OK” button.

TC017: Font Size Boundary Check (Min 5, Max 50)

  • Preconditions:
    • The VM is running, and the terminal screen is visible.
    • Open “Settings” -> “Appearance” -> “Font size” (FontAdjustOverlay).
  • Test Steps:
    1. Attempt to decrease the font size below 5 using the [-] button (Verify it becomes disabled at 5).
    2. Manually enter 4 in the input field. Verify the error state.
    3. Attempt to increase the font size above 50 using the [+] button (Verify it becomes disabled at 50).
    4. Manually enter 51 in the input field. Verify the error state.
  • Expected Result:
    • Font size cannot be set below 5 or above 50. Out-of-bounds manual values disable the “OK” button.

TC018: Custom Font File Size Limit Check (15MB Limit)

  • Preconditions:
    • Prepare two custom font files (.ttf):
      • File A: Size <= 15MB.
      • File B: Size > 15MB.
    • Open “Settings” -> “Appearance” -> “Font family” -> “Import custom font...”.
  • Test Steps:
    1. Select and import File A.
    2. Select and import File B.
  • Expected Result:
    • File A is successfully imported, added to the font family list, and applied.
    • File B fails to import, and a warning snackbar “Font file size exceeds 15MB limit” is displayed.

TC019: Keep Awake Configuration

  • Preconditions:
    • In the Settings screen, navigate to the “Advanced” page.
  • Test Steps:
    1. Tap on “Keep awake”.
    2. Verify the warning message about battery life is displayed.
    3. Select a duration (e.g., “10 minutes”).
    4. Tap “OK”.
    5. Verify the summary text on the settings page updates to “10 minutes”.
  • Expected Result:
    • A persistent notification “Terminal is keeping the device awake” appears in the notification drawer while active.

Group 5: Advanced Features

TC020: Port Forwarding Lower Boundary Check (Port 1024 vs 1023) (Negative)

  • Preconditions:
    • In the Settings screen, navigate to the “Security” page.
  • Test Steps:
    1. Tap the “+” (Add) floating action button.
    2. Enter 1024 (Lower limit for custom ports) and tap “Save”.
    3. Verify it is saved successfully.
    4. Tap “+” again, enter 1023 (Reserved port range).
  • Expected Result:
    • Port 1024 is allowed.
    • Port 1023 is rejected with the error message “Invalid port number” (or similar error indicating it falls under the reserved port range).

TC021: Port Forwarding Upper Boundary Check (Port 65535 vs 65536) (Negative)

  • Preconditions:
    • In the Settings screen, navigate to the “Security” page.
  • Test Steps:
    1. Tap the “+” (Add) floating action button.
    2. Enter 65535 (Maximum valid port) and tap “Save”.
    3. Verify it is saved successfully.
    4. Tap “+” again, enter 65536 (Out of TCP port range).
  • Expected Result:
    • Port 65535 is allowed.
    • Port 65536 is rejected with the error message “Invalid port number”.

TC022: Port Forwarding Duplicate Prevention (Negative)

  • Preconditions:
    • In the Settings screen, navigate to the “Security” page.
    • Port 8080 is already allowed and present in the “Saved allowed ports” list.
  • Test Steps:
    1. Tap the “+” (Add) floating action button.
    2. Enter 8080 and tap “Save”.
  • Expected Result:
    • The entry is rejected with the error message “Port already exists”.

TC023: Theme Import Path Traversal Prevention (Security / Negative)

  • Preconditions:
    • Prepare a malicious theme configuration file where the filename contains path traversal sequences (e.g., ../../malicious_theme.toml or containing URL-encoded ..%2f).
  • Test Steps:
    1. Trigger theme import using the malicious file via external intent or theme selection.
  • Expected Result:
    • The application detects the path traversal attempt.
    • The import is aborted, returning false internally, and a snackbar showing “Invalid theme” is displayed. No files are written outside the designated themes/ directory.

TC020A: Guest-initiated Port Forwarding Alert

  • Preconditions:
    • The VM is running. “Auto-forward all ports” setting is disabled.
  • Test Steps:
    1. Inside the terminal, run python3 -m http.server 8080.
    2. Verify the host system notification.
    3. Tap “Accept” / “Allow once” on the notification.
    4. Verify accessibility at http://localhost:8080 in Chrome on host.
    5. Kill python server, go to Settings -> Security -> Port control, verify 8080 is listed under “Saved allowed ports”.
    6. Repeat python server boot, but choose “Deny” on the notification. Try to access localhost in Chrome.
  • Expected Result:
    • Triggering a socket listen in VM raises a host notification: “Terminal is requesting to open a new port... 8080 (python3)”.
    • Allowing it enables local port-forwarding (local webpage accessible).
    • Denying it rejects connection; Chrome displays connection error.

TC025: Shared Folders Bidirectional Synchronization

  • Preconditions:
    • Shared folders are enabled in settings and Downloads directory is shared.
  • Test Steps:
    1. On the host device, write a test file to Downloads: adb shell touch /sdcard/Download/android-file-sync.txt
    2. Inside the VM terminal, check if the file is visible: ls /mnt/shared/Download/android-file-sync.txt
    3. Inside the VM terminal, write a file to the shared directory: touch /mnt/shared/Download/vm-file-sync.txt
    4. On the host device, check if the file exists: adb shell ls /sdcard/Download/vm-file-sync.txt
  • Expected Result:
    • Files created/modified by the Android host are immediately visible inside the VM under /mnt/shared/... and vice-versa (bidirectional sync works).

TC027: GUI Application Support (Wayland / Weston / Vulkan)

  • Preconditions:
    • terminal_gui_support flag is enabled.
    • Graphics acceleration is configured properly.
  • Test Steps:
    1. Run weston-terminal in the shell, and tap the “Display options” (monitor icon) to view the virtual display.
    2. Run Vulkan spinning box demo: vkcube --wsi wayland (or vkcube --wsi xcb).
    3. Run Weston flower demo: weston-flower and click on it.
    4. Install and run editor: sudo apt update && sudo apt install gedit -y && gedit.
    5. Check full screen toggling and virtual soft keyboard input inside the Weston window.
  • Expected Result:
    • weston-terminal successfully spawns a nested graphical window on the guest screen.
    • vkcube renders a rotating 3D box smoothly using Vulkan.
    • gedit and flower demos draw correct graphical UI components, responding to tap inputs and showing the OSK properly.

TC028: System Docker Execution Capability

  • Preconditions:
    • VM is running with network connection.
  • Test Steps:
    1. Run docker installer script: curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh
    2. Start the hello-world container: sudo docker run hello-world
  • Expected Result:
    • The Docker daemon initializes successfully.
    • hello-world image is pulled and executes correctly, printing “Hello from Docker!” message.

TC029: OTA Image Upgrade and Recovery Data Backup

  • Preconditions:
    • VM is running, and a test file exists: echo "Hi" > ~/important-data.txt.
  • Test Steps:
    1. Simulate a system upgrade push: adb root && adb shell mkdir -p /sdcard/linux/ && adb shell touch /sdcard/linux/force_upgrade && adb shell killall com.android.virtualization.terminal
    2. Re-launch the Terminal app.
    3. Choose “Upgrade” on the prompt.
    4. Once booted, a recovery option will ask whether to restore backup.
    5. Run Test 1: Accept/Continue recovery. Verify cat ~/important-data.txt.
    6. Run Test 2: Repeat upgrade but Reject recovery. Verify cat ~/important-data.txt.
    7. Clean up: adb shell rm -rf /sdcard/linux/
  • Expected Result:
    • Accepting recovery restores user space filesystem data (prints "Hi").
    • Rejecting recovery performs a fresh install (prints "No such file or directory").

Group 6: Tab Drag and Drop (Reordering)

TC030: Basic Tab Reordering via Long Press Drag

  • Preconditions:
    • Terminal app is running with at least 3 active tabs (e.g. Tab A, Tab B, Tab C).
  • Test Steps:
    1. Long press on Tab A.
    2. Verify that Tab A's visual height shrinks slightly and a small bottom padding appears (enters drag mode).
    3. Drag Tab A to the right, past Tab B.
    4. Verify that Tab B smoothly shifts to the left to clear up a slot.
    5. Drag Tab A past Tab C, then release the drag.
  • Expected Result:
    • Tab A is dropped at the end. The final tab order is updated permanently to: Tab B, Tab C, Tab A.

TC031: Tab Scrolling vs Drag Gesture Separation

  • Preconditions:
    • Terminal app has 10+ tabs active, causing the tab bar to exceed the screen width (scrollable state).
  • Test Steps:
    1. Place a finger on any tab and swipe left/right quickly (scroll swipe).
    2. Verify that the tab bar scrolls horizontally and no tab enters drag mode.
    3. Long press on a tab until it shrinks.
    4. Drag it left/right.
  • Expected Result:
    • Simple swipe swipes/scrolls the tab bar container horizontally without triggering drag reordering.
    • Only long press initiates the drag state.

TC032: Drag Bounds Boundary Constraints

  • Preconditions:
    • Terminal app has at least 2 active tabs.
  • Test Steps:
    1. Long press on the first tab.
    2. Drag it far to the left, past the screen/tab bar edge.
    3. Verify that the visual drag indicator card stays bounded at the far-left edge and does not crash the app.
    4. Release the drag.
    5. Repeat by dragging the last tab far to the right, past the edge.
  • Expected Result:
    • The dragged tab position is safely bounded at the edges. The app does not crash (coerceIn limits are correctly enforced).

TC033: Concurrent Tab Creation During Drag

  • Preconditions:
    • Terminal app has 2 active tabs.
    • Physical keyboard is connected.
  • Test Steps:
    1. Long press on Tab A to start dragging.
    2. While holding the drag (do not release), press Ctrl+Shift+T on the physical keyboard to create a new tab in the background.
    3. Drag Tab A left and right, then release.
  • Expected Result:
    • The new Tab C is successfully created.
    • The drag gesture continues smoothly without crashing the app (maxOffset boundary safety logic prevents IllegalArgumentException).

TC034: Drag Cancellation State Restoration

  • Preconditions:
    • Terminal app has 3 active tabs (Tab A, Tab B, Tab C).
  • Test Steps:
    1. Long press on Tab A and drag it to the right, hovering over Tab C.
    2. Verify that adjacent tabs shift aside.
    3. While holding the drag, swipe the System Back gesture (or trigger a drag cancellation event).
  • Expected Result:
    • The drag is canceled.
    • Tab A goes back to its original slot. Adjacent tabs return to their normal positions. The final tab order remains Tab A, Tab B, Tab C.