Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
97 lines
3.7 KiB
Go
97 lines
3.7 KiB
Go
//go:build windows && (amd64 || arm64)
|
|
|
|
package windows
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo/internal/platform"
|
|
)
|
|
|
|
func TestPhysicalKeyDoesNotEscapeIME(t *testing.T) {
|
|
// IMEs (including Korean and Japanese) own VK_PROCESSKEY events.
|
|
// Their scan codes must not turn back into application keys, even on
|
|
// release or repeat. VK_PACKET likewise carries injected Unicode text.
|
|
for _, vk := range []uintptr{vkProcessKey, vkPacket} {
|
|
for _, flags := range []uintptr{0, 1 << 30, 1<<30 | 1<<31} {
|
|
for _, release := range []bool{false, true} {
|
|
k, physical, ok := keyAndPosition(vk, 31<<16|flags, release, platform.ModCtrl|platform.ModAlt)
|
|
if ok || k != platform.KeyUnknown || physical != platform.KeyUnknown {
|
|
t.Errorf("vk=%#x flags=%#x release=%v: (%v, %v, %v), want no key", vk, flags, release, k, physical, ok)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPhysicalKeyDistinguishesKeypadSlash(t *testing.T) {
|
|
for _, release := range []bool{false, true} {
|
|
for _, tc := range []struct {
|
|
vk, flags uintptr
|
|
physical platform.Key
|
|
}{
|
|
{0xBF, 0, platform.KeySlash},
|
|
{0x6F, 1 << 24, platform.KeyUnknown},
|
|
} {
|
|
k, physical, ok := keyAndPosition(tc.vk, 53<<16|tc.flags, release, 0)
|
|
if !ok || k != platform.KeySlash || physical != tc.physical {
|
|
t.Errorf("vk=%#x release=%v: (%v, %v, %v), want (%v, %v, true)", tc.vk, release, k, physical, ok, platform.KeySlash, tc.physical)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestKeyAndPosition(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
vk, scan uintptr
|
|
mods platform.Modifiers
|
|
release bool
|
|
key, physical platform.Key
|
|
ok bool
|
|
}{
|
|
{"Russian VK_S already identifies S", 'S', 31, platform.ModCtrl, false, platform.KeyS, platform.KeyS, true},
|
|
{"known layout key wins over position", 'Z', 21, platform.ModCtrl, false, platform.KeyZ, platform.KeyY, true},
|
|
{"unknown layout chord", 0xDF, 41, platform.ModCtrl, false, platform.KeyUnknown, platform.KeyBackquote, true},
|
|
{"unknown layout ordinary typing", 0xDF, 41, 0, false, platform.KeyUnknown, platform.KeyBackquote, false},
|
|
{"unknown layout shifted typing", 0xDF, 41, platform.ModShift, false, platform.KeyUnknown, platform.KeyBackquote, false},
|
|
{"release after modifiers lifted", 0xDF, 41, 0, true, platform.KeyUnknown, platform.KeyBackquote, true},
|
|
{"unmapped scan code", 0xDF, 0, platform.ModCtrl, false, platform.KeyUnknown, platform.KeyUnknown, false},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
key, physical, ok := keyAndPosition(tc.vk, tc.scan<<16, tc.release, tc.mods)
|
|
if key != tc.key || physical != tc.physical || ok != tc.ok {
|
|
t.Fatalf("got (%v, %v, %v), want (%v, %v, %v)", key, physical, ok, tc.key, tc.physical, tc.ok)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestKeyCodeOfMessage(t *testing.T) {
|
|
const extended = 1 << 24
|
|
for _, c := range []struct {
|
|
vk, lp uintptr
|
|
want platform.KeyCode
|
|
}{
|
|
{vkShift, 0x2A << 16, platform.CodeShiftLeft},
|
|
{vkShift, 0x36 << 16, platform.CodeShiftRight},
|
|
{vkControl, 0x1D << 16, platform.CodeControlLeft},
|
|
{vkControl, 0x1D<<16 | extended, platform.CodeControlRight},
|
|
{vkMenu, 0x38 << 16, platform.CodeAltLeft},
|
|
{vkMenu, 0x38<<16 | extended, platform.CodeAltRight},
|
|
{vkLWin, 0x5B<<16 | extended, platform.CodeSuperLeft},
|
|
{0x14, 0x3A << 16, platform.CodeCapsLock},
|
|
{0x2C, 0x37<<16 | extended, platform.CodePrintScreen},
|
|
{0x90, 0x45<<16 | extended, platform.CodeNumLock},
|
|
{0x13, 0x45 << 16, platform.CodePause},
|
|
{0xE2, 0x56 << 16, platform.CodeIntlBackslash},
|
|
// Input methods and injected text keep the key from the application.
|
|
{vkProcessKey, 0x1E << 16, platform.CodeUnknown},
|
|
{vkPacket, 0x1E << 16, platform.CodeUnknown},
|
|
} {
|
|
if got := keyCode(c.vk, c.lp); got != c.want {
|
|
t.Errorf("vk %#x, lp %#x: got %#x, want %#x", c.vk, c.lp, got, c.want)
|
|
}
|
|
}
|
|
}
|