X reset twice during the session start and threw away the resources xrdb had just merged, so xterm came up in the bitmap fixed font. clipmenud's one-second xsel read of a screenshot was killed mid-transfer and left the image's owner hung, so every paste after it hung.
67 lines
2.4 KiB
Go
67 lines
2.4 KiB
Go
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
|
|
// Started once, through the module's text-only xsel (a selection holding an image is never read).
|
|
if strings.Count(code, "clipmenud &\n") != 1 || !strings.Contains(code, `PATH="/usr/local/lib/mesh-clipmenu:$PATH" clipmenud &`) ||
|
|
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)
|
|
}
|