detached b594e4f

test(cef): cover nil-host resize pulses

commit
b594e4f416c47459a01fa54cbcee00cd8f71a71f
author
brice · · 2026-06-20 14:56 UTC
parent
84b9d0c
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +54 -0
M internal/infrastructure/cef/webview_viewport_test.go +54 -0
@@ -492,3 +492,57 @@ func TestScheduleResizeRepaintPulse_SkipsStaleHost(t *testing.T) {
492492 require.Empty(t, capturedHost.calls)
493493 require.Empty(t, currentHost.calls)
494494 }
495+
496+func TestScheduleResizeRepaintPulse_SkipsWhenHostNilAtScheduleTime(t *testing.T) {
497+ oldNewTask := cefNewTask
498+ oldPostDelayedTask := cefPostDelayedTask
499+ defer func() {
500+ cefNewTask = oldNewTask
501+ cefPostDelayedTask = oldPostDelayedTask
502+ }()
503+
504+ cefNewTask = func(task purecef.Task) purecef.Task { return task }
505+
506+ var scheduled []purecef.Task
507+ cefPostDelayedTask = func(_ purecef.ThreadID, task purecef.Task, _ int64) int32 {
508+ scheduled = append(scheduled, task)
509+ return 1
510+ }
511+
512+ wv := &WebView{ctx: context.Background()}
513+
514+ wv.scheduleResizeRepaintPulse(context.Background(), "nil-host")
515+
516+ require.Empty(t, scheduled)
517+}
518+
519+func TestScheduleResizeRepaintPulse_SkipsWhenHostClearedBeforeExecution(t *testing.T) {
520+ oldNewTask := cefNewTask
521+ oldPostDelayedTask := cefPostDelayedTask
522+ defer func() {
523+ cefNewTask = oldNewTask
524+ cefPostDelayedTask = oldPostDelayedTask
525+ }()
526+
527+ cefNewTask = func(task purecef.Task) purecef.Task { return task }
528+
529+ var scheduled []purecef.Task
530+ cefPostDelayedTask = func(threadID purecef.ThreadID, task purecef.Task, delayMs int64) int32 {
531+ require.Equal(t, purecef.ThreadIDTidUi, threadID)
532+ require.NotNil(t, task)
533+ scheduled = append(scheduled, task)
534+ return 1
535+ }
536+
537+ host := &viewportSyncOrderHost{}
538+ wv := &WebView{ctx: context.Background(), host: host}
539+
540+ wv.scheduleResizeRepaintPulse(context.Background(), "nil-host-before-execute")
541+ wv.host = nil
542+
543+ require.Len(t, scheduled, 2)
544+ scheduled[0].Execute()
545+ scheduled[1].Execute()
546+
547+ require.Empty(t, host.calls)
548+}
@@ -492,3 +492,57 @@ func TestScheduleResizeRepaintPulse_SkipsStaleHost(t *testing.T) {
492 require.Empty(t, capturedHost.calls)492 require.Empty(t, capturedHost.calls)
493 require.Empty(t, currentHost.calls)493 require.Empty(t, currentHost.calls)
494 }494 }
495+
496+func TestScheduleResizeRepaintPulse_SkipsWhenHostNilAtScheduleTime(t *testing.T) {
497+ oldNewTask := cefNewTask
498+ oldPostDelayedTask := cefPostDelayedTask
499+ defer func() {
500+ cefNewTask = oldNewTask
501+ cefPostDelayedTask = oldPostDelayedTask
502+ }()
503+
504+ cefNewTask = func(task purecef.Task) purecef.Task { return task }
505+
506+ var scheduled []purecef.Task
507+ cefPostDelayedTask = func(_ purecef.ThreadID, task purecef.Task, _ int64) int32 {
508+ scheduled = append(scheduled, task)
509+ return 1
510+ }
511+
512+ wv := &WebView{ctx: context.Background()}
513+
514+ wv.scheduleResizeRepaintPulse(context.Background(), "nil-host")
515+
516+ require.Empty(t, scheduled)
517+}
518+
519+func TestScheduleResizeRepaintPulse_SkipsWhenHostClearedBeforeExecution(t *testing.T) {
520+ oldNewTask := cefNewTask
521+ oldPostDelayedTask := cefPostDelayedTask
522+ defer func() {
523+ cefNewTask = oldNewTask
524+ cefPostDelayedTask = oldPostDelayedTask
525+ }()
526+
527+ cefNewTask = func(task purecef.Task) purecef.Task { return task }
528+
529+ var scheduled []purecef.Task
530+ cefPostDelayedTask = func(threadID purecef.ThreadID, task purecef.Task, delayMs int64) int32 {
531+ require.Equal(t, purecef.ThreadIDTidUi, threadID)
532+ require.NotNil(t, task)
533+ scheduled = append(scheduled, task)
534+ return 1
535+ }
536+
537+ host := &viewportSyncOrderHost{}
538+ wv := &WebView{ctx: context.Background(), host: host}
539+
540+ wv.scheduleResizeRepaintPulse(context.Background(), "nil-host-before-execute")
541+ wv.host = nil
542+
543+ require.Len(t, scheduled, 2)
544+ scheduled[0].Execute()
545+ scheduled[1].Execute()
546+
547+ require.Empty(t, host.calls)
548+}

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