Add window resizing test
This commit is contained in:
Executable
+122
@@ -0,0 +1,122 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# This is a regression test for window resizing in Mosh. Making it
|
||||
# happen is a little kludgy: we have to create other panes in tmux and
|
||||
# resize them. But it works!
|
||||
#
|
||||
|
||||
fail()
|
||||
{
|
||||
printf "$@" 2>&1
|
||||
exit 99
|
||||
}
|
||||
|
||||
|
||||
|
||||
PATH=$PATH:.:$srcdir
|
||||
# Top-level wrapper.
|
||||
if [ $# -eq 0 ]; then
|
||||
e2e-test $0 tmux baseline
|
||||
exit
|
||||
fi
|
||||
|
||||
sleepf()
|
||||
{
|
||||
(sleep .1 || sleep 1) > /dev/null 2>&1
|
||||
}
|
||||
|
||||
seq()
|
||||
{
|
||||
if [ $# -lt 1 -o $# -gt 3 ]; then
|
||||
echo "bad args" >&2
|
||||
fi
|
||||
first=$1
|
||||
incr=1
|
||||
last=0
|
||||
case $# in
|
||||
3)
|
||||
incr=$2
|
||||
last=$3
|
||||
;;
|
||||
2)
|
||||
last=$2
|
||||
;;
|
||||
1)
|
||||
;;
|
||||
esac
|
||||
while :; do
|
||||
printf '%d\n' $first
|
||||
first=$(expr $first + $incr)
|
||||
if [ $first -gt $last ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
tmux_resize_commands()
|
||||
{
|
||||
hv=$1
|
||||
shrink=$2
|
||||
grow=$3
|
||||
# Split the window into two panes.
|
||||
printf "split-window -${hv}\n"
|
||||
# Shrink the pane we created
|
||||
for i in $(seq 1 10); do
|
||||
sleepf
|
||||
printf "resize-pane -${shrink}\n"
|
||||
done
|
||||
# And grow it
|
||||
for i in $(seq 1 10); do
|
||||
sleepf
|
||||
printf "resize-pane -${grow}\n"
|
||||
done
|
||||
sleep 1
|
||||
# Remove the pane we created.
|
||||
printf "kill-pane\n"
|
||||
}
|
||||
|
||||
tmux_commands()
|
||||
{
|
||||
# An interactive shell is waiting for us in the mosh session.
|
||||
# Start a full screen application that will redraw on window
|
||||
# resize.
|
||||
printf "send-keys 'less /etc/services' 0x0d\n"
|
||||
sleep 1
|
||||
# we control the horizontal...
|
||||
tmux_resize_commands v D U
|
||||
sleep 1
|
||||
# and the vertical.
|
||||
tmux_resize_commands h L R
|
||||
sleep 1
|
||||
# Exit less.
|
||||
printf "send-keys 'q'\n"
|
||||
sleep 1
|
||||
# Exit mosh session shell.
|
||||
printf "send-keys 'exit 0' 0x0d\n"
|
||||
# need to sleep extra long here, to let child commands complete,
|
||||
# and not have tmux exit prematurely
|
||||
sleep 5
|
||||
}
|
||||
|
||||
tmux_stdin()
|
||||
{
|
||||
tmux_commands | "$@"
|
||||
exit
|
||||
}
|
||||
|
||||
baseline()
|
||||
{
|
||||
# Just start an interactive shell and wait. The tmux action drives.
|
||||
sh
|
||||
}
|
||||
|
||||
case $1 in
|
||||
tmux)
|
||||
shift;
|
||||
tmux_stdin "$@";;
|
||||
baseline)
|
||||
baseline;;
|
||||
*)
|
||||
fail "unknown test argument %s\n" $1;;
|
||||
esac
|
||||
Reference in New Issue
Block a user