frames_test.go RawHistoryFolder

1package drm
2
3import (
4	"testing"
5
6	"github.com/bnema/neferwl/internal/ports"
7	"github.com/stretchr/testify/require"
8)
9
10// A flip of an animating scene tells core the next frame is due; the flip
11// of any other frame does not.
12func TestCompletedSendsFrameOnlyForAnimatingScene(t *testing.T) {
13	o, _, commits := testOutput(t)
14	o.cursor = nil
15	frames := make(chan ports.OutputFrame, 2)
16	o.Frames = frames
17	seen := map[ports.WindowID]uint64{}
18
19	require.NoError(t, o.commitFrame(70, nil, false, false, pendingFrame{}))
20	require.True(t, o.completed(eventOf((*commits)[0]), seen))
21	require.Empty(t, frames, "a settled scene wakes nobody")
22
23	require.NoError(t, o.commitFrame(70, nil, false, false, pendingFrame{animating: true}))
24	require.True(t, o.completed(eventOf((*commits)[1]), seen))
25	require.Equal(t, []ports.OutputFrame{{Output: "DP-1"}}, drain(frames))
26
27}
28
29// A frames channel core has not read stays full: the owner never waits.
30func TestCompletedFramesNeverBlock(t *testing.T) {
31	o, _, commits := testOutput(t)
32	o.cursor = nil
33	frames := make(chan ports.OutputFrame, 1)
34	o.Frames = frames
35	seen := map[ports.WindowID]uint64{}
36	for i := range 3 {
37		require.NoError(t, o.commitFrame(70, nil, false, false, pendingFrame{animating: true}))
38		require.True(t, o.completed(eventOf((*commits)[i]), seen))
39	}
40	require.Len(t, frames, 1)
41}
42
43// An output without a frames channel (tests, nobody to wake) just flips.
44func TestCompletedWithoutFramesChannel(t *testing.T) {
45	o, _, commits := testOutput(t)
46	o.cursor = nil
47	require.NoError(t, o.commitFrame(70, nil, false, false, pendingFrame{animating: true}))
48	require.True(t, o.completed(eventOf((*commits)[0]), map[ports.WindowID]uint64{}))
49}
50
51func drain(ch chan ports.OutputFrame) []ports.OutputFrame {
52	var out []ports.OutputFrame
53	for len(ch) > 0 {
54		out = append(out, <-ch)
55	}
56	return out
57}
58
59// The frame send of an animating flip allocates nothing, full channel or not.
60func TestAnimatingFrameSendAllocations(t *testing.T) {
61	o, _, _ := testOutput(t)
62	frames := make(chan ports.OutputFrame, 1)
63	o.Frames = frames
64	if n := testing.AllocsPerRun(100, func() {
65		o.wakeCore() // fills the channel, or finds it full
66		select {
67		case <-frames:
68		default:
69		}
70		o.wakeCore()
71	}); n != 0 {
72		t.Fatalf("wakeCore: %v allocations", n)
73	}
74}

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