Add emulation-attributes test for true color.

This commit is contained in:
Kang.Jianbin
2017-10-28 14:01:07 +08:00
committed by John Hood
parent 6cfa4aef59
commit 96b5027d9e
3 changed files with 54 additions and 3 deletions
+1
View File
@@ -19,6 +19,7 @@ displaytests = \
emulation-attributes-16color.test \
emulation-attributes-256color8.test \
emulation-attributes-256color248.test \
emulation-attributes-truecolor.test \
emulation-back-tab.test \
emulation-cursor-motion.test \
emulation-multiline-scroll.test \
+1
View File
@@ -0,0 +1 @@
emulation-attributes.test
+52 -3
View File
@@ -1,9 +1,10 @@
#!/bin/sh
#
# This validates VT100, 16-color, and 256-color attributes against
# tmux. It is not run directly, but as subtests based on the
# executable's name for vt100, 16color, 256color8, and 256color248.
# This validates VT100, 16-color, 256-color and true color attributes
# against tmux. It is not run directly, but as subtests based on the
# executable's name for vt100, 16color, 256color8, 256color248 and
# truecolor.
# This is because Mosh internally represents the first 8 values of the
# 256color space as though they were the 16-color values they are
# equivalent to. tmux does not filter this out on its redisplay, so
@@ -24,6 +25,34 @@ if [ $# -ne 1 ]; then
fail "bad arguments %s\n" "$@"
fi
test_true_color()
{
s=$(printf "\033[0")
for i in $@; do
s="$s;$i"
done
s="${s}m"
for attr in $(seq 0 76); do
r=$((255-(attr*255/76)))
g=$((attr*510/76))
b=$((attr*255/76))
if [ $g -gt 255 ]; then
g=$((510-g))
fi
invr=$((255-r))
invg=$((255-g))
invb=$((255-b))
c="E"
printf "%s" "$s"
printf "\033[48;2;%d;%d;%dm" $r $g $b;
printf "\033[38;2;%d;%d;%dm" $invr $invg $invb
printf "%s\033[m" "$c"
done
printf "\n"
}
baseline()
{
# Strip our name to the last dash-separated word before the .test suffix.
@@ -61,6 +90,26 @@ baseline()
printf '\033[48;5;%dmM\033[m ' "$attr"
done
;;
# True color.
# See https://gist.github.com/XVilka/8346728 for the test case
truecolor)
echo "Normal:"
test_true_color
echo "Bold:"
test_true_color 1
echo "Italic:"
test_true_color 3
echo "Underline:"
test_true_color 4
echo "Blink:"
test_true_color 5
echo "Inverse:"
test_true_color 7
echo "Invisible:"
test_true_color 8
echo "Bold, italic and underline:"
test_true_color 1 3 4
;;
*)
fail "unknown test name %s\n" "$1"
;;