summaryrefslogtreecommitdiff
path: root/examples/shaders/test
diff options
context:
space:
mode:
Diffstat (limited to 'examples/shaders/test')
-rw-r--r--examples/shaders/test/reload.script31
-rw-r--r--examples/shaders/test/shaders.script43
-rw-r--r--examples/shaders/test/timeline.script71
3 files changed, 145 insertions, 0 deletions
diff --git a/examples/shaders/test/reload.script b/examples/shaders/test/reload.script
new file mode 100644
index 0000000..ba0063a
--- /dev/null
+++ b/examples/shaders/test/reload.script
@@ -0,0 +1,31 @@
+# Live reload with State kept: the second build ({v2}) changes the plot
+# colour of expo in the Zig shader and in the GLSL one, and the label
+# colour in the sketch's Zig code (see addReloadCheck in build.zig).
+frames 10
+key right
+key left
+expect example 0
+expect language zig
+screenshot .zig-cache/e2e/reload-zig-before.png
+key l
+expect language glsl
+frames 2
+screenshot .zig-cache/e2e/reload-glsl-before.png
+key l
+key right
+expect example 1
+frames 2
+load {v2}
+expect example 1
+expect language zig
+key left
+frames 2
+screenshot .zig-cache/e2e/reload-zig-after.png
+key l
+expect language glsl
+frames 2
+screenshot .zig-cache/e2e/reload-glsl-after.png
+# The plot (the shaders) and the label (the Zig code) both changed.
+expect-different-screenshot .zig-cache/e2e/reload-zig-before.png .zig-cache/e2e/reload-zig-after.png 0 40 600 560
+expect-different-screenshot .zig-cache/e2e/reload-glsl-before.png .zig-cache/e2e/reload-glsl-after.png 0 40 600 560
+expect-different-screenshot .zig-cache/e2e/reload-zig-before.png .zig-cache/e2e/reload-zig-after.png 0 0 300 30
diff --git a/examples/shaders/test/shaders.script b/examples/shaders/test/shaders.script
new file mode 100644
index 0000000..a67e0db
--- /dev/null
+++ b/examples/shaders/test/shaders.script
@@ -0,0 +1,43 @@
+# Each example in Zig, then in GLSL: the screenshots of a pair should match.
+frames 30
+screenshot .zig-cache/e2e/expo-zig.png
+key l
+expect language glsl
+frames 2
+screenshot .zig-cache/e2e/expo-glsl.png
+key l
+key right
+frames 2
+screenshot .zig-cache/e2e/hsb_wheel-zig.png
+key l
+expect language glsl
+frames 2
+screenshot .zig-cache/e2e/hsb_wheel-glsl.png
+key l
+key right
+frames 2
+screenshot .zig-cache/e2e/polar-zig.png
+key l
+expect language glsl
+frames 2
+screenshot .zig-cache/e2e/polar-glsl.png
+key l
+key right
+frames 2
+screenshot .zig-cache/e2e/truchet-zig.png
+key l
+expect language glsl
+frames 2
+screenshot .zig-cache/e2e/truchet-glsl.png
+key l
+key right
+frames 2
+screenshot .zig-cache/e2e/clouds-zig.png
+key l
+expect language glsl
+frames 2
+screenshot .zig-cache/e2e/clouds-glsl.png
+key l
+key right
+frames 2
+expect example 0
diff --git a/examples/shaders/test/timeline.script b/examples/shaders/test/timeline.script
new file mode 100644
index 0000000..0041d73
--- /dev/null
+++ b/examples/shaders/test/timeline.script
@@ -0,0 +1,71 @@
+# Timeline check (design.md "Acceptance: timeline"), from
+# noc/test/accel_to_mouse.timeline.script. State is the example index, the
+# language and the time, summed from recorded ticks: a replay must land on
+# the same example, language and time to the bit, and draw the same picture.
+
+# 1. Record: keys and a click change example and language while time runs.
+frames 10
+console snapshot 1
+console record 0
+frames 20
+key right
+frames 15
+key l
+frames 10
+down 300 300
+up 300 300
+frames 20
+key right
+key right
+frames 10
+key l
+key left
+frames 25
+expect example 3
+expect language zig
+console save 2
+
+# 2. Played to the end, exactly.
+console play 0
+frames 150
+expect-snapshot 2
+screenshot .zig-cache/e2e/shaders-played.png
+# 5. Paused: `draw` must not move State (time included).
+frames 30
+expect-snapshot 2
+
+# 3. Sought to the end, and to the middle and played on.
+console seek end
+expect-snapshot 2
+screenshot .zig-cache/e2e/shaders-sought.png
+# 7. What a seek shows equals what playing showed.
+expect-same-screenshot .zig-cache/e2e/shaders-played.png .zig-cache/e2e/shaders-sought.png
+console seek 1000
+console pause
+frames 10
+console pause
+frames 30
+console pause
+frames 150
+expect-snapshot 2
+
+# 4. Stepped from the start, then back and forth.
+console seek start
+console step 100000
+expect-snapshot 2
+console step -25
+console step 25
+expect-snapshot 2
+screenshot .zig-cache/e2e/shaders-stepped.png
+expect-same-screenshot .zig-cache/e2e/shaders-played.png .zig-cache/e2e/shaders-stepped.png
+
+# 6. Live input (a click, a key), then the same replay.
+console stop
+down 100 100
+up 100 100
+key l
+frames 10
+console play 0
+frames 150
+expect-snapshot 2
+console stop