AtlatestRepositorysigil-wm

sigil-wm / tree / testfacts.sgl

1(import (sigil async)
2 (sigil wm host))
3
4(define host (start-host!))
5(define previous #f)
6(define configured 0)
7(define named? #f)
8
9(define (configure! id enabled?)
10 (configure-output! host id
11 (dict enabled: enabled? x: 17 y: 23 scale: 1 transform: 0
12 mode: -1 width: 960 height: 640 refresh: 60000)))
14(on-event! host
15 (lambda (event)
16 (case (event-type event)
17 ((output-name)
18 (let* ((output (car (dict-ref (host-snapshot host) outputs:)))
19 (name (dict-ref output name:)))
20 (unless (and (string? name) (> (string-length name) 0))
21 (error "connector name was not assembled"))
22 (set! named? #t)
23 (configure! (event-ref event id:) #t)))
24 ((output-configured)
25 (let ((output (car (dict-ref (host-snapshot host) outputs:)))
26 (id (event-ref event id:)))
27 (set! configured (+ configured 1))
28 (case configured
29 ((1)
30 (unless (and (dict-ref output enabled?:)
31 (= (dict-ref output x:) 17)
32 (= (dict-ref output y:) 23)
33 (= (dict-ref output transform:) 0))
34 (error "configured output facts incomplete"))
35 (set! previous output)
36 (configure! id #f))
37 ((2)
38 (when (dict-ref output enabled?:)
39 (error "disabled output remains enabled in snapshot"))
40 (unless (and (dict-ref previous enabled?:)
41 (= (dict-ref previous width:) 960))
42 (error "previous snapshot was mutated"))
43 (configure! id #t))
44 ((3)
45 (unless (dict-ref output enabled?:)
46 (error "reenabled output missing from snapshot"))
47 (stop-host! host))))))))
49(with-async (run-host! host))
50(unless (and named? (= configured 3) (= (host-statistic host 2) 0))
51 (error "output fact cycle incomplete" configured))
52(display "FACTS=PASS connector enabled disabled reenabled detached snapshots\n")