Resolves sixel rendering regression issue and adds gui unit test to validate rendered image (#221)

* Reset line feed mode on sixel handling

* Sixel test
This commit is contained in:
Max Risuhin 2019-02-14 18:58:15 +02:00 committed by Liam Galvin
parent a5e51dbbdd
commit 82ab02da9b
3 changed files with 36 additions and 2 deletions

View File

@ -24,8 +24,12 @@ func terminate(msg string) int {
return 1
}
func sleep() {
time.Sleep(time.Second)
func sleep(seconds ...int) {
count := 1
if len(seconds) > 0 {
count = seconds[0]
}
time.Sleep(time.Duration(count) * time.Second)
}
func hash(path string) string {
@ -162,6 +166,30 @@ func TestScreenFeatures(t *testing.T) {
})
}
func TestSixel(t *testing.T) {
runMain(func() {
testFunc := func(term *terminal.Terminal, g *gui.GUI) {
termRef = term; guiRef = g
sleep()
send(term, "export PS1='> '\n")
sleep()
send(term, "clear\n")
sleep()
send(term, "cat example.sixel\n")
sleep(4)
guiRef.Screenshot("test-sixel.png")
validateScreen("test-sixel.png")
g.Close()
}
initialize(testFunc)
})
}
// Last Test should terminate main goroutine since it's infinity looped to execute others GUI tests in main goroutine
func TestExit(t *testing.T) {
os.Exit(0)

View File

@ -125,6 +125,12 @@ func sixelHandler(pty chan rune, terminal *Terminal) error {
return fmt.Errorf("Failed to parse sixel data: %s", err)
}
isNewLineMode := terminal.terminalState.IsNewLineMode()
if isNewLineMode == false {
terminal.SetNewLineMode()
defer terminal.SetLineFeedMode()
}
drawSixel(six, terminal)
return nil

BIN
vttest/test-sixel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB