detached fdd661a

hintlabel_test.go RawHistoryFolder

1package hintlabel
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/require"
7)
8
9func TestHintLabelSize(t *testing.T) {
10	var r Raster
11	_, w1, h1 := r.Label("f", 0, 1)
12	_, w2, h2 := r.Label("fj", 0, 1)
13	require.Greater(t, w1, 0)
14	require.Greater(t, w2, w1, "a longer label is wider")
15	require.Equal(t, h1, h2)
16	_, w3, h3 := r.Label("fj", 0, 2)
17	// The 1 px border does not scale: compare the boxes without it.
18	require.InDelta(t, 2*(w2-2), w3-2, 1)
19	require.InDelta(t, 2*(h2-2), h3-2, 1)
20}
21
22func TestHintLabelCache(t *testing.T) {
23	var r Raster
24	a, w, h := r.Label("fj", 1, 1)
25	b, _, _ := r.Label("fj", 1, 1)
26	require.Len(t, a, w*h*4)
27	require.Same(t, &a[0], &b[0], "same key returns the cached slice")
28	c, _, _ := r.Label("fj", 0, 1)
29	require.NotSame(t, &a[0], &c[0], "typed count is part of the key")
30}
31
32func TestHintLabelPremultiplied(t *testing.T) {
33	var r Raster
34	pix, w, h := r.Label("ab", 1, 1.5)
35	require.Len(t, pix, w*h*4)
36	for i := 0; i < len(pix); i += 4 {
37		a := pix[i+3]
38		require.GreaterOrEqual(t, a, pix[i])
39		require.GreaterOrEqual(t, a, pix[i+1])
40		require.GreaterOrEqual(t, a, pix[i+2])
41	}
42}
43
44func TestHintLabelTypedIsDimmed(t *testing.T) {
45	var r Raster
46	plain, _, _ := r.Label("fj", 0, 1)
47	dim, _, _ := r.Label("fj", 1, 1)
48	require.NotEqual(t, plain, dim)
49}
50
51func TestHintLabelEmptyAndCacheBound(t *testing.T) {
52	var r Raster
53	pix, w, h := r.Label("", 0, 1)
54	require.Nil(t, pix)
55	require.Zero(t, w+h)
56	for i := 0; i < maxEntries+10; i++ {
57		r.Label("a", 0, 1+float64(i)/100000)
58	}
59	require.LessOrEqual(t, len(r.cache), maxEntries)
60}

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