aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Kangas2022-09-06 13:03:40 +0200
committerStefan Kangas2022-09-06 13:13:15 +0200
commit015fb4ac1c84485c563934087884f8a7dfe51955 (patch)
tree6c2c96d27e6fe76d2802467f74ea44315d254860 /test/src
parent2d29ee5ddedaf43ee1ee2e476810bbba06bf177e (diff)
downloademacs-015fb4ac1c84485c563934087884f8a7dfe51955.tar.gz
emacs-015fb4ac1c84485c563934087884f8a7dfe51955.zip
Add tests for opening different image formats
* test/src/image-tests.el (image-tests-make-load-image-test): New macro. (image-tests-load-image/gif) (image-tests-load-image/jpeg) (image-tests-load-image/pbm) (image-tests-load-image/png) (image-tests-load-image/svg) (image-tests-load-image/tiff) (image-tests-load-image/webp) (image-tests-load-image/xbm) (image-tests-load-image/xpm): New tests.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/image-tests.el37
1 files changed, 35 insertions, 2 deletions
diff --git a/test/src/image-tests.el b/test/src/image-tests.el
index c05582ada75..0a13db67d45 100644
--- a/test/src/image-tests.el
+++ b/test/src/image-tests.el
@@ -33,11 +33,12 @@
33 `(skip-unless (and (display-images-p) 33 `(skip-unless (and (display-images-p)
34 (image-type-available-p ,format)))) 34 (image-type-available-p ,format))))
35 35
36;;;; Images 36
37;;;; Image data
37 38
38(defconst image-tests--images 39(defconst image-tests--images
39 `((gif . ,(expand-file-name "test/data/image/black.gif" 40 `((gif . ,(expand-file-name "test/data/image/black.gif"
40 source-directory)) 41 source-directory))
41 (jpeg . ,(expand-file-name "test/data/image/black.jpg" 42 (jpeg . ,(expand-file-name "test/data/image/black.jpg"
42 source-directory)) 43 source-directory))
43 (pbm . ,(find-image '((:file "splash.svg" :type svg)))) 44 (pbm . ,(find-image '((:file "splash.svg" :type svg))))
@@ -51,6 +52,34 @@
51 (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm)))) 52 (xbm . ,(find-image '((:file "gnus/gnus.xbm" :type xbm))))
52 (xpm . ,(find-image '((:file "splash.xpm" :type xpm)))))) 53 (xpm . ,(find-image '((:file "splash.xpm" :type xpm))))))
53 54
55
56;;;; Load image
57
58(defmacro image-tests-make-load-image-test (type)
59 `(ert-deftest ,(intern (format "image-tests-load-image/%s"
60 (eval type t)))
61 ()
62 (image-skip-unless ,type)
63 (let* ((img (cdr (assq ,type image-tests--images)))
64 (file (if (listp img)
65 (plist-get (cdr img) :file)
66 img)))
67 (find-file file))
68 (should (equal major-mode 'image-mode))
69 ;; Cleanup
70 (kill-buffer (current-buffer))))
71
72(image-tests-make-load-image-test 'gif)
73(image-tests-make-load-image-test 'jpeg)
74(image-tests-make-load-image-test 'pbm)
75(image-tests-make-load-image-test 'png)
76(image-tests-make-load-image-test 'svg)
77(image-tests-make-load-image-test 'tiff)
78(image-tests-make-load-image-test 'webp)
79(image-tests-make-load-image-test 'xbm)
80(image-tests-make-load-image-test 'xpm)
81
82
54;;;; image-test-size 83;;;; image-test-size
55 84
56(declare-function image-size "image.c" (spec &optional pixels frame)) 85(declare-function image-size "image.c" (spec &optional pixels frame))
@@ -126,6 +155,7 @@
126 (skip-unless (not (display-images-p))) 155 (skip-unless (not (display-images-p)))
127 (should-error (image-size 'invalid-spec))) 156 (should-error (image-size 'invalid-spec)))
128 157
158
129;;;; image-mask-p 159;;;; image-mask-p
130 160
131(declare-function image-mask-p "image.c" (spec &optional frame)) 161(declare-function image-mask-p "image.c" (spec &optional frame))
@@ -178,6 +208,7 @@
178 (skip-unless (not (display-images-p))) 208 (skip-unless (not (display-images-p)))
179 (should-error (image-mask-p (cdr (assq 'xpm image-tests--images))))) 209 (should-error (image-mask-p (cdr (assq 'xpm image-tests--images)))))
180 210
211
181;;;; image-metadata 212;;;; image-metadata
182 213
183(declare-function image-metadata "image.c" (spec &optional frame)) 214(declare-function image-metadata "image.c" (spec &optional frame))
@@ -235,6 +266,7 @@
235 (skip-unless (not (display-images-p))) 266 (skip-unless (not (display-images-p)))
236 (should-error (image-metadata (cdr (assq 'xpm image-tests--images))))) 267 (should-error (image-metadata (cdr (assq 'xpm image-tests--images)))))
237 268
269
238;;;; ImageMagick 270;;;; ImageMagick
239 271
240(ert-deftest image-tests-imagemagick-types () 272(ert-deftest image-tests-imagemagick-types ()
@@ -242,6 +274,7 @@
242 (when (fboundp 'imagemagick-types) 274 (when (fboundp 'imagemagick-types)
243 (should (listp (imagemagick-types))))) 275 (should (listp (imagemagick-types)))))
244 276
277
245;;;; Initialization 278;;;; Initialization
246 279
247(ert-deftest image-tests-init-image-library () 280(ert-deftest image-tests-init-image-library ()