package main import ( "reflect" "strings" "testing" ) // clipmenu's shape (novox/hq ADR 0208, research 026/04): it claims node-clipboard serving history // and copy, requires the X display on its own machine, replaces greenclip, starts its daemon once // from the session's start, and binds its menu as an i3 drop-in through the launcher's dmenu command. func TestItClaimsTheClipboardSeatServingHistoryAndCopy(t *testing.T) { m := readManifest(t) if m.Module != "clipmenu" || m.Seats != nil { t.Fatalf("module %q declares seats %v", m.Module, m.Seats) } if !reflect.DeepEqual(m.Claims, []claim{{Name: "node-clipboard", Scope: "node", Serves: []string{"history", "copy"}}}) { t.Fatalf("claims: %+v", m.Claims) } if !reflect.DeepEqual(m.Requires, []string{"x11-display"}) { t.Fatalf("requires: %v", m.Requires) } present, absent := m.packages() if !reflect.DeepEqual(present, []string{"clipmenu"}) || !reflect.DeepEqual(absent, []string{"rofi-greenclip"}) { t.Fatalf("packages: %v, absent %v", present, absent) } } func TestTheDaemonStartsOnceFromTheSessionsStart(t *testing.T) { m := readManifest(t) if len(m.Shell) != 1 || m.Shell[0].For != "xinitrc" || m.Shell[0].Slot != "normal" { t.Fatalf("%+v", m.Shell) } code := m.Shell[0].Code if strings.Count(code, "\nclipmenud &\n") != 1 || strings.Contains(code, "greenclip") { t.Fatalf("%q", code) } for _, r := range m.Resources { if r["type"] == "service" || r["type"] == "process" { t.Fatalf("a second start: %v", r) } } } func TestItsSettingsAreEnvironmentAndItsMenuIsTheLaunchersDmenu(t *testing.T) { m := readManifest(t) if !reflect.DeepEqual(m.Environment.Variables, map[string]string{"CM_SELECTIONS": "clipboard", "CM_MAX_CLIPS": "500", "CM_HISTLENGTH": "15"}) { t.Fatalf("%v", m.Environment.Variables) } if _, set := m.Environment.Variables["CM_LAUNCHER"]; set { t.Fatal("the launcher is clipmenu's default, dmenu: the seat's command") } m.sameAsSource(t, "i3-bindings", "files/i3/50-clipmenu.conf") if c := m.resource(t, "i3-bindings")["content"].(string); !strings.Contains(c, "bindsym $mod+period exec --no-startup-id clipmenu") { t.Fatalf("%s", c) } } func TestTheToolsAgreeWithTheManifest(t *testing.T) { m := readManifest(t) checkTheToolsAgree(t, m) checkNoSecretsOrInstallationNames(t) }