package beatglow import ( "testing" "github.com/BeatGlow/beatglow/app" ) type navigationTestLayout struct { app.Layout name string visible bool } func (l *navigationTestLayout) String() string { return l.name } func (l *navigationTestLayout) Show(app.Context) { l.visible = true } func (l *navigationTestLayout) Hide(app.Context) { l.visible = false } func (l *navigationTestLayout) IsVisible() bool { return l.visible } func TestSettingsReturnsToActiveLayout(t *testing.T) { settings := &navigationTestLayout{name: "settings"} playing := &navigationTestLayout{name: "playing"} analyzer := &navigationTestLayout{name: "analyzer"} c := &controllerContext{settingsLayout: settings, layouts: []app.Layout{settings, playing, analyzer}} c.Show(playing) c.Show(analyzer) for i := 0; i < 2; i++ { c.Show(settings) if c.active != settings || c.previous != analyzer { t.Fatal("settings did not remember the active screen") } c.Show(nil) if c.active != analyzer || !analyzer.visible || settings.visible { t.Fatal("exiting settings did not restore analyzer") } } }