vtest "Test Teken terminal emulator"

feature cmd "vttest --version 2>&1 | grep -q Usage"

process p4 {vttest} -ansi-response -start

process p4 -expect-text 21 11 "Enter choice number (0 - 12):"
process p4 -screen_dump

# 1. Test of cursor movements
process p4 -writehex "31 0d"
process p4 -expect-text 14 61 "RETURN"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 14 87 "RETURN"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 22 7 "RETURN"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 3 132 "i"
process p4 -expect-text 22 7 "RETURN"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 9 7 "RETURN"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 4 1 "This is a correct sentence"
process p4 -expect-text 20 7 "RETURN"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 21 11 "Enter choice number (0 - 12):"
process p4 -screen_dump

# 2. Test of screen features
process p4 -writehex "32 0d"
process p4 -expect-text 8 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 5 1 "should look the same. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 0 0 "This is 132 column mode, light background.Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 0 0 "This is 80 column mode, light background.Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 0 0 "This is 132 column mode, dark background.Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 0 0 "This is 80 column mode, dark background.Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 0 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 3 1 "Soft scroll down region [1..24] size 24 Line 28"
process p4 -expect-text 1 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 0 1 "Jump scroll down region [12..13] size 2 Line 29"
process p4 -expect-text 0 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 3 1 "Jump scroll down region [1..24] size 24 Line 28"
process p4 -expect-text 1 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 23 0 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 1 0 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 23 1 "Dark background. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 23 1 "Light background. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 24 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 21 11 "Enter choice number (0 - 12):"
process p4 -screen_dump

# 4. Test of double-sized characters
process p4 -writehex "34 0d"
process p4 -expect-text 21 1 "This is not a double-width line"
process p4 -expect-text 23 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex "0d"
process p4 -expect-text 21 1 "This **is** a double-width line"
process p4 -expect-text 23 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex "0d"
process p4 -expect-text 21 1 "This is not a double-width line"
process p4 -expect-text 23 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex "0d"
process p4 -expect-text 21 1 "This **is** a double-width line"
process p4 -expect-text 23 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex "0d"
delay 2
process p4 -expect-text 23 41 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex "0d"
delay 2
process p4 -expect-text 1 1 "Exactly half of the box should remain. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 21 11 "Enter choice number (0 - 12):"
process p4 -screen_dump

# 8. Test of VT102 features (Insert/Delete Char/Line)
process p4 -writehex "38 0d"
process p4 -expect-text 4 1 "Screen accordion test (Insert & Delete Line). Push <RETURN>D"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 2 45 "nothing more. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 4 59 "*B'. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 4 52 "'AB'. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 5 1 "by one.  Push <RETURN>E"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 5 1 "by one.  Push <RETURN>EEEEEEEEEEEEE "
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 10 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 4 1 "Screen accordion test (Insert & Delete Line). Push <RETURN>D"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 2 45 "nothing more. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 4 59 "*B'. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 4 52 "'AB'. Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 5 1 "by one.  Push <RETURN>E"
process p4 -screen_dump


process p4 -writehex 0d
process p4 -expect-text 5 59 "EEE "
process p4 -expect-text 5 1 "by one.  Push <RETURN>E"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 10 1 "Push <RETURN>"
process p4 -screen_dump

process p4 -writehex 0d
process p4 -expect-text 21 11 "Enter choice number (0 - 12):"
process p4 -screen_dump

# 11. Test non-VT100 (e.g., VT220, XTERM) terminals
process p4 -writehex "31 31 0d"
process p4 -expect-text 0 0 "Menu 11: Non-VT100 Tests"

process p4 -writehex "37 0d"
process p4 -expect-text 0 0 "Menu 11.7: Miscellaneous ISO-6429 (ECMA-48) Tests"

process p4 -writehex "32 0d"
process p4 -expect-text 0 0 "Push <RETURN>"
process p4 -screen_dump
process p4 -expect-text 20 1 "Test Repeat (REP)"
process p4 -expect-text 1 1 " ++ "
process p4 -expect-text 2 2 " ++ "
process p4 -expect-text 17 17 " ++ "
process p4 -expect-text 18 18 "*++*"
process p4 -writehex "0d"
process p4 -expect-text 0 0 "Menu 11.7: Miscellaneous ISO-6429 (ECMA-48) Tests"
process p4 -writehex "30 0d"
process p4 -expect-text 0 0 "Menu 11: Non-VT100 Tests"
process p4 -writehex "30 0d"

# 0. Exit
process p4 -writehex "30 0d"
process p4 -expect-text 12 30 "That's all, folks!"
process p4 -screen_dump

process p4 -wait
