v0.33.1 9577fee

settings_runtime_test.go RawHistoryFolder

1package webkit
2
3import (
4	"context"
5	"testing"
6
7	"github.com/bnema/dumber/internal/domain/entity"
8	"github.com/bnema/puregotk/v4/webkit"
9	"github.com/rs/zerolog"
10)
11
12func TestSettingsManagerUpdateFromPayloadStoresTypedRuntimeSettings(t *testing.T) {
13	sm := NewSettingsManager(context.Background(), entity.EngineSettingsPayload{})
14	payload := entity.EngineSettingsPayload{
15		WebContent: entity.EngineWebContentSettingsPayload{
16			SansFont:         "Inter",
17			SerifFont:        "Literata",
18			MonospaceFont:    "Fira Code",
19			DefaultFontSize:  16,
20			HardwareDecoding: entity.EngineHardwareDecodingForce,
21		},
22	}
23
24	sm.UpdateFromPayload(context.Background(), payload)
25
26	got := sm.current()
27	if got.WebContent.SansFont != "Inter" ||
28		got.WebContent.SerifFont != "Literata" ||
29		got.WebContent.MonospaceFont != "Fira Code" ||
30		got.WebContent.DefaultFontSize != 16 ||
31		got.WebContent.HardwareDecoding != entity.EngineHardwareDecodingForce {
32		t.Fatalf("stored payload=%#v", got)
33	}
34}
35
36func TestApplyMediaSettingsUpdatesHardwareDecodingKnobsOnSameSettingsObject(t *testing.T) {
37	tests := []struct {
38		name         string
39		first        entity.EngineHardwareDecodingMode
40		next         entity.EngineHardwareDecodingMode
41		wantPolicy   webkit.HardwareAccelerationPolicy
42		wantHWTypes  string
43		wantEmptyHWT bool
44	}{
45		{
46			name:        "disable to force resets acceleration policy",
47			first:       entity.EngineHardwareDecodingDisable,
48			next:        entity.EngineHardwareDecodingForce,
49			wantPolicy:  webkit.HardwareAccelerationPolicyAlwaysValue,
50			wantHWTypes: "video/av01;video/mp4;video/webm;video/x-h264;video/x-h265",
51		},
52		{
53			name:         "force to disable clears required content types",
54			first:        entity.EngineHardwareDecodingForce,
55			next:         entity.EngineHardwareDecodingDisable,
56			wantPolicy:   webkit.HardwareAccelerationPolicyNeverValue,
57			wantEmptyHWT: true,
58		},
59		{
60			name:         "disable to auto resets acceleration policy",
61			first:        entity.EngineHardwareDecodingDisable,
62			next:         entity.EngineHardwareDecodingAuto,
63			wantPolicy:   webkit.HardwareAccelerationPolicyAlwaysValue,
64			wantEmptyHWT: true,
65		},
66	}
67
68	logger := zerolog.Nop()
69	for _, tt := range tests {
70		t.Run(tt.name, func(t *testing.T) {
71			settings := &recordingMediaSettings{}
72
73			applyMediaSettings(settings, tt.first, &logger)
74			applyMediaSettings(settings, tt.next, &logger)
75
76			if got := settings.hardwareAccelerationPolicy; got != tt.wantPolicy {
77				t.Fatalf("HardwareAccelerationPolicy=%v, want %v", got, tt.wantPolicy)
78			}
79			gotHWTypes := settings.mediaContentTypesRequiringHardwareSupport
80			if tt.wantEmptyHWT {
81				if gotHWTypes != "" {
82					t.Fatalf("MediaContentTypesRequiringHardwareSupport=%q, want empty", gotHWTypes)
83				}
84				return
85			}
86			if gotHWTypes != tt.wantHWTypes {
87				t.Fatalf("MediaContentTypesRequiringHardwareSupport=%q, want %q", gotHWTypes, tt.wantHWTypes)
88			}
89		})
90	}
91}
92
93type recordingMediaSettings struct {
94	hardwareAccelerationPolicy                webkit.HardwareAccelerationPolicy
95	mediaContentTypesRequiringHardwareSupport string
96}
97
98func (*recordingMediaSettings) SetEnableWebaudio(bool) {}
99
100func (*recordingMediaSettings) SetEnableWebgl(bool) {}
101
102func (*recordingMediaSettings) SetEnableMedia(bool) {}
103
104func (*recordingMediaSettings) SetEnableMediasource(bool) {}
105
106func (*recordingMediaSettings) SetEnableMediaCapabilities(bool) {}
107
108func (*recordingMediaSettings) SetEnableEncryptedMedia(bool) {}
109
110func (*recordingMediaSettings) SetMediaPlaybackRequiresUserGesture(bool) {}
111
112func (*recordingMediaSettings) SetMediaPlaybackAllowsInline(bool) {}
113
114func (s *recordingMediaSettings) SetHardwareAccelerationPolicy(policy webkit.HardwareAccelerationPolicy) {
115	s.hardwareAccelerationPolicy = policy
116}
117
118func (s *recordingMediaSettings) SetMediaContentTypesRequiringHardwareSupport(contentTypes *string) {
119	if contentTypes == nil {
120		s.mediaContentTypesRequiringHardwareSupport = ""
121		return
122	}
123	s.mediaContentTypesRequiringHardwareSupport = *contentTypes
124}

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