feat: show no-WFB kiosk fallback only while video absent (#2)
Build Ground Station / build (push) Successful in 44s
Build Ground Station / build (push) Successful in 44s
This commit was merged in pull request #9.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package display
|
||||
|
||||
import "testing"
|
||||
|
||||
const wantFallbackText = "Brak połączenia WFB"
|
||||
|
||||
func TestFallbackTemplateShowsExactTextWhileVideoAbsent(t *testing.T) {
|
||||
canvas := &fakeCanvas{width: 800, height: 600}
|
||||
presence := NewVideoPresence()
|
||||
|
||||
NewFallbackTemplate(presence, wantFallbackText).Draw(canvas)
|
||||
|
||||
clears, flushes := canvas.drawCounts()
|
||||
if clears != 1 || flushes != 1 {
|
||||
t.Fatalf("clears=%d flushes=%d want 1 and 1", clears, flushes)
|
||||
}
|
||||
lines := canvas.lines()
|
||||
if len(lines) != 1 || lines[0] != wantFallbackText {
|
||||
t.Fatalf("lines=%q want [%q]", lines, wantFallbackText)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackTemplateDisappearsWhileVideoPresent(t *testing.T) {
|
||||
canvas := &fakeCanvas{width: 800, height: 600}
|
||||
presence := NewVideoPresence()
|
||||
presence.SetActive(true)
|
||||
|
||||
NewFallbackTemplate(presence, wantFallbackText).Draw(canvas)
|
||||
|
||||
clears, flushes := canvas.drawCounts()
|
||||
if clears != 1 || flushes != 1 {
|
||||
t.Fatalf("clears=%d flushes=%d want 1 and 1", clears, flushes)
|
||||
}
|
||||
if lines := canvas.lines(); len(lines) != 0 {
|
||||
t.Fatalf("video has priority: fallback lines %q must disappear", lines)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackTemplateReturnsWhenVideoEnds(t *testing.T) {
|
||||
canvas := &fakeCanvas{width: 800, height: 600}
|
||||
presence := NewVideoPresence()
|
||||
presence.SetActive(true)
|
||||
template := NewFallbackTemplate(presence, wantFallbackText)
|
||||
|
||||
template.Draw(canvas)
|
||||
if lines := canvas.lines(); len(lines) != 0 {
|
||||
t.Fatalf("lines=%q must stay empty while video is present", lines)
|
||||
}
|
||||
|
||||
presence.SetActive(false)
|
||||
template.Draw(canvas)
|
||||
|
||||
lines := canvas.lines()
|
||||
if len(lines) != 1 || lines[0] != wantFallbackText {
|
||||
t.Fatalf("lines=%q want fallback [%q] after video end", lines, wantFallbackText)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user