render_experiment_test.go RawHistoryFolder

1package cef
2
3import (
4	"strconv"
5	"testing"
6
7	purecef "github.com/bnema/purego-cef/cef"
8)
9
10func TestWindowlessFrameRatePinnedFollowsTheOverride(t *testing.T) {
11	cases := []struct {
12		value string
13		want  bool
14	}{
15		{value: "", want: false},
16		{value: "60", want: true},
17		{value: " 144 ", want: true},
18		{value: "0", want: false},
19		{value: "-60", want: false},
20		{value: "many", want: false},
21		{value: strconv.FormatInt(int64(1)<<40, 10), want: false},
22	}
23	for _, testCase := range cases {
24		t.Run("pin:"+testCase.value, func(t *testing.T) {
25			t.Setenv(cefWindowlessFrameRateEnvVar, testCase.value)
26			if got := windowlessFrameRatePinned(); got != testCase.want {
27				t.Fatalf("windowlessFrameRatePinned(%q) = %v, want %v", testCase.value, got, testCase.want)
28			}
29		})
30	}
31}
32
33func TestConfigureNativePopupWindowEnablesExternalBeginFrameByDefault(t *testing.T) {
34	// The default is only worth asserting through a real call site: an inverted
35	// default shipped before because only the boolean helper was covered.
36	cases := []struct {
37		value string
38		want  int32
39	}{
40		{value: "", want: 1},
41		{value: "1", want: 1},
42		{value: "true", want: 1},
43		{value: "on", want: 1},
44		{value: "random", want: 1},
45		{value: "0", want: 0},
46		{value: "false", want: 0},
47		{value: "off", want: 0},
48	}
49	for _, testCase := range cases {
50		t.Run("call-site:"+testCase.value, func(t *testing.T) {
51			t.Setenv(cefExternalBeginFrameEnvVar, testCase.value)
52			windowInfo := purecef.NewWindowInfo()
53			settings := purecef.NewBrowserSettings()
54
55			configureNativePopupWindow(&windowInfo, &settings, 60)
56
57			if windowInfo.ExternalBeginFrameEnabled != testCase.want {
58				t.Fatalf("ExternalBeginFrameEnabled with %q = %d, want %d",
59					testCase.value, windowInfo.ExternalBeginFrameEnabled, testCase.want)
60			}
61		})
62	}
63}
64
65func TestResolveWindowlessFrameRatePrefersAPinnedRate(t *testing.T) {
66	t.Setenv(cefWindowlessFrameRateEnvVar, "")
67
68	rate, adaptive := resolveWindowlessFrameRate(0, true)
69	if rate != defaultCEFWindowlessFrameRate || !adaptive {
70		t.Fatalf("unpinned resolve = (%d, %v), want (%d, true)", rate, adaptive, defaultCEFWindowlessFrameRate)
71	}
72
73	rate, adaptive = resolveWindowlessFrameRate(90, true)
74	if rate != 90 || !adaptive {
75		t.Fatalf("configured resolve = (%d, %v), want (90, true)", rate, adaptive)
76	}
77
78	rate, adaptive = resolveWindowlessFrameRate(90, false)
79	if rate != 90 || adaptive {
80		t.Fatalf("non-adaptive resolve = (%d, %v), want (90, false)", rate, adaptive)
81	}
82
83	t.Setenv(cefWindowlessFrameRateEnvVar, "144")
84	rate, adaptive = resolveWindowlessFrameRate(0, true)
85	if rate != 144 || adaptive {
86		t.Fatalf("pinned resolve = (%d, %v), want (144, false)", rate, adaptive)
87	}
88
89	t.Setenv(cefWindowlessFrameRateEnvVar, "not-a-rate")
90	rate, adaptive = resolveWindowlessFrameRate(0, true)
91	if rate != defaultCEFWindowlessFrameRate || !adaptive {
92		t.Fatalf("unparsable pin resolve = (%d, %v), want the configured fallback", rate, adaptive)
93	}
94
95	t.Setenv(cefWindowlessFrameRateEnvVar, "0")
96	rate, adaptive = resolveWindowlessFrameRate(60, true)
97	if rate != 60 || !adaptive {
98		t.Fatalf("zero pin resolve = (%d, %v), want (60, true)", rate, adaptive)
99	}
100
101	t.Setenv(cefWindowlessFrameRateEnvVar, "-60")
102	rate, adaptive = resolveWindowlessFrameRate(60, true)
103	if rate != 60 || !adaptive {
104		t.Fatalf("negative pin resolve = (%d, %v), want (60, true)", rate, adaptive)
105	}
106
107	overflow := strconv.FormatInt(int64(1)<<40, 10)
108	t.Setenv(cefWindowlessFrameRateEnvVar, overflow)
109	rate, adaptive = resolveWindowlessFrameRate(60, true)
110	if rate != 60 || !adaptive {
111		t.Fatalf("overflowing pin resolve = (%d, %v), want (60, true)", rate, adaptive)
112	}
113}

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