summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/manual.script73
-rw-r--r--test/svg/image.svg9
-rw-r--r--test/svg/typst-image.typ6
3 files changed, 88 insertions, 0 deletions
diff --git a/test/manual.script b/test/manual.script
new file mode 100644
index 0000000..3bc3c73
--- /dev/null
+++ b/test/manual.script
@@ -0,0 +1,73 @@
+# The manual example (examples/manual.zig) on Vol. 2 of the Intel SDM:
+# Figure 2-1 stepped through in the stock player, and exported twice.
+# Built only when the PDF is there (-Dmanual).
+frames 150
+expect deck.waiting true
+expect deck.log.len 0
+screenshot .zig-cache/manual/page.png
+# The page on its paper, the whole of it in view.
+expect-pixel .zig-cache/manual/page.png 400 650 255 255 255 255 2
+# Onto the figure; the rest of the page greys.
+key space
+await deck.waiting true
+screenshot .zig-cache/manual/figure.png
+expect-pixel .zig-cache/manual/figure.png 460 160 255 255 255 255 2
+# Each field in turn, tinted: the third is ModR/M.
+key space
+await deck.waiting true
+key space
+await deck.waiting true
+key space
+await deck.waiting true
+expect deck.log.len 4
+screenshot .zig-cache/manual/modrm.png
+expect-pixel .zig-cache/manual/modrm.png 460 160 192 233 242 255 3
+expect-pixel .zig-cache/manual/modrm.png 300 160 255 255 255 255 2
+# Back a step: Opcode's tint again, ModR/M's gone.
+key page_up
+expect deck.log.len 3
+frames 2
+screenshot .zig-cache/manual/opcode.png
+expect-pixel .zig-cache/manual/opcode.png 460 160 255 255 255 255 2
+expect-pixel .zig-cache/manual/opcode.png 300 160 192 233 242 255 3
+key space
+await deck.waiting true
+key space
+await deck.waiting true
+key space
+await deck.waiting true
+key space
+await deck.waiting true
+# 83 C0 01 written below, where the footnotes were.
+key space
+await deck.waiting true
+screenshot .zig-cache/manual/bytes.png
+# Into their fields: ModR/M's label gives way to C0.
+key space
+await deck.waiting true
+screenshot .zig-cache/manual/flown.png
+expect-different-screenshot .zig-cache/manual/bytes.png .zig-cache/manual/flown.png 440 140 180 90
+# C0 down into its boxes as bits, then split over Mod, Reg and R/M.
+key space
+await deck.waiting true
+screenshot .zig-cache/manual/bits.png
+expect-pixel .zig-cache/manual/bits.png 527 185 255 255 255 255 2
+key space
+await deck.waiting true
+screenshot .zig-cache/manual/split.png
+expect-different-screenshot .zig-cache/manual/bits.png .zig-cache/manual/split.png 280 420 310 70
+expect deck.log.len 11
+# Back to the page, filled in, and the end of the talk.
+key space
+frames 120
+expect deck.log.len 12
+expect deck.waiting false
+screenshot .zig-cache/manual/end.png
+expect-different-screenshot .zig-cache/manual/page.png .zig-cache/manual/end.png 470 260 340 120
+# Exported ({a}, {b}: 10 fps, half size), each step held 1.5 s: the same
+# frames twice, and the talk moves through them.
+expect-same-screenshot {a}/000040.png {b}/000040.png
+expect-same-screenshot {a}/000200.png {b}/000200.png
+expect-same-screenshot {a}/000340.png {b}/000340.png
+expect-different-screenshot {a}/000040.png {a}/000200.png
+expect-different-screenshot {a}/000200.png {a}/000340.png
diff --git a/test/svg/image.svg b/test/svg/image.svg
new file mode 100644
index 0000000..f5a5d8e
--- /dev/null
+++ b/test/svg/image.svg
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 200 100" width="200" height="100">
+ <!-- SVG documents as data-URI images (how Typst places an SVG or a PDF
+ page): placed, stretched or fitted into their boxes, with their own ids
+ and gradients, and an id the outer document also uses. -->
+ <defs><radialGradient id="g"><stop offset="0" stop-color="#58c4dd"/><stop offset="1" stop-color="#9a72ac"/></radialGradient></defs>
+ <rect x="150" y="10" width="40" height="80" fill="url(#g)"/>
+ <image x="10" y="10" width="40" height="80" xlink:href="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNDAgNDAiIHdpZHRoPSI0MHB0IiBoZWlnaHQ9IjQwcHQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5O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WxsPSJ1cmwoI2cpIi8+Cjx1c2UgeGxpbms6aHJlZj0iI2xlYWYiIHg9IjEwIiB5PSIyMCIgZmlsbD0iIzgzYzE2NyIvPgo8L3N2Zz4=" transform="rotate(10 100 50)"/>
+</svg>
diff --git a/test/svg/typst-image.typ b/test/svg/typst-image.typ
new file mode 100644
index 0000000..2c88207
--- /dev/null
+++ b/test/svg/typst-image.typ
@@ -0,0 +1,6 @@
+// An SVG placed by Typst: an <image> with the document as a data URI.
+#set page(width: auto, height: auto, margin: 6pt, fill: none)
+#stack(dir: ltr, spacing: 8pt,
+ image("use.svg", width: 120pt),
+ image("gradients.svg", width: 80pt, height: 60pt, fit: "stretch"),
+)