feat: add tray layout controls
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -64,6 +65,37 @@ func TestMissingActiveLayoutFails(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLayoutNamesAreUniqueAndOrdered(t *testing.T) {
|
||||
c := Default()
|
||||
c.Layouts = append(c.Layouts,
|
||||
Layout{Name: "Columns", Monitor: `\\.\DISPLAY2`},
|
||||
Layout{Name: "Rows", Monitor: "*"},
|
||||
)
|
||||
got := c.LayoutNames()
|
||||
if len(got) != 2 || got[0] != "columns" || got[1] != "Rows" {
|
||||
t.Fatalf("unexpected names: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetActiveLayoutPreservesConfiguration(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "fancywin.yaml")
|
||||
original := "# keep this comment\r\nversion: 1\r\nactive_layout: old # old value\r\nlayouts: []\r\n"
|
||||
if err := os.WriteFile(path, []byte(original), 0o640); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := SetActiveLayout(path, "new layout"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
text := string(data)
|
||||
if !strings.Contains(text, "# keep this comment\r\n") || !strings.Contains(text, "active_layout: new layout\r\n") || !strings.Contains(text, "layouts: []\r\n") {
|
||||
t.Fatalf("unexpected rewritten file: %q", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExcluded(t *testing.T) {
|
||||
c := Default()
|
||||
c.Excluded = []string{"notepad", "exact.exe"}
|
||||
|
||||
Reference in New Issue
Block a user