main f2d166b

damage_log_test.go RawHistoryFolder

1package wayland
2
3import (
4	"fmt"
5	"strings"
6	"testing"
7	"time"
8
9	"github.com/bnema/go-wayland-bindings/server/wayland"
10	"github.com/bnema/zerowrap"
11)
12
13// --debug=wayland-damage logs one "client damage" entry per fresh commit
14// with the damage in buffer pixels; without it nothing is logged.
15func TestClientDamageLog(t *testing.T) {
16	for _, on := range []bool{true, false} {
17		t.Run(fmt.Sprintf("LogDamage=%v", on), func(t *testing.T) {
18			var out lockedBuffer
19			log := zerowrap.New(zerowrap.Config{Level: "debug", Format: "json", Output: &out}).WithField("component", "wayland")
20			s, events, _, contents, dir := contentServerWith(t, Options{LogDamage: on}, log)
21			c := protocolClient(t, s, dir)
22			// A mapped window (its 1×1 first buffer is not under test), then
23			// the 16×16 buffer the commits below attach.
24			_, surf, _ := surfaceMapperAt(t, c, events, 4)()
25			drainContents(contents)
26			buf := shmBufferSized(t, c, 16, 16)
27			commit := func(rects ...[4]int32) {
28				t.Helper()
29				requestProtocol(t, c, surf, wayland.SurfaceRequestAttach, buf, int32(0), int32(0))
30				for _, r := range rects {
31					requestProtocol(t, c, surf, wayland.SurfaceRequestDamageBuffer, r[0], r[1], r[2], r[3])
32				}
33				requestProtocol(t, c, surf, wayland.SurfaceRequestCommit)
34				if err := c.Roundtrip(); err != nil {
35					t.Fatal(err)
36				}
37				select {
38				case <-contents:
39				case <-time.After(2 * time.Second):
40					t.Fatal("no content")
41				}
42			}
43			// First buffer: a new size, full. Then a small rect, then one
44			// covering the whole buffer.
45			commit([4]int32{0, 0, 4, 4})
46			commit([4]int32{2, 3, 4, 5})
47			commit([4]int32{0, 0, 16, 16})
48			var damage []string
49			for _, l := range strings.Split(strings.TrimSpace(out.String()), "\n") {
50				if strings.Contains(l, `"client damage"`) {
51					damage = append(damage, l)
52				}
53			}
54			if !on {
55				if len(damage) != 0 {
56					t.Fatalf("logged with LogDamage off: %q", damage)
57				}
58				return
59			}
60			// The mapping commit logged one entry of its own.
61			if len(damage) != 4 {
62				t.Fatalf("%d client damage entries, want 4 (mapping commit and 3 commits): %q", len(damage), damage)
63			}
64			damage = damage[1:]
65			for i, want := range []string{`"full_buffer":true`, `"full_buffer":false`, `"full_buffer":true`} {
66				if !strings.Contains(damage[i], want) {
67					t.Errorf("entry %d lacks %s: %s", i, want, damage[i])
68				}
69			}
70			for _, want := range []string{`"component":"wayland"`, `"bw":16`, `"bh":16`, `"rects":1`, `"window":`, `"first_rects":[{"x":2,"y":3,"w":4,"h":5}]`} {
71				if !strings.Contains(damage[1], want) {
72					t.Errorf("entry 1 lacks %s: %s", want, damage[1])
73				}
74			}
75		})
76	}
77}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 25

Tags 10

↑↓ moveenter openesc close