mirror of
https://github.com/YuzuZensai/TrollSSH.git
synced 2026-09-13 18:09:02 +00:00
🐛 fix: apply final resize after debounce instead of dropping it
This commit is contained in:
@@ -3,6 +3,7 @@ package sshserver
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
@@ -102,6 +103,26 @@ func TestTermSizeDebouncesResize(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTermSizeAppliesFinalResizeAfterDebounce(t *testing.T) {
|
||||
size := &termSize{}
|
||||
size.set(80, 24, 512, 500*512, true)
|
||||
|
||||
// Rapid burst of resize events, as happens during an interactive drag-resize.
|
||||
size.set(100, 40, 512, 500*512, false)
|
||||
size.set(150, 60, 512, 500*512, false)
|
||||
size.set(200, 100, 512, 500*512, false)
|
||||
|
||||
if w, h := size.get(); w != 80 || h != 24 {
|
||||
t.Fatalf("size changed before debounce elapsed: %dx%d", w, h)
|
||||
}
|
||||
|
||||
time.Sleep(resizeDebounce + 50*time.Millisecond)
|
||||
|
||||
if w, h := size.get(); w != 200 || h != 100 {
|
||||
t.Fatalf("final resize was not applied after debounce: got %dx%d, want 200x100", w, h)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClampTermSize(t *testing.T) {
|
||||
w, h := clampTermSize(1000, 500, 512, 65536, 4)
|
||||
if w < 1 || h < 1 || w > 512 || h > 512 || w*h > 65536 {
|
||||
|
||||
Reference in New Issue
Block a user