summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/scene_compiled.script2
-rw-r--r--test/scene_live.script21
-rw-r--r--test/talk.script104
3 files changed, 118 insertions, 9 deletions
diff --git a/test/scene_compiled.script b/test/scene_compiled.script
index 3c9ef44..df2d62f 100644
--- a/test/scene_compiled.script
+++ b/test/scene_compiled.script
@@ -2,7 +2,7 @@
# 30 fps, 640x360, so half size, played once without the player's controls).
frames 30
screenshot .zig-cache/anim/compiled-written.png
-console set t 1.5
+console set deck.t 1.5
frames 1
screenshot .zig-cache/anim/compiled-morph.png
# Frame 68 is 2.27 s in: the dot over the panel's corner, at half size.
diff --git a/test/scene_live.script b/test/scene_live.script
index 30b2087..e480d8d 100644
--- a/test/scene_live.script
+++ b/test/scene_live.script
@@ -1,6 +1,9 @@
-# The live test scene, through the player. It holds at the pause.
+# The live test scene, through the player. At the pause it waits for a
+# click, time running on and nothing after the pause starting.
frames 150
-expect t 2
+expect deck.waiting true
+expect deck.t 2.5 ~0.02
+expect deck.log.len 0
screenshot .zig-cache/anim/live.png
# The custom panel is over the circle added before it,
expect-pixel .zig-cache/anim/live.png 600 330 32 64 96 255 1
@@ -11,23 +14,25 @@ expect-pixel .zig-cache/anim/live.png 725 400 131 193 103 255 1
expect-pixel .zig-cache/anim/live.png 600 390 240 172 95 255 1
expect-pixel .zig-cache/anim/live.png 680 390 32 64 96 255 1
# Half way through its move it is half way.
-console set playing false
-console set t 1.5
+console set deck.playing false
+console set deck.t 1.5
screenshot .zig-cache/anim/live-moving.png
expect-pixel .zig-cache/anim/live-moving.png 400 330 32 64 96 255 1
expect-pixel .zig-cache/anim/live-moving.png 600 330 252 98 85 255 1
# The CPU renderer layers the same way.
-console set t 2
+console set deck.t 2
key b
expect backend cpu
screenshot .zig-cache/anim/live-cpu.png
expect-pixel .zig-cache/anim/live-cpu.png 600 330 32 64 96 255 1
expect-pixel .zig-cache/anim/live-cpu.png 725 400 131 193 103 255 1
key b
-# A click continues: the camera zooms to 2 and the panel fades to half,
-# over the background where it now reaches.
+# A click opens the pause and plays on: the camera zooms to 2 and the
+# panel fades to half, over the background where it now reaches.
click 640 360
-expect playing true
+expect deck.playing true
+expect deck.log.len 1
+expect deck.waiting false
frames 70
screenshot .zig-cache/anim/live-zoom.png
expect-pixel .zig-cache/anim/live-zoom.png 800 300 30 46 64 255 2
diff --git a/test/talk.script b/test/talk.script
new file mode 100644
index 0000000..e123d59
--- /dev/null
+++ b/test/talk.script
@@ -0,0 +1,104 @@
+# The talk example (examples/talk.zig): a Deck in the sketch's own State,
+# stepped by the clicks and keys the sketch turns into asks.
+frames 90
+expect deck.waiting false
+expect deck.slide 1
+# Slide 2 lies after the choice, which has not been made.
+expect deck.slides 1
+# A click during the first step finishes it: held at the first pause.
+click 100 100
+expect deck.t 2.5 ~0.0001
+expect deck.waiting true
+expect deck.log.len 0
+# The mass bobs while the deck waits.
+screenshot .zig-cache/talk/bob-a.png
+frames 14
+screenshot .zig-cache/talk/bob-b.png
+expect-different-screenshot .zig-cache/talk/bob-a.png .zig-cache/talk/bob-b.png
+# The next click opens the pause where it lands: the slider comes in, and
+# the deck waits at the choice.
+click 100 100
+expect deck.log.len 1
+expect deck.log.buffer[0].wait 0.2833 ~0.001
+await deck.waiting true
+frames 5
+# Reloaded mid-wait, the first step retimed from 2 s to 3: the same step,
+# as far into it, a second later.
+console set deck.playing false
+expect deck.t 3.4833 ~0.001
+load {v2}
+expect deck.t 4.4833 ~0.001
+expect deck.waiting true
+expect deck.log.len 1
+expect deck.log.buffer[0].wait 0.2833 ~0.001
+console set deck.playing true
+# A click on the slider is the slider's: zeta goes there, the deck stays.
+click 790 580
+expect app.zeta 1.5 ~0.01
+expect deck.log.len 1
+expect deck.waiting true
+# So is a drag along it, let go and all.
+down 640 580
+move 400 580
+up 400 580
+expect app.zeta 0.2 ~0.01
+expect app.dragging false
+expect deck.log.len 1
+expect deck.waiting true
+# Going on chooses by the slider: under 1, it rings; slide 2 is laid.
+key space
+expect deck.log.len 2
+expect deck.log.buffer[1].value 0
+expect deck.slides 2
+frames 90
+screenshot .zig-cache/talk/rings.png
+# Back: held at the choice again; over 1, it creeps.
+key page_up
+expect deck.log.len 1
+expect deck.waiting true
+click 840 580
+expect app.zeta 1.667 ~0.01
+key space
+expect deck.log.len 2
+expect deck.log.buffer[1].value 1
+frames 90
+screenshot .zig-cache/talk/creeps.png
+expect-different-screenshot .zig-cache/talk/rings.png .zig-cache/talk/creeps.png
+# Slide 2 at rest: it holds no pause, so its end.
+key right_bracket
+expect deck.slide 2
+expect deck.log.len 3
+expect deck.waiting false
+# Back a slide: slide 1 at rest, held at its first pause (3 s of writing
+# in this build, then the mass).
+key left_bracket
+expect deck.slide 1
+expect deck.log.len 0
+expect deck.t 3.5 ~0.0001
+expect deck.waiting true
+# Recorded, clicks, the slider and keys replay to the same State: the deck
+# opens gates in update, from events and State alone.
+console record 0
+click 100 100
+frames 40
+click 790 580
+key space
+frames 30
+key page_up
+key right_bracket
+frames 10
+console save 2
+console play 0
+frames 120
+expect-snapshot 2
+console stop
+# Exported ({a}, {b}: 30 fps, half size), each gate holds 2 s: the mass
+# bobs through the first hold (to 4.5 s), nothing moves at the choice
+# (5.1 to 7.1 s), and the verdict writes after it. Twice, the same frames.
+expect-different-screenshot {a}/000080.png {a}/000090.png
+expect-different-screenshot {a}/000130.png {a}/000170.png
+expect-same-screenshot {a}/000170.png {a}/000200.png
+expect-different-screenshot {a}/000200.png {a}/000230.png
+expect-same-screenshot {a}/000080.png {b}/000080.png
+expect-same-screenshot {a}/000230.png {b}/000230.png
+expect-same-screenshot {a}/000350.png {b}/000350.png