v0.32.0 0617278

webview_lifecycle_test.go RawHistoryFolder

1package cef
2
3import (
4	"testing"
5
6	purecef "github.com/bnema/purego-cef/cef"
7	"github.com/stretchr/testify/require"
8)
9
10func TestCef2gtkAdapterPageZoomCompensationDefaultsToOne(t *testing.T) {
11	var nilAdapter *Cef2gtkAdapter
12	require.InDelta(t, 1.0, nilAdapter.PageZoomCompensation(), 1e-9)
13
14	adapter := &Cef2gtkAdapter{}
15	require.InDelta(t, 1.0, adapter.PageZoomCompensation(), 1e-9)
16	adapter.destroyed.Store(true)
17	require.InDelta(t, 1.0, adapter.PageZoomCompensation(), 1e-9)
18}
19
20func TestDestroy_WithHostDefersBridgeDestroyUntilBeforeClose(t *testing.T) {
21	bridge := &Cef2gtkAdapter{}
22	host := &stubBrowserHost{}
23	wv := &WebView{
24		viewBridge: bridge,
25		host:       host,
26	}
27
28	wv.Destroy()
29
30	require.True(t, wv.IsDestroyed())
31	require.True(t, host.closeBrowserCalled)
32	require.False(t, bridge.IsDestroyed(), "Destroy should request CEF close before destroying the GTK bridge")
33
34	wv.destroyViewBridgeOnGTKSync()
35
36	require.True(t, bridge.IsDestroyed())
37}
38
39func TestDestroy_WithoutHostDestroysBridgeImmediately(t *testing.T) {
40	bridge := &Cef2gtkAdapter{}
41	wv := &WebView{viewBridge: bridge}
42
43	wv.Destroy()
44
45	require.True(t, bridge.IsDestroyed())
46}
47
48func TestHandleInputAttachFailureClosesBrowserForAnyAttachError(t *testing.T) {
49	host := &stubBrowserHost{}
50	wv := &WebView{}
51
52	wv.handleInputAttachFailure(assertAnError{}, host)
53
54	require.True(t, host.closeBrowserCalled)
55}
56
57type assertAnError struct{}
58
59func (assertAnError) Error() string { return "attach failed" }
60
61// stubBrowserHost intentionally only stubs CloseBrowser. The embedded
62// purecef.BrowserHost may be nil; calling any other BrowserHost method will
63// panic and should be avoided in these lifecycle tests.
64type stubBrowserHost struct {
65	purecef.BrowserHost
66	closeBrowserCalled bool
67}
68
69func (s *stubBrowserHost) CloseBrowser(int32) {
70	s.closeBrowserCalled = true
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