Files
rdplib/grdp_scancode_test.go

34 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package grdp
import (
"testing"
"git.zeroonesoft.cn/golib/rdplib/protocol/pdu"
)
// 慢路径 Serialize 原样输出 KeyCode;0xE0xx 约定必须拆成
// KBDFLAGS_EXTENDED + 8 位扫描码,否则服务器收到非法扫描码直接丢弃
// (实测症状:远端按 Delete 删不掉文件)。
func TestNewScancodeEventExtended(t *testing.T) {
cases := []struct {
sc int
release bool
flags uint16
key uint16
}{
{0xE053, false, pdu.KBDFLAGS_EXTENDED, 0x53}, // Delete down
{0xE053, true, pdu.KBDFLAGS_EXTENDED | pdu.KBDFLAGS_RELEASE, 0x53}, // Delete up
{0xE048, false, pdu.KBDFLAGS_EXTENDED, 0x48}, // ArrowUp
{0x39, false, 0, 0x39}, // Space:无前缀不动
{0x1C, true, pdu.KBDFLAGS_RELEASE, 0x1C}, // Enter up
{0xE01C, false, pdu.KBDFLAGS_EXTENDED, 0x1C}, // NumpadEnter
}
for _, c := range cases {
p := newScancodeEvent(c.sc, c.release)
if p.KeyboardFlags != c.flags || p.KeyCode != c.key {
t.Fatalf("sc=%#x release=%v: got flags=%#x key=%#x, want flags=%#x key=%#x",
c.sc, c.release, p.KeyboardFlags, p.KeyCode, c.flags, c.key)
}
}
}