Files
aego/app/docsview/component_warmup_gl_test.go
sanspie 50be5c04bc
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
Stage 12.5: Art Workspace and asset authoring
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.
2026-11-15 10:37:50 +03:00

107 lines
3.6 KiB
Go

//go:build aego_editor && aego_gltest && linux && cgo && !aego_nonative
package docsview
import (
"bytes"
"context"
"encoding/json"
"math"
"runtime"
"slices"
"testing"
"aego/app/playground"
"aego/engine/docs/democheck"
)
// Check the real AnimationPlayer after the contract's full warmup, not merely
// the runner's short bootstrap. This is synthetic SDL input and may use Mesa.
func TestComponentContractObservationWarmupNative(t *testing.T) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
p, err := playground.New()
if err != nil {
t.Fatal(err)
}
entry, ok := p.Docs().Get("animation.AnimationPlayer")
if !ok || entry.Demo == nil || len(entry.Demo.Actions) != 1 || entry.Demo.Actions[0].Field != "animation.AnimationPlayer.Speed" {
t.Fatal("the eight-frame AnimationPlayer speed contract is missing")
}
contract := *entry.Demo
// The currently shipped example deliberately starts the clip at speed 0.
// Exercise a 12-frame warmup using its real scene rather than relying on a
// different checkpoint's autoplay scene or changing the published contract.
contract.WarmupFrames = 12
if !slices.ContainsFunc(contract.Actions[0].Expected, func(expectation democheck.Expectation) bool {
return expectation.Observable == "animation.AnimationPlayer.Time"
}) {
t.Fatal("the published AnimationPlayer contract does not inspect its runtime time")
}
ctx := context.Background()
instance, err := (&nativeTryRunner{p: p}).Open(ctx, contract, "native")
if err != nil {
t.Fatal(err)
}
defer func() {
if err := instance.Close(); err != nil {
t.Error(err)
}
}()
app := instance.(*nativeTryInstance).app
if got := app.session.State().Frames; got != 4 {
t.Fatalf("bootstrap frames = %d, want 4", got)
}
assertFrames := func(phase string) {
t.Helper()
if got, want := app.session.State().Frames, uint64(warmupFrames(contract)); got != want {
t.Fatalf("%s observed %d frames, want %d", phase, got, want)
}
}
if err := instance.Reset(ctx, contract.Reset); err != nil {
t.Fatal(err)
}
before, err := instance.Observe(ctx)
if err != nil {
t.Fatal(err)
}
assertFrames("before")
var animationTime float64
if err := json.Unmarshal(before.Observables["animation.AnimationPlayer.Time"], &animationTime); err != nil {
t.Fatal(err)
}
if math.Abs(animationTime) > 1e-6 {
t.Fatalf("zero-speed clip advanced before the action: %f", animationTime)
}
if err := instance.Action(ctx, contract.Actions[0]); err != nil {
t.Fatal(err)
}
after, err := instance.Observe(ctx)
if err != nil {
t.Fatal(err)
}
assertFrames("action")
if err := json.Unmarshal(after.Observables["animation.AnimationPlayer.Time"], &animationTime); err != nil {
t.Fatal(err)
}
// At speed 8 the real 0.8-second clip reaches its held final frame after
// the full warmup; a four-frame bootstrap alone reaches only about 0.53 s.
if math.Abs(animationTime-0.8) > 1e-5 {
t.Fatalf("warmed clip time = %f, want the 0.8-second final frame", animationTime)
}
if err := instance.Reset(ctx, contract.Reset); err != nil {
t.Fatal(err)
}
reset, err := instance.Observe(ctx)
if err != nil {
t.Fatal(err)
}
assertFrames("reset")
if err := json.Unmarshal(reset.Observables["animation.AnimationPlayer.Time"], &animationTime); err != nil || math.Abs(animationTime) > 1e-6 {
t.Fatalf("reset did not restore the held clip time: %f, %v", animationTime, err)
}
if len(before.Frames) != 1 || len(after.Frames) != 1 || len(reset.Frames) != 1 || bytes.Equal(before.Frames[0].Pixels, after.Frames[0].Pixels) || !bytes.Equal(before.Frames[0].Pixels, reset.Frames[0].Pixels) {
t.Fatal("actual warmed animation frames did not change and reset")
}
}