|
1 | 1 | (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.")) |
3 | 3 | (in-package #:xlib-test-displays)
|
4 | 4 |
|
5 | 5 | ;;; Manual notes:
|
|
66 | 66 | (is (null (xlib:close-display display)))
|
67 | 67 | ;; We can't query closed display.
|
68 | 68 | (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