package main import ( "os" "path/filepath" "testing" ) // xfwm4 falls back to an ugly built-in frame when any of these slices is missing. var requiredSlices = []string{ "top-left", "top-right", "left", "right", "bottom", "bottom-left", "bottom-right", "title-1", "title-2", "title-3", "title-4", "title-5", } var requiredButtons = []string{ "close", "hide", "maximize", "maximize-toggled", "menu", "shade", "shade-toggled", "stick", "stick-toggled", } func TestGenerateWritesCompleteTheme(t *testing.T) { for name, v := range variants { t.Run(name, func(t *testing.T) { dir := t.TempDir() if err := generate(v, dir); err != nil { t.Fatal(err) } want := []string{"themerc"} for _, s := range requiredSlices { want = append(want, s+"-active.png", s+"-inactive.png") } for _, b := range requiredButtons { for _, state := range []string{"active", "inactive", "prelight", "pressed"} { want = append(want, b+"-"+state+".png") } } for _, f := range want { if _, err := os.Stat(filepath.Join(dir, f)); err != nil { t.Errorf("missing %s", f) } } }) } } func TestTopLeftCornerIsTransparentOutsideRadius(t *testing.T) { img := render(cornerWidth, titleHeight, topLeft(variants["light"].active)) if a := img.NRGBAAt(0, 0).A; a != 0 { t.Errorf("corner pixel alpha = %d, want 0", a) } if a := img.NRGBAAt(cornerWidth-1, titleHeight/2).A; a != 0xff { t.Errorf("title pixel alpha = %d, want 255", a) } } func TestButtonsMatchTitleHeight(t *testing.T) { for _, p := range pieces(variants["dark"]) { if p.w == buttonWidth && p.h != titleHeight { t.Errorf("%s height = %d, want %d", p.name, p.h, titleHeight) } } }