1package vulkan
2
3import (
4 "image"
5 "testing"
6
7 "github.com/bnema/neferwl/internal/ports"
8)
9
10func TestSceneBelowFloatBoundary(t *testing.T) {
11 r := &Renderer{width: 80, height: 60}
12 s := ports.Scene{Border: ports.Border{Active: "#ffffff"}, Windows: []ports.SceneWindow{
13 {ID: 1, Floating: true, Below: true, Rect: ports.Rect{W: 80, H: 60}},
14 {ID: 2, Rect: ports.Rect{W: 40, H: 60}},
15 }, Separators: []ports.Separator{{Rect: ports.Rect{W: 80, H: 1}, Active: true}}}
16 draws := func() []draw { return r.draws(s, nil, newDamage(&target{}, s, image.Rect(0, 0, 80, 60))) }
17 ds := draws()
18 if len(ds) != 3 || ds[0].pc.rect[2] != 80 || ds[1].pc.rect[2] != 40 || ds[2].pc.rect[3] != 1 {
19 t.Fatalf("below float / tile / lines: %+v", ds)
20 }
21 s.Dim = 0.4
22 s.Windows = append(s.Windows, ports.SceneWindow{ID: 3, Floating: true, Rect: ports.Rect{X: 50, W: 20, H: 20}})
23 ds = draws()
24 if len(ds) != 5 || ds[3].pc.color != [4]float32{0, 0, 0, 0.4} || ds[4].pc.rect[0] != 50 {
25 t.Fatalf("veil boundary: %+v", ds)
26 }
27 // An overview preview of a float is not a float above the tiles: the
28 // tile lines follow the last window.
29 s.Dim = 0
30 s.Windows = []ports.SceneWindow{
31 {ID: 1, Floating: true, Preview: 0.5, Rect: ports.Rect{W: 40, H: 30}},
32 {ID: 2, Preview: 0.5, Rect: ports.Rect{X: 40, W: 40, H: 30}},
33 }
34 ds = draws()
35 if len(ds) != 3 || ds[2].pc.rect[3] != 1 {
36 t.Fatalf("preview boundary: %+v", ds)
37 }
38}