Files
aego/tests/integration/settings_test.go
sanspie b6cc16531d
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 6m34s
ci / release (push) Successful in 5m9s
ci / checks (push) Successful in 4m47s
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
tests: the setting-changed test picks a volume that differs from the saved one, so it passes when run again in the same process
2026-10-26 01:42:55 +03:00

40 lines
870 B
Go

package integration
import (
"testing"
"aego/engine/recorder"
"aego/schema"
)
func TestPlatformerSettingChangedEvent(t *testing.T) {
pf := openPlatformer(t)
pf.step(5)
vol := 0.5
if st := pf.app.Settings; st.Value(st.Key("audio.bus.music.volume")).F == vol {
vol = 0.25
}
tx := pf.app.Settings.Begin()
if err := tx.SetID("audio.bus.music.volume", schema.Float64(vol)); err != nil {
t.Fatal(err)
}
if err := tx.Apply(); err != nil {
t.Fatal(err)
}
pf.step(3)
player := pf.app.Scene.ID(pf.player)
n := 0
for _, r := range pf.app.Engine.MainWorld().Recorder.Snapshot(nil) {
if r.Kind == recorder.Event && r.Name == "OnSettingChanged" {
if r.Owner != player {
t.Fatalf("delivered to %v, want the player %v", r.Owner, player)
}
n++
}
}
if n != 1 {
t.Fatalf("OnSettingChanged delivered %d times, want 1", n)
}
pf.noFaults(t)
}