cursor_test.go RawHistoryFolder

1package vulkan
2
3import (
4	"testing"
5	"unsafe"
6)
7
8// Cursor images are packed (pitch = size*4), exported, and WriteCursor
9// crops to the image and clears around the pixels.
10func TestCursorBuffersWriteCursor(t *testing.T) {
11	r, err := New(64, 48)
12	if err != nil {
13		t.Skipf("Vulkan unavailable: %v", err)
14	}
15	defer r.Close()
16	bufs, err := r.CursorBuffers(64)
17	if err != nil {
18		t.Skipf("no exportable cursor images: %v", err)
19	}
20	for _, b := range bufs {
21		if p := b.Planes[0]; p.Stride != 64*4 || p.Offset != 0 || b.Format != fourccARGB {
22			t.Fatalf("layout %+v format %#x", p, b.Format)
23		}
24		b.Planes[0].File.Close()
25	}
26	mem := func() []byte { c := r.cursors[1]; return unsafe.Slice((*byte)(c.mapped), c.pitch*c.size) }
27	// A first image fills the corner; a second, smaller one must clear it.
28	big := make([]byte, 100*100*4)
29	for i := range big {
30		big[i] = 0xff
31	}
32	if err := r.WriteCursor(1, big, 100, 100); err != nil { // cropped to 64
33		t.Fatal(err)
34	}
35	if m := mem(); m[63*256+63*4] != 0xff {
36		t.Fatal("cropped image not written")
37	}
38	if err := r.WriteCursor(1, []byte{1, 2, 3, 4}, 1, 1); err != nil {
39		t.Fatal(err)
40	}
41	m := mem()
42	if m[0] != 1 || m[3] != 4 || m[4] != 0 || m[256] != 0 || m[63*256+63*4] != 0 {
43		t.Fatal("image not cleared around the new pixels")
44	}
45	if err := r.WriteCursor(1, []byte{1}, 1, 1); err == nil {
46		t.Fatal("short image accepted")
47	}
48}
49
50func TestHDRCursorWritesBothImagesAndInvalidates(t *testing.T) {
51	r, err := New(32, 16)
52	if err != nil {
53		t.Skipf("Vulkan unavailable: %v", err)
54	}
55	defer r.Close()
56	bufs, err := r.CursorBuffers(64)
57	if err != nil {
58		t.Skipf("no cursor images: %v", err)
59	}
60	for _, b := range bufs {
61		b.Planes[0].File.Close()
62	}
63	r.SetHDR(203)
64	px := []byte{255, 255, 255, 255}
65	if err := r.WriteCursor(0, px, 1, 1); err != nil {
66		t.Fatal(err)
67	}
68	if err := r.WriteCursor(1, px, 1, 1); err != nil {
69		t.Fatal(err)
70	}
71	for _, c := range r.cursors {
72		got := unsafe.Slice((*byte)(c.mapped), 4)
73		if got[0] != 148 || got[1] != 148 || got[2] != 148 || got[3] != 255 {
74			t.Fatalf("cursor HDR pixel: %v", got)
75		}
76	}
77	r.SetHDR(0)
78	if r.cursorCache.Len() != 0 {
79		t.Fatal("SetHDR kept conversion")
80	}
81	if err := r.WriteCursor(0, px, 1, 1); err != nil {
82		t.Fatal(err)
83	}
84	if got := unsafe.Slice((*byte)(r.cursors[0].mapped), 4); got[0] != 255 || r.cursorCache.Len() != 0 {
85		t.Fatalf("SDR cursor/cache: %v %d", got, r.cursorCache.Len())
86	}
87}

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