1package vulkan
2
3import (
4 "image"
5 "testing"
6
7 "github.com/bnema/neferwl/internal/ports"
8)
9
10// Each whole-window redraw is counted under its reason, so the stats tell
11// a client claiming full damage from a history too short.
12func TestFullRedrawReasons(t *testing.T) {
13 rect := image.Rect(0, 0, 10, 10)
14 held := &target{valid: true, windows: map[ports.WindowID]heldWindow{1: {seq: 1, rect: rect}}}
15 var why fullRedraws
16 d := &damageRegion{held: held, seen: map[ports.WindowID]bool{}, drawn: map[ports.WindowID]heldWindow{}, bound: rect, why: &why}
17 pixels := ports.SurfaceContent{Width: 10, Height: 10, SHM: &ports.SHMBuffer{}}
18
19 known := pixels
20 known.ID, known.Seq = 1, 2
21 known.DamageHistory = []ports.SeqDamage{{Seq: 2, Rects: []ports.Rect{{W: 1, H: 1}}}}
22 d.window(1, known, rect)
23 if why != (fullRedraws{}) {
24 t.Fatalf("partial damage counted as full: %v", why)
25 }
26
27 d.seen = map[ports.WindowID]bool{}
28 gap := pixels
29 gap.ID, gap.Seq = 1, 9
30 gap.DamageHistory = []ports.SeqDamage{{Seq: 9, Rects: []ports.Rect{{W: 1, H: 1}}}}
31 d.window(1, gap, rect)
32 d.window(2, gap, rect)
33 if why[fullHistory] != 1 || why[fullNewWindow] != 1 {
34 t.Fatalf("reasons %v", why)
35 }
36 if got := why.take(); got[fullHistory] != 1 || why != (fullRedraws{}) {
37 t.Fatalf("take %v left %v", got, why)
38 }
39}