v0.4.0 b6be3a8

dmabuf_yuv_test.go RawHistoryFolder

1package wayland
2
3import (
4	"testing"
5
6	"github.com/bnema/go-wayland-bindings/server/linuxdmabuf"
7	"github.com/bnema/neferwl/internal/ports"
8	"golang.org/x/sys/unix"
9)
10
11func TestYUVParams(t *testing.T) {
12	for _, tc := range []struct {
13		name        string
14		format      uint32
15		two         bool
16		modMismatch bool
17		short       bool
18		errCode     uint32
19	}{
20		{name: "NV12", format: fourccNV12, two: true},
21		{name: "P010", format: fourccP010, two: true},
22		{name: "missing plane", format: fourccNV12, errCode: uint32(linuxdmabuf.ZwpLinuxBufferParamsV1ErrorIncomplete)},
23		{name: "extra plane", format: fourccNV12, two: true, errCode: uint32(linuxdmabuf.ZwpLinuxBufferParamsV1ErrorIncomplete)},
24		{name: "modifier mismatch", format: fourccNV12, two: true, modMismatch: true, errCode: uint32(linuxdmabuf.ZwpLinuxBufferParamsV1ErrorInvalidFormat)},
25		{name: "P010 short chroma", format: fourccP010, two: true, short: true, errCode: uint32(linuxdmabuf.ZwpLinuxBufferParamsV1ErrorOutOfBounds)},
26	} {
27		t.Run(tc.name, func(t *testing.T) {
28			s, _, _, dir := dmabufServer(t, ports.DMABufSupport{Formats: []ports.DMABufFormat{{Format: fourccNV12}, {Format: fourccP010}}})
29			c := protocolClient(t, s, dir)
30			dm := bindVersion(t, c, "zwp_linux_dmabuf_v1", 4)
31			p := c.AllocateID()
32			requestProtocol(t, c, dm, linuxdmabuf.ZwpLinuxDmabufV1RequestCreateParams, p)
33			proxy := &paramsProxy{result: make(chan uint16, 2)}
34			proxy.SetID(p)
35			registerWireProxy(c, proxy)
36			fd, err := unix.MemfdCreate("yuv-params", 0)
37			if err != nil {
38				t.Fatal(err)
39			}
40			defer unix.Close(fd)
41			if err := unix.Ftruncate(fd, 8192); err != nil {
42				t.Fatal(err)
43			}
44			add := func(idx, offset, stride, mod uint32) {
45				t.Helper()
46				if err := wireRequest(c, p, uint16(linuxdmabuf.ZwpLinuxBufferParamsV1RequestAdd), []int{fd}, idx, offset, stride, uint32(0), mod); err != nil {
47					t.Fatal(err)
48				}
49			}
50			stride := uint32(64)
51			if tc.format == fourccP010 {
52				stride = 128
53			}
54			add(0, 0, stride, 0)
55			if tc.two {
56				mod := uint32(0)
57				if tc.modMismatch {
58					mod = 1
59				}
60				offset := uint32(1024)
61				if tc.short {
62					offset = 8180
63				}
64				add(1, offset, stride, mod)
65			}
66			if tc.name == "extra plane" {
67				add(2, 4096, 64, 0)
68			}
69			if tc.modMismatch {
70				expectProtocolError(t, c, p, tc.errCode)
71				return
72			}
73			requestProtocol(t, c, p, linuxdmabuf.ZwpLinuxBufferParamsV1RequestCreate, int32(64), int32(16), tc.format, uint32(0))
74			if tc.errCode != 0 {
75				expectProtocolError(t, c, p, tc.errCode)
76				return
77			}
78			if err := c.Roundtrip(); err != nil {
79				t.Fatal(err)
80			}
81			if op := <-proxy.result; op != uint16(linuxdmabuf.ZwpLinuxBufferParamsV1EventCreated) {
82				t.Fatalf("created event %d", op)
83			}
84		})
85	}
86}

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 23

Tags 10

↑↓ moveenter openesc close