v0.6.0 7d47882

flash_test.go RawHistoryFolder

1package flash
2
3import (
4	"context"
5	"os"
6	"testing"
7	"time"
8
9	"github.com/bnema/neferclient"
10	"github.com/stretchr/testify/assert"
11	"github.com/stretchr/testify/require"
12
13	"github.com/bnema/nefercap/internal/ports"
14)
15
16func TestLayerConfigWholeOutput(t *testing.T) {
17	c := layerConfig("DP-1", ports.Region{})
18	assert.Equal(t, "DP-1", c.Output)
19	assert.Equal(t, neferclient.AnchorTop|neferclient.AnchorBottom|neferclient.AnchorLeft|neferclient.AnchorRight, c.Anchors)
20	assert.Equal(t, [4]int32{}, c.Margin)
21	assert.Zero(t, c.Width)
22	assert.Zero(t, c.Height)
23	assert.Equal(t, neferclient.KeyboardNone, c.Keyboard)
24	assert.NotNil(t, c.InputRects, "an empty non-nil input region lets clicks through")
25	assert.Empty(t, c.InputRects)
26}
27
28func TestLayerConfigRegion(t *testing.T) {
29	c := layerConfig("DP-1", ports.Region{X: 10, Y: 20, Width: 300, Height: 200})
30	assert.Equal(t, neferclient.AnchorTop|neferclient.AnchorLeft, c.Anchors)
31	assert.Equal(t, [4]int32{20, 0, 0, 10}, c.Margin)
32	assert.Equal(t, int32(300), c.Width)
33	assert.Equal(t, int32(200), c.Height)
34	assert.NotNil(t, c.InputRects)
35	assert.Empty(t, c.InputRects)
36}
37
38func TestFadeSteps(t *testing.T) {
39	ctx, cancel := context.WithCancel(context.Background())
40	defer cancel()
41	f := &fade{done: cancel}
42	start := time.Unix(100, 0)
43	assert.Equal(t, "s0", f.class(start), "the fade starts with the first frame")
44	assert.Equal(t, "s0", f.class(start.Add(step-time.Millisecond)))
45	assert.Equal(t, "s1", f.class(start.Add(step)))
46	assert.Equal(t, "s9", f.class(start.Add(9*step)))
47	assert.NoError(t, ctx.Err())
48	assert.False(t, f.ended)
49	assert.Equal(t, "s9", f.class(start.Add(10*step)), "past the end the faintest step stays")
50	assert.Equal(t, "s9", f.class(start.Add(time.Hour)))
51	assert.ErrorIs(t, ctx.Err(), context.Canceled, "the fade ends the run")
52	assert.True(t, f.ended)
53	assert.Equal(t, "s0", (&fade{start: start, done: cancel}).class(start.Add(-time.Second)), "a reading before start never underflows")
54}
55
56func TestShowRequiresOutputName(t *testing.T) {
57	err := Show(context.Background(), ports.Output{ID: 3}, ports.Region{})
58	require.ErrorIs(t, err, ports.ErrOutputNotFound)
59}
60
61// TestSmokeShow shows the real flash. It needs a Wayland compositor with
62// layer-shell and Vulkan, so it runs only when NEFERCAP_FLASH_OUTPUT names the
63// wl_output to show it on (for example HEADLESS-1 on a NeferWL headless
64// compositor).
65func TestSmokeShow(t *testing.T) {
66	name := os.Getenv("NEFERCAP_FLASH_OUTPUT")
67	if name == "" {
68		t.Skip("set NEFERCAP_FLASH_OUTPUT to the output name on a Wayland session")
69	}
70	began := time.Now()
71	require.NoError(t, Show(context.Background(), ports.Output{ID: 1, Name: name}, ports.Region{X: 40, Y: 40, Width: 320, Height: 200}))
72	assert.Less(t, time.Since(began), Limit+time.Second)
73}

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