ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
144 lines
3.8 KiB
Go
144 lines
3.8 KiB
Go
package editor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"aego/asset"
|
|
"aego/audio/mix"
|
|
"aego/core/log"
|
|
"aego/core/mathx"
|
|
"aego/demos"
|
|
"aego/editor/core/context"
|
|
"aego/engine"
|
|
"aego/engine/base"
|
|
"aego/engine/i18n"
|
|
"aego/engine/module"
|
|
"aego/modules/audio"
|
|
"aego/platform/input"
|
|
"aego/render/text"
|
|
"aego/script/bind"
|
|
"aego/ui/core"
|
|
)
|
|
|
|
func TestAudioTransportButtonsControlOnlyPreview(t *testing.T) {
|
|
bundle := i18n.Default()
|
|
previous := bundle.Language()
|
|
bundle.SetLanguage(i18n.English)
|
|
defer bundle.SetLanguage(previous)
|
|
types, err := base.NewTypes()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
man, err := module.Load(types, bind.New(), audio.New())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
settings, err := man.NewSettings()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
e, err := engine.NewBuilder(engine.Config{Headless: true, HeadlessFrameTime: 1.0 / 60,
|
|
UserRoot: t.TempDir(), AppID: "audio-transport-test"}).WithLogger(log.Nop()).Use(man.Engine()).Build()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer e.Close()
|
|
if err := man.Init(&module.InitContext{Engine: e, Settings: settings, Log: log.Nop()}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer man.Shutdown()
|
|
settings.Start()
|
|
mod := audio.ModuleOf(e)
|
|
if mod == nil || mod.Mixer() == nil {
|
|
t.Fatal("no audio module")
|
|
}
|
|
ui := core.New(nil)
|
|
font := text.NewFont(14, 1, 16, 12)
|
|
for ch := rune(32); ch < 127; ch++ {
|
|
font.SetGlyph(ch, text.FontGlyph{Advance: 8})
|
|
}
|
|
ui.SetFont(font)
|
|
ed := &context.Editor{UI: ui}
|
|
p := &plugin{ed: ed, clip: clipEdit{loop: true}}
|
|
state := &input.State{}
|
|
draw := func() {
|
|
ui.Begin(state, mathx.Vec2{X: 320, Y: 180}, 1)
|
|
ui.Region(mathx.Rect{W: 320, H: 180})
|
|
v := ClipView{ID: asset.BuiltinMelody, Seconds: 30}
|
|
if mod.PreviewClip() == v.ID {
|
|
v.Position, v.Playing = mod.PreviewPosition()
|
|
v.Paused = v.Playing && mod.PreviewPaused()
|
|
}
|
|
p.transport(ed, mod, v)
|
|
ui.PopCursor()
|
|
ui.End()
|
|
}
|
|
click := func(x float32) {
|
|
at := mathx.Vec2{X: x, Y: ui.Theme.Padding + ui.Theme.RowHeight/2}
|
|
state.BeginFrame()
|
|
state.ApplyMouseDown(at, input.MouseLeft)
|
|
draw()
|
|
state.BeginFrame()
|
|
state.ApplyMouseUp(at, input.MouseLeft)
|
|
draw()
|
|
}
|
|
step := func(n int) {
|
|
for range n {
|
|
if !e.Step(demos.Base{}) {
|
|
t.Fatal("headless engine stopped", e.Err())
|
|
}
|
|
}
|
|
}
|
|
game := mod.Play(&mix.Memory{PCM: make([]float32, 48000), Rate: 48000, Channels: 1}, "sfx", audio.PlayOptions{Loop: true})
|
|
if !game.Valid() {
|
|
t.Fatal("could not create independent game voice")
|
|
}
|
|
click(16) // Play
|
|
if mod.PreviewClip() != asset.BuiltinMelody || mod.PreviewPaused() {
|
|
t.Fatal("Play did not start the preview")
|
|
}
|
|
step(4)
|
|
click(16) // Pause
|
|
if !mod.PreviewPaused() {
|
|
t.Fatal("Pause button did not queue pause")
|
|
}
|
|
step(4)
|
|
paused, _ := mod.PreviewPosition()
|
|
gameBefore := mod.Mixer().Position(game)
|
|
step(8)
|
|
again, _ := mod.PreviewPosition()
|
|
if paused != again || mod.Mixer().Position(game) <= gameBefore {
|
|
t.Fatal("Pause stopped the wrong voice or did not hold preview position")
|
|
}
|
|
click(16) // Resume
|
|
if mod.PreviewPaused() {
|
|
t.Fatal("Resume button did not queue resume")
|
|
}
|
|
step(4)
|
|
resumed, _ := mod.PreviewPosition()
|
|
if resumed <= paused {
|
|
t.Fatal("Resume button did not restart preview")
|
|
}
|
|
queue := mod.Mixer().Commands()
|
|
count := 0
|
|
for count < 4096 && queue.Push(mix.Command{Kind: mix.CmdBusMute, Bus: -1}) {
|
|
count++
|
|
}
|
|
if count == 4096 {
|
|
t.Fatal("fixture could not fill command queue")
|
|
}
|
|
click(80) // Stop, rejected by the full queue.
|
|
if notice, ok := ed.LastNotice(); !ok || notice.Level != context.LevelError || mod.PreviewClip() != asset.BuiltinMelody {
|
|
t.Fatal("Stop failure was not reported, or lost control of the preview")
|
|
}
|
|
step(3)
|
|
click(80) // Retry Stop.
|
|
step(3)
|
|
if !mod.PreviewClip().IsZero() || !mod.Mixer().Live(game) {
|
|
t.Fatal("Stop did not release only the preview voice")
|
|
}
|
|
if ed.Docs != nil {
|
|
t.Fatal("transport changed document state")
|
|
}
|
|
}
|