//go:build darwin package hotkey import "testing" func TestDarwinModifierDiagnosticsIncludeOptionAndCommand(t *testing.T) { tests := []struct { name string keyCode int want int }{ {name: "left option", keyCode: 58, want: 0}, {name: "right option", keyCode: 61, want: 1}, {name: "left command", keyCode: 55, want: 2}, {name: "right command", keyCode: 54, want: 3}, {name: "non diagnostic", keyCode: 49, want: -1}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := modifierDiagnosticIndex(tt.keyCode); got != tt.want { t.Fatalf("modifierDiagnosticIndex(%d) = %d, want %d", tt.keyCode, got, tt.want) } }) } } func TestDarwinHotkeySourceNameDocumentsCommandFallback(t *testing.T) { tests := []struct { source int want string }{ {source: 0, want: "none"}, {source: 1, want: "physicalHID"}, {source: 2, want: "physicalCombined"}, {source: 3, want: "eventTap"}, {source: 4, want: "recent"}, {source: 5, want: "aggregateCommandFlag"}, } for _, tt := range tests { if got := hotkeySourceName(tt.source); got != tt.want { t.Fatalf("hotkeySourceName(%d) = %q, want %q", tt.source, got, tt.want) } } } func TestDarwinSideModifierSourceAcceptedRejectsAggregateCommandFlag(t *testing.T) { tests := []struct { name string source int want bool }{ {name: "none", source: 0, want: false}, {name: "physical HID", source: 1, want: true}, {name: "physical combined", source: 2, want: true}, {name: "event tap tracked", source: 3, want: true}, {name: "recent side-specific event", source: 4, want: true}, {name: "aggregate command diagnostic only", source: 5, want: false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := sideModifierSourceAccepted(tt.source); got != tt.want { t.Fatalf("sideModifierSourceAccepted(%d) = %t, want %t", tt.source, got, tt.want) } }) } } func TestDarwinModifierGroupIncludesCommandSides(t *testing.T) { if got := modifierGroup(0x5B); got != 4 { t.Fatalf("modifierGroup(L-Command) = %d, want 4", got) } if got := modifierGroup(0x5C); got != 4 { t.Fatalf("modifierGroup(R-Command) = %d, want 4", got) } }