v0.4.0 76bcd84

backdrop_test.go RawHistoryFolder

1package selection
2
3import (
4	"image"
5	"testing"
6
7	"github.com/stretchr/testify/assert"
8	"github.com/stretchr/testify/require"
9
10	"github.com/bnema/nefercap/internal/ports"
11)
12
13func TestBackdropImageIsOpaqueRGBA(t *testing.T) {
14	// One XRGB8888 pixel is B, G, R, X in memory; the stride has padding.
15	f := ports.Frame{Pixels: []byte{
16		0x10, 0x20, 0x30, 0x00, 0x40, 0x50, 0x60, 0x00, 0xee, 0xee, 0xee, 0xee,
17		0x70, 0x80, 0x90, 0x00, 0xa0, 0xb0, 0xc0, 0x00,
18	}, Width: 2, Height: 2, Stride: 12, Format: ports.XRGB8888}
19	require.NoError(t, f.Validate())
20	img := backdropImage(f)
21	assert.Equal(t, image.Rect(0, 0, 2, 2), img.Bounds())
22	assert.Equal(t, []byte{0x30, 0x20, 0x10, 0xff, 0x60, 0x50, 0x40, 0xff, 0x90, 0x80, 0x70, 0xff, 0xc0, 0xb0, 0xa0, 0xff}, img.Pix)
23}
24
25func TestWithBackdrops(t *testing.T) {
26	small := ports.Frame{Pixels: make([]byte, 4*4*4), Width: 4, Height: 4, Stride: 16, Format: ports.XRGB8888}
27	s, err := New(ports.Screenshot, ports.VideoSettings{}, nil, false).WithBackdrops(map[uint32]ports.Frame{7: small})
28	require.NoError(t, err)
29	assert.Contains(t, s.backdrops, uint32(7))
30
31	huge := ports.Frame{Width: maxBackdrop + 1, Height: 1, Stride: (maxBackdrop + 1) * 4, Format: ports.XRGB8888}
32	_, err = New(ports.Screenshot, ports.VideoSettings{}, nil, false).WithBackdrops(map[uint32]ports.Frame{9: huge})
33	assert.ErrorContains(t, err, "at most 4096", "the caller freezes only outputs CanBackdrop accepts")
34}
35
36func TestCanBackdrop(t *testing.T) {
37	assert.True(t, CanBackdrop(ports.Output{Width: 3840, Height: 2160}))
38	assert.True(t, CanBackdrop(ports.Output{Width: 2160, Height: 4096}))
39	assert.False(t, CanBackdrop(ports.Output{Width: 5120, Height: 2880}))
40	assert.False(t, CanBackdrop(ports.Output{}), "an unknown mode stays live")
41}
42
43// The frozen screen is drawn under a screenshot selection only: a recording
44// selects on the live screen.
45func TestBackdropDrawnOnlyForScreenshots(t *testing.T) {
46	m := newTestModel(t)
47	m.backdrop = image.NewNRGBA(image.Rect(0, 0, 1920, 1080))
48	assert.True(t, drawsBackdrop(m))
49	m.mode = ports.Record
50	assert.False(t, drawsBackdrop(m))
51	m.mode, m.backdrop = ports.Screenshot, nil
52	assert.False(t, drawsBackdrop(m))
53}

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 2

Tags 9

↑↓ moveenter openesc close