30 lines
842 B
Go
30 lines
842 B
Go
package reims
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestBorderlessResolutionFallback(t *testing.T) {
|
|
for _, tc := range []struct{ name, display, config, want string }{
|
|
{"configured", "borderless", "resolution = '5120x2880'", "5120x2880"},
|
|
{"missing", "borderless", "", "1920x1080"},
|
|
{"explicit", "one, opening at 2560x1440", "resolution = '5120x2880'", "2560x1440"},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
dir := t.TempDir()
|
|
if tc.config != "" {
|
|
if err := os.WriteFile(filepath.Join(dir, "vm.toml"), []byte("[display]\n"+tc.config+"\n"), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
d := ParseShow("vm", "directory "+dir+"\ndisplay "+tc.display)
|
|
applyBorderlessResolutionFallback(&d)
|
|
if d.Resolution != tc.want {
|
|
t.Fatalf("resolution = %q, want %q", d.Resolution, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|