Skip to content

Commit 6e39a0d

Browse files
authored
Merge pull request #88 from uint/feature-tests
tests: Add core protocol tests (manual, Screens section)
2 parents c2931ec + 249b8c3 commit 6e39a0d

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

tests/core-protocol.lisp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(fiasco:define-test-package (#:xlib-test-displays :in xlib-test:xlib-all-tests)
2-
(:documentation "Tests for `3. Displays' section of the manual."))
2+
(:documentation "Tests for the core protocol."))
33
(in-package #:xlib-test-displays)
44

55
;;; Manual notes:
@@ -66,3 +66,43 @@
6666
(is (null (xlib:close-display display)))
6767
;; We can't query closed display.
6868
(signals xlib:closed-display (xlib:query-extension display "FOO"))))
69+
70+
(defmacro with-default-display (display &body body)
71+
`(let ((,display (xlib:open-default-display)))
72+
(unwind-protect
73+
(progn ,@body)
74+
(xlib:close-display ,display))))
75+
76+
(deftest screen-protocol ()
77+
"Gets the default screen of the default display and validates its attributes."
78+
(with-default-display display
79+
(let ((screen (xlib:display-default-screen display)))
80+
(is (member (xlib:screen-backing-stores screen) '(:always :never :when-mapped)))
81+
(is (typep (xlib:screen-black-pixel screen) 'xlib:pixel))
82+
(is (typep (xlib:screen-default-colormap screen) 'xlib:colormap))
83+
(let ((depths (xlib:screen-depths screen)))
84+
(loop for depth in depths do
85+
(is (consp depth))
86+
(is (< 0 (car depth)))
87+
(is (listp (cdr depth)))
88+
(loop for visual in (cdr depth) do
89+
(is (typep visual 'xlib:visual-info)))))
90+
(is (typep (xlib:screen-event-mask-at-open screen) 'xlib:mask32))
91+
(is (typep (xlib:screen-height screen) 'xlib:card16))
92+
(is (typep (xlib:screen-height-in-millimeters screen) 'xlib:card16))
93+
(is (typep (xlib:screen-max-installed-maps screen) 'xlib:card16))
94+
(is (typep (xlib:screen-min-installed-maps screen) 'xlib:card16))
95+
96+
;; Test whether we can insert and retrieve a property.
97+
(is (xlib:screen-p screen))
98+
(is (typep (xlib:screen-plist screen) 'list))
99+
(finishes (setf (getf (xlib:screen-plist screen) 'foo) "hell is empty"))
100+
(is (string= "hell is empty" (getf (xlib:screen-plist screen) 'foo)))
101+
102+
(is (typep (xlib:screen-root screen) '(or null xlib:window)))
103+
(is (typep (xlib:screen-root-depth screen) 'xlib:image-depth))
104+
(is (typep (xlib:screen-root-visual screen) 'xlib:card29))
105+
(is (typep (xlib:screen-save-unders-p screen) 'boolean))
106+
(is (typep (xlib:screen-white-pixel screen) 'xlib:pixel))
107+
(is (typep (xlib:screen-width screen) 'xlib:card16))
108+
(is (typep (xlib:screen-width-in-millimeters screen) 'xlib:card16)))))

0 commit comments

Comments
 (0)