feat: split kiosk into fallback canvas and OSD overlay layers (#8)
Build Ground Station / build (push) Successful in 37s
Build Ground Station / build (push) Successful in 37s
Drive two independent visual layers per display target from one shared video presence signal: the fullscreen fallback/menu canvas below video and a transparent, input-transparent OSD overlay above video, reserved as the future flight OSD rendering surface. WFB and video decode stay out of the UI process; pilot video keeps rendering priority.
This commit was merged in pull request #12.
This commit is contained in:
@@ -242,6 +242,87 @@ func TestRunReconnectsAfterSessionFailure(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunLayersDrawsEveryLayerOnItsOwnCanvas(t *testing.T) {
|
||||
canvasSession := newFakeSession()
|
||||
osdSession := newFakeSession()
|
||||
layers := []Layer{
|
||||
{
|
||||
Name: "fallback-canvas",
|
||||
Opener: fakeOpener{open: func(int) (Session, error) { return canvasSession, nil }},
|
||||
Template: NewStatusTemplate("canvas"),
|
||||
},
|
||||
{
|
||||
Name: "osd-overlay",
|
||||
Opener: fakeOpener{open: func(int) (Session, error) { return osdSession, nil }},
|
||||
Template: NewOSDTemplate(NewVideoPresence()),
|
||||
},
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
RunLayers(ctx, layers)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
waitFor(t, func() bool { return canvasSession.canvas.lineCount() == 1 }, "canvas layer draw")
|
||||
waitFor(t, func() bool {
|
||||
clears, _ := osdSession.canvas.drawCounts()
|
||||
return clears == 1
|
||||
}, "osd layer transparent clear")
|
||||
cancel()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("run layers did not stop after cancel")
|
||||
}
|
||||
if got := canvasSession.closeCount(); got != 1 {
|
||||
t.Fatalf("canvas session closed %d times, want 1", got)
|
||||
}
|
||||
if got := osdSession.closeCount(); got != 1 {
|
||||
t.Fatalf("osd session closed %d times, want 1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunLayersKeepsOtherLayerAliveWhenOneTargetFails(t *testing.T) {
|
||||
alive := newFakeSession()
|
||||
layers := []Layer{
|
||||
{
|
||||
Name: "dead",
|
||||
Opener: fakeOpener{open: func(int) (Session, error) { return nil, errors.New("target down") }},
|
||||
Template: NewStatusTemplate("never drawn"),
|
||||
},
|
||||
{
|
||||
Name: "alive",
|
||||
Opener: fakeOpener{open: func(int) (Session, error) { return alive, nil }},
|
||||
Template: NewOSDTemplate(NewVideoPresence()),
|
||||
},
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
RunLayers(ctx, layers)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
waitFor(t, func() bool {
|
||||
clears, _ := alive.canvas.drawCounts()
|
||||
return clears == 1
|
||||
}, "alive layer keeps drawing while the other target fails")
|
||||
cancel()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("run layers did not stop after cancel")
|
||||
}
|
||||
if got := alive.closeCount(); got != 1 {
|
||||
t.Fatalf("alive session closed %d times, want 1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunStopsWithoutConnectingWhenContextAlreadyCancelled(t *testing.T) {
|
||||
var opens int32
|
||||
opener := fakeOpener{open: func(int) (Session, error) {
|
||||
|
||||
Reference in New Issue
Block a user