detached 4c97002

player_state_test.go RawHistoryFolder

1package core
2
3import (
4	"testing"
5)
6
7func TestPlayerStateCallbackFanout(t *testing.T) {
8	var callbackStates []PlayerState
9	callbacks := playerCallbacks{
10		OnStateChange: func(state PlayerState) {
11			callbackStates = append(callbackStates, state)
12		},
13	}
14
15	p := newPlayer(playerConfig{}, callbacks)
16
17	// Trigger a transition
18	if err := p.transition(PlayerStateStarting); err != nil {
19		t.Errorf("transition to Starting failed: %v", err)
20	}
21
22	// Verify callback was invoked with the new state
23	if len(callbackStates) != 1 {
24		t.Errorf("callback invoked %d times, want 1", len(callbackStates))
25	}
26	if len(callbackStates) > 0 && callbackStates[0] != PlayerStateStarting {
27		t.Errorf("callback received state %v, want %v", callbackStates[0], PlayerStateStarting)
28	}
29
30	// Trigger another transition
31	if err := p.transition(PlayerStatePlaying); err != nil {
32		t.Errorf("transition to Playing failed: %v", err)
33	}
34
35	// Verify callback was invoked again
36	if len(callbackStates) != 2 {
37		t.Errorf("callback invoked %d times, want 2", len(callbackStates))
38	}
39	if len(callbackStates) > 1 && callbackStates[1] != PlayerStatePlaying {
40		t.Errorf("callback received state %v, want %v", callbackStates[1], PlayerStatePlaying)
41	}
42}
43
44func TestPlayerStateTransitionsIdleStartStopClose(t *testing.T) {
45	p := newPlayer(playerConfig{}, playerCallbacks{})
46
47	if got := p.State(); got != PlayerStateIdle {
48		t.Errorf("initial state = %v, want %v", got, PlayerStateIdle)
49	}
50
51	if err := p.transition(PlayerStateStarting); err != nil {
52		t.Errorf("transition to Starting failed: %v", err)
53	}
54	if got := p.State(); got != PlayerStateStarting {
55		t.Errorf("after transition to Starting, state = %v, want %v", got, PlayerStateStarting)
56	}
57
58	if err := p.transition(PlayerStatePlaying); err != nil {
59		t.Errorf("transition to Playing failed: %v", err)
60	}
61	if got := p.State(); got != PlayerStatePlaying {
62		t.Errorf("after transition to Playing, state = %v, want %v", got, PlayerStatePlaying)
63	}
64
65	if err := p.transition(PlayerStateStopped); err != nil {
66		t.Errorf("transition to Stopped failed: %v", err)
67	}
68	if got := p.State(); got != PlayerStateStopped {
69		t.Errorf("after transition to Stopped, state = %v, want %v", got, PlayerStateStopped)
70	}
71
72	if err := p.transition(PlayerStateClosing); err != nil {
73		t.Errorf("transition to Closing failed: %v", err)
74	}
75	if got := p.State(); got != PlayerStateClosing {
76		t.Errorf("after transition to Closing, state = %v, want %v", got, PlayerStateClosing)
77	}
78
79	if err := p.transition(PlayerStateClosed); err != nil {
80		t.Errorf("transition to Closed failed: %v", err)
81	}
82	if got := p.State(); got != PlayerStateClosed {
83		t.Errorf("after transition to Closed, state = %v, want %v", got, PlayerStateClosed)
84	}
85}

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 1

Tags 8

↑↓ moveenter openesc close