Fix menu navigation, informational items, and boolean editing

This commit is contained in:
maze committed 2026-10-29 18:59:46 +01:00
1 parent e4c2060422
commit 62b32c15cf
8 files changed
+355 -24

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
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")
}
}
}