Files
NanoKVM-MIRROR/server/service/hid/hid_test.go
SiYue-ZO 57e1f6a4d6 fix(picoclaw): cancel runtime lifecycle on mode switch
Cancel PicoClaw start/readiness waits when MCP takes control, clear held manual input state after failed release reports, and keep paste duration below the control-mode wait budget.

Also add MCP copy failure translations and avoid reconnect effect churn when the locale changes.
2026-07-29 15:16:06 +08:00

29 lines
841 B
Go

package hid
import (
"testing"
"time"
)
func TestReportLengthValidation(t *testing.T) {
h := &Hid{}
if err := h.WriteKeyboardReport(make([]byte, 7)); err == nil {
t.Fatal("expected keyboard length error")
}
if err := h.WriteRelativeMouseReport(make([]byte, 5)); err == nil {
t.Fatal("expected relative mouse length error")
}
if err := h.WriteAbsoluteMouseReport(make([]byte, 7)); err == nil {
t.Fatal("expected absolute mouse length error")
}
}
func TestPasteDurationLeavesModeSwitchMargin(t *testing.T) {
if maxPasteDuration >= 30*time.Second {
t.Fatalf("maxPasteDuration = %s, want below 30s mode switch wait budget", maxPasteDuration)
}
if got := time.Duration(maxPasteContentRunes) * defaultPasteDelay; got > maxPasteDuration {
t.Fatalf("max paste content duration = %s, want <= %s", got, maxPasteDuration)
}
}