diff --git a/scripts/ci/desktop-linux/smoke-test.sh b/scripts/ci/desktop-linux/smoke-test.sh index 0ab1251806..7ed1e26f0e 100755 --- a/scripts/ci/desktop-linux/smoke-test.sh +++ b/scripts/ci/desktop-linux/smoke-test.sh @@ -151,6 +151,26 @@ in_row_of() { [ "$label" -ge "$name" ] && [ $((label - name)) -lt 45 ] } +# the value is on the same line as its setting's title +in_line_with() { + local value title + value=$(y_of "$1") || return 1 + title=$(y_of "$2") || return 1 + [ $((value - title)) -lt 10 ] && [ $((title - value)) -lt 10 ] +} + +# Scrolls the left pane down until the text shows above its bottom toolbar. +scroll_to() { + local y + for _ in 1 2 3 4 5 6 7 8; do + if y=$(y_of "$1") && [ "$y" -lt 640 ]; then + return 0 + fi + "$ui" scroll 195 400 down + done + return 1 +} + # the count's text is smaller than the description's above it: both have capitals and ascenders, no descenders count_text_smaller() { local count description @@ -377,24 +397,32 @@ use_names_server() { "$ui" click "$switch_x" "$y" "$ui" shot new-server "$ui" key Escape + # the New server screen shows the address with "127.0.0.1" too, until it closes + "$ui" wait "Add server" 10 + "$ui" wait "Test servers" 10 "$ui" click-text "127.0.0.1" 10 - "$ui" wait "To resolve names" 10 + "$ui" wait "SMP server" 10 + scroll_to "To resolve names" || fail "no \"To resolve names\" in the test server's settings" # the dropdown opens from its value; a custom server's roles default to yes, yes and no, so this is the names one "$ui" click-text "default (no)" "$ui" click-text "yes" 10 "$ui" shot names-server-roles - "$ui" wait "To resolve names" 10 - in_row_of "yes" "To resolve names" || fail "the test server's \"To resolve names\" is not yes" + in_line_with "yes" "To resolve names" || fail "the test server's \"To resolve names\" is not yes" "$ui" key Escape + "$ui" wait "Add server" 10 "$ui" key Escape for operator in "SimpleX Chat" Flux; do "$ui" click-text "$operator" 10 - "$ui" wait "To resolve names" 10 + # the operator's own toggle: the title " servers" can wrap + "$ui" wait "Use servers" 10 + scroll_to "To resolve names" || fail "no \"To resolve names\" in the $operator settings" y=$(y_of "To resolve names") "$ui" click "$switch_x" "$y" "$ui" shot "names-off-$(tr -cd 'a-zA-Z' <<< "$operator")" "$ui" key Escape + "$ui" wait "Your servers" 10 done + scroll_to "Save servers" || fail "no \"Save servers\" in Network & servers" "$ui" click-text "Save servers" 10 sleep 2 "$ui" shot servers-saved diff --git a/scripts/ci/desktop-linux/ui b/scripts/ci/desktop-linux/ui index f89f1cb39d..38b12cfab0 100755 --- a/scripts/ci/desktop-linux/ui +++ b/scripts/ci/desktop-linux/ui @@ -12,6 +12,8 @@ # ui wait [secs] wait up to secs (30) until the text is on screen # ui click click at x,y # ui click-text [secs] wait up to secs (20) for the text and click its centre +# ui scroll [clicks] +# turn the mouse wheel over x,y, 3 clicks unless given # ui avatar [colour] print how many pixels of the profile image left of a list row's name (the text) stand out # from the background, and their mean colour, saving the area as UI_OUT/NN-avatar-.png; # with red, green or blue, fail unless that colour dominates @@ -150,6 +152,21 @@ click() { sleep 1 } +# X buttons 4 and 5 are the wheel turned up and down +scroll() { + local button + case "$3" in + up) button=4 ;; + down) button=5 ;; + *) + echo "error: scroll up or down, not \"$3\"" + return 1 + ;; + esac + xdotool mousemove --sync "$1" "$2" click --repeat "$4" --delay 100 "$button" + sleep 1 +} + # A list row's profile image is 42 px square, 8 px left of the row's name, and starts a little below the name's top: # the area allows for OCR's box being a few pixels off, and leaves out the rows above and below. avatar() { @@ -207,6 +224,10 @@ case "${1:-}" in click "$x" "$y" log "click-text \"$2\" at $x,$y" ;; + scroll) + scroll "$2" "$3" "$4" "${5:-3}" + log "scroll $4 at $2,$3, ${5:-3} clicks" + ;; avatar) avatar "$2" "${3:-}" ;; type) xdotool type --delay 50 -- "$2"