startup_presentation_hooks_test.go RawHistoryFolder

1package cef
2
3import (
4	"bytes"
5	"encoding/json"
6	"strings"
7	"testing"
8	"time"
9
10	"github.com/rs/zerolog"
11	"github.com/stretchr/testify/require"
12)
13
14func TestStartupPresentationHooksWireEveryUpstreamFirstPresentationCallback(t *testing.T) {
15	var output bytes.Buffer
16	trace := newStartupTrace(time.Now, time.Now())
17	trace.SetBackend("gdk-dmabuf")
18	logger := zerolog.New(&output)
19	trace.SetLogger(&logger)
20	for _, milestone := range []string{
21		"process_entry",
22		"config_complete",
23		"cef_library_load_begin",
24		"cef_initialized",
25		"browser_create_requested",
26	} {
27		require.Truef(t, trace.Mark(milestone), "seed milestone %q", milestone)
28	}
29
30	hooks := startupPresentationHooks(trace)
31	require.NotNil(t, hooks.OnFirstAcceleratedPaint)
32	require.NotNil(t, hooks.OnFirstDMABUFTextureSwap)
33	require.NotNil(t, hooks.OnFirstPresentation)
34	require.NotNil(t, hooks.OnDMABUFUnsupported)
35
36	// The unsupported fact may arrive before the successful presentation path.
37	// Each callback is invoked twice to make no-op, swapped, and duplicate bodies
38	// observable through the exact trace output below.
39	hooks.OnDMABUFUnsupported()
40	hooks.OnDMABUFUnsupported()
41	hooks.OnFirstAcceleratedPaint()
42	hooks.OnFirstAcceleratedPaint()
43	hooks.OnFirstDMABUFTextureSwap()
44	hooks.OnFirstDMABUFTextureSwap()
45	hooks.OnFirstPresentation()
46	hooks.OnFirstPresentation()
47
48	var milestones []string
49	summaryCount := 0
50	var incompleteReason string
51	for _, line := range strings.Split(strings.TrimSpace(output.String()), "\n") {
52		var event struct {
53			Message          string `json:"message"`
54			Milestone        string `json:"milestone"`
55			IncompleteReason string `json:"incomplete_reason"`
56		}
57		require.NoError(t, json.Unmarshal([]byte(line), &event))
58		switch event.Message {
59		case "startup_trace: milestone":
60			milestones = append(milestones, event.Milestone)
61		case "startup_trace: first presentation":
62			summaryCount++
63			incompleteReason = event.IncompleteReason
64		}
65	}
66
67	require.Equal(t, []string{
68		"process_entry",
69		"config_complete",
70		"cef_library_load_begin",
71		"cef_initialized",
72		"browser_create_requested",
73		"first_accelerated_paint_received",
74		"first_dmabuf_texture_swap",
75		"first_gtk_presentation",
76	}, milestones)
77	require.Equal(t, "dmabuf_texture_swap_unavailable", incompleteReason)
78	require.Equal(t, 1, summaryCount)
79}

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 8

Tags 42

↑↓ moveenter openesc close