Files
openchamber-android-native/third_party/mygo/internal/accelerator/accelerator_test.go
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
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.
2026-11-18 13:22:59 +08:00

77 lines
2.3 KiB
Go

package accelerator
import "testing"
func TestParse(t *testing.T) {
tests := []struct {
in string
goos string
want Accelerator
}{
{"CmdOrCtrl+Q", "darwin", Accelerator{Super, "q"}},
{"CmdOrCtrl+Q", "linux", Accelerator{Ctrl, "q"}},
{"CommandOrControl+Shift+Z", "windows", Accelerator{Ctrl | Shift, "z"}},
{"Alt+F4", "windows", Accelerator{Alt, "F4"}},
{"Option+Cmd+I", "darwin", Accelerator{Alt | Super, "i"}},
{"F11", "linux", Accelerator{0, "F11"}},
{"Ctrl+Plus", "linux", Accelerator{Ctrl, "+"}},
{"CmdOrCtrl++", "darwin", Accelerator{Super, "+"}},
{"CmdOrCtrl+=", "darwin", Accelerator{Super, "="}},
{"Cmd+,", "darwin", Accelerator{Super, ","}},
{"Shift+Return", "darwin", Accelerator{Shift, "Enter"}},
{"Esc", "darwin", Accelerator{0, "Escape"}},
{"Ctrl+Num5", "linux", Accelerator{Ctrl, "Num5"}},
{"Super+Space", "linux", Accelerator{Super, "Space"}},
{"ctrl + shift + up", "linux", Accelerator{Ctrl | Shift, "Up"}},
}
for _, tt := range tests {
got, err := Parse(tt.in, tt.goos)
if err != nil {
t.Errorf("Parse(%q): %v", tt.in, err)
continue
}
if got != tt.want {
t.Errorf("Parse(%q, %s) = %+v, want %+v", tt.in, tt.goos, got, tt.want)
}
}
}
func TestParseErrors(t *testing.T) {
for _, in := range []string{"", "Ctrl+", "Hyper+A", "Ctrl+F25", "Ctrl+Foo", "Ctrl+A+B"} {
if _, err := Parse(in, "linux"); err == nil {
t.Errorf("Parse(%q) succeeded, want error", in)
}
}
}
func TestString(t *testing.T) {
a, _ := Parse("Shift+CmdOrCtrl+k", "linux")
if got := a.String(); got != "Ctrl+Shift+K" {
t.Errorf("String() = %q", got)
}
}
func TestXDGTrigger(t *testing.T) {
for in, want := range map[string]string{
"Shift+CmdOrCtrl+K": "CTRL+SHIFT+k",
"Super+Space": "LOGO+space",
"Alt+Shift+Enter": "ALT+SHIFT+Return",
"CmdOrCtrl+,": "CTRL+comma",
"Ctrl+Plus": "CTRL+plus",
"Ctrl+Alt+Super+F12": "CTRL+ALT+LOGO+F12",
"Ctrl+Num7": "CTRL+KP_7",
"Ctrl+PageDown": "CTRL+Page_Down",
"MediaPlayPause": "XF86AudioPlay",
"Ctrl+1": "CTRL+1",
"Ctrl+é": "CTRL+U00E9",
} {
a, err := Parse(in, "linux")
if err != nil {
t.Fatal(err)
}
if got := a.XDGTrigger(); got != want {
t.Errorf("XDGTrigger(%q) = %q, want %q", in, got, want)
}
}
}