ssh-workbench/scripts/test_terminal.sh
jima 70ab307294 Pinch-to-zoom fixes, telnet tab color, SFTP simplify, render reliability
Zoom: defer commit to ACTION_UP so ScaleGestureDetector min-span restarts
don't interrupt continuous zoom-out. Suppress tap after pinch to prevent
AKB appearing on finger lift. Thread-safe font metrics (@Volatile).

Tabs: telnet sessions show violet accent, detect session type (SSH/Telnet/
Local) via TabType enum. Connection list now sorts by last-used (call
updateLastConnected on connect).

SFTP: simplify large download confirmation (inline threshold check),
AndroidViewModel for string resource access, proper error on null stream.

Render: consume dirty after lockCanvas, re-request on lockCanvas failure,
extra render after zoom settle. Default font size 10sp. Dismiss soft
keyboard when navigating to NavHost. Paste preview color matches keyboard
hint (#888888).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 09:42:15 +02:00

149 lines
2.7 KiB
Bash
Executable file

#!/bin/bash
# Terminal input & cursor position test script
# Runs on the host, sends commands to the Zebra via ADB
#
# Prerequisites:
# - App installed and connected to a session (Duero)
# - Keyboard set to system keyboard (AKB)
#
# Usage: ./scripts/test_terminal.sh
set -e
ACTION="com.roundingmobile.sshworkbench.INPUT"
send_text() {
adb shell "am broadcast -a $ACTION --es text '$1'" 2>/dev/null >/dev/null
sleep 0.3
}
send_enter() {
adb shell "am broadcast -a $ACTION --ez enter true" 2>/dev/null >/dev/null
sleep 0.5
}
send_esc() {
adb shell "am broadcast -a $ACTION --es esc '$1'" 2>/dev/null >/dev/null
sleep 0.3
}
send_bytes() {
adb shell "am broadcast -a $ACTION --es bytes '$1'" 2>/dev/null >/dev/null
sleep 0.3
}
log_cursor() {
adb shell "am broadcast -a $ACTION --ez log true" 2>/dev/null >/dev/null
sleep 0.3
}
read_cursor_log() {
adb shell cat /sdcard/Download/SshWorkbench/sshworkbench_debug.txt 2>/dev/null | grep "\[cursor\]"
}
screenshot() {
local name="${1:-state}"
adb exec-out screencap -p > "/tmp/zebra_test_${name}.png" 2>/dev/null
}
echo "=== Terminal Input & Cursor Test ==="
echo ""
# Clean start: Ctrl+U to clear any existing input
send_bytes "15"
sleep 0.3
# Test 1: Basic text and cursor tracking
echo "--- Test 1: Type words and track cursor ---"
send_text "echo "
log_cursor
send_text "hello world this is a long line that should wrap"
log_cursor
screenshot "t1_after_text"
# Clear the line
send_bytes "15"
sleep 0.3
send_enter
sleep 0.5
# Test 2: Word navigation with ESC b (Alt+Left / word back)
echo "--- Test 2: Word navigation ---"
send_text "echo one two three four five"
log_cursor
echo " ESC b (word back) x3..."
send_bytes "1b 62"
log_cursor
send_bytes "1b 62"
log_cursor
send_bytes "1b 62"
log_cursor
echo " ESC f (word forward) x2..."
send_bytes "1b 66"
log_cursor
send_bytes "1b 66"
log_cursor
screenshot "t2_word_nav"
# Clear
send_bytes "15"
sleep 0.3
send_enter
sleep 0.5
# Test 3: Arrow keys at line boundaries
echo "--- Test 3: Arrow keys ---"
send_text "echo short"
log_cursor
echo " Left arrow x3..."
send_esc "[D"
log_cursor
send_esc "[D"
log_cursor
send_esc "[D"
log_cursor
echo " Right arrow x3..."
send_esc "[C"
log_cursor
send_esc "[C"
log_cursor
send_esc "[C"
log_cursor
screenshot "t3_arrows"
# Clear
send_bytes "15"
sleep 0.3
send_enter
sleep 0.5
# Test 4: Home / End
echo "--- Test 4: Home / End ---"
send_text "echo testing home end keys"
log_cursor
echo " Home..."
send_esc "[H"
log_cursor
echo " End..."
send_esc "[F"
log_cursor
screenshot "t4_home_end"
# Clear
send_bytes "15"
sleep 0.3
send_enter
sleep 0.5
echo ""
echo "=== Cursor log ==="
echo ""
read_cursor_log
echo ""
echo "=== Test complete ==="