v0.33.2 57f21d6

render_handler_popup_test.go RawHistoryFolder

1package cef
2
3import (
4	"testing"
5
6	purecef "github.com/bnema/purego-cef/cef"
7	cefmocks "github.com/bnema/purego-cef/cef/mocks"
8	"github.com/stretchr/testify/assert"
9)
10
11type popupSurfaceRecorder struct {
12	visible bool
13	rect    purecef.Rect
14	calls   []string
15}
16
17func (r *popupSurfaceRecorder) SetPopupVisible(visible bool) {
18	r.visible = visible
19	r.calls = append(r.calls, "visible")
20}
21
22func (r *popupSurfaceRecorder) SetPopupRect(rect purecef.Rect) {
23	r.rect = rect
24	r.calls = append(r.calls, "rect")
25}
26
27func TestDumberRenderHandler_RoutesPopupAcceleratedPaintToPopupSurface(t *testing.T) {
28	mainHandler := cefmocks.NewMockRenderHandler(t)
29	popupHandler := cefmocks.NewMockRenderHandler(t)
30	h := &dumberRenderHandler{
31		main:  mainHandler,
32		popup: popupHandler,
33	}
34
35	info := &purecef.AcceleratedPaintInfo{}
36	popupHandler.EXPECT().OnAcceleratedPaint(nil, purecef.PaintElementTypePetPopup, []purecef.Rect(nil), info).Return().Once()
37
38	h.OnAcceleratedPaint(nil, purecef.PaintElementTypePetPopup, []purecef.Rect(nil), info)
39
40	mainHandler.AssertNotCalled(t, "OnAcceleratedPaint", nil, purecef.PaintElementTypePetPopup, []purecef.Rect(nil), info)
41}
42
43func TestDumberRenderHandler_TracksPopupLifecycle(t *testing.T) {
44	recorder := &popupSurfaceRecorder{}
45	// With a nil engine, WebView.runOnGTK/webview.go executes inline so popup
46	// lifecycle updates stay synchronous in this unit test.
47	wv := &WebView{}
48	wv.engine = nil
49	h := &dumberRenderHandler{
50		wv:           wv,
51		popupSurface: recorder,
52	}
53
54	popupRect := &purecef.Rect{X: 12, Y: 34, Width: 180, Height: 240}
55	h.OnPopupShow(nil, 1)
56	h.OnPopupSize(nil, popupRect)
57	h.OnPopupShow(nil, 0)
58
59	assert.Equal(t, []string{"visible", "rect", "visible"}, recorder.calls)
60	assert.Equal(t, purecef.Rect{X: 12, Y: 34, Width: 180, Height: 240}, recorder.rect)
61	assert.False(t, recorder.visible)
62}
63
64func TestDeviceToLogicalSize_RoundsUp(t *testing.T) {
65	assert.Equal(t, int32(4), deviceToLogicalSize(5, 1.25))
66	assert.Equal(t, int32(1), deviceToLogicalSize(1, 1.5))
67	assert.Equal(t, int32(0), deviceToLogicalSize(0, 2.0))
68	assert.Equal(t, int32(0), deviceToLogicalSize(-1, 2.0))
69	assert.Equal(t, int32(10), deviceToLogicalSize(10, 1.0))
70	assert.Equal(t, int32(1), deviceToLogicalSize(1, 100.0))
71}

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