| Bring vidya in cfd3e36 nandi 19d ago | 1 | (ns glimmer-vidya.smoke |
| 2 | "Non-interactive check against a real window. |
| 3 | |
| 4 | Mounts a tree, drives the reconciler from a timer so widgets are created, |
| 5 | patched, reordered and removed while frames are being painted, then quits on |
| 6 | its own. `VIDYA_CAPTURE=<path>` writes a frame out as a PPM, which is how a |
| 7 | rendering backend gets verified where nobody can look at the screen: |
| 8 | |
| 9 | VIDYA_CAPTURE=/tmp/frame.ppm LD_LIBRARY_PATH=../build jolt smoke" |
| 10 | (:require [glimmer.ratom :as r :refer [atom]] |
| 11 | [glimmer.core :as ui] |
| 12 | [glimmer-vidya.core :as vidya])) |
| 13 | |
| 14 | (defonce items (atom [:a :b :c])) |
| 15 | (defonce ticks (atom 0)) |
| 16 | |
| 17 | (defn app [] |
| 18 | [:page {:max-width 480} |
| 19 | [:title {:label "smoke"}] |
| 20 | [:label {:label (str "tick " @ticks)}] |
| 21 | [:card {} |
| 22 | (for [item @items] |
| 23 | ^{:key item} [:label {:label (str item)}])]]) |
| 24 | |
| 25 | (defn -main [& _] |
| 26 | ;; Reverse the list, drop one, put it back: reorder, remove and create, all |
| 27 | ;; against a tree that is being painted at the same time. |
| 28 | (vidya/every! 200 (fn [] |
| 29 | (swap! ticks inc) |
| 30 | (swap! items (fn [xs] |
| 31 | (case (mod @ticks 3) |
| 32 | 0 (vec (reverse xs)) |
| 33 | 1 (vec (rest xs)) |
| 34 | (vec (cons :a xs))))))) |
| 35 | (ui/run app :title "smoke" :width 480 :height 360 :auto-quit-ms 3000) |
| 36 | (println "smoke: ok, painted" @ticks "ticks")) |