33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/Nwflower/reims-go/internal/vmstart"
|
|
)
|
|
|
|
func TestKeymapStatusWithoutPluginManager(t *testing.T) {
|
|
a := &App{}
|
|
t.Cleanup(func() { a.getInputService().Close() })
|
|
a.syncKeymapRules()
|
|
cfg := vmstart.VMKeymapConfig{Preset: vmstart.KeymapWinToCmd}
|
|
got := a.keymapStatus("mac", true, cfg)
|
|
if got.Preset != "win_to_cmd" || got.Bindings["lwin"] != "lcmd" ||
|
|
!got.NeedsGuestTools || !got.InputServiceAvailable || !got.Running || got.RequiredAgentVersion != KeymapRequiredAgentVersion ||
|
|
got.GuestConnected || got.GuestKeymapActive || got.HookActive {
|
|
t.Fatalf("unexpected status: %+v", got)
|
|
}
|
|
got = a.keymapStatus("mac", false, vmstart.DefaultVMKeymapConfig())
|
|
if got.Preset != "off" || got.Running || got.NeedsGuestTools || got.Bindings == nil || len(got.Bindings) != 0 {
|
|
t.Fatalf("unexpected defaults: %+v", got)
|
|
}
|
|
}
|
|
|
|
func TestKeymapStatusWithoutInputService(t *testing.T) {
|
|
a := &App{inputShuttingDown: true}
|
|
status := a.keymapStatus("mac", true, vmstart.VMKeymapConfig{Preset: vmstart.KeymapWinToCmd})
|
|
if status.InputServiceAvailable || status.HookActive || !status.NeedsGuestTools {
|
|
t.Fatalf("unexpected status: %+v", status)
|
|
}
|
|
}
|